Patchwork [4,of,4,topic-experiment] topics: show more information in `hg topics`

login
register
mail settings
Submitter Pulkit Goyal
Date June 26, 2017, 8:28 a.m.
Message ID <8523d4018183cf29600c.1498465733@workspace>
Download mbox | patch
Permalink /patch/21729/
State Changes Requested
Headers show

Comments

Pulkit Goyal - June 26, 2017, 8:28 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1497889184 -19800
#      Mon Jun 19 21:49:44 2017 +0530
# Node ID 8523d4018183cf29600c4b1633479e941f89c6c2
# Parent  4c0852883a31643a3f4fe50688f85ac90a8d63b9
topics: show more information in `hg topics`

`hg topics` is the only way to show the list of topics currently. The default
version shows only the topics name which is very less. This patch makes `hg
topics` show number of changeset and branch related information also.
Pierre-Yves David - June 29, 2017, 3:44 p.m.
On 06/26/2017 10:28 AM, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1497889184 -19800
> #      Mon Jun 19 21:49:44 2017 +0530
> # Node ID 8523d4018183cf29600c4b1633479e941f89c6c2
> # Parent  4c0852883a31643a3f4fe50688f85ac90a8d63b9
> topics: show more information in `hg topics`
> 
> `hg topics` is the only way to show the list of topics currently. The default
> version shows only the topics name which is very less. This patch makes `hg
> topics` show number of changeset and branch related information also.

I'm not sure if this is the right thing to show, but it seems like a 
good idea to show more. I've taken that one. too

The output highlight a small bug where the branch of an emtpy topic is 
"nothing". We should use the current branch instead can you look into this?

Cheers,
Pierre-Yves David - June 29, 2017, 3:47 p.m.
On 06/29/2017 05:44 PM, Pierre-Yves David wrote:
> On 06/26/2017 10:28 AM, Pulkit Goyal wrote:
>> # HG changeset patch
>> # User Pulkit Goyal <7895pulkit@gmail.com>
>> # Date 1497889184 -19800
>> #      Mon Jun 19 21:49:44 2017 +0530
>> # Node ID 8523d4018183cf29600c4b1633479e941f89c6c2
>> # Parent  4c0852883a31643a3f4fe50688f85ac90a8d63b9
>> topics: show more information in `hg topics`
>>
>> `hg topics` is the only way to show the list of topics currently. The 
>> default
>> version shows only the topics name which is very less. This patch 
>> makes `hg
>> topics` show number of changeset and branch related information also.
> 
> I'm not sure if this is the right thing to show, but it seems like a 
> good idea to show more. I've taken that one. too

actually I just checked the performance impact in a larger repository 
and it is quite visible :-/ I've dropped it for now. You can get the 
updated version as 89d79b2ac79b in my wip repository.


> 
> The output highlight a small bug where the branch of an emtpy topic is 
> "nothing". We should use the current branch instead can you look into this?
> 
> Cheers,
>
Pulkit Goyal - June 29, 2017, 3:57 p.m.
On Thu, Jun 29, 2017 at 9:17 PM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
>
>
> On 06/29/2017 05:44 PM, Pierre-Yves David wrote:
>>
>> On 06/26/2017 10:28 AM, Pulkit Goyal wrote:
>>>
>>> # HG changeset patch
>>> # User Pulkit Goyal <7895pulkit@gmail.com>
>>> # Date 1497889184 -19800
>>> #      Mon Jun 19 21:49:44 2017 +0530
>>> # Node ID 8523d4018183cf29600c4b1633479e941f89c6c2
>>> # Parent  4c0852883a31643a3f4fe50688f85ac90a8d63b9
>>> topics: show more information in `hg topics`
>>>
>>> `hg topics` is the only way to show the list of topics currently. The
>>> default
>>> version shows only the topics name which is very less. This patch makes
>>> `hg
>>> topics` show number of changeset and branch related information also.
>>
>>
>> I'm not sure if this is the right thing to show, but it seems like a good
>> idea to show more. I've taken that one. too
>
>
> actually I just checked the performance impact in a larger repository and it
> is quite visible :-/ I've dropped it for now. You can get the updated
> version as 89d79b2ac79b in my wip repository.

Yeah that can be the case. Maybe listing only topic names in `hg
topics` is okay.
Pierre-Yves David - June 29, 2017, 4 p.m.
On 06/29/2017 05:57 PM, Pulkit Goyal wrote:
> On Thu, Jun 29, 2017 at 9:17 PM, Pierre-Yves David
> <pierre-yves.david@ens-lyon.org> wrote:
>>
>>
>> On 06/29/2017 05:44 PM, Pierre-Yves David wrote:
>>>
>>> On 06/26/2017 10:28 AM, Pulkit Goyal wrote:
>>>>
>>>> # HG changeset patch
>>>> # User Pulkit Goyal <7895pulkit@gmail.com>
>>>> # Date 1497889184 -19800
>>>> #      Mon Jun 19 21:49:44 2017 +0530
>>>> # Node ID 8523d4018183cf29600c4b1633479e941f89c6c2
>>>> # Parent  4c0852883a31643a3f4fe50688f85ac90a8d63b9
>>>> topics: show more information in `hg topics`
>>>>
>>>> `hg topics` is the only way to show the list of topics currently. The
>>>> default
>>>> version shows only the topics name which is very less. This patch makes
>>>> `hg
>>>> topics` show number of changeset and branch related information also.
>>>
>>>
>>> I'm not sure if this is the right thing to show, but it seems like a good
>>> idea to show more. I've taken that one. too
>>
>>
>> actually I just checked the performance impact in a larger repository and it
>> is quite visible :-/ I've dropped it for now. You can get the updated
>> version as 89d79b2ac79b in my wip repository.
> 
> Yeah that can be the case. Maybe listing only topic names in `hg
> topics` is okay.

The branch is important to understand the topic concept.

This the only way to have an empty topic is to have it active I think is 
is fine to use the active branch there too.

Cheers

Patch

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -395,7 +395,7 @@ 
     fm = ui.formatter('bookmarks', opts)
     activetopic = repo.currenttopic
     namemask = '%s'
-    if repo.topics and ui.verbose:
+    if repo.topics:
         maxwidth = max(len(t) for t in repo.topics)
         namemask = '%%-%is' % maxwidth
     for topic in sorted(repo.topics):
@@ -411,8 +411,7 @@ 
             fm.plain(' %s ' % marker, label=label)
         fm.write('topic', namemask, topic, label=label)
         fm.data(active=active)
-        if ui.verbose:
-            # XXX we should include the data even when not verbose
+        if not ui.quiet:
             data = stack.stackdata(repo, topic)
             fm.plain(' (')
             fm.write('branches+', 'on branch: %s',
@@ -421,26 +420,27 @@ 
             fm.plain(', ')
             fm.write('changesetcount', '%d changesets', data['changesetcount'],
                      label='topic.list.changesetcount')
-            if data['troubledcount']:
-                fm.plain(', ')
-                fm.write('troubledcount', '%d troubled',
-                         data['troubledcount'],
-                         label='topic.list.troubledcount')
-            if 1 < data['headcount']:
-                fm.plain(', ')
-                fm.write('headcount', '%d heads',
-                         data['headcount'],
-                         label='topic.list.headcount.multiple')
-            if 0 < data['behindcount']:
-                fm.plain(', ')
-                fm.write('behindcount', '%d behind',
-                         data['behindcount'],
-                         label='topic.list.behindcount')
-            elif -1 == data['behindcount']:
-                fm.plain(', ')
-                fm.write('behinderror', '%s',
-                         _('ambiguous destination'),
-                         label='topic.list.behinderror')
+            if ui.verbose:
+                if data['troubledcount']:
+                    fm.plain(', ')
+                    fm.write('troubledcount', '%d troubled',
+                             data['troubledcount'],
+                             label='topic.list.troubledcount')
+                if 1 < data['headcount']:
+                    fm.plain(', ')
+                    fm.write('headcount', '%d heads',
+                             data['headcount'],
+                             label='topic.list.headcount.multiple')
+                if 0 < data['behindcount']:
+                    fm.plain(', ')
+                    fm.write('behindcount', '%d behind',
+                             data['behindcount'],
+                             label='topic.list.behindcount')
+                elif -1 == data['behindcount']:
+                    fm.plain(', ')
+                    fm.write('behinderror', '%s',
+                             _('ambiguous destination'),
+                             label='topic.list.behinderror')
             fm.plain(')')
         fm.plain('\n')
     fm.end()
diff --git a/tests/test-topic-dest.t b/tests/test-topic-dest.t
--- a/tests/test-topic-dest.t
+++ b/tests/test-topic-dest.t
@@ -229,12 +229,12 @@ 
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg topic
-     elephant
-   * monkey
+     elephant (on branch: default, 1 changesets)
+   * monkey   (on branch: default, 2 changesets)
   $ hg ci -m 'merge with default'
   $ hg topic
-     elephant
-   * monkey
+     elephant (on branch: default, 1 changesets)
+   * monkey   (on branch: default, 3 changesets)
   $ hg log -G
   @    13 (monkey) merge with default
   |\
diff --git a/tests/test-topic-stack-data.t b/tests/test-topic-stack-data.t
--- a/tests/test-topic-stack-data.t
+++ b/tests/test-topic-stack-data.t
@@ -157,10 +157,10 @@ 
 basic output
 
   $ hg topic
-     bar
-     baz
-   * foo
-     fuz
+     bar (on branch: default, 5 changesets)
+     baz (on branch: default, 2 changesets)
+   * foo (on branch: lake, 2 changesets)
+     fuz (on branch: default, 3 changesets)
 
 quiet version
 
@@ -184,18 +184,26 @@ 
   [
    {
     "active": false,
+    "branches+": "default",
+    "changesetcount": 5,
     "topic": "bar"
    },
    {
     "active": false,
+    "branches+": "default",
+    "changesetcount": 2,
     "topic": "baz"
    },
    {
     "active": true,
+    "branches+": "lake",
+    "changesetcount": 2,
     "topic": "foo"
    },
    {
     "active": false,
+    "branches+": "default",
+    "changesetcount": 3,
     "topic": "fuz"
    }
   ]
diff --git a/tests/test-topic-stack.t b/tests/test-topic-stack.t
--- a/tests/test-topic-stack.t
+++ b/tests/test-topic-stack.t
@@ -68,7 +68,7 @@ 
 'hg stack' list all changeset in the topic
 
   $ hg topic
-   * foo
+   * foo (on branch: default, 4 changesets)
   $ hg stack
   ### topic: foo
   ### branch: default
diff --git a/tests/test-topic-tutorial.t b/tests/test-topic-tutorial.t
--- a/tests/test-topic-tutorial.t
+++ b/tests/test-topic-tutorial.t
@@ -60,7 +60,7 @@ 
 As for named branch, our topic is active but it does not contains any changesets yet::
 
   $ hg topic
-   * food
+   * food (on branch: , 0 changesets)
   $ hg summary
   parent: 0:38da43f0a2ea tip
    Shopping list
@@ -131,7 +131,7 @@ 
   $ hg up default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg topic
-     food
+     food (on branch: default, 2 changesets)
 
 Note that ``default`` (name of the branch) now refers to the tipmost changeset of default without a topic::
 
@@ -161,7 +161,7 @@ 
   switching to topic food
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg topic
-   * food
+   * food (on branch: default, 2 changesets)
 
 The name used for updating does not affect the activation of the topic, updating to a revision part of a topic will activate it in all cases::
 
@@ -171,7 +171,7 @@ 
   switching to topic food
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg topic
-   * food
+   * food (on branch: default, 2 changesets)
 
 .. server side activity::
 
@@ -274,7 +274,7 @@ 
 The topic information will fade out when we publish the changesets::
 
   $ hg topic
-     food
+     food (on branch: default, 2 changesets)
   $ hg push
   pushing to $TESTTMP/server (glob)
   searching for changes
@@ -343,8 +343,8 @@ 
 We now have two topics::
 
   $ hg topic
-   * drinks
-     tools
+   * drinks (on branch: default, 2 changesets)
+     tools  (on branch: default, 3 changesets)
 
 The information ``hg stack`` command adapt to the active topic::
 
diff --git a/tests/test-topic.t b/tests/test-topic.t
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -68,28 +68,28 @@ 
   [255]
   $ hg revert alpha
   $ hg topic
-   * topicflag
+   * topicflag (on branch: , 0 changesets)
 
 Make a topic
   $ hg topic narf
   $ hg topics
-   * narf
+   * narf (on branch: , 0 changesets)
   $ echo topic work >> alpha
   $ hg ci -m 'start on narf'
   $ hg co .^
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg topic fran
   $ hg topics
-   * fran
-     narf
+   * fran (on branch: , 0 changesets)
+     narf (on branch: default, 1 changesets)
   $ echo >> fran work >> beta
   $ hg ci -m 'start on fran'
   $ hg co narf
   switching to topic narf
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg topic
-     fran
-   * narf
+     fran (on branch: default, 1 changesets)
+   * narf (on branch: default, 1 changesets)
   $ hg log -r . -T '{topics}\n'
   narf
   $ echo 'narf!!!' >> alpha
@@ -288,7 +288,7 @@ 
   |    summary:     start on narf
   |
   $ hg topics
-   * query
+   * query (on branch: default, 1 changesets)
   $ cd ../pinky
   $ hg co query
   switching to topic query
@@ -307,9 +307,9 @@ 
   $ hg topic narf
   $ hg ci -m 'Finish narf'
   $ hg topics
-     fran
-   * narf
-     query
+     fran  (on branch: default, 1 changesets)
+   * narf  (on branch: default, 2 changesets)
+     query (on branch: default, 2 changesets)
   $ hg debugnamecomplete # branch:topic here is a buggy side effect
   default
   default:fran
@@ -325,8 +325,8 @@ 
 narf commits public:
 
   $ hg topics
-     fran
-   * narf
+     fran (on branch: default, 1 changesets)
+   * narf (on branch: , 0 changesets)
   $ hg log -Gl 6
   @    changeset:   9:ae074045b7a7
   |\   tag:         tip
@@ -367,7 +367,7 @@ 
   |
   $ cd ../brain
   $ hg topics
-   * query
+   * query (on branch: default, 1 changesets)
   $ hg pull ../pinky -r narf
   pulling from ../pinky
   abort: unknown revision 'narf'!
@@ -381,7 +381,7 @@ 
   added 3 changesets with 3 changes to 1 files
   (run 'hg update' to get a working copy)
   $ hg topics
-   * query
+   * query (on branch: , 0 changesets)
 
 We can pull in the draft-phase change and we get the new topic
 
@@ -394,8 +394,8 @@ 
   added 1 changesets with 1 changes to 1 files (+1 heads)
   (run 'hg heads' to see heads)
   $ hg topics
-     fran
-   * query
+     fran  (on branch: default, 1 changesets)
+   * query (on branch: , 0 changesets)
   $ hg log -Gr 'draft()'
   o  changeset:   9:0469d521db49
   |  tag:         tip
@@ -411,7 +411,7 @@ 
 
   $ hg topics --clear
   $ hg topics
-     fran
+     fran (on branch: default, 1 changesets)
 
 --clear when we don't have an active topic isn't an error:
 
@@ -502,7 +502,7 @@ 
 
 Match current topic:
   $ hg topic
-     fran
+     fran (on branch: default, 1 changesets)
   $ hg log -r 'topic(.)'
 (no output is expected)
   $ hg co fran
@@ -520,7 +520,7 @@ 
 
 Deactivate the topic.
   $ hg topics
-   * fran
+   * fran (on branch: default, 1 changesets)
   $ hg topics --clear
   $ echo fran? >> beta
   $ hg ci -m 'fran?'
@@ -540,7 +540,7 @@ 
   |  summary:     start on fran
   |
   $ hg topics
-     fran
+     fran (on branch: default, 1 changesets)
 Changing topic fails if we don't give a topic
   $ hg topic --rev 9
   abort: changing topic requires a topic name or --clear