[Python-Dev] PEP: Collecting information about git

Nikolaus Rath Nikolaus at rath.org
Wed Sep 16 22:38:41 CEST 2015


On Sep 16 2015, Paul Moore <p.f.moore at gmail.com> wrote:
> I'm on revision X, which is at tip (master in git, the default branch
> in Mercurial). I do git checkout -b foo (or hg bookmark foo). Now I
> check in some changes. In git, I'm on branch foo and I can go back to
> master with git checkout master. In Mercurial, I am at bookmark foo,
> but where's the place I started from? The main line of development
> (the default branch) doesn't have a bookmark, so I have to go hunting
> for the revision I first switched to the bookmark at.

Yes - but you could bookmark it before committing, then you don't have
to hunt for it :-).

$ hg pull
$ hg bookmark "my-origin-branch"
$ hg bookmark "my-local-branch"
$ hg update -r my-local-branch
$ hg commit
$ hg update -r my-origin-branch

> Similarly, if I'm at revision X, hg bookmark foo; hg bookmark bar
> creates 2 bookmarks. If I then check in a change, I guess *both*
> bookmarks move.

No, only the active bookmark moves automatically:

$ hg bookmark foo
$ hg bookmark bar
$ hg log -r tip
changeset:   0:d1c121e915b8
bookmark:    bar
bookmark:    foo
tag:         tip
user:        Nikolaus Rath <Nikolaus at rath.org>
date:        Wed Sep 16 13:31:13 2015 -0700
files:       file
description:
initial commit


$ hg update -r foo
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark foo)
$ echo barf > file
$ hg commit -m "Barf!"
file
committed changeset 1:ad44f9b935dc
$ hg log -r tip
changeset:   1:ad44f9b935dc
bookmark:    foo
tag:         tip
user:        Nikolaus Rath <Nikolaus at rath.org>
date:        Wed Sep 16 13:31:42 2015 -0700
files:       file
description:
Barf!

> In git, if I do git checkout -b foo; git checkout -b
> bar, I have created two branches, and checkins now only go on bar. The
> difference comes from the fact that in git, branches are "real
> things", but in hg, bookmarks are names for points on the DAG

You'll have to elaborate on that. What is it the difference between a
named leaf in the DAG and a branch that makes the branch "real"?

> See what I mean when I say I get confused? ;-)

I think what you mean is that you haven't read the Mercurial
documentation for quite some time :-).

>> The "remote tracking branch" in Mercurial always exists, but it doesn't
>> have a special name. In hg, branches do not need to have names, they are
>> identified by their commit id. Assigning names is pure convenience, this
>> is why they're called "bookmarks".
>
> And yet branches are *not* simply names in git - a branch with no
> commits on it is still distinct from its parent branch.
>
> So conceptually, the idea that hg bookmarks and git branches are the
> same thing, isn't actually true...

Well, the one thing were you thought they were different wasn't actually
the case. Is there another?

>>> Also, my workflow involves 2 separate PCs, and I use my personal
>>> github forks to share work in progress between them. Mercurial makes
>>> it very difficult to edit "published" history, and I can't tell it
>>> that my bitbucket repo doesn't count as "published" (as far as I
>>> know).
>>
>> In general you can do that by configuring the repository with
>>
>>       [phases]
>>       publish = False
>>
>> However, I believe BitBucket doesn't allow you to do that. But that's
>> not hg's fault.
>
> Well, yes and no. The fact that you have to edit the remote repository
> before it will allow you to violate its "history is immutable"

That's not true. You have to edit the remote repository only if you want
to edit history without --force.


Best,
-Nikolaus
-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«


More information about the Python-Dev mailing list