Pull behaviour using branches with bookmarks

Giorgos Keramidas keramida at ceid.upatras.gr
Fri Jan 28 11:26:03 CST 2011


On Wed, 26 Jan 2011 18:05:49 +0100, "Alexander Schatten" <ml_alexanderschatten at gmx.at> 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:
>
> -------------------------------------------------------------
> # 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"
> # 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!
> # (b) bookmarks are messed up, e.g. "main" bookmark is on wrong position
> -------------------------------------------------------------

When you are using bookmarks as 'head names' there is the notion of a
'current' bookmark.

If before pulling from another repository:

  (a) You have updated to a bookmark *and*
  (b) The option `[bookmarks]track.current = True' is in your current
      configuration *and*
  (c) You pull changes that attach on top of the currently active
      bookmark.

Then the currently active bookmark slides automatically forward!

But I think you may have hit really close to a 'bug' of the bookmarks
extension.  I would expect that the following would *not* move any
bookmarks:

    hg update --clean default
    hg pull

But it seems it does.

The attached `test-script.sh' file shows this bug at work.  The
annotated `test-logfile.txt' shows where I think things start going
wrong with the current bookmark extension.

After an 'hg update --clean default' the `.hg/bookmarks.current' file
should always be cleared.  Even if there *is* a bookmark that happens to
point at the same location as the tip of the 'default' branch.  Or there
should be an option that explicitly clears it, e.g. one of:

    hg update --bookmark '' default
    hg bookmark ''

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-script.sh
Type: text/x-sh
Size: 3037 bytes
Desc: test script; run in a new, clean directory
URL: <http://selenic.com/pipermail/mercurial/attachments/20110128/724d3847/attachment.sh>
-------------- next part --------------
.. @  1[tip]   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. updating to branch default
.. 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
.. @  2[tip]   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |    added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. pulling from /tmp/foo/hgtest-1
.. ????????? ???????
.. ???????? ???????
.. adding manifests
.. adding file changes
.. added 1 changesets with 1 changes to 1 files (+1 heads)
.. (????? 'hg heads' ??? ?? ????? ?? ??????????, 'hg merge' ??? ??????????)
.. o  3[tip]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. |    added d.txt
.. |
.. | @  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
.. @  4[feature,tip]:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. |    beta text
.. |
.. | o  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. o |  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. alternative #1: pull with 'main' as the current bookmark
.. 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
.. current bookmark: main
.. tags before pull
.. tip                                4:94fa5a683c02
.. feature                            4:94fa5a683c02
.. main                               3:c5cbef0ade24
.. o  4[feature,tip]:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. |    beta text
.. |
.. | @  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. o |  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. pulling from ../hgtest-1
.. ????????? ???????
.. ???????? ???????
.. adding manifests
.. adding file changes
.. added 1 changesets with 1 changes to 1 files
.. (????? 'hg update' ??? ?? ??????? ????????? ????????)
.. tags after pull
.. tip                                5:a6915a4621e9
.. main                               5:a6915a4621e9
.. feature                            4:94fa5a683c02
.. o  5[main,tip]:3   a6915a4621e9   1970-01-01 01:15 +0000   User
.. |    final alpha line
.. |
.. | o  4[feature]:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. | |    beta text
.. | |
.. @ |  3:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. | o  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. alternative #2: pull with 'feature' as the current bookmark
.. 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
.. current bookmark: feature
.. tags before pull
.. tip                                4:94fa5a683c02
.. feature                            4:94fa5a683c02
.. main                               3:c5cbef0ade24
.. @  4[feature,tip]:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. |    beta text
.. |
.. | o  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. o |  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. pulling from ../hgtest-1
.. ????????? ???????
.. ???????? ???????
.. adding manifests
.. adding file changes
.. added 1 changesets with 1 changes to 1 files
.. (????? 'hg update' ??? ?? ??????? ????????? ????????)
.. tags after pull
.. tip                                5:a6915a4621e9
.. feature                            5:a6915a4621e9
.. main                               3:c5cbef0ade24
.. o  5[feature,tip]:3   a6915a4621e9   1970-01-01 01:15 +0000   User
.. |    final alpha line
.. |
.. | @  4:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. | |    beta text
.. | |
.. o |  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. | o  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. alternative #3: pull without *any* active bookmark
.. 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
.. c5cbef0ade24 main
.. current bookmark:
.. tags before pull
.. tip                                4:94fa5a683c02
.. feature                            4:94fa5a683c02
.. main                               3:c5cbef0ade24
.. o  4[feature,tip]:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. |    beta text
.. |
.. | @  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. o |  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. pulling from ../hgtest-1
.. ????????? ???????
.. ???????? ???????
.. adding manifests
.. adding file changes
.. added 1 changesets with 1 changes to 1 files
.. (????? 'hg update' ??? ?? ??????? ????????? ????????)
.. tags after pull
.. tip                                5:a6915a4621e9
.. feature                            4:94fa5a683c02
.. main                               3:c5cbef0ade24
.. o  5[tip]:3   a6915a4621e9   1970-01-01 01:15 +0000   User
.. |    final alpha line
.. |
.. | o  4[feature]:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. | |    beta text
.. | |
.. @ |  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. | o  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. alternative #4: pull without *any* active bookmark
.. 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
.. 94fa5a683c02 feature/tip
.. current bookmark: feature

This is wrong. I just used the commands:

  hg update --clean default

to *reset* the current bookmark.  It should be unset at this point,
instead of being 'feature'.

.. tags before pull
.. tip                                4:94fa5a683c02
.. feature                            4:94fa5a683c02
.. main                               3:c5cbef0ade24
.. @  4[feature,tip]:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. |    beta text
.. |
.. | o  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. o |  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..
.. pulling from ../hgtest-1
.. ????????? ???????
.. ???????? ???????
.. adding manifests
.. adding file changes
.. added 1 changesets with 1 changes to 1 files
.. (????? 'hg update' ??? ?? ??????? ????????? ????????)
.. tags after pull
.. tip                                5:a6915a4621e9
.. feature                            5:a6915a4621e9
.. main                               3:c5cbef0ade24
.. o  5[feature,tip]:3   a6915a4621e9   1970-01-01 01:15 +0000   User
.. |    final alpha line
.. |
.. | @  4:2   94fa5a683c02   1970-01-01 01:06 +0000   User
.. | |    beta text
.. | |
.. o |  3[main]:1   c5cbef0ade24   1970-01-01 00:58 +0000   User
.. | |    added d.txt
.. | |
.. | o  2   ec735c6381d0   1970-01-01 00:50 +0000   User
.. |/     added b.txt
.. |
.. o  1   be0be0f346da   1970-01-01 00:33 +0000   User
.. |    one line in a
.. |
.. o  0   1d481ee2cf7e   1970-01-01 00:16 +0000   User
..      added a.txt
..


More information about the Mercurial mailing list