newbie question for 'hg bookmark'

Martin Geisler mg at lazybytes.net
Fri Aug 27 09:17:55 UTC 2010


SungHyun Nam <goweol at gmail.com> writes:

> Hello,
>
> I did 'hg bookmark' as I did with git.  But it didn't work and I
> don't know why.  The BookmarksExtension wiki page didn't help. :(

Let me try to annotate your steps by showing the changeset graph. You
should enable the graphlog extension and see 'hg glog' for yourself.
Another way to orient yourself is to use 'hg serve' and go to

  http://localhost:8000/graph/

> Here is a brief sequence I did.
>
>     $ hg bookmarks
>     no bookmarks set
>
>     $ hg bookmark  patch10/perf-fixes

Graph now looks like this:

  ... [A]
       |
  @patch10/perf-fixes

that is, changeset A has the bookmark "patch10/perf-fixes" and your
working copy is also placed at A (see "hg parents" or look it up in "hg
help glossary").

>     $ patch -p1 < ../../0002-clean-up.patch
>     $ patch -p1 < ../../0003-speed-up.patch

If you are ever on a Windows machine, you will be happy to know that you
can use 'hg import --no-commit' instead of patch(1) on that platform.

>     $ hg ci

The world now looks like this:

  ... [A] --- [B]
               |
        @patch10/perf-fixes

>     $ hg up default
>     0 files updated, 0 files merged, 0 files removed, 0 files unresolved

Nothing happened! Changeset A and B are both on the named branch called
'default' and when you use the branch name, it is resolved as the
tip-most changeset on that branch -- that is B.

>     $ hg merge patch10/perf-fixes
>     abort: can't merge with ancestor

Here you are trying to merge the working copy parent revision (B) with
patch10/perf-fixes (B) and this is of course a silly thing to do:
merging with an ancestor (or yourself) has no effect.

> Hmm, I should use '-C' then...
>     $ hg up -C default
>     0 files updated, 0 files merged, 0 files removed, 0 files unresolved

Again, nothing happened...

>     $ hg merge patch10/perf-fixes
>     abort: can't merge with ancestor
> ...
>
> In git world, I always did:

Git works differently:

>     git co -b patch10/perf-fixes master

There are now two "labels" pointing to the current changeset and the
patch10/perf-fixes label is the active one (the currently checked out
"branch" in Git):

    master
       |
  ... [A]
       |
  @patch10/perf-fixes

>     edit and commit...

Only the currently checked out branch label moves:

    master
       |
  ... [A] --- [B]
               |
       @patch10/perf-fixes

>     git co master

You jump back to changeset A:

    @master
       |
  ... [A] --- [B]
               |
       patch10/perf-fixes

>     git merge patch10/perf-fixes

Since there is nothing to merge, Git does it's so-called "fast forward
merge" which really just means that it moves the branch pointer:

            @master
               |
  ... [A] --- [B]
               |
       patch10/perf-fixes

> Please fix me, what should I do?

I would just make the commits and when I pull, I do a 'hg rebase'
afterwards. No real need for bookmarks here, IMHO.

-- 
Martin Geisler

Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20100827/c37113b3/attachment.asc>


More information about the Mercurial mailing list