Patchwork commit: show active bookmark in commit editor helper text

login
register
mail settings
Submitter Antonio Zanardo
Date Feb. 2, 2013, 5:47 p.m.
Message ID <510D512B.3090404@gmail.com>
Download mbox | patch
Permalink /patch/796/
State Accepted
Commit 94317c2d53b8b9bb75eb7280ec15d247ae6ed8cf
Delegated to: Kevin Bullock
Headers show

Comments

Antonio Zanardo - Feb. 2, 2013, 5:47 p.m.
# HG changeset patch
# User Antonio Zanardo <zanardo@gmail.com>
# Date 1359826637 7200
# Node ID 18fe48212f7d922727a38e9d2c0e8bd7100b9f44
# Parent  7068089c95a2ff3c1b536bbb52ca6bc1f06fc06e
commit: show active bookmark in commit editor helper text

If there is an active bookmark while committing, the bookmark name
will be visible inside the commit message helper, below the branch
name.

This should make easier for the user to detect a mistaken commit
parent, while working for example with a bookmark centric workflow
like topic branches.

The active bookmark is checked to be in the working directory, as
pointed by Kevin Bullock, because otherwise committing would not
advance it. In other words, this would not show the active
bookmark name if the user changed the working tree parents with
'hg debugsetparents', for example.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -12,6 +12,7 @@ 
  import match as matchmod
  import subrepo, context, repair, graphmod, revset, phases, obsolete
  import changelog
+import bookmarks
  import lock as lockmod

  def parsealiases(cmd):
@@ -1793,6 +1794,8 @@ 
          edittext.append(_("HG: branch merge"))
      if ctx.branch():
          edittext.append(_("HG: branch '%s'") % ctx.branch())
+    if bookmarks.iscurrent(repo):
+        edittext.append(_("HG: bookmark '%s'") % repo._bookmarkcurrent)
      edittext.extend([_("HG: subrepo %s") % s for s in subs])
      edittext.extend([_("HG: added %s") % f for f in added])
      edittext.extend([_("HG: changed %s") % f for f in modified])
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -263,6 +263,7 @@ 
    $ cd commitmsg
    $ echo changed > changed
    $ echo removed > removed
+  $ hg book currentbookmark
    $ hg ci -qAm init

    $ hg rm removed
@@ -277,6 +278,7 @@ 
    HG: --
    HG: user: test
    HG: branch 'default'
+  HG: bookmark 'currentbookmark'
    HG: added added
    HG: changed changed
    HG: removed removed