[PATCH] bookmarks: do not move merged bookmarks (issue1877)

Matt Mackall mpm at selenic.com
Fri Mar 25 09:36:43 CDT 2011


On Fri, 2011-03-25 at 14:36 +0100, Oben Sonne wrote:
> # HG changeset patch
> # User Oben Sonne <obensonne at googlemail.com>
> # Date 1301058026 -3600
> # Branch stable
> # Node ID 4e046b57caf4f2e282bddbb93c7e192ae00788ba
> # Parent  913c2c66a555934cab9bcdac3412703256f9cdf2
> bookmarks: do not move merged bookmarks (issue1877)

An excellent first patch submission. But we generally try to avoid
adding a whole new test script to add a simple test. If every bugfix
needed to create its own trivial repo to run its test on, the test suite
would take an hour to to run. Instead, try to find somewhere else in the
bookmark tests that is already creating a repo with branches and test
merging those.

I'm not entirely sure if this is the right behavior. Merges are
generally symmetric. Currently the only exception to this is branch
names, and perhaps this is similar enough to that case that it makes
sense, but I'd like to see an actual argument for it.

> Bookmarks are supposed to move on commits but they shouldn't do so if
> they belong to the second parent of a merge. This patch fixes this
> issue and adds a corresponding test.
> 
> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -126,7 +126,7 @@
>      marks = repo._bookmarks
>      update = False
>      mark = repo._bookmarkcurrent
> -    if mark and marks[mark] in parents:
> +    if mark and marks[mark] == parents[0]:
>          old = repo[marks[mark]]
>          new = repo[node]
>          if new in old.descendants():
> diff --git a/tests/test-bookmarks-merge.t b/tests/test-bookmarks-merge.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-bookmarks-merge.t
> @@ -0,0 +1,36 @@
> +  $ hg init
> +
> +set up a repo with 2 heads, 1 bookmarked
> +
> +  $ echo a > a
> +  $ hg commit -A -m 0
> +  adding a
> +  $ echo b > b
> +  $ hg commit -A -m 1
> +  adding b
> +  $ hg bookmark X
> +  $ hg update 0
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ echo c > c
> +  $ hg commit -A -m 2
> +  adding c
> +  created new head
> +
> +heads and bookmarks (we are at the head without a bookmark)
> +
> +  $ hg id -n
> +  2
> +  $ hg bookmarks
> +     X                         1:925d80f479bb
> +
> +merge in bookmarked head
> +
> +  $ hg merge
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  (branch merge, don't forget to commit)
> +  $ hg commit -m 3
> +
> +bookmark X shouldn't have moved with the merge
> +
> +  $ hg bookmarks
> +     X                         1:925d80f479bb
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list