changeset 24397:d0ea2028e8e6

bookmarks: add incoming() to replace diff() for incoming bookmarks This replacement makes enhancement of "show incoming bookmarks" easy, because "compare()" can detect more detailed difference of bookmarks between two repositories.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 19 Mar 2015 23:36:05 +0900
parents 9e03602cd2d8
children c0096a2bd3ff
files mercurial/bookmarks.py mercurial/commands.py
diffstat 2 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Mar 18 15:59:45 2015 -0700
+++ b/mercurial/bookmarks.py	Thu Mar 19 23:36:05 2015 +0900
@@ -442,6 +442,34 @@
             writer(msg)
         localmarks.recordchange(tr)
 
+def incoming(ui, repo, other):
+    '''Show bookmarks incoming from other to repo
+    '''
+    ui.status(_("searching for changed bookmarks\n"))
+
+    r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
+                dsthex=hex)
+    addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
+
+    incomings = []
+    if ui.debugflag:
+        getid = lambda id: id
+    else:
+        getid = lambda id: id[:12]
+    def add(b, id):
+        incomings.append("   %-25s %s\n" % (b, getid(id)))
+    for b, scid, dcid in addsrc:
+        add(b, scid)
+
+    if not incomings:
+        ui.status(_("no changed bookmarks found\n"))
+        return 1
+
+    for s in sorted(incomings):
+        ui.write(s)
+
+    return 0
+
 def diff(ui, dst, src):
     ui.status(_("searching for changed bookmarks\n"))
 
--- a/mercurial/commands.py	Wed Mar 18 15:59:45 2015 -0700
+++ b/mercurial/commands.py	Thu Mar 19 23:36:05 2015 +0900
@@ -4302,7 +4302,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: