Patchwork [06,of,12,V2] bookmarks: add "incoming()" to replace "diff()" for incoming bookmarks

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Sept. 22, 2013, 2:05 p.m.
Message ID <e08135a62638c6c1ba74.1379858732@feefifofum>
Download mbox | patch
Permalink /patch/2603/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Sept. 22, 2013, 2:05 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1379858556 -32400
#      Sun Sep 22 23:02:36 2013 +0900
# Node ID e08135a62638c6c1ba7420103c00505791a90aa6
# Parent  343b503c285bcd8963180f2acfa1dfe75f4b6ca5
bookmarks: add "incoming()" to replace "diff()" for incoming bookmarks

This patch adds "incoming()", which uses "compare()" to compare
bookmarks between the local and the remote repositories, to replace
"diff()" for incoming bookmarks newly from the remote repository.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -417,6 +417,27 @@ 
                   'or remote repository!\n') % inst.args[0])
         return 2
 
+def incoming(ui, repo, other):
+    ui.status(_("searching for changed bookmarks\n"))
+
+    def write(b, id):
+        ui.write("   %-25s %s\n" %
+                 (b, ui.debugflag and id or id[:12]))
+        return True
+    def addsrc(b, scid, dcid):
+        return write(b, scid)
+
+    if not _execactions(compare(repo,
+                                other.listkeys('bookmarks'), repo._bookmarks,
+                                dsthex=hex),
+                        {'addsrc': addsrc,
+                         },
+                        ignore=set(['adddst', 'advsrc', 'advdst',
+                                    'diverge','differ'])):
+        ui.status(_("no changed bookmarks found\n"))
+        return 1
+    return 0
+
 def diff(ui, dst, src):
     ui.status(_("searching for changed bookmarks\n"))
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3867,7 +3867,7 @@ 
             ui.warn(_("remote doesn't support bookmarks\n"))
             return 0
         ui.status(_('comparing with %s\n') % util.hidepassword(source))
-        return bookmarks.diff(ui, repo, other)
+        return bookmarks.incoming(ui, repo, other)
 
     repo._subtoppath = ui.expandpath(source)
     try: