[cig-commits] commit: new fupdate command
Mercurial
hg at geodynamics.org
Mon Nov 24 11:27:01 PST 2008
changeset: 37:44e66014dd8d
user: Robin Farine <robin.farine at terminus.org>
date: Thu Dec 21 16:51:24 2006 +0100
files: forest.py test-forest test-forest.out
description:
new fupdate command
The fupdate command updates working directories to tip or according to
a snapshot file.
diff -r 01a10f7bd85c -r 44e66014dd8d forest.py
--- a/forest.py Thu Dec 21 15:05:23 2006 +0100
+++ b/forest.py Thu Dec 21 16:51:24 2006 +0100
@@ -159,7 +159,7 @@ class ForestSnapshot(object):
self.rootmap[root] = tree
self.trees.append(tree)
- def __call__(self, ui, toprepo, func, pathalias):
+ def __call__(self, ui, toprepo, func, pathalias=None):
"""Apply a function to trees matching a snapshot entry.
Call func(repo, rev, path) for each repo in toprepo and its
@@ -170,7 +170,7 @@ class ForestSnapshot(object):
for t in self.trees:
root, rev, path = t.info(pathalias)
ui.write("[%s]\n" % root)
- if path is None:
+ if pathalias is not None and path is None:
ui.write(_("skipped, no path alias '%s' defined\n\n")
% pathalias)
continue
@@ -362,6 +362,34 @@ def trees(ui, *unused, **opts):
l = enumerate_repos(ui)
for t in l:
ui.write(t + '\n')
+
+def update(ui, toprepo, snapfile=None, tip=False, **opts):
+ """Update working directories to tip or according to a snapshot file.
+
+ When the tip option is specified, the working directory of the
+ toplevel repository and of each nested repository found in the
+ local filesystem is updated to its tip. When a snapshot file is
+ specified, the working directory of each repository listed in the
+ snapshot file is updated to the revision recorded in the snapshot.
+
+ The tip option or the snapshot file are exclusive.
+ """
+
+ if snapfile is not None and tip or snapfile is None and not tip:
+ raise util.Abort(_("need either --tip or SNAPSHOT-FILE"))
+ if tip:
+ for rpath in enumerate_repos(ui):
+ repo = repository(ui, rpath)
+ ui.write("[%s]\n" % util.pconvert(rpath))
+ commands.update(repo.ui, repo, node='tip', **opts)
+ ui.write("\n")
+ else:
+
+ def doit(repo, path, rev):
+ commands.update(repo.ui, repo, node=rev, **opts)
+
+ snapshot = ForestSnapshot(snapfile)
+ snapshot(ui, toprepo, doit)
def uisetup(ui):
@@ -400,5 +428,11 @@ def uisetup(ui):
(trees,
[('c', 'convert', None,
_("convert paths to mercurial representation"))],
- _('hg ftrees [OPTIONS]'))
+ _('hg ftrees [OPTIONS]')),
+ "fupdate" :
+ (update,
+ [('', 'tip', False,
+ _("update working directories to a specified revision"))]
+ + cmd_options(ui, 'update', remove=('d',)),
+ _('hg fupdate (--tip | SNAPSHOT-FILE)'))
}
diff -r 01a10f7bd85c -r 44e66014dd8d test-forest
--- a/test-forest Thu Dec 21 15:05:23 2006 +0100
+++ b/test-forest Thu Dec 21 16:51:24 2006 +0100
@@ -53,6 +53,16 @@ diff -u top-snap1 top-snap2 | \
diff -u top-snap1 top-snap2 | \
sed -e 's/--- top-snap1.*$/--- top-snap1/' \
-e 's/+++ top-snap2.*$/+++ top-snap2/'
+
+echo "# fupdate"
+hg fclone toplevel newtop > /dev/null
+hg fupdate --cwd newtop ../top-snap > /dev/null
+hg parents --cwd newtop/d/d/t
+hg parents --cwd newtop/t/t
+hg fupdate --cwd newtop --tip > /dev/null
+hg parents --cwd newtop/d/d/t
+hg parents --cwd newtop/t/t
+rm -rf newtop
echo "# fseed"
hg clone toplevel newtop
diff -r 01a10f7bd85c -r 44e66014dd8d test-forest.out
--- a/test-forest.out Thu Dec 21 15:05:23 2006 +0100
+++ b/test-forest.out Thu Dec 21 16:51:24 2006 +0100
@@ -72,6 +72,30 @@ adding d/d/f2
[tree5.paths]
+# fupdate
+changeset: 0:11d08ba64b67
+tag: tip
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: start
+
+changeset: 0:5d60830890a2
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: start
+
+changeset: 0:11d08ba64b67
+tag: tip
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: start
+
+changeset: 1:e7ef7301b2dd
+tag: tip
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: new line
+
# fseed
4 files updated, 0 files merged, 0 files removed, 0 files unresolved
[d/d/t]
More information about the CIG-COMMITS
mailing list