[PATCH 06 of 15 V4] bookmarks: add "incoming()" to replace "diff()" for incoming bookmarks

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Oct 15 10:25:28 CDT 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1381849966 -32400
#      Wed Oct 16 00:12:46 2013 +0900
# Node ID fed21b736c42c16a712660df949917779798d061
# Parent  f7d7c8c9614afbd13d750e3021e6140078bdf58a
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.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -410,6 +410,28 @@
     if failed:
         return 1
 
+def incoming(ui, repo, other):
+    ui.status(_("searching for changed bookmarks\n"))
+    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
+     ) = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
+                 dsthex=hex)
+
+    incomings = []
+    def add(b, id):
+        incomings.append("   %-25s %s\n" %
+                         (b, ui.debugflag and id or id[:12]))
+    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"))
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3868,7 +3868,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:


More information about the Mercurial-devel mailing list