Mercurial: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎How Mercurial is different: curb my enthusiasm)
(add some links)
Line 92: Line 92:


There's no LXR/MXR for mozilla-central.
There's no LXR/MXR for mozilla-central.
= See also =
* [[mdc:Mercurial]]
* [[Using Mercurial locally with CVS]]
* [[Mercurial on Windows]]

Revision as of 18:08, 4 February 2008

Mercurial is the version control system that we'll be using to develop Mozilla 2. It will eventually pretty much replace CVS.

How Mercurial is different

Mercurial vs. CVS:

  • Mercurial checkins are atomic.
  • In Mercurial, tagging is fast and O(1).
  • Mercurial makes it easy for anyone to fork the central repository. (The command is hg clone.)
  • With Mercurial, a complete, fully armed and operational clone of the entire Mozilla repository is on your local hard drive. You can do work locally and check it in without affecting anybody else. To push changes upstream, use hg push.
  • Mercurial queues can help you juggle patches. It's like Quilt. The idea behind Quilt is this:

    The scripts allow to manage a series of patches by keeping track of the changes each patch makes. Patches can be applied, un-applied, refreshed, etc.

    The key philosophical concept is that your primary output is patches. Not ".c" files, not ".h" files. But patches. So patches are the first-class object here.

  • When CVS finds merge conflicts, it puts conflict markers in your file. When Mercurial finds merge conflicts, it launches a merge program. This is a pain in the neck.
  • In a lot of places where CVS is per-file or per-directory, Mercurial is per-repository. For example, a single Mercurial changeset may contain changes to many files throughout the tree.
  • We hope Mercurial will allow us to rethink the way we work. Teams and individuals should be able to branch and merge much more easily—without opening IT tickets. People outside the community who are powerhouse developers should be able to do surprising stuff with this. Companies maintaining forks of Mozilla should have an easier time too. It all sort of remains to be seen, though.

Basics

Installing Mercurial

Try one of these:

apt-get update; apt-get install mercurial
emerge mercurial
sudo port install mercurial
yum install mercurial

Or visit: http://mercurial.berkwood.com/

Warning signWarning: The Windows version of Mercurial does not automatically convert line endings between Windows and Unix styles. All our repositories use Unix line endings. We need a story for Windows, but right now I have no ideas.

Important: Be sure to set up a merge program.

Checking out

The Mozilla 2 trunk is located at http://hg.mozilla.org/mozilla-central .

hg clone http://hg.mozilla.org/mozilla-central
cd mozilla-central
python client.py checkout
Warning signWarning: If you don't run client.py, it won't build. Then you'll go on IRC and ask why it won't build, and once it becomes clear that you haven't run client.py, you will be ruthlessly mocked. (This is maybe not the best failure mode, but that's how it works right now. Sorry!)

Editing and updating

You can randomly edit files, just like CVS.

The equivalent of cvs up is:

hg pull -u

Diffing and patching

  • hg diff diffs the entire tree by default. Use hg diff . (note the dot) to diff only the current directory.
  • When applying a patch generated by Mercurial, use patch -p1, not patch -p0. (This is due to a quirk of Mercurial diff output—it refers to fictional "a" and "b" directories. Don't ask.)

hg has no exact equivalent of cvs diff -u8p. The simplest thing is hg diff, which provides 3 lines of context.

To get 8 lines of context, enable the hg extdiff command (by editing your ~/.hgrc file). If you agree this is super lame, please leave a polite comment at http://www.selenic.com/mercurial/bts/issue654 .

Checking in

To commit your changes to your local repository:

hg commit

To push those changes upstream to the central repository:

hg push

For that to work, you have to have committer access, and you must edit the file (your-local-hg-root)/.hg/hgrc to add this line:

[paths]
default = http://hg.mozilla.org/mozilla-central/
default-push = ssh://hg.mozilla.org/mozilla-central/

You'll get a bogus error message each time you push:

remote: Could not chdir to home directory : No such file or directory

Just ignore it.

What we don't have

There's no Bonsai for mozilla-central; but if you go to http://hg.mozilla.org/mozilla-central/ and click on "manifest", you can at least browse the tree and get "revisions" (change logs) or "annotate" (blame) for files. (And it works for any repository, not just mozilla-central.)

There's no LXR/MXR for mozilla-central.

See also