Patchwork [4,of,5,V6-3] bookmarks: show more detail about incoming bookmarks

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 3, 2015, 5:21 p.m.
Message ID <52464858f510461d6714.1428081663@juju>
Download mbox | patch
Permalink /patch/8480/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - April 3, 2015, 5:21 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1428081282 -32400
#      Sat Apr 04 02:14:42 2015 +0900
# Node ID 52464858f510461d6714d50d68bcc961c8097ebc
# Parent  1bbe353452c4e9df453e2bd37b5a5ccc7a2f218b
bookmarks: show more detail about incoming bookmarks

Before this patch, "hg incoming -B" shows only difference of bookmarks
between two repositories, and it isn't user friendly.

This patch shows more detail about incoming bookmarks for "hg incoming
-B" with --verbose as below:

    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

From the point of view of "hg pull" behavior, this patch shows "added
remotely" for the bookmark existing only in the remote repository,
even if it is deleted locally in fact.
Matt Mackall - April 3, 2015, 9:55 p.m.
On Sat, 2015-04-04 at 02:21 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1428081282 -32400
> #      Sat Apr 04 02:14:42 2015 +0900
> # Node ID 52464858f510461d6714d50d68bcc961c8097ebc
> # Parent  1bbe353452c4e9df453e2bd37b5a5ccc7a2f218b
> bookmarks: show more detail about incoming bookmarks
> 
> Before this patch, "hg incoming -B" shows only difference of bookmarks
> between two repositories, and it isn't user friendly.
> 
> This patch shows more detail about incoming bookmarks for "hg incoming
> -B" with --verbose as below:
> 
>     BM1                       01234567890a (-) advanced remotely
>     BM2                       1234567890ab (B) advanced locally

If I understand this correctly, this bookmark shouldn't be considered
incoming at all?

>     BM3                       234567890abc (@) diverged
>     BM4                       34567890abcd (?) changed

Stylistically, I'm not excited about the new action column. I think the
table should instead look like:

    BM1                       01234567890a advanced
    BM3                       234567890abc diverged
    BM4                       34567890abcd changed

and we can define those terms in the help. Also.. we seem to have lost
what was originally the only information available here: which bookmarks
are not present at all locally?
Matt Mackall - April 3, 2015, 10 p.m.
On Fri, 2015-04-03 at 16:55 -0500, Matt Mackall wrote:
> On Sat, 2015-04-04 at 02:21 +0900, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1428081282 -32400
> > #      Sat Apr 04 02:14:42 2015 +0900
> > # Node ID 52464858f510461d6714d50d68bcc961c8097ebc
> > # Parent  1bbe353452c4e9df453e2bd37b5a5ccc7a2f218b
> > bookmarks: show more detail about incoming bookmarks
> > 
> > Before this patch, "hg incoming -B" shows only difference of bookmarks
> > between two repositories, and it isn't user friendly.
> > 
> > This patch shows more detail about incoming bookmarks for "hg incoming
> > -B" with --verbose as below:
> > 
> >     BM1                       01234567890a (-) advanced remotely
> >     BM2                       1234567890ab (B) advanced locally
> 
> If I understand this correctly, this bookmark shouldn't be considered
> incoming at all?
> 
> >     BM3                       234567890abc (@) diverged
> >     BM4                       34567890abcd (?) changed
> 
> Stylistically, I'm not excited about the new action column. I think the
> table should instead look like:
> 
>     BM1                       01234567890a advanced
>     BM3                       234567890abc diverged
>     BM4                       34567890abcd changed
>
> and we can define those terms in the help. Also.. we seem to have lost
> what was originally the only information available here: which bookmarks
> are not present at all locally?

Ok, I see it's in your tests, but it didn't have its own action entry.
Another strike against the separate action column.
Yuya Nishihara - April 4, 2015, 6:23 a.m.
On Fri, 03 Apr 2015 16:55:42 -0500, Matt Mackall wrote:
> On Sat, 2015-04-04 at 02:21 +0900, FUJIWARA Katsunori wrote:
> >     BM3                       234567890abc (@) diverged
> >     BM4                       34567890abcd (?) changed
> 
> Stylistically, I'm not excited about the new action column. I think the
> table should instead look like:
> 
>     BM1                       01234567890a advanced
>     BM3                       234567890abc diverged
>     BM4                       34567890abcd changed
> 
> and we can define those terms in the help.

and untranslated terms will be necessary for machine-readable format when
we'll port it to ui.formatter API.

Regards,
Katsunori FUJIWARA - April 4, 2015, 2:49 p.m.
At Fri, 03 Apr 2015 17:00:27 -0500,
Matt Mackall wrote:
> 
> On Fri, 2015-04-03 at 16:55 -0500, Matt Mackall wrote:
> > On Sat, 2015-04-04 at 02:21 +0900, FUJIWARA Katsunori wrote:
> > > # HG changeset patch
> > > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > > # Date 1428081282 -32400
> > > #      Sat Apr 04 02:14:42 2015 +0900
> > > # Node ID 52464858f510461d6714d50d68bcc961c8097ebc
> > > # Parent  1bbe353452c4e9df453e2bd37b5a5ccc7a2f218b
> > > bookmarks: show more detail about incoming bookmarks
> > > 
> > > Before this patch, "hg incoming -B" shows only difference of bookmarks
> > > between two repositories, and it isn't user friendly.
> > > 
> > > This patch shows more detail about incoming bookmarks for "hg incoming
> > > -B" with --verbose as below:
> > > 
> > >     BM1                       01234567890a (-) advanced remotely
> > >     BM2                       1234567890ab (B) advanced locally
> > 
> > If I understand this correctly, this bookmark shouldn't be considered
> > incoming at all?

This patch writes it as a part of difference of bookmarks between
repositories. It may help users to know quickly which and how
bookmarks are changed.

But I don't have strong demand to show it.

I'll hide bookmarks categorized as this kind in revised series.


> > >     BM3                       234567890abc (@) diverged
> > >     BM4                       34567890abcd (?) changed
> > 
> > Stylistically, I'm not excited about the new action column. I think the
> > table should instead look like:
> > 
> >     BM1                       01234567890a advanced
> >     BM3                       234567890abc diverged
> >     BM4                       34567890abcd changed
> >
> > and we can define those terms in the help. Also.. we seem to have lost
> > what was originally the only information available here: which bookmarks
> > are not present at all locally?
> 
> Ok, I see it's in your tests, but it didn't have its own action entry.
> Another strike against the separate action column.

I'll drop "action at XXXing" column in revised ones.

> -- 
> Mathematics is the supreme nostalgia of our time.
> 
> 
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -456,18 +456,23 @@  def incoming(ui, repo, other):
         getid = lambda id: id
     else:
         getid = lambda id: id[:12]
-    def add(b, id):
-        incomings.append("   %-25s %s\n" % (b, getid(id)))
+    if ui.verbose:
+        def add(b, id, act, msg):
+            incomings.append("   %-25s %s (%s) %s\n" %
+                             (b, getid(id), act, msg))
+    else:
+        def add(b, id, act, msg):
+            incomings.append("   %-25s %s\n" % (b, getid(id)))
     for b, scid, dcid in addsrc:
-        add(b, scid)
+        add(b, scid, '-', _('added remotely'))
     for b, scid, dcid in advsrc:
-        add(b, scid)
+        add(b, scid, '-', _('advanced remotely'))
     for b, scid, dcid in advdst:
-        add(b, scid)
+        add(b, scid, 'B', _('advanced locally'))
     for b, scid, dcid in diverge:
-        add(b, scid)
+        add(b, scid, '@', _('diverged'))
     for b, scid, dcid in differ:
-        add(b, scid)
+        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
@@ -4159,6 +4159,29 @@  def import_(ui, repo, patch1=None, *patc
 
     .. container:: verbose
 
+      With -B/--bookmarks, the result of bookmark comparison between
+      local and remote repositories is displayed. In addition to it,
+      -v/--verbose shows also detail for each bookmarks in the format
+      below::
+
+        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
+
+    .. container:: verbose
+
       Examples:
 
       - import a traditional patch from a website and detect renames::
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
@@ -526,13 +526,13 @@  be excahnged)
   $ hg -R repo1 incoming -B repo2 -v
   comparing with repo2
   searching for changed bookmarks
-     ADD_ON_REPO2              66f7d451a68b
-     ADV_ON_REPO1              1ea73414a91b
-     ADV_ON_REPO2              66f7d451a68b
-     DIFF_ADV_ON_REPO1         1ea73414a91b
-     DIFF_ADV_ON_REPO2         e7bd5218ca15
-     DIFF_DIVERGED             e7bd5218ca15
-     DIVERGED                  fa942426a6fd
+     ADD_ON_REPO2              66f7d451a68b (-) added remotely
+     ADV_ON_REPO1              1ea73414a91b (B) advanced locally
+     ADV_ON_REPO2              66f7d451a68b (-) advanced remotely
+     DIFF_ADV_ON_REPO1         1ea73414a91b (B) advanced locally
+     DIFF_ADV_ON_REPO2         e7bd5218ca15 (?) changed
+     DIFF_DIVERGED             e7bd5218ca15 (?) changed
+     DIVERGED                  fa942426a6fd (@) diverged
   $ hg -R repo1 outgoing -B repo2 -v
   comparing with repo2
   searching for changed bookmarks
@@ -548,13 +548,13 @@  be excahnged)
   $ hg -R repo2 incoming -B repo1 -v
   comparing with repo1
   searching for changed bookmarks
-     ADD_ON_REPO1              66f7d451a68b
-     ADV_ON_REPO1              fa942426a6fd
-     ADV_ON_REPO2              1ea73414a91b
-     DIFF_ADV_ON_REPO1         6100d3090acf
-     DIFF_ADV_ON_REPO2         1ea73414a91b
-     DIFF_DIVERGED             6100d3090acf
-     DIVERGED                  66f7d451a68b
+     ADD_ON_REPO1              66f7d451a68b (-) added remotely
+     ADV_ON_REPO1              fa942426a6fd (-) advanced remotely
+     ADV_ON_REPO2              1ea73414a91b (B) advanced locally
+     DIFF_ADV_ON_REPO1         6100d3090acf (?) changed
+     DIFF_ADV_ON_REPO2         1ea73414a91b (B) advanced locally
+     DIFF_DIVERGED             6100d3090acf (?) changed
+     DIVERGED                  66f7d451a68b (@) diverged
   $ hg -R repo2 outgoing -B repo1 -v
   comparing with repo1
   searching for changed bookmarks