Differences between revisions 2 and 3
Revision 2 as of 2008-04-25 08:43:23
Size: 3059
Comment:
Revision 3 as of 2008-04-28 08:16:24
Size: 3814
Comment:
Deletions are marked like this. Additions are marked like this.
Line 58: Line 58:
Now that dependency lists are created, the next step is to download (clone) them. So, if we want the dependencies for 1.0:{{{ Now that dependency lists are created, the next step is to download (clone) them. So, if we want the dependencies for 1.0, we just type:{{{
Line 62: Line 62:
Note, that if you create the dependencies sometime after your project has started, you will probably have some already defined tags. So, if you add dependencies for an old version and someone wants to obtain that version and its dependencies, she will need to obtain the dependencies first and then update to the old version, that is:{{{
$ hg clone http://hg.server.com/project
$ hg depsclone 0.9.1
$ hg update 0.9.1
}}}

This is the same as if you create Mercurial tags for old revisions, the ''.hgtags'' will only exist in newer versions, as well as the ''.hgdeps'' file.{{{
# This is a common error
$ hg clone -r 0.9.1 http://hg.server.com/project
$ hg depsclone 0.9.1 <----- fails: .hgdeps did not exists in 0.9.1
}}}

Deps Extension

This extension is not distributed with Mercurial.

Author: Aleix Conchillo Flaque

Download site: http://hg.hacks-galore.org/aleix/hgdeps

Overview

This extension is useful when a repository might depend on some versioned external dependencies: other repositories (Mercurial, CVS, Subversion…), files not handled by a SCM tool or some other dependencies.

Configuration

To enable this extension, add this to your global .hgrc file (or to your repository .hg/hgrc file):

[extensions]
hgext.deps =
# or, if deps.py is not in the hgext dir:
# deps = /path/to/deps.py

Setting dependencies locations

In order to define external dependencies, you need to add a section [deps] in your repository .hg/hgrc file (or in the global .hgrc) where you will define how to find them. As an example, let’s say that our repository depends on two external libraries managed by different SCM tools: ‘libfoo’ managed by Mercurial and ‘libbar’ managed by CVS.

[deps]
aliases = libfoo, libbar
alias.libfoo = /path/to/libfoo
alias.libbar = :pserver:anonymous@cvs.server.org:/sources/bar
alias.libbar.command = cvs -z3 -d$source co -r $rev -d $dest bar

Two aliases have been defined, one for each library, and also the sources where the libraries can be obtained. ‘libbar’ has two options: the library location and the CVS command to use in order to get the library. For ‘libfoo’ only a path to the Mercurial repository has been specified. $rev, $source, and $dest are substitution placeholders and will be explained later.

Adding dependencies

Once the location of the depedencies have been defined, dependency lists can be created. A depedency list has an associated name. Following the example above, two depedency lists will be created, one for version 0.9.1 of our repository and another for version 1.0. 0.9.1 and 1.0 will be used as the name of the lists.

$ hg deps -a libfoo -r 3a9b061bada1 -d lib/foo 0.9.1
$ hg deps -a libbar -r v0r7_8 -d lib/bar 0.9.1

$ hg deps -a libfoo -r f24139319bdb -d lib/foo 1.0
$ hg deps -a libbar -r v0r8_0 -d lib/bar 1.0

The .hgdeps file will look like this:

[1.0]
f24139319bdb    libfoo    lib/foo
v0r8_0          libbar    lib/bar

[0.9.1]
3a9b061bada1    libfoo    lib/foo
v0r7_8          libbar    lib/bar

A dependency is defined by three fields: a revision name, the alias of the external dependency and a destination directory. The alias must be one of the aliases defined in the [deps] section (see above). The revision name will be substituted for the placeholder $rev also seen before. For Mercurial, the revision name will just be a Mercurial revision of the external repository. Finally, the destination directory will be substituted for $dest.

Cloning dependencies

Now that dependency lists are created, the next step is to download (clone) them. So, if we want the dependencies for 1.0, we just type:

$ hg depsclone 1.0

Note, that if you create the dependencies sometime after your project has started, you will probably have some already defined tags. So, if you add dependencies for an old version and someone wants to obtain that version and its dependencies, she will need to obtain the dependencies first and then update to the old version, that is:

$ hg clone http://hg.server.com/project
$ hg depsclone 0.9.1
$ hg update 0.9.1

This is the same as if you create Mercurial tags for old revisions, the .hgtags will only exist in newer versions, as well as the .hgdeps file.

# This is a common error
$ hg clone -r 0.9.1 http://hg.server.com/project
$ hg depsclone 0.9.1     <----- fails: .hgdeps did not exists in 0.9.1


CategoryExtension

DepsExtension (last edited 2012-02-15 21:45:14 by ks3095497)