|
|
(9 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| '''Mercurial''' is the version control system that we'll be using to develop Mozilla 2. It will eventually pretty much replace CVS.
| | #redirect [[mdc:Mercurial]] |
| | |
| = 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 <code>hg clone</code>.)
| |
| | |
| * Mercurial makes branching quick and easy and keeps merging pretty much sane. (See [[Publishing Mercurial Clones]].)
| |
| | |
| * 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 <code>hg push</code>.
| |
| | |
| * [http://hgbook.red-bean.com/hgbookch12.html#x16-26700012 Mercurial queues] can help you juggle patches. It's like [http://savannah.nongnu.org/projects/quilt Quilt]. The idea behind Quilt is this: <blockquote><p>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.</p> <p>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.</p> </blockquote>
| |
| | |
| * When CVS finds merge conflicts, it puts conflict markers in your file. When Mercurial finds merge conflicts, it launches a [http://www.selenic.com/mercurial/wiki/index.cgi/MergeProgram 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|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 [http://www.selenic.com/mercurial/wiki/index.cgi/MergeProgram merge program].
| |
| | |
| == Checking out ==
| |
| The Mozilla 2 trunk is located at http://hg.mozilla.org/mozilla-central .
| |
| | |
| hg clone <nowiki>http://hg.mozilla.org/mozilla-central</nowiki>
| |
| cd mozilla-central
| |
| python client.py checkout
| |
| | |
| {{warning|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 <code>cvs up</code> is:
| |
| | |
| hg pull -u
| |
| | |
| == Diffing and patching ==
| |
| | |
| * <code>hg diff</code> diffs the entire tree by default. Use <code>hg diff .</code> (note the dot) to diff only the current directory.
| |
| | |
| * When applying a patch generated by Mercurial, use <code>patch -p1</code>, not <code>patch -p0</code>. (This is due to a quirk of Mercurial diff output—it refers to fictional "a" and "b" directories. Don't ask.)
| |
| | |
| <code>hg</code> has no exact equivalent of <code>cvs diff -u8p</code>. The simplest thing is <code>hg diff</code>, which provides 3 lines of context.
| |
| | |
| To get 8 lines of context, enable the <code>hg extdiff</code> command (by editing your <code>~/.hgrc</code> 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 <code>''(your-local-hg-root)''/.hg/hgrc</code> to add this line:
| |
| | |
| <nowiki>[paths]
| |
| default = http://hg.mozilla.org/mozilla-central/</nowiki>
| |
| '''default-push = <nowiki>ssh://hg.mozilla.org/mozilla-central/</nowiki>'''
| |
| | |
| 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.
| |