Patchwork [2,of,2] summary: show when active bookmark moved

login
register
mail settings
Submitter Kevin Bullock
Date Jan. 27, 2013, 6:09 p.m.
Message ID <b404fa10325396082450.1359310195@slower-than-infinity.lan>
Download mbox | patch
Permalink /patch/746/
State Deferred
Headers show

Comments

Kevin Bullock - Jan. 27, 2013, 6:09 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock@ringworld.org>
# Date 1359309800 21600
# Branch stable
# Node ID b404fa103253960824500066dffa2b7d6cff33ee
# Parent  a367f06d8c96c2279c500a688ab4ff65ac278b16
summary: show when active bookmark moved

Further breaking down the active/current bookmark dichotomy.
Bryan O'Sullivan - Jan. 30, 2013, 5:47 p.m.
On Sun, Jan 27, 2013 at 10:09 AM, Kevin Bullock <
kbullock+mercurial@ringworld.org> wrote:

> +                bmend = _(' (active bookmark moved)\n')
>

Suppose I see this message: I have no idea what it means, whether it's good
or bad, or whether to do anything as a consequence of seeing it. And I'm
presumably expected to be in the know.

Can you describe what the context is? I saw some back-and-forth between you
and Matt about active and current bookmarks, but couldn't tell you what the
distinction between these things is (in fact, I didn't even know there were
two concepts until that thread, and I still don't know what they are).
Matt Mackall - Jan. 31, 2013, 12:23 a.m.
On Wed, 2013-01-30 at 12:22 -0600, Kevin Bullock wrote:
> Thus we now have the situation that 'hg bookmarks' shows the
> current-but-not-active bookmark, but 'hg summary' gives no indication
> that an update will go to said bookmark. I'd like to fix this, but my
> patch isn't the right way to do it (as I mentioned before).

It probably ought to look like this:

$ hg sum
parent: 18473:692cbda1eb50 tip
 revset: evaluate sub expressions correctly (issue3775)
branch: stable
bookmarks: *@
commit: 15 unknown (clean)
update: (current)

$ hg pull
<some pull that moves @ out from under us>

$ hg sum
parent: 18472:37100f30590f 
 test-rebase: add another test for rebase with multiple roots
branch: stable
bookmarks: (@)
commit: 15 unknown (clean)
update: 1 new changesets (update)

Note the last line in particular: summary's calculation of the default
update target probably needs attention. We possibly even want something
like an update() revset predicate that tells us where we're going.

Also, something I encountered while constructing the last example: when
we update to an ancestor of the active bookmark, we might want the
bookmark to remain active, but not move:

$ hg up @ <- we're on @
$ hg up <- we go to @ if @ moved
$ hg up @^ <- we hop off @, oops
$ hg up <- we go to the branch tip, @ stops getting updated

Or, more expansively, we might want to only drop the active bookmark if
we move to a commit outside of (::x or x::). So, for instance:
        
o-a-o-o-@-o-o-x   (. = @)
     \   \
      u   o-o-y

hg up -> no-op, we're at @
hg up a -> we leave @ active, but go backwards
hg up x -> we advance @ to x
hg up y -> we advance @ to y
hg up u -> @ is deactivated

But we probably don't want to do this in the case of updating to
symbolic markers like tags, branches, other bookmarks, so this might be
too complex.
Matt Mackall - Jan. 31, 2013, 8:21 p.m.
On Thu, 2013-01-31 at 10:11 -0600, Kevin Bullock wrote:
> On Jan 31, 2013, at 8:07 AM, Augie Fackler wrote:
> 
> > On Wed, Jan 30, 2013 at 07:29:33PM -0600, Kevin Bullock wrote:
> >> On 30 Jan 2013, at 6:23 PM, Matt Mackall wrote:
> >>> $ hg up @ <- we're on @
> >>> $ hg up <- we go to @ if @ moved
> >>> $ hg up @^ <- we hop off @, oops
> >>> $ hg up <- we go to the branch tip, @ stops getting updated
> >>> 
> >>> Or, more expansively, we might want to only drop the active bookmark if
> >>> we move to a commit outside of (::x or x::). So, for instance:
> >>> 
> >>> o-a-o-o-@-o-o-x   (. = @)
> >>>    \   \
> >>>     u   o-o-y
> >>> 
> >>> hg up -> no-op, we're at @
> >>> hg up a -> we leave @ active, but go backwards
> >>> hg up x -> we advance @ to x
> >>> hg up y -> we advance @ to y
> >>> hg up u -> @ is deactivated
> >>> 
> >>> But we probably don't want to do this in the case of updating to
> >>> symbolic markers like tags, branches, other bookmarks, so this might be
> >>> too complex.
> >> 
> > 
> > I think this would break my current workflow, where I have a bookmark
> > for every local topic I'm working on, and then update to "mpm/stable"
> > to start a new one. IOW:
> > 
> >  $ hg sum
> >  ...
> >  bookmarks: *disallow-three-arg-raise
> >  ...
> >  $ hg up mpm/stable
> >  $ hg book fix-a-horrible-bug
> >  [ hack hack ]
> >  $ hg commit
> > 
> > Is how I generally work at present, and moving
> > disallow-three-arg-raise backwards when I did the update back to your
> > tip would not be helpful.
> 
> It wouldn't move backwards, for two reasons:
> 
> 1. In the new world order, "keep the active bookmark" does not imply
> *moving* that bookmark. It just means retaining .hg/bookmarks.current,
> so that we can detect later that we should move back to it on a *bare*
> 'hg update' (no explicit rev).

Right. If, for instance, your fix-a-horrible-bug branch has multiple
commits and you want to go back and run tests on each one, Mercurial
will not lose track of the fact that you're logically in an area of
history marked by "fix-a-horrible-bug".

But this is probably best left for the sprint.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5574,12 +5574,16 @@  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:
+        bmend = '\n'
+        if current is not None:
             ui.write(' *' + current, label='bookmarks.current')
-            marks.remove(current)
+            if current in marks:
+                marks.remove(current)
+            else:
+                bmend = _(' (active bookmark moved)\n')
         for m in marks:
             ui.write(' ' + m, label='log.bookmark')
-        ui.write('\n', label='log.bookmark')
+        ui.write(bmend, label='log.bookmark')
 
     st = list(repo.status(unknown=True))[:6]
 
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -465,7 +465,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 (active bookmark moved)
   commit: 1 added, 1 unknown (new branch head)
   update: 2 new changesets (update)
   $ hg update