Sharing Changes
I mentioned earlier that repositories in Mercurial are self-contained. This means that the changeset we just created exists only in our my-hello repository. Let’s look at a few ways that we can propagate this change into other repositories.
Pulling Changes from Another Repository
To get started, let’s clone our original hello repository, which does not contain the change we just committed. We’ll call our temporary repository hello-pull:
$
cd ..
$
hg clone hello hello-pull
updating working directory 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
We’ll use the hg pull command to bring changes from my-hello into hello-pull. However, blindly pulling unknown changes into a repository is a somewhat scary prospect. Mercurial provides the hg incoming command to tell us what changes the hg pull command would pull into the repository, without actually pulling the changes in:
$
cd hello-pull
$
hg incoming ../my-hello
comparing with ../my-hello searching for changes changeset: 5:12efb75cbece tag: tip user: Bryan O'Sullivan <bos@serpentine.com> date: Tue May 05 06:44:49 2009 +0000 summary: Added an extra line of output
Bringing changes into a repository is a simple matter of running the hg pull command, and optionally telling it which repository to pull from:
$
hg tip
changeset: 4:2278160e78d4 tag: tip user: Bryan O'Sullivan <bos@serpentine.com> date: Sat Aug 16 22:16:53 2008 +0200 summary: Trim comments.$
hg pull ../my-hello
pulling from ../my-hello searching ...
Get Mercurial: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.