bookmarks: allow pushkey if new equals current
authorDurham Goode <durham@fb.com>
Tue, 26 Aug 2014 04:58:41 -0700
changeset 22364 5c153c69fdb2
parent 22363 9510b0e9480b
child 22367 c5df4af17110
bookmarks: allow pushkey if new equals current Previously a bookmark pushkey would be rejected if the specified 'old' value didn't match the servers 'current' value. This change allows this situation, as long as the 'current' server value equals the 'new' pushkey value already. We are trying to write a hook that forces a server bookmark to move forward, using a changegroup hook. If the user also pushed the bookmark, they would get an error, since they computed their pushkey (old,new) pair before the server moved the bookmark. Long term, bundle2 will let us do this more smartly, but this change seems reasonable for now.
mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Fri Aug 29 12:17:53 2014 +0200
+++ b/mercurial/bookmarks.py	Tue Aug 26 04:58:41 2014 -0700
@@ -228,7 +228,8 @@
     w = repo.wlock()
     try:
         marks = repo._bookmarks
-        if hex(marks.get(key, '')) != old:
+        existing = hex(marks.get(key, ''))
+        if existing != old and existing != new:
             return False
         if new == '':
             del marks[key]