mercurial/bookmarks.py
changeset 24397 d0ea2028e8e6
parent 24355 ca4b89683078
child 24398 c0096a2bd3ff
--- 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"))