# HG changeset patch # User Bryan O'Sullivan # Date 1239950707 25200 # Node ID e6c99cbd0abdfe935a157a99ce4c28f61f405c59 # Parent 3b640272a9663835379f292b699f31767ce2a81e Updates to chapters 5, 6, and 7 diff -r 3b640272a966 -r e6c99cbd0abd en/ch05-collab.xml --- a/en/ch05-collab.xml Sun Apr 12 00:05:30 2009 -0700 +++ b/en/ch05-collab.xml Thu Apr 16 23:45:07 2009 -0700 @@ -19,10 +19,12 @@ For interactive use, the web interface lets you browse a single repository or a collection of repositories. You can view the history of a repository, examine each change (comments and - diffs), and view the contents of each directory and file. + diffs), and view the contents of each directory and file. You + can even get a view of history that gives a graphical view of + the relationships between individual changes and merges. - Also for human consumption, the web interface provides an - RSS feed of the changes in a repository. This lets you + Also for human consumption, the web interface provides + Atom and RSS feeds of the changes in a repository. This lets you subscribe to a repository using your favorite feed reader, and be automatically notified of activity in that repository as soon as it happens. I find this capability much @@ -40,22 +42,40 @@ The easiest way to get started with the web interface is to use your web browser to visit an existing repository, such as the master Mercurial repository at http://www.selenic.com/repo/hg?style=gitweb. + url="http://www.selenic.com/repo/hg">http://www.selenic.com/repo/hg. If you're interested in providing a web interface - to your own repositories, Mercurial provides two ways to do - this. The first is using the hg + to your own repositories, there are several good ways to do + this. + + The easiest and fastest way to get started in an informal + environment is to use the hg serve command, which is best suited to short-term lightweight serving. See below for details of how to use - this command. If you have a long-lived repository that you'd - like to make permanently available, Mercurial has built-in - support for the CGI (Common Gateway Interface) standard, which - all common web servers support. See for details of CGI + this command. + + For longer-lived repositories that you'd like to have + permanently available, there are several public hosting services + available. + + + + Bitbucket, at http://bitbucket.org/, + provides free hosting for open source projects, and paid + hosting for commercial projects. + + + + If you would prefer to host your own repositories, Mercurial + has built-in support for several popular hosting technologies, + most notably CGI (Common Gateway Interface), and WSGI (Web + Services Gateway Interface). See for details of CGI and WSGI configuration. + - Collaboration models @@ -96,8 +116,8 @@ could avoid this particular problem by writing a hook that prevents changes from being merged from an inappropriate branch. + - Informal anarchy @@ -115,7 +135,7 @@ place) and spend several days more or less locked in there, hacking intensely on a handful of projects. - A sprint is the perfect place to use the + A sprint or a hacking session in a coffee shop are the perfect places to use the hg serve command, since hg serve does not require any fancy server infrastructure. You can get started with @@ -129,14 +149,15 @@ they can clone a branch containing a new feature and try it out. - The charm, and the problem, with doing things in an ad hoc - fashion like this is that only people who know about your - changes, and where they are, can see them. Such an informal - approach simply doesn't scale beyond a handful people, because - each individual needs to know about $n$ different repositories - to pull from. + The charm, and the problem, with doing things + in an ad hoc fashion like this is that only people who know + about your changes, and where they are, can see them. Such an + informal approach simply doesn't scale beyond a handful + people, because each individual needs to know about + n different repositories to pull + from. + - A single central repository @@ -162,17 +183,39 @@ lets us put off publishing the potentially unsafe change until it has had a little testing. - In this kind of scenario, people usually use - the ssh protocol to securely push changes - to the central repository, as documented in If a team is hosting its own repository in this + kind of scenario, people will usually use the + ssh protocol to securely push changes to + the central repository, as documented in . It's also usual to publish a - read-only copy of the repository over HTTP using CGI, as in - . Publishing - over HTTP satisfies the needs of people who don't have push - access, and those who want to use web browsers to browse the - repository's history. + read-only copy of the repository over HTTP, as in + . Publishing over HTTP + satisfies the needs of people who don't have push access, and + those who want to use web browsers to browse the repository's + history. + + + + A hosted central repository + A wonderful thing about public hosting services like + Bitbucket is that + not only do they handle the fiddly server configuration + details, such as user accounts, authentication, and secure + wire protocols, they provide additional infrastructure to make + this model work well. + + For instance, a well-engineered hosting service will let + people clone their own copies of a repository with a single + click. This lets people work in separate spaces and share + their changes when they're ready. + + In addition, a good hosting service will let people + communicate with each other, for instance to say there + are changes ready for you to review in this + tree. + Working with multiple branches @@ -196,7 +239,7 @@ another as the need arises. Because repositories are independent of each other, unstable changes in a development branch will never affect a stable branch unless someone - explicitly merges those changes in. + explicitly merges those changes into the stable branch. Here's an example of how this can work in practice. Let's say you have one main branch on a central @@ -227,38 +270,41 @@ &interaction.branching.update; In addition, immediately after the main branch is tagged, - someone can then clone the main branch on the server to a new + we can then clone the main branch on the server to a new stable branch, also on the server. &interaction.branching.clone; - Someone who needs to make a change to the stable branch - can then clone that repository, make - their changes, commit, and push their changes back there. + If we need to make a change to the stable + branch, we can then clone that + repository, make our changes, commit, and push our changes + back there. &interaction.branching.stable; Because Mercurial repositories are independent, and Mercurial doesn't move changes around automatically, the stable and main branches are isolated - from each other. The changes that you made on the main branch + from each other. The changes that we made on the main branch don't leak to the stable branch, and vice versa. - You'll often want all of your bugfixes on the stable + We'll often want all of our bugfixes on the stable branch to show up on the main branch, too. Rather than - rewrite a bugfix on the main branch, you can simply pull and + rewrite a bugfix on the main branch, we can simply pull and merge changes from the stable to the main branch, and - Mercurial will bring those bugfixes in for you. + Mercurial will bring those bugfixes in for us. + + &interaction.branching.merge; - &interaction.branching.merge; + The main branch will still contain changes that + are not on the stable branch, but it will also contain all of + the bugfixes from the stable branch. The stable branch + remains unaffected by these changes, since changes are only + flowing from the stable to the main branch, and not the other + way. + - The main branch will still contain changes that are not on - the stable branch, but it will also contain all of the - bugfixes from the stable branch. The stable branch remains - unaffected by these changes. - - Feature branches @@ -281,8 +327,8 @@ shape, someone on that feature team pulls and merges from the master branch into the feature branch, then pushes back up to the master branch. + - The release train @@ -297,8 +343,8 @@ went out on that train release into the feature branch, and the team continues its work on top of that release so that their feature can make the next release. + - The Linux kernel model @@ -372,8 +418,8 @@ it appropriate; and the pace of development is astounding. And yet Linux is a highly successful, well-regarded piece of software. + - Pull-only versus shared-push collaboration @@ -391,12 +437,11 @@ you'll have to roll your own approach on top (such as applying a patch by hand). - A good distributed revision control tool, such as - Mercurial, will support both models. You and your - collaborators can then structure how you work together based - on your own needs and preferences, not on what contortions - your tools force you into. - + A good distributed revision control tool will + support both models. You and your collaborators can then + structure how you work together based on your own needs and + preferences, not on what contortions your tools force you + into. Where collaboration meets branch management @@ -409,16 +454,16 @@ Even though this subject is intimately related to how your team collaborates, it's dense enough to merit treatment of its own, in . - + The technical side of sharing The remainder of this chapter is devoted to the question of - serving data to your collaborators. + sharing changes with your collaborators. + - Informal sharing with <command role="hg-cmd">hg serve</command> @@ -495,9 +540,9 @@ find out what URL you should send to your collaborators, start it with the option. - + Using the Secure Shell (ssh) protocol @@ -506,11 +551,11 @@ protocol. To use this successfully, you may have to do a little bit of configuration on the client or server sides. - If you're not familiar with ssh, it's a network protocol - that lets you securely communicate with another computer. To - use it with Mercurial, you'll be setting up one or more user - accounts on a server so that remote users can log in and execute - commands. + If you're not familiar with ssh, it's the name of + both a command and a network protocol that let you securely + communicate with another computer. To use it with Mercurial, + you'll be setting up one or more user accounts on a server so + that remote users can log in and execute commands. (If you are familiar with ssh, you'll probably find some of the material that follows to be elementary @@ -569,8 +614,8 @@ absolute path on the server, begin the path component with two slashes, as in this example. ssh://server//absolute/path + - Finding an ssh client for your system @@ -582,44 +627,44 @@ unlikely event that it isn't present, take a look at your system documentation to figure out how to install it. - On Windows, you'll first need to download a suitable ssh - client. There are two alternatives. - - Simon Tatham's excellent PuTTY package - web:putty provides a complete suite - of ssh client commands. - - If you have a high tolerance for pain, you can - use the Cygwin port of OpenSSH. - - In either case, you'll need to edit your hg.ini file to - tell Mercurial where to find the actual client command. For - example, if you're using PuTTY, you'll need to use the - plink command as a command-line ssh - client. - [ui] -ssh = C:/path/to/plink.exe -ssh -i "C:/path/to/my/private/key" + On Windows, the TortoiseHg package is bundled + with a version of Simon Tatham's excellent + plink command, and you should not need to + do any further configuration. + - - The path to plink shouldn't contain - any whitespace characters, or Mercurial may not be able to - run it correctly (so putting it in C:\Program Files is probably - not a good idea). - - - Generating a key pair - To avoid the need to repetitively type a password every - time you need to use your ssh client, I recommend generating a - key pair. On a Unix-like system, the - ssh-keygen command will do the trick. On - Windows, if you're using PuTTY, the - puttygen command is what you'll - need. + To avoid the need to repetitively type a + password every time you need to use your ssh client, I + recommend generating a key pair. + + + Key pairs are not mandatory + + Mercurial knows nothing about ssh authentication or key + pairs. You can, if you like, safely ignore this section and + the one that follows until you grow tired of repeatedly + typing ssh passwords. + + + + + On a Unix-like system, the + ssh-keygen command will do the + trick. + On Windows, if you're using TortoiseHg, you may need + to download a command named puttygen + from the + PuTTY web site to generate a key pair. See + the + puttygen documentation for + details of how use the command. + + When you generate a key pair, it's usually highly advisable to protect it with a @@ -642,7 +687,6 @@ public key to a file of your choosing, or paste it from the window it's displayed in straight into the authorized_keys file. - Using an authentication agent @@ -663,21 +707,34 @@ judgment as to whether this is an acceptable risk. It certainly saves a lot of repeated typing. - On Unix-like systems, the agent is called - ssh-agent, and it's often run automatically - for you when you log in. You'll need to use the - ssh-add command to add passphrases to the - agent's store. On Windows, if you're using PuTTY, the - pageant command acts as the agent. It adds - an icon to your system tray that will let you manage stored - passphrases. + + + On Unix-like systems, the agent is called + ssh-agent, and it's often run + automatically for you when you log in. You'll need to use + the ssh-add command to add passphrases + to the agent's store. + + + On Windows, if you're using TortoiseHg, the + pageant command acts as the agent. As + with puttygen, you'll need to download + pageant from the PuTTY web + site and read its + documentation. The pageant + command adds an icon to your system tray that will let you + manage stored passphrases. + + + - Configuring the server side properly Because ssh can be fiddly to set up if you're new to it, - there's a variety of things that can go wrong. Add Mercurial + a variety of things can go wrong. Add Mercurial on top, and there's plenty more scope for head-scratching. Most of these potential problems occur on the server side, not the client side. The good news is that once you've gotten a @@ -821,7 +878,6 @@ If you run into problems with Mercurial and ssh at this point, try using the option to get a clearer picture of what's going on. - Using compression with ssh @@ -842,31 +898,40 @@ accept a option which turns on compression. You can easily edit your ~/.hgrc to enable compression for - all of Mercurial's uses of the ssh protocol. + all of Mercurial's uses of the ssh protocol. Here is how to + do so for regular ssh on Unix-like systems, + for example. [ui] ssh = ssh -C - If you use ssh, you can configure it to - always use compression when talking to your server. To do - this, edit your .ssh/config file (which may not - yet exist), as follows. + If you use ssh on a + Unix-like system, you can configure it to always use + compression when talking to your server. To do this, edit + your .ssh/config file + (which may not yet exist), as follows. + Host hg Compression yes HostName hg.example.com - This defines an alias, hg. When you - use it on the ssh command line or in a - Mercurial ssh-protocol URL, it will cause + + This defines a hostname alias, + hg. When you use that hostname on the + ssh command line or in a Mercurial + ssh-protocol URL, it will cause ssh to connect to hg.example.com and use compression. This gives you both a shorter name to type and compression, each of which is a good thing in its own right. - + Serving over HTTP using CGI + The simplest way to host one or more repositories in a + permanent way is to use a web server and Mercurial's CGI + support. + Depending on how ambitious you are, configuring Mercurial's CGI interface can take anything from a few moments to several hours. @@ -877,13 +942,20 @@ your web server's configuration. - Configuring a web server is a complex, fiddly, and - highly system-dependent activity. I can't possibly give you - instructions that will cover anything like all of the cases - you will encounter. Please use your discretion and judgment in - following the sections below. Be prepared to make plenty of - mistakes, and to spend a lot of time reading your server's - error logs. + High pain tolerance required + + Configuring a web server is a complex, fiddly, + and highly system-dependent activity. I can't possibly give + you instructions that will cover anything like all of the + cases you will encounter. Please use your discretion and + judgment in following the sections below. Be prepared to make + plenty of mistakes, and to spend a lot of time reading your + server's error logs. + + If you don't have a strong stomach for tweaking + configurations over and over, or a compelling need to host + your own services, you might want to try one of the public + hosting services that I mentioned earlier. @@ -893,9 +965,10 @@ aspects of your system's setup. - Do you have a web server installed at all? - Mac OS X ships with Apache, but many other systems may not - have a web server installed. + Do you have a web server installed + at all? Mac OS X and some Linux distributions ship with + Apache, but many other systems may not have a web server + installed. If you have a web server installed, is it actually running? On most systems, even if one is @@ -917,8 +990,8 @@ repositories. And lighttpd is undeniably much easier to get started with than Apache. + - Basic CGI configuration @@ -1048,8 +1121,8 @@ At this point, when you try to reload the page, you should be presented with a nice HTML view of your repository's history. Whew! + - Configuring lighttpd @@ -1084,9 +1157,9 @@ configure than Apache, even though I've used Apache for over a decade, and this was my first exposure to lighttpd. - + Sharing multiple repositories with one CGI script @@ -1214,14 +1287,16 @@ file. - If multiple repositories have the same virtual path, - hgwebdir.cgi will not - report an error. Instead, it will behave - unpredictably. + Beware duplicate virtual paths + + If several repositories have the same + virtual path, hgwebdir.cgi will not report + an error. Instead, it will behave unpredictably. - + Downloading source archives @@ -1234,8 +1309,7 @@ you'll need to add an allow_archive item to the web section of your ~/.hgrc. - + role="special">~/.hgrc; see below for details. Web configuration options @@ -1317,9 +1391,28 @@ style: Controls the template Mercurial uses to display the web interface. Mercurial - ships with two web templates, named - default and gitweb - (the latter is much more visually attractive). You can + ships with several web templates. + + + coal is monochromatic. + + + gitweb emulates the visual + style of git's web interface. + + + monoblue uses solid blues and + greys. + + + paper is the default. + + + spartan was the default for a + long time. + + + You can also specify a custom template of your own; see for details. Here, you can see how to enable the gitweb @@ -1360,8 +1453,8 @@ interface. This overrides the default name, which is the last component of the repository's path. + - Options specific to the <command role="hg-cmd">hg serve</command> command @@ -1399,8 +1492,8 @@ Integer. The TCP port number on which the server should listen. The default port number used is 8000. + - Choosing the right <filename role="special">~/.hgrc</filename> file to add <literal @@ -1422,10 +1515,55 @@ <filename role="special">~/.hgrc</filename> file in the home directory of the user ID that runs your web server, or add those settings to a system-wide <filename - role="special">~/.hgrc</filename> file.</para> + role="special">hgrc</filename> file.</para> + </sect3> + </sect2> + </sect1> + + <sect1> + <title>System-wide configuration + + On Unix-like systems shared by multiple users (such as a + server to which people publish changes), it often makes sense to + set up some global default behaviors, such as what theme to use + in web interfaces. + + If a file named /etc/mercurial/hgrc + exists, Mercurial will read it at startup time and apply any + configuration settings it finds in that file. It will also look + for files ending in a .rc extension in a + directory named /etc/mercurial/hgrc.d, and + apply any configuration settings it finds in each of those + files. + + + Making Mercurial more trusting + One situation in which a global hgrc + can be useful is if users are pulling changes owned by other + users. By default, Mercurial will not trust most of the + configuration items in a .hg/hgrc file + inside a repository that is owned by a different user. If we + clone or pull changes from such a repository, Mercurial will + print a warning stating that it does not trust their + .hg/hgrc. - + If everyone in a particular Unix group is on the same team + and should trust each other's + configuration settings, or we want to trust particular users, + we can override Mercurial's skeptical defaults by creating a + system-wide hgrc file such as the + following: + + # Save this as e.g. /etc/mercurial/hgrc.d/trust.rc +[trusted] +# Trust all entries in any hgrc file owned by the "editors" or +# "www-data" groups. +groups = editors, www-data + +# Trust entries in hgrc files owned by the following users. +users = apache, bobo + diff -r 3b640272a966 -r e6c99cbd0abd en/ch06-filenames.xml --- a/en/ch06-filenames.xml Sun Apr 12 00:05:30 2009 -0700 +++ b/en/ch06-filenames.xml Thu Apr 16 23:45:07 2009 -0700 @@ -27,8 +27,8 @@ before continuing with the current directory. &interaction.filenames.dirs; + - Running commands without any file names @@ -70,8 +70,8 @@ role="hg-cmd">hg root command. &interaction.filenames.wdir-relname; + - Telling you what's going on @@ -85,17 +85,17 @@ The principle here is of least surprise. If you've exactly named a file on the command line, there's no point in repeating it back at you. If - Mercurial is acting on a file implicitly, + Mercurial is acting on a file implicitly, e.g. because you provided no names, or a directory, or a pattern (see - below), it's safest to tell you what it's doing. + below), it is safest to tell you what files it's operating on. For commands that behave this way, you can silence them using the option. You can also get them to print the name of every file, even those you've named explicitly, using the option. + - Using patterns to identify files @@ -194,9 +194,9 @@ example illustrates the difference between the two. &interaction.filenames.glob.star-starstar; - + Regular expression matching with <literal>re</literal> patterns @@ -227,9 +227,9 @@ string; it doesn't look for a match anywhere within the string. To match anywhere in a string, start your pattern with .*. - + Filtering files @@ -266,14 +266,65 @@ pattern. &interaction.filenames.filter.exclude; + - - Ignoring unwanted files and directories + Permanently ignoring unwanted files and directories + + When you create a new repository, the chances are + that over time it will grow to contain files that ought to + not be managed by Mercurial, but which you + don't want to see listed every time you run hg + status. For instance, build products + are files that are created as part of a build but which should + not be managed by a revision control system. The most common + build products are output files produced by software tools such + as compilers. As another example, many text editors litter a + directory with lock files, temporary working files, and backup + files, which it also makes no sense to manage. + + To have Mercurial permanently ignore such files, create a + file named .hgignore in the root of your + repository. You should hg + add this file so that it gets tracked with the rest of + your repository contents, since your collaborators will probably + find it useful too. + + By default, the .hgignore file should + contain a list of regular expressions, one per line. Empty + lines are skipped. Most people prefer to describe the files they + want to ignore using the glob syntax that we + described above, so a typical .hgignore + file will start with this directive: - XXX. + syntax: glob + + This tells Mercurial to interpret the lines that follow as + glob patterns, not regular expressions. + + Here is a typical-looking .hgignore + file. + + syntax: glob +# This line is a comment, and will be skipped. +# Empty lines are skipped too. +# Backup files left behind by the Emacs editor. +*~ + +# Lock files used by the Emacs editor. +# Notice that the "#" character is quoted with a backslash. +# This prevents it from being interpreted as starting a comment. +.\#* + +# Temporary files used by the vim editor. +.*.swp + +# A hidden file created by the Mac OS X Finder. +.DS_Store + + Case sensitivity @@ -361,8 +412,8 @@ conflict between the two file names that the filesystem would treat as the same, and forbid the update or merge from occurring. + - Fixing a case conflict @@ -388,15 +439,6 @@ hg update your working directory to that changeset on a Windows or MacOS system, but you can continue development unimpeded. - - - Prior to version 0.9.3, Mercurial did not use a case - safe repository storage mechanism, and did not detect case - folding conflicts. If you are using an older version of - Mercurial on Windows or MacOS, I strongly recommend that you - upgrade. - - diff -r 3b640272a966 -r e6c99cbd0abd en/ch07-branch.xml --- a/en/ch07-branch.xml Sun Apr 12 00:05:30 2009 -0700 +++ b/en/ch07-branch.xml Thu Apr 16 23:45:07 2009 -0700 @@ -128,7 +128,7 @@ Mercurial stores tags in a normal revision-controlled file in your repository. If you've created any tags, you'll find - them in a file named .hgtags. When you run the hg tag command, Mercurial modifies this file, then automatically commits the change to it. This @@ -170,8 +170,8 @@ location of the error, which you can then fix and commit. You should then run hg tags again, just to be sure that your fix is correct. + - Tags and cloning @@ -195,8 +195,8 @@ project's history in the new repository, but not the tag you might have expected. + - When permanent tags are too much @@ -221,9 +221,9 @@ controlled. Any tags you create using remain strictly local to the repository you're currently working in. - + The flow of changes&emdash;big picture vs. little @@ -252,8 +252,8 @@ merging changes. They expose the narrative of how the code was developed. + - Managing big-picture branches in repositories @@ -285,8 +285,8 @@ the myproject repository. &interaction.branch-repo.new; + - Don't repeat yourself: merging across branches @@ -308,8 +308,8 @@ push back to the main branch. &interaction.branch-repo.merge; + - Naming branches within one repository @@ -408,8 +408,8 @@ In practice, this is something you won't do very often, as branch names tend to have fairly long lifetimes. (This isn't a rule, just an observation.) + - Dealing with multiple named branches in a repository @@ -454,8 +454,8 @@ introduces a new head. &interaction.branch-named.foo-commit; + - Branch names and merging @@ -496,8 +496,8 @@ Mercurial will choose the right (bleeding-edge) branch name when I pull and merge from stable. + - Branch naming is generally useful @@ -522,7 +522,6 @@ /.hgrc. [hooks] pretxnchangegroup.branch = hg heads --template '{branches} ' | grep mybranch -