[PATCH 09 of 12 V2] bookmarks: show more detail about incoming bookmarks

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Sep 22 09:05:35 CDT 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1379858556 -32400
#      Sun Sep 22 23:02:36 2013 +0900
# Node ID 961cf1b2ae49a60878c64178ace4bda1aa81eaf8
# Parent  53d0b139719b99d8575816a79d60a6f32eb2a2cc
bookmarks: show more detail about incoming bookmarks

Before this patch, "hg incoming -B" shows only bookmarks added
remotely.

So, users can't know whether "hg pull" implicitly updates bookmarks or
not, before execution of it.

This patch shows more detail about incoming bookmarks for "hg incoming
-B", as follows:

    BM1                       01234567890a (-) advanced remotely
    BM2                       1234567890ab (B) advanced locally
    BM3                       234567890abc (@) diverged
    BM4                       34567890abcd (?) changed

Each lines consist of four columns: "bookmark name", "remote value",
"action at pulling" and "detail of difference".

"action at pulling" column shows about bookmark updating in the local
repository by marks below:

  - "-": updated or added implicitly
  - "B": not updated implicitly (use -B to update forcibly)
  - "@": same as "B" except for implicit creation of diverged one
  - "?": undefined, because remote revision is unknown for local

This patch shows "added remotely" for the bookmark which exists only
in the remote repository, from the point of view of "hg pull"
behavior, even though it is deleted locally in fact.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -420,20 +420,31 @@
 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]))
+    def write(b, id, opt, msg):
+        ui.write("   %-25s %s (%s) %s\n" %
+                 (b, ui.debugflag and id or id[:12], opt, msg))
         return True
     def addsrc(b, scid, dcid):
-        return write(b, scid)
+        return write(b, scid, '-', _('added remotely'))
+    def advsrc(b, scid, dcid):
+        return write(b, scid, '-', _('advanced remotely'))
+    def advdst(b, scid, dcid):
+        return write(b, scid, 'B', _('advanced locally'))
+    def diverge(b, scid, dcid):
+        return write(b, scid, '@', _('diverged'))
+    def differ(b, scid, dcid):
+        return write(b, scid, '?', _('changed'))
 
     if not _execactions(compare(repo,
                                 other.listkeys('bookmarks'), repo._bookmarks,
                                 dsthex=hex),
                         {'addsrc': addsrc,
+                         'advsrc': advsrc,
+                         'advdst': advdst,
+                         'diverge': diverge,
+                         'differ': differ,
                          },
-                        ignore=set(['adddst', 'advsrc', 'advdst',
-                                    'diverge','differ'])):
+                        ignore=set(['adddst'])):
         ui.status(_("no changed bookmarks found\n"))
         return 1
     return 0
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3843,6 +3843,27 @@
 
     See pull for valid source format details.
 
+    .. container:: verbose
+
+      With -B/--bookmarks, the result of bookmark comparison between
+      local and remote repositories is displayed as follows::
+
+        BM1                       01234567890a (-) advanced remotely
+        BM2                       1234567890ab (B) advanced locally
+        BM3                       234567890abc (@) diverged
+        BM4                       34567890abcd (?) changed
+
+      Each lines consist of four columns: "bookmark name", "remote
+      value", "action at pulling" and "detail of difference".
+
+      "action at pulling" column shows about bookmark updating in the
+      local repository by marks below:
+
+      :``-``: updated or added implicitly
+      :``B``: not updated implicitly (use -B to update forcibly)
+      :``@``: same as ``B`` except for implicit creation of diverged one
+      :``?``: undefined, because remote revision is unknown for local
+
     Returns 0 if there are incoming changes, 1 otherwise.
     """
     if opts.get('graph'):
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -362,9 +362,11 @@
   $ hg in -B http://localhost:$HGPORT/
   comparing with http://localhost:$HGPORT/
   searching for changed bookmarks
-     Z                         0d2164f0ce0d
-     foo                       000000000000
-     foobar                    9b140be10808
+     @                         9b140be10808 (@) diverged
+     X                         9b140be10808 (@) diverged
+     Z                         0d2164f0ce0d (-) added remotely
+     foo                       000000000000 (-) added remotely
+     foobar                    9b140be10808 (-) added remotely
   $ hg pull -B Z http://localhost:$HGPORT/
   pulling from http://localhost:$HGPORT/
   no changes found
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -191,7 +191,7 @@
   $ hg in -B
   comparing with ssh://user@dummy/remote
   searching for changed bookmarks
-     foo                       a28a9d1a809c
+     foo                       a28a9d1a809c (-) added remotely
   $ hg book -f -r 0 foo
   $ hg pull -B foo
   pulling from ssh://user@dummy/remote


More information about the Mercurial-devel mailing list