Pull behaviour using branches with bookmarks

Tom Widmer tom.widmer at googlemail.com
Thu Jan 27 07:56:28 CST 2011


On 26/01/2011 17:05, Alexander Schatten wrote:
> ok, please check out the bash script under the line; includes documentation. In my opinion, the pull behaviour is pretty questionable, particularly as it is not documented anywhere; at least I could not find it:

Yes, it seems to me that 'fast forward merges' or whatever hg calls them 
should either update no bookmarks, or update the bookmarks on the fast 
forward changeset.

The behaviour is also strange if you amend your procedure as follows:

> -------------------------------------------------------------
> # first repo
> hg init hgtest
> cd hgtest
> touch a.txt
> hg add
> hg commit -m "added a.txt" -u "User A"
> echo "one line in a.txt">>  a.txt
> hg commit -m "one line in a" -u "User A"
> hg status
> hg glog
> cd ..
> # clone repo
> hg clone hgtest hgtest1
> # work in second repo
> cd hgtest1
> touch b.txt
> hg add
> hg commit -m "added b.txt" -u "User B"
> hg status
> hg glog
> # back to first repo
> cd ../hgtest
> touch d.txt
> hg add
> hg commit -m "added d.txt" -u "User A"
> # go to second repo and pull changes: branching
> cd ../hgtest1
> hg pull
> hg glog
> hg bookmark main -r 3
> hg bookmark feature -r 2
> hg update feature
> echo "one line in b.txt">>  b.txt
> hg commit -m "added b.txt" -u "User B"
> hg status
> hg glog
> # back to first repo and adding changes
> cd ../hgtest
> echo "second line in a.txt">>  a.txt
> hg commit -m "second line in a" -u "User A"

# add same bookmark to hgtest repo
hg bookmark main

> # until here everything is fine
> # now back to repo 2, and test the two alternatives
> # (1) go to main branch and pull:
> cd ../hgtest1
> hg update main
> hg pull
> hg glog
> # behaviour as expected: changeset added to main branch, main bookmark moved, feature bookmark untouched
> # (2) Alternative: go to feature branch and pull:
> cd ../hgtest1
> hg update feature
> hg pull
> hg glog
> # what happened:
> # (a) changeset was put on top of feature branch, thus messed up branches!

By branch, I think you mean bookmark (there is no named feature branch 
or named clone called feature in your example). The changeset certainly 
gets added in the correct place, on top of the commit: hg commit -m 
"added d.txt" -u "User A", but the feature bookmark gets updated to 
point to it.

> # (b) bookmarks are messed up, e.g. "main" bookmark is on wrong position

# (3) Alternative: go to feature branch and pull main bookmark:
cd ../hgtest1
hg update feature
hg pull -B main
hg glog
# what happened:
# Both main AND feature bookmarks are updated to tip of hgtest!

I agree this looks like a bug - moving the feature bookmark in cases (2) 
and (3) is wrong, and in case (2) I think the main bookmark should be 
moved as well as in case (3).

Tom



More information about the Mercurial mailing list