Patchwork [10,of,12,V3] bookmarks: show more detail about outgoing bookmarks

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 2, 2013, 2:38 p.m.
Message ID <fbb2a9a6a33ae3f53005.1380724727@feefifofum>
Download mbox | patch
Permalink /patch/2703/
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 fbb2a9a6a33ae3f53005aff61b4e72ae68af55cc
# Parent  cdc47657654f8180e12eec3391b1762f30a21728
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.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -449,11 +449,21 @@ 
                  srchex=hex)
 
     outgoings = []
-    def add(b, id):
-        outgoings.append("   %-25s %s\n" %
-                         (b, ui.debugflag and id or id[:12]))
+    def add(b, id, act, msg):
+        outgoings.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, 'B', _('added locally'))
+    for b, scid, dcid in adddst:
+        add(b, ' ' * 40, 'B', _('deleted locally, perhaps'))
+    for b, scid, dcid in advsrc:
+        add(b, scid, '-', _('advanced locally'))
+    for b, scid, dcid in advdst:
+        add(b, scid, 'B', _('advanced remotely'))
+    for b, scid, dcid in diverge:
+        add(b, scid, 'B', _('diverged'))
+    for b, scid, dcid in differ:
+        add(b, scid, 'B', _('changed'))
 
     if not outgoings:
         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
@@ -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