Forest Extension
This extension is not being distributed along with Mercurial.
Author: Robin FarineBR Maintainer: Simon Law <simon@akoha.org>
Download site: [http://hg.akoha.org/hgforest/ public development repository].
Works with: Mercurial 0.9.3, 0.9.4, and 0.9.5.
Note: The snapshot file is undergoing a bit of refactoring. But new versions of Forest should be able to read old ones.
Overview
The Forest extension allows operations on trees with nested Mercurial repositories, called forests. Those to some degree correspond to multi-project CVS/Svn/... repositories.
The extension defines some new commands, which work on the whole tree of repositories instead of working on single directory - fclone, fpull, fpush, fstatus, fupdate. It also adds own specific commands: fseed, fsnap, ftrees.
ToDo: old description claimed that status and update work recursively, it does not seem to be a case? Or is it just a bug?
The forest extension brings one new concept - a snapshot file. This file represents state of a forest at a given time
ToDo: detailed explanation what exactly is the snapshot file
Enabling the extension
Configure your .hgrc to enable the extension by adding following lines:
[extensions] hgext.forest= # or, if forest.py is not in the hgext dir: # forest=/path/to/forest.py
Some additional configuration can be done using the '[forest]' stanza in your configuration file:
[forest] # will nested repositories directly under a .hg directory be skipped (0|no|false) or not (1|yes|true)?. # The default value is 0. (don't skip them) walkhg = (0|no|false|1|yes|true)
ToDo: does walkhg=true truly mean that .hg is NOT walked? It is crazy....
Usage
Below some typical examples of how the extension can be used.
1. Creating a forest from scratch
Forest is just a mercurial repository containing some other mercurial repositories.
mkdir forestdir forestdir/subproject1 forestdir/subproject2 cd forestdir # Initialize mercurial repo for the forest itself hg init # Initialize subproject repos cd subproject1 hg init cd ../subproject2 hg init cd ..
We have a forest containing two subprojects. Of course new subprojects can be added at any time in the same way.
2. Creating a forest on top of existing repositories
Let's consider more realistic example - we want to bind as forest some already existing repositories. Then there are two options. To create the forest in new location, just initialize repository there and clone subprojects into subdirectories:
mkdir forestdir cd forestdir hg init # To keep the same name (here - somelib) hg clone <some-location>/somelib # To change name hg clone <some-location>/somelib sublib
Instead of cloning, one can just move the directories (this preserves working dir state).
One can also build forest in existing directory. Let's say we have mercurial repositories in $HOME/someproject/subproject1 and $HOME/someproject/subproject2. Then bare
cd $HOME/someproject hg init
creates the forest in $HOME/someproject.
3. Cloning existing forest
To clone a forest use fclone. It works just as normal clone (the same URL syntaxes are recognized). For example:
hg fclone /some/existing/forest new_forest # Remote syntax should work too hg fclone ssh://some.machine/some/existing/forest ./forest
4. Building cloned forest on top of already cloned repositories
ToDo: describe (casus when I have machineA:devel/proj1, machineA:devel/proj2, machineB:devel/proj1, machineB:devel/proj2 and want to forestize devel directory)
5. Verifying status of the existing forest
To display the status of the forest use
cd forestdir hg fstatus
This will display aggregated status of all subprojects (and the main forest repo itself).
Note: you must issue this command while being in main forest directory, issuing it in subproject dir will bring just the status of this dir, this is some limitation of the extension.
To list just the roots of repositories (forest contents), use:
cd forestdir hg ftrees
(as above, issue it in main forest directory)
6. Developing within forest
Actions like add/delete/commit/... work as usual - cd to the subproject you want to develop, hack there, add/remove/commit there. There are no global shortcuts to execute such commands on a forest as a whole.
Note: beware of using add/delete for subproject files while being in the top-level forest directory. If you do sth like
cd forestdir hg add subproject/file1.txt
then the file will be marked for addition for the forest repository, not for the subproject repository! This is never something you would like to do...
7. Pulling, pushing and updating
One can of course use standard pull, push, and update commands while working in individual forest subprojects, they work as usual.
To pull, push and update whole forest at once, use fpull, fpush and fupdate. To use fpull and fpush we need a snapshot file. For the simplest case, let's create the file which points to the tips of subprojects:
cd forestdir hg fsnap -t > snapshot.txt
(you may take a look at snapshot.txt, this is simple textual file which lists subprojects)
Then you can try
cd forestdir hg fpull snapshot.txt default hg fpush snapshot.txt default
In case of the snapshot built with -t option (pointing to tips) those commands just push or pull all forest subprojects and the main forest directory.
Update can be performed similarly
cd forestdir hg fupdate snapshot.txt
but here, when we use tips, snapshot is not necessary, alternatively one can issue
cd forestdir hg fupdate --tip
Note: you can alias remote forests by creating aliases in top level forest mercurial repository.
ToDo: or maybe aliases must be defined both on top and in subdirs? And what if there is mismatch, or somewhere we lack some alias?
8. Partial clone
Forest subproject is still normal mercurial repository. So it can be cloned as usual.
# Clone only subproject1 without cloning the rest of the forest hg clone forestdir/subproject1 subproject1_branch
9. Using snapshots
ToDo: some explanation what non-tip snapshots are used for, how should one operate on them etc is desperately needed.
ToDo: some explanation what hg fseed does is desperately needed.