Patchwork [3,of,3] summary: show active bookmark even if not at current changeset

login
register
mail settings
Submitter Kevin Bullock
Date Feb. 9, 2013, 5:54 p.m.
Message ID <9d727e125244520c4fe6.1360432474@s0-0.paconsult7.bbnplanet.net>
Download mbox | patch
Permalink /patch/903/
State Accepted
Commit f9eebf5629fa6282e069989d5d29af3d762657c8
Headers show

Comments

Kevin Bullock - Feb. 9, 2013, 5:54 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock@ringworld.org>
# Date 1360360042 0
# Node ID 9d727e125244520c4fe60a4b8d60e29269d24af3
# Parent  04f1a301c90a00480839f8ee86c7e550a7e98f87
summary: show active bookmark even if not at current changeset

Before this change, 'hg summary' would not show the active bookmark
unless it pointed to the working directory parent. After this change, it
will show it in parentheses, like so:

parent: 18581:f0ff45fe6700 tip
 summary: simplify handling of active bookmark
branch: default
bookmarks: [crew]
commit: (clean)
update: (current)
Matt Mackall - Feb. 9, 2013, 10:19 p.m.
On Sat, 2013-02-09 at 17:54 +0000, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock <kbullock@ringworld.org>
> # Date 1360360042 0
> # Node ID 9d727e125244520c4fe60a4b8d60e29269d24af3
> # Parent  04f1a301c90a00480839f8ee86c7e550a7e98f87
> summary: show active bookmark even if not at current changeset
> 
> Before this change, 'hg summary' would not show the active bookmark
> unless it pointed to the working directory parent. After this change, it
> will show it in parentheses, like so:
> 
> parent: 18581:f0ff45fe6700 tip
>  summary: simplify handling of active bookmark
> branch: default
> bookmarks: [crew]
> commit: (clean)
> update: (current)

Looks good to me.

> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5574,9 +5574,12 @@ def summary(ui, repo, **opts):
>          current = repo._bookmarkcurrent
>          # i18n: column positioning for "hg summary"
>          ui.write(_('bookmarks:'), label='log.bookmark')
> -        if current is not None and current in marks:
> -            ui.write(' *' + current, label='bookmarks.current')
> -            marks.remove(current)
> +        if current is not None:
> +            if current in marks:
> +                ui.write(' *' + current, label='bookmarks.current')
> +                marks.remove(current)
> +            else:
> +                ui.write('[%s]' % current, label='bookmarks.current')
>          for m in marks:
>              ui.write(' ' + m, label='log.bookmark')
>          ui.write('\n', label='log.bookmark')
> diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
> --- a/tests/test-bookmarks.t
> +++ b/tests/test-bookmarks.t
> @@ -471,7 +471,7 @@ update to current bookmark if it's not t
>    parent: 2:db815d6d32e6 
>     2
>    branch: default
> -  bookmarks: Y x  y
> +  bookmarks:[Z] Y x  y
>    commit: 1 added, 1 unknown (new branch head)
>    update: 2 new changesets (update)
>    $ hg update
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5574,9 +5574,12 @@  def summary(ui, repo, **opts):
         current = repo._bookmarkcurrent
         # i18n: column positioning for "hg summary"
         ui.write(_('bookmarks:'), label='log.bookmark')
-        if current is not None and current in marks:
-            ui.write(' *' + current, label='bookmarks.current')
-            marks.remove(current)
+        if current is not None:
+            if current in marks:
+                ui.write(' *' + current, label='bookmarks.current')
+                marks.remove(current)
+            else:
+                ui.write('[%s]' % current, label='bookmarks.current')
         for m in marks:
             ui.write(' ' + m, label='log.bookmark')
         ui.write('\n', label='log.bookmark')
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -471,7 +471,7 @@  update to current bookmark if it's not t
   parent: 2:db815d6d32e6 
    2
   branch: default
-  bookmarks: Y x  y
+  bookmarks:[Z] Y x  y
   commit: 1 added, 1 unknown (new branch head)
   update: 2 new changesets (update)
   $ hg update