Patchwork [09,of,12,V3] bookmarks: show more detail about incoming bookmarks

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 2, 2013, 2:38 p.m.
Message ID <cdc47657654f8180e12e.1380724726@feefifofum>
Download mbox | patch
Permalink /patch/2701/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Oct. 2, 2013, 2:38 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1380723659 -32400
#      Wed Oct 02 23:20:59 2013 +0900
# Node ID cdc47657654f8180e12eec3391b1762f30a21728
# Parent  b169b5c03ea66ee6aff1df3d1fc91591eff4bf0a
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.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -418,11 +418,19 @@ 
                  dsthex=hex)
 
     incomings = []
-    def add(b, id):
-        incomings.append("   %-25s %s\n" %
-                         (b, ui.debugflag and id or id[:12]))
+    def add(b, id, act, msg):
+        incomings.append("   %-25s %s (%s) %s\n" %
+                         (b, ui.debugflag and id or id[:12], act, msg))
     for b, scid, dcid in addsrc:
-        add(b, scid)
+        add(b, scid, '-', _('added remotely'))
+    for b, scid, dcid in advsrc:
+        add(b, scid, '-', _('advanced remotely'))
+    for b, scid, dcid in advdst:
+        add(b, scid, 'B', _('advanced locally'))
+    for b, scid, dcid in diverge:
+        add(b, scid, '@', _('diverged'))
+    for b, scid, dcid in differ:
+        add(b, scid, '?', _('changed'))
 
     if not incomings:
         ui.status(_("no changed bookmarks found\n"))
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