bos@553: bos@553: dongsheng@625: bos@572: bos@553: A tour of Mercurial: the basics bos@559: dongsheng@625: bos@553: Installing Mercurial on your system bos@553: bos@553: Prebuilt binary packages of Mercurial are available for bos@553: every popular operating system. These make it easy to start bos@553: using Mercurial on your computer immediately. bos@553: bos@553: bos@553: Linux bos@553: bos@553: Because each Linux distribution has its own packaging bos@553: tools, policies, and rate of development, it's difficult to bos@553: give a comprehensive set of instructions on how to install bos@553: Mercurial binaries. The version of Mercurial that you will bos@553: end up with can vary depending on how active the person is who bos@553: maintains the package for your distribution. bos@553: bos@553: To keep things simple, I will focus on installing bos@553: Mercurial from the command line under the most popular Linux bos@553: distributions. Most of these distributions provide graphical bos@553: package managers that will let you install Mercurial with a bos@553: single click; the package name to look for is bos@553: mercurial. bos@553: bos@553: bos@553: Debian: bos@579: apt-get install mercurial bos@553: Fedora Core: bos@579: yum install mercurial bos@553: Gentoo: bos@553: emerge mercurial bos@553: OpenSUSE: bos@579: yum install mercurial bos@553: Ubuntu: Ubuntu's Mercurial package is based on bos@553: Debian's. To install it, run the following bos@553: command. bos@579: apt-get install mercurial bos@553: bos@553: bos@553: bos@553: bos@553: Solaris bos@553: bos@553: SunFreeWare, at http://www.sunfreeware.com, bos@553: is a good source for a large number of pre-built Solaris bos@553: packages for 32 and 64 bit Intel and Sparc architectures, bos@553: including current versions of Mercurial. bos@553: bos@553: bos@553: bos@553: Mac OS X bos@553: bos@553: Lee Cantey publishes an installer of Mercurial for Mac OS bos@553: X at http://mercurial.berkwood.com. bos@559: This package works on both Intel- and Power-based Macs. Before bos@559: you can use it, you must install a compatible version of bos@559: Universal MacPython web:macpython. This bos@559: is easy to do; simply follow the instructions on Lee's bos@553: site. bos@553: bos@553: It's also possible to install Mercurial using Fink or bos@553: MacPorts, two popular free package managers for Mac OS X. If bos@553: you have Fink, use sudo apt-get install bos@553: mercurial-py25. If MacPorts, sudo port bos@553: install mercurial. bos@553: bos@553: bos@553: bos@553: Windows bos@553: bos@553: Lee Cantey publishes an installer of Mercurial for Windows bos@553: at http://mercurial.berkwood.com. bos@553: This package has no external dependencies; it just bos@553: works. bos@553: bos@553: bos@553: The Windows version of Mercurial does not bos@553: automatically convert line endings between Windows and Unix bos@553: styles. If you want to share work with Unix users, you must bos@553: do a little additional configuration work. XXX Flesh this bos@553: out. bos@553: bos@553: bos@553: bos@553: bos@553: bos@553: Getting started bos@553: bos@553: To begin, we'll use the hg bos@553: version command to find out whether Mercurial is bos@553: actually installed properly. The actual version information bos@553: that it prints isn't so important; it's whether it prints bos@559: anything at all that we care about. bos@559: bos@566: &interaction.tour.version; bos@553: bos@553: bos@553: Built-in help bos@553: bos@553: Mercurial provides a built-in help system. This is bos@559: invaluable for those times when you find yourself stuck bos@559: trying to remember how to run a command. If you are bos@559: completely stuck, simply run hg bos@559: help; it will print a brief list of commands, bos@559: along with a description of what each does. If you ask for bos@559: help on a specific command (as below), it prints more bos@559: detailed information. bos@559: bos@566: &interaction.tour.help; bos@559: bos@559: For a more impressive level of detail (which you won't bos@559: usually need) run hg help . The option is short for bos@559: , and tells bos@559: Mercurial to print more information than it usually bos@559: would. bos@553: bos@553: bos@553: bos@553: bos@553: Working with a repository bos@553: bos@553: In Mercurial, everything happens inside a bos@553: repository. The repository for a project bos@553: contains all of the files that belong to that bos@553: project, along with a historical record of the project's bos@553: files. bos@553: bos@553: There's nothing particularly magical about a repository; it bos@553: is simply a directory tree in your filesystem that Mercurial bos@553: treats as special. You can rename or delete a repository any bos@553: time you like, using either the command line or your file bos@553: browser. bos@553: bos@553: bos@553: Making a local copy of a repository bos@553: bos@553: Copying a repository is just a little bos@553: bit special. While you could use a normal file copying bos@553: command to make a copy of a repository, it's best to use a bos@553: built-in command that Mercurial provides. This command is bos@553: called hg clone, because it bos@559: creates an identical copy of an existing repository. bos@559: bos@566: &interaction.tour.clone; bos@559: bos@559: If our clone succeeded, we should now have a local bos@559: directory called hello. bos@559: This directory will contain some files. bos@559: bos@566: &interaction.tour.ls; bos@559: bos@559: These files have the same contents and history in our bos@559: repository as they do in the repository we cloned. bos@553: bos@553: Every Mercurial repository is complete, self-contained, bos@553: and independent. It contains its own private copy of a bos@553: project's files and history. A cloned repository remembers bos@553: the location of the repository it was cloned from, but it does bos@553: not communicate with that repository, or any other, unless you bos@553: tell it to. bos@553: bos@553: What this means for now is that we're free to experiment bos@553: with our repository, safe in the knowledge that it's a private bos@553: sandbox that won't affect anyone else. bos@553: bos@553: bos@553: bos@553: What's in a repository? bos@553: bos@553: When we take a more detailed look inside a repository, we bos@553: can see that it contains a directory named .hg. This is where Mercurial bos@559: keeps all of its metadata for the repository. bos@559: bos@566: &interaction.tour.ls-a; bos@553: bos@553: The contents of the .hg directory and its bos@553: subdirectories are private to Mercurial. Every other file and bos@553: directory in the repository is yours to do with as you bos@553: please. bos@553: bos@553: To introduce a little terminology, the .hg directory is the bos@553: real repository, and all of the files and bos@553: directories that coexist with it are said to live in the bos@553: working directory. An easy way to bos@553: remember the distinction is that the bos@553: repository contains the bos@553: history of your project, while the bos@553: working directory contains a bos@553: snapshot of your project at a particular bos@553: point in history. bos@553: bos@553: bos@553: bos@553: bos@553: A tour through history bos@553: bos@553: One of the first things we might want to do with a new, bos@553: unfamiliar repository is understand its history. The hg log command gives us a view of bos@559: history. bos@559: bos@566: &interaction.tour.log; bos@559: bos@559: By default, this command prints a brief paragraph of output bos@559: for each change to the project that was recorded. In Mercurial bos@559: terminology, we call each of these recorded events a bos@553: changeset, because it can contain a record bos@553: of changes to several files. bos@553: bos@553: The fields in a record of output from hg log are as follows. bos@553: bos@553: changeset: This field has the bos@553: format of a number, followed by a colon, followed by a bos@553: hexadecimal string. These are bos@553: identifiers for the changeset. There bos@553: are two identifiers because the number is shorter and easier bos@553: to type than the hex string. bos@553: user: The identity of the bos@553: person who created the changeset. This is a free-form bos@553: field, but it most often contains a person's name and email bos@553: address. bos@553: date: The date and time on bos@553: which the changeset was created, and the timezone in which bos@553: it was created. (The date and time are local to that bos@553: timezone; they display what time and date it was for the bos@553: person who created the changeset.) bos@553: summary: The first line of bos@553: the text message that the creator of the changeset entered bos@553: to describe the changeset. bos@553: The default output printed by hg bos@553: log is purely a summary; it is missing a lot of bos@553: detail. bos@553: dongsheng@640: Figure provides a bos@553: graphical representation of the history of the hello repository, to make it a bos@553: little easier to see which direction history is bos@553: flowing in. We'll be returning to this figure bos@553: several times in this chapter and the chapter that bos@553: follows. bos@553: dongsheng@625: bos@558: dongsheng@625: bos@558: XXX add text dongsheng@640: Graphical history of dongsheng@640: the hello repository dongsheng@640: bos@558: bos@558: bos@553: bos@553: bos@553: Changesets, revisions, and talking to other bos@553: people bos@553: bos@553: As English is a notoriously sloppy language, and computer bos@553: science has a hallowed history of terminological confusion bos@553: (why use one term when four will do?), revision control has a bos@553: variety of words and phrases that mean the same thing. If you bos@553: are talking about Mercurial history with other people, you bos@553: will find that the word changeset is often bos@553: compressed to change or (when written) bos@553: cset, and sometimes a changeset is referred to bos@553: as a revision or a rev. bos@553: bos@553: While it doesn't matter what word you bos@553: use to refer to the concept of a changeset, the bos@553: identifier that you use to refer to bos@553: a specific changeset is of bos@553: great importance. Recall that the changeset bos@553: field in the output from hg bos@553: log identifies a changeset using both a number and bos@553: a hexadecimal string. bos@553: bos@553: The revision number is only valid in bos@553: that repository, bos@553: while the hex string is the bos@553: permanent, unchanging identifier that bos@553: will always identify that exact changeset in bos@553: every copy of the bos@553: repository. bos@553: This distinction is important. If you send someone an bos@553: email talking about revision 33, there's a high bos@553: likelihood that their revision 33 will not be the bos@553: same as yours. The reason for this is that a bos@553: revision number depends on the order in which changes arrived bos@553: in a repository, and there is no guarantee that the same bos@553: changes will happen in the same order in different bos@553: repositories. Three changes $a,b,c$ can easily appear in one bos@553: repository as $0,1,2$, while in another as $1,0,2$. bos@553: bos@553: Mercurial uses revision numbers purely as a convenient bos@553: shorthand. If you need to discuss a changeset with someone, bos@553: or make a record of a changeset for some other reason (for bos@553: example, in a bug report), use the hexadecimal bos@553: identifier. bos@553: bos@553: bos@553: bos@553: Viewing specific revisions bos@553: bos@553: To narrow the output of hg bos@553: log down to a single revision, use the (or ) option. You can use bos@553: either a revision number or a long-form changeset identifier, bos@559: and you can provide as many revisions as you want. bos@559: bos@566: &interaction.tour.log-r; bos@553: bos@553: If you want to see the history of several revisions bos@553: without having to list each one, you can use range bos@553: notation; this lets you express the idea I bos@559: want all revisions between abc and bos@559: def, inclusive. bos@559: bos@566: &interaction.tour.log.range; bos@559: bos@559: Mercurial also honours the order in which you specify bos@559: revisions, so hg log -r 2:4 bos@559: prints 2, 3, and 4. while hg log -r bos@559: 4:2 prints 4, 3, and 2. bos@553: bos@553: bos@553: bos@553: More detailed information bos@553: bos@553: While the summary information printed by hg log is useful if you already know bos@553: what you're looking for, you may need to see a complete bos@553: description of the change, or a list of the files changed, if bos@553: you're trying to decide whether a changeset is the one you're bos@553: looking for. The hg log bos@553: command's (or ) option gives you bos@559: this extra detail. bos@559: bos@566: &interaction.tour.log-v; bos@553: bos@553: If you want to see both the description and content of a bos@553: change, add the (or bos@553: ) option. This bos@553: displays the content of a change as a unified bos@553: diff (if you've never seen a unified diff before, dongsheng@625: see section for an bos@559: overview). bos@559: bos@566: &interaction.tour.log-vp; bos@553: bos@553: bos@553: bos@553: bos@553: All about command options bos@553: bos@553: Let's take a brief break from exploring Mercurial commands bos@553: to discuss a pattern in the way that they work; you may find bos@553: this useful to keep in mind as we continue our tour. bos@553: bos@553: Mercurial has a consistent and straightforward approach to bos@553: dealing with the options that you can pass to commands. It bos@553: follows the conventions for options that are common to modern bos@553: Linux and Unix systems. bos@553: bos@553: Every option has a long name. For example, as bos@553: we've already seen, the hg bos@553: log command accepts a option. bos@553: Most options have short names, too. Instead of bos@553: , we can use . (The reason that some bos@553: options don't have short names is that the options in bos@553: question are rarely used.) bos@553: Long options start with two dashes (e.g. ), while short options bos@553: start with one (e.g. ). bos@553: Option naming and usage is consistent across bos@553: commands. For example, every command that lets you specify bos@553: a changeset ID or revision number accepts both and bos@553: arguments. bos@553: In the examples throughout this book, I use short options bos@553: instead of long. This just reflects my own preference, so don't bos@553: read anything significant into it. bos@553: bos@553: Most commands that print output of some kind will print more bos@553: output when passed a bos@553: (or ) option, and bos@553: less when passed (or bos@553: ). bos@553: bos@553: bos@553: bos@553: Making and reviewing changes bos@553: bos@553: Now that we have a grasp of viewing history in Mercurial, bos@553: let's take a look at making some changes and examining bos@553: them. bos@553: bos@553: The first thing we'll do is isolate our experiment in a bos@553: repository of its own. We use the hg bos@553: clone command, but we don't need to clone a copy of bos@553: the remote repository. Since we already have a copy of it bos@553: locally, we can just clone that instead. This is much faster bos@553: than cloning over the network, and cloning a local repository bos@559: uses less disk space in most cases, too. bos@559: bos@566: &interaction.tour.reclone; bos@559: bos@559: As an aside, it's often good practice to keep a bos@559: pristine copy of a remote repository around, bos@559: which you can then make temporary clones of to create sandboxes bos@559: for each task you want to work on. This lets you work on bos@559: multiple tasks in parallel, each isolated from the others until bos@559: it's complete and you're ready to integrate it back. Because bos@559: local clones are so cheap, there's almost no overhead to cloning bos@559: and destroying repositories whenever you want. bos@553: bos@553: In our my-hello bos@553: repository, we have a file hello.c that bos@553: contains the classic hello, world program. Let's bos@553: use the ancient and venerable sed command to bos@553: edit this file so that it prints a second line of output. (I'm bos@553: only using sed to do this because it's easy bos@553: to write a scripted example this way. Since you're not under bos@553: the same constraint, you probably won't want to use bos@553: sed; simply use your preferred text editor to bos@559: do the same thing.) bos@559: bos@566: &interaction.tour.sed; bos@553: bos@553: Mercurial's hg status bos@553: command will tell us what Mercurial knows about the files in the bos@559: repository. bos@559: bos@566: &interaction.tour.status; bos@559: bos@559: The hg status command bos@559: prints no output for some files, but a line starting with bos@553: M for bos@553: hello.c. Unless you tell it to, hg status will not print any output bos@553: for files that have not been modified. bos@553: bos@553: The M indicates that bos@553: Mercurial has noticed that we modified bos@553: hello.c. We didn't need to bos@553: inform Mercurial that we were going to bos@553: modify the file before we started, or that we had modified the bos@553: file after we were done; it was able to figure this out bos@553: itself. bos@553: bos@553: It's a little bit helpful to know that we've modified bos@553: hello.c, but we might prefer to know bos@553: exactly what changes we've made to it. To bos@553: do this, we use the hg diff bos@559: command. bos@559: bos@566: &interaction.tour.diff; bos@553: bos@553: bos@553: bos@553: Recording changes in a new changeset bos@553: bos@553: We can modify files, build and test our changes, and use bos@553: hg status and hg diff to review our changes, until bos@553: we're satisfied with what we've done and arrive at a natural bos@553: stopping point where we want to record our work in a new bos@553: changeset. bos@553: bos@553: The hg commit command lets bos@553: us create a new changeset; we'll usually refer to this as bos@553: making a commit or bos@553: committing. bos@553: bos@553: bos@553: Setting up a username bos@553: bos@553: When you try to run hg bos@553: commit for the first time, it is not guaranteed to bos@553: succeed. Mercurial records your name and address with each bos@553: change that you commit, so that you and others will later be bos@553: able to tell who made each change. Mercurial tries to bos@553: automatically figure out a sensible username to commit the bos@553: change with. It will attempt each of the following methods, bos@553: in order: bos@553: bos@553: If you specify a option to the hg commit command on the command bos@553: line, followed by a username, this is always given the bos@553: highest precedence. bos@553: If you have set the HGUSER bos@553: environment variable, this is checked bos@553: next. bos@553: If you create a file in your home directory bos@553: called .hgrc, with a bos@553: username entry, that will bos@553: be used next. To see what the contents of this file bos@553: should look like, refer to section bos@553: below. bos@553: If you have set the EMAIL bos@553: environment variable, this will be used bos@553: next. bos@553: Mercurial will query your system to find out bos@553: your local user name and host name, and construct a bos@553: username from these components. Since this often results bos@553: in a username that is not very useful, it will print a bos@553: warning if it has to do bos@558: this. bos@558: bos@558: If all of these mechanisms fail, Mercurial will bos@553: fail, printing an error message. In this case, it will not bos@553: let you commit until you set up a bos@558: username. bos@558: You should think of the HGUSER environment bos@558: variable and the bos@558: option to the hg commit bos@558: command as ways to override Mercurial's bos@558: default selection of username. For normal use, the simplest bos@558: and most robust way to set a username for yourself is by bos@558: creating a .hgrc file; see bos@558: below for details. dongsheng@625: bos@553: Creating a Mercurial configuration file bos@558: bos@558: To set a user name, use your favourite editor bos@553: to create a file called .hgrc in your home directory. bos@553: Mercurial will use this file to look up your personalised bos@553: configuration settings. The initial contents of your bos@553: .hgrc should look like bos@558: this. bos@558: # This is a Mercurial configuration file. bos@579: [ui] bos@579: username = Firstname Lastname bos@558: <email.address@domain.net> bos@558: bos@558: The [ui] line begins a bos@558: section of the config file, so you can bos@558: read the username = ... bos@558: line as meaning set the value of the bos@558: username item in the bos@558: ui section. A section continues bos@558: until a new section begins, or the end of the file. bos@558: Mercurial ignores empty lines and treats any text from bos@558: # to the end of a line as bos@558: a comment. bos@553: bos@558: bos@553: bos@553: Choosing a user name bos@553: bos@558: You can use any text you like as the value of bos@553: the username config item, since this bos@553: information is for reading by other people, but for bos@553: interpreting by Mercurial. The convention that most bos@553: people follow is to use their name and email address, as bos@558: in the example above. bos@553: bos@558: Mercurial's built-in web server obfuscates bos@553: email addresses, to make it more difficult for the email bos@553: harvesting tools that spammers use. This reduces the bos@553: likelihood that you'll start receiving more junk email bos@553: if you publish a Mercurial repository on the bos@558: web. bos@553: bos@553: bos@553: bos@553: bos@553: Writing a commit message bos@553: bos@558: When we commit a change, Mercurial drops us into bos@553: a text editor, to enter a message that will describe the bos@553: modifications we've made in this changeset. This is called bos@553: the commit message. It will be a bos@553: record for readers of what we did and why, and it will be bos@553: printed by hg log after bos@558: we've finished committing. bos@558: bos@566: &interaction.tour.commit; bos@558: bos@558: The editor that the hg bos@553: commit command drops us into will contain an bos@553: empty line, followed by a number of lines starting with bos@558: HG:. bos@558: bos@558: XXX fix this XXX bos@558: bos@558: Mercurial ignores the lines that start with bos@553: HG:; it uses them only to bos@553: tell us which files it's recording changes to. Modifying or bos@558: deleting these lines has no effect. bos@553: bos@553: bos@553: Writing a good commit message bos@553: bos@558: Since hg log bos@553: only prints the first line of a commit message by default, bos@553: it's best to write a commit message whose first line stands bos@553: alone. Here's a real example of a commit message that bos@553: doesn't follow this guideline, and bos@553: hence has a summary that is not bos@558: readable. bos@558: bos@558: bos@558: changeset: 73:584af0e231be bos@579: user: Censored Person <censored.person@example.org> bos@579: date: Tue Sep 26 21:37:07 2006 -0700 bos@558: summary: include buildmeister/commondefs. Add exports. bos@558: bos@558: As far as the remainder of the contents of the bos@553: commit message are concerned, there are no hard-and-fast bos@553: rules. Mercurial itself doesn't interpret or care about the bos@553: contents of the commit message, though your project may have bos@553: policies that dictate a certain kind of bos@558: formatting. bos@558: My personal preference is for short, but bos@553: informative, commit messages that tell me something that I bos@553: can't figure out with a quick glance at the output of bos@553: hg log bos@558: --patch. bos@553: bos@553: bos@553: Aborting a commit bos@553: bos@558: If you decide that you don't want to commit bos@553: while in the middle of editing a commit message, simply exit bos@553: from your editor without saving the file that it's editing. bos@553: This will cause nothing to happen to either the repository bos@558: or the working directory. bos@558: If we run the hg bos@553: commit command without any arguments, it records bos@553: all of the changes we've made, as reported by hg status and hg diff. bos@553: bos@553: bos@553: Admiring our new handiwork bos@553: bos@558: Once we've finished the commit, we can use the bos@553: hg tip command to display bos@553: the changeset we just created. This command produces output bos@553: that is identical to hg bos@553: log, but it only displays the newest revision in bos@558: the repository. bos@558: bos@566: &interaction.tour.tip; bos@558: bos@558: We refer to bos@553: the newest revision in the repository as the tip revision, bos@558: or simply the tip. bos@553: bos@553: bos@558: bos@553: bos@553: Sharing changes bos@553: bos@558: We mentioned earlier that repositories in bos@553: Mercurial are self-contained. This means that the changeset bos@553: we just created exists only in our my-hello repository. Let's bos@553: look at a few ways that we can propagate this change into bos@558: other repositories. bos@558: dongsheng@625: bos@553: Pulling changes from another repository bos@558: To get started, let's clone our original bos@553: hello repository, bos@553: which does not contain the change we just committed. We'll bos@553: call our temporary repository hello-pull. bos@558: bos@566: &interaction.tour.clone-pull; bos@558: bos@558: We'll use the hg bos@553: pull command to bring changes from my-hello into hello-pull. However, blindly bos@553: pulling unknown changes into a repository is a somewhat bos@553: scary prospect. Mercurial provides the hg incoming command to tell us bos@553: what changes the hg pull bos@553: command would pull into the repository, bos@558: without actually pulling the changes in. bos@558: bos@566: &interaction.tour.incoming; bos@558: bos@558: (Of course, someone could bos@553: cause more changesets to appear in the repository that we bos@553: ran hg incoming in, before bos@553: we get a chance to hg pull bos@553: the changes, so that we could end up pulling changes that we bos@558: didn't expect.) bos@558: bos@558: Bringing changes into a repository is a simple bos@553: matter of running the hg bos@553: pull command, and telling it which repository to bos@558: pull from. bos@558: bos@566: &interaction.tour.pull; bos@558: bos@558: As you can see bos@553: from the before-and-after output of hg tip, we have successfully bos@553: pulled changes into our repository. There remains one step bos@553: before we can see these changes in the working bos@558: directory. bos@553: bos@553: bos@553: Updating the working directory bos@553: bos@559: We have so far glossed over the relationship between a bos@559: repository and its working directory. The hg pull command that we ran in dongsheng@625: section brought changes bos@559: into the repository, but if we check, there's no sign of those bos@559: changes in the working directory. This is because hg pull does not (by default) touch bos@559: the working directory. Instead, we use the hg update command to do this. bos@559: bos@566: &interaction.tour.update; bos@559: bos@559: It might seem a bit strange that hg bos@559: pull doesn't update the working directory bos@559: automatically. There's actually a good reason for this: you bos@559: can use hg update to update bos@559: the working directory to the state it was in at any bos@559: revision in the history of the repository. If bos@559: you had the working directory updated to an old revision---to bos@559: hunt down the origin of a bug, say---and ran a hg pull which automatically updated bos@559: the working directory to a new revision, you might not be bos@559: terribly happy. bos@559: However, since pull-then-update is such a common thing to bos@559: do, Mercurial lets you combine the two by passing the option to hg pull. bos@558: bos@558: If you look back at the output of hg pull in section when we ran it without , you can see that it printed bos@559: a helpful reminder that we'd have to take an explicit step to bos@559: update the working directory: bos@558: bos@558: bos@558: bos@559: To find out what revision the working directory is at, use bos@559: the hg parents bos@559: command. bos@558: bos@566: &interaction.tour.parents; bos@558: bos@559: If you look back at figure , bos@559: you'll see arrows connecting each changeset. The node that bos@559: the arrow leads from in each case is a bos@559: parent, and the node that the arrow leads bos@559: to is its child. The working directory bos@559: has a parent in just the same way; this is the changeset that bos@559: the working directory currently contains. bos@559: bos@559: To update the working directory to a particular revision, bos@559: bos@559: give a revision number or changeset ID to the hg update command. bos@559: bos@566: &interaction.tour.older; bos@559: bos@559: If you omit an explicit revision, hg update will update to the tip bos@559: revision, as shown by the second call to hg update in the example bos@559: above. bos@558: bos@558: bos@553: bos@553: Pushing changes to another repository bos@553: bos@558: Mercurial lets us push changes to another bos@553: repository, from the repository we're currently visiting. bos@553: As with the example of hg bos@553: pull above, we'll create a temporary repository bos@558: to push our changes into. bos@558: bos@566: &interaction.tour.clone-push; bos@558: bos@558: The hg outgoing command bos@553: tells us what changes would be pushed into another bos@558: repository. bos@558: bos@566: &interaction.tour.outgoing; bos@558: bos@558: And the bos@553: hg push command does the bos@558: actual push. bos@558: bos@566: &interaction.tour.push; bos@558: bos@558: As with bos@553: hg pull, the hg push command does not update bos@553: the working directory in the repository that it's pushing bos@553: changes into. (Unlike hg bos@553: pull, hg push bos@553: does not provide a -u option that updates bos@558: the other repository's working directory.) bos@558: bos@558: What happens if we try to pull or push changes bos@553: and the receiving repository already has those changes? bos@558: Nothing too exciting. bos@558: bos@566: &interaction.tour.push.nothing; bos@553: bos@553: bos@553: Sharing changes over a network bos@553: bos@558: The commands we have covered in the previous few bos@553: sections are not limited to working with local repositories. bos@553: Each works in exactly the same fashion over a network bos@558: connection; simply pass in a URL instead of a local bos@558: path. bos@558: bos@566: &interaction.tour.outgoing.net; bos@558: bos@558: In this example, we bos@553: can see what changes we could push to the remote repository, bos@553: but the repository is understandably not set up to let bos@558: anonymous users push to it. bos@558: bos@566: &interaction.tour.push.net; bos@553: bos@553: bos@553: bos@553: bos@553: