Bug 3277 - updating to the last active bookmark reactive it
Summary: updating to the last active bookmark reactive it
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Idan Kamara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-17 12:38 UTC by Pierre-Yves David
Modified: 2012-02-28 22:00 UTC (History)
7 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Yves David 2012-02-17 12:38 UTC
When you don't have any active bookmark. Updating to a revision that happen to
have a bookmark may enable this bookmark. This happen if the bookmark was the
last you had active.

The following updated test case:

    diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
    --- a/tests/test-bookmarks.t
    +++ b/tests/test-bookmarks.t
    @@ -342,10 +342,25 @@ create bundle with two heads
          X2                        1:925d80f479bb
          Y                         2:db815d6d32e6
        * Z                         3:125c9a1d6df6
          x  y                      2:db815d6d32e6
     
    +  $ hg up -C 1
    +  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
    +  $ hg bookmarks
    +     X2                        1:925d80f479bb
    +     Y                         2:db815d6d32e6
    +     Z                         3:125c9a1d6df6
    +     x  y                      2:db815d6d32e6
    +  $ hg up 3
    +  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
    +  $ hg bookmarks
    +     X2                        1:925d80f479bb
    +     Y                         2:db815d6d32e6
    +     Z                         3:125c9a1d6df6
    +     x  y                      2:db815d6d32e6
    +
     test wrongly formated bookmark
     
       $ echo '' >> .hg/bookmarks
       $ hg bookmarks
          X2                        1:925d80f479bb

Fails as follow:

    --- /home/pyves/src/mercurial-dev/tests/test-bookmarks.t 
    +++ /home/pyves/src/mercurial-dev/tests/test-bookmarks.t.err 
    @@ -356,7 +356,7 @@
       $ hg bookmarks
          X2                        1:925d80f479bb
          Y                         2:db815d6d32e6
    -     Z                         3:125c9a1d6df6
    +   * Z                         3:125c9a1d6df6
          x  y                      2:db815d6d32e6
Comment 1 Idan Kamara 2012-02-17 13:42 UTC
I remember seeing this about a year ago:

http://mercurial.markmail.org/thread/rhrwvpt6tshdv6pj

Don't really remember if there was anything concrete that prevented changing 
this.
Comment 2 Matt Mackall 2012-02-17 15:09 UTC
I was hoping to get an enumeration of the rules for active bookmarks. That
probably looks something like this:

1. A bookmark becomes active on creation if it's for '.'
2. A bookmark becomes active when you update to it explicitly
3. Activating a bookmark deactivates any previous bookmark
4. An active bookmark is moved forward by commit or -bare update-
5. A bookmark remains active during merge
6. A bookmark becomes inactive when you do any other sort of update

So Idan's patch is probably correct, though it'd be nice if these rules were
somehow confined to and documented in bookmarks.py rather than scattered
throughout the code.

Also, there's the whole business with "current/active" in the code that
confuses matters.
Comment 3 Kevin Bullock 2012-02-20 13:28 UTC
I think that's a reasonably complete list. We might start with:

0. A bookmark is active (or synonymously, current) when it points to '.' and 
is listed in bookmarks.current

Note that (4) and (5) taken together imply that the following:

$ hg up @
$ hg merge feature-branch
$ hg ci -m 'merge feature-branch'

results in feature-branch staying put on the second parent of the merge 
(issue1877).
Comment 4 Matt Mackall 2012-02-20 13:33 UTC
Yeah, I think we ought to purge either the "active" or "current" jargon.
Probably "current" because we've got command line options that mention active.
Comment 5 Matt Mackall 2012-02-24 14:59 UTC
Idan, can you resend that patch?
Comment 6 Idan Kamara 2012-02-24 15:45 UTC
Sure, I'd like to go over it again so expect it shortly after Monday (got a 
test).
Comment 7 HG Bot 2012-02-28 22:00 UTC
Fixed by http://selenic.com/repo/hg/rev/7c75924a6926
Idan Kamara <idankk86@gmail.com>
update: delete bookmarks.current when explicitly updating to a rev (issue3276)

(please test the fix)
Comment 8 Bugzilla 2012-05-12 09:28 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:28 EDT  ---

This bug was previously known as _bug_ 3276 at http://mercurial.selenic.com/bts/issue3276