diff mercurial/commands.py @ 20026:84905561ad41

bookmarks: rewrite pushing local bookmarks in "commands.push()" by "compare()" This patch adds "pushtoremote()", which uses "compare()" to compare bookmarks between the local and the remote repositories, to replace pushing local bookmarks in "commands.push()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 08 Nov 2013 12:45:52 +0900
parents de16c673455b
children 1e5b38a919dd
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Nov 08 12:45:52 2013 +0900
+++ b/mercurial/commands.py	Fri Nov 08 12:45:52 2013 +0900
@@ -4711,25 +4711,11 @@
     result = not result
 
     if opts.get('bookmark'):
-        rb = other.listkeys('bookmarks')
-        for b in opts['bookmark']:
-            # explicit push overrides remote bookmark if any
-            if b in repo._bookmarks:
-                ui.status(_("exporting bookmark %s\n") % b)
-                new = repo[b].hex()
-            elif b in rb:
-                ui.status(_("deleting remote bookmark %s\n") % b)
-                new = '' # delete
-            else:
-                ui.warn(_('bookmark %s does not exist on the local '
-                          'or remote repository!\n') % b)
-                return 2
-            old = rb.get(b, '')
-            r = other.pushkey('bookmarks', b, old, new)
-            if not r:
-                ui.warn(_('updating bookmark %s failed!\n') % b)
-                if not result:
-                    result = 2
+        bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark'])
+        if bresult == 2:
+            return 2
+        if not result and bresult:
+            result = 2
 
     return result