[PATCH 10 of 12 V2] bookmarks: show more detail about outgoing bookmarks

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Sep 22 09:05:36 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 42fa20a5628f09cfd4f997dcfa7682874758db1c
# Parent  961cf1b2ae49a60878c64178ace4bda1aa81eaf8
bookmarks: show more detail about outgoing bookmarks

Before this patch, "hg outgoing -B" shows only bookmarks added
locally.

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

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

    BM1                       01234567890a (-) advanced locally
    BM2                       1234567890ab (B) diverged
    BM3                                    (B) deleted locally, perhaps

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

"action at pushing" column shows about bookmark updating in the remote
repository by marks below:

  - "-": updated implicitly
  - "B": not updated implicitly (use -B to update forcibly)

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

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -452,20 +452,34 @@
 def outgoing(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]))
+    delid = ' ' * 40
+    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, 'B', _('added locally'))
+    def adddst(b, scid, dcid):
+        return write(b, delid, 'B', _('deleted locally, perhaps'))
+    def advsrc(b, scid, dcid):
+        return write(b, scid, '-', _('advanced locally'))
+    def advdst(b, scid, dcid):
+        return write(b, scid, 'B', _('advanced remotely'))
+    def diverge(b, scid, dcid):
+        return write(b, scid, 'B', _('diverged'))
+    def differ(b, scid, dcid):
+        return write(b, scid, 'B', _('changed'))
 
     if not _execactions(compare(repo,
                                 repo._bookmarks, other.listkeys('bookmarks'),
                                 srchex=hex),
                         {'addsrc': addsrc,
-                         },
-                        ignore=set(['adddst', 'advsrc', 'advdst',
-                                    'diverge', 'differ'])):
+                         'adddst': adddst,
+                         'advsrc': advsrc,
+                         'advdst': advdst,
+                         'diverge': diverge,
+                         'differ': differ,
+                         }):
         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
@@ -4335,6 +4335,23 @@
 
     See pull for details of valid destination formats.
 
+    .. container:: verbose
+
+      With -B/--bookmarks, the result of bookmark comparison between
+      local and remote repositories is displayed as follows::
+
+        BM1                       01234567890a (-) advanced locally
+        BM2                       1234567890ab (B) diverged
+
+      Each lines consist of four columns: "bookmark name", "local
+      value", "action at pushing" and "detail of difference".
+
+      "action at pushing" column shows about bookmark updating in the
+      remote repository by marks below:
+
+      :``-``: updated implicitly
+      :``B``: not updated implicitly (use -B to update forcibly)
+
     Returns 0 if there are outgoing 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
@@ -350,8 +350,11 @@
   $ hg out -B http://localhost:$HGPORT/
   comparing with http://localhost:$HGPORT/
   searching for changed bookmarks
-  no changed bookmarks found
-  [1]
+     @                         0d2164f0ce0d (B) diverged
+     X                         0d2164f0ce0d (B) diverged
+     Z                         0d2164f0ce0d (B) diverged
+     foo                                    (B) deleted locally, perhaps
+     foobar                                 (B) deleted locally, perhaps
   $ hg push -B Z http://localhost:$HGPORT/
   pushing to http://localhost:$HGPORT/
   searching for changes
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -171,7 +171,7 @@
   $ hg out -B
   comparing with ssh://user@dummy/remote
   searching for changed bookmarks
-     foo                       1160648e36ce
+     foo                       1160648e36ce (B) added locally
   $ hg push -B foo
   pushing to ssh://user@dummy/remote
   searching for changes


More information about the Mercurial-devel mailing list