[Python-Dev] Mercurial migration readiness

Martin Geisler mg at lazybytes.net
Sun Jul 4 13:37:11 CEST 2010


"Martin v. Löwis" <martin at v.loewis.de> writes:

>> My question is basically the same as Terry Reedy's, but I'm going to
>> phrase it a bit differently:
>> 
>> This is perhaps a naive question, but why do you create a second local
>> clone instead of just creating a branch?
>
> IIUC, if you create a named branch, the branch will become globally
> visible when you push your changes back. I assume people will consider
> that clutter - it would be sufficient to just push the changes on the
> branch, along with commit messages, but not the branch itself (which
> would be only temporary, anyway).
>
> I'm not even sure how you pull changes from one branch into another:
> can somebody kindly explain the commands that would be required?

You don't -- it is tempting to think of a "named branch" as a kind of
container for changesets, but that metaphor makes people think that you
can put changesets "into" a named branch and takes them "out" again.

The opposite is in fact true: the changesets induce the named branch.
Each changeset has a field in its metadata that names the branch it is
on. So if you do

  hg branch X
  hg commit -m "Created X branch"

then the newly created changeset has branch="X" in its metadata. The X
branch has thus been created because of the changeset. If there are no
changesets with branch="X" in your repository, then there is no X
branch.


A named branch is thus more a labeling system -- changesets belonging to
the branch can (in principle) be scattered all over the repository. They
are normally a connected sub-graph, though, and Mercurial will complain
if you try to re-start a branch name.

Since the branch name is embedded into the changesets themselves, you
cannot changeset it without changing the identities of the changesets.

A branch appears in the output of 'hg branches' if there are any open
branch heads (a "branch head" is a changeset with no children on the
same named branch).

Use the 'hg commit --close-branch' command to make a closed branch head.
The branch is considered closed when it only has closed branch heads.


Summing up, the notion of named branches correspond quite closely to how
people model branches in Subversion: if you make your changes in the
directory branches/X/, then we say you "work on the X branch". These
revisions will always be on that branch. You can delete the branch by
deleting the directory from the HEAD revision. The changes remain in the
history and even after merging with trunk/, the old revision will of
course show that they were made in the branches/X/ directory.


Take a look at the bookmarks extension if you want to work with un-named
branches (often called anonymous branches) instead. These branches are
just a fork in the history graph, but they have no permanent name. The
bookmarks gives you a convenient way to refer to them. Without bookmarks
you can of course look at 'hg heads' or some other log viewer.

  http://mercurial.selenic.com/wiki/BookmarksExtension

Since Mercurial 1.6, you can push and pull the bookmarks between
repositories. They used to be local only, but this is now solved. See
the bottom of the wiki page.

-- 
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://mail.python.org/pipermail/python-dev/attachments/20100704/39072623/attachment.pgp>


More information about the Python-Dev mailing list