site

(Pierre-Yves David)
2011-09-09: Use dedicated mechanism to report pushkey success

Use dedicated mechanism to report pushkey success

diff --git a/hgext/states.py b/hgext/states.py
--- a/hgext/states.py
+++ b/hgext/states.py
@@ -183,8 +183,12 @@ def pushstatesheads(repo, key, old, new)
     w = repo.wlock()
     try:
         newhead = node.bin(key)
-        repo[newhead]
+        try:
+            repo[newhead]
+        except error.RepoLookupError:
+            return False
         repo.setstate(st, [newhead])
+        return True
     finally:
         w.release()
 
@@ -407,9 +411,8 @@ def reposetup(ui, repo):
             missing = local - set(remoteheads)
             while missing:
                 h = missing.pop()
-                try:
-                    remote.pushkey('states-heads', node.hex(h), '', state.name)
-                except error.RepoLookupError:
+                ok = remote.pushkey('states-heads', node.hex(h), '', state.name)
+                if not ok:
                     missing.update(p.node() for p in repo[h].parents())