Use dedicated mechanism to report pushkey success
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 09 Sep 2011 11:15:44 +0200
changeset 57 62f2fe22bd42
parent 56 27f9c0d0a996
child 58 2ba7355f6e11
Use dedicated mechanism to report pushkey success
hgext/states.py
--- a/hgext/states.py	Thu Sep 08 19:07:00 2011 +0200
+++ b/hgext/states.py	Fri Sep 09 11:15:44 2011 +0200
@@ -183,8 +183,12 @@
     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 @@
             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())