[cig-commits] commit: `hg fseed` now uses the Forest framework
Mercurial
hg at geodynamics.org
Mon Nov 24 11:27:11 PST 2008
changeset: 65:0c80cfba6b38
user: Simon Law <simon at akoha.org>
date: Mon Aug 27 13:45:18 2007 -0400
files: forest.py test-forest test-forest.out
description:
`hg fseed` now uses the Forest framework
diff -r a45213137945 -r 0c80cfba6b38 forest.py
--- a/forest.py Mon Aug 27 13:43:43 2007 -0400
+++ b/forest.py Mon Aug 27 13:45:18 2007 -0400
@@ -326,29 +326,6 @@ def _statichttprepo_forests(self, walkhg
return [root[len(url):].rstrip('/') or "." for root in res]
statichttprepo.statichttprepository.forests = _statichttprepo_forests
-
-
-tree_section_re = re.compile(r"^tree(\w+)$")
-
-def tree_sections(cfg, withtop=True):
- """Return lexicographically sorted list of tree sections."""
-
- allsecs = cfg.sections()
- secs = []
- top = None
- for s in allsecs:
- if tree_section_re.match(s):
- secs.append(s)
- if cfg.get(s, "root") == ".":
- top = s
- if top is None:
- raise util.Abort(_("snapshot has no entry with root '.'"))
- secs.sort(lambda a,b: cmp(cfg.get(a, "root"), cfg.get(b, "root")))
- # ensure that '.' comes first, regardless of sort
- secs.remove(top)
- if withtop:
- secs.insert(0, top)
- return secs
def die_on_numeric_revs(revs):
@@ -987,37 +964,52 @@ def push(ui, top, dest=None, pathalias=N
prehooks=[lambda tree: check_mq(tree)])
-def seed(ui, snapshot, pathalias='default', root='', tip=False, **opts):
- """Populate a forest according to a snapshot file."""
-
- cfg = ConfigParser.RawConfigParser()
- cfg.read(snapshot)
- pfx = root
- for section in tree_sections(cfg, bool(pfx)):
- root = cfg.get(section, 'root')
- ui.write("[%s]\n" % root)
- dest = os.path.normpath(os.path.join(pfx, util.localpath(root)))
- psect = section + '.paths'
- if not cfg.has_option(psect, pathalias):
- ui.write(_("skipped, no path alias '%s' defined\n\n") % pathalias)
+def seed(ui, snapshot=None, source='default', **opts):
+ """populate a forest according to a snapshot file.
+
+ Populate an empty local forest according to a snapshot file.
+
+ Given a snapshot file, clone any non-existant directory from the
+ provided path-alias. This defaults to cloning from the 'default'
+ path.
+
+ Unless the --tip option is set, this command will clone the
+ revision specified in the snapshot file.
+
+ Look at the help text for the clone command for more information.
+ """
+
+ snapfile = snapshot or opts['snapfile']
+ if not snapfile:
+ raise cmdutil.ParseError("fseed", _("invalid arguments"))
+ forest = Forest(snapfile=snapfile)
+ tip = opts['tip']
+ dest = opts['root']
+ if not dest:
+ dest = os.curdir
+ forest.trees.remove(forest.top())
+ dest = os.path.normpath(dest)
+ for tree in forest.trees:
+ srcpath = tree.getpath([source])
+ if not srcpath:
+ ui.status("[%s]\n" % util.pconvert(tree.root))
+ ui.warn(_("skipped: path alias %s not defined\n") % source)
+ ui.status("\n")
continue
- source = cfg.get(psect, pathalias)
- if os.path.exists(dest):
- ui.write(_("skipped, destination '%s' already exists\n\n") % dest)
- continue
- destpfx = os.path.dirname(dest)
- if destpfx and not os.path.exists(destpfx):
- os.makedirs(destpfx)
- # 'clone -r rev' not implemented for all remote repos, clone
- # everything and then use 'update' if necessary
- opts['rev'] = []
- commands.clone(ui, source, dest, **opts)
- if not tip:
- rev = cfg.get(section, 'revision')
- if rev and rev != 'tip' and rev != node.nullid:
- repo = hg.repository(ui, dest)
- commands.update(repo.ui, repo, node=rev)
- ui.write("\n")
+ srcpath = urltopath(srcpath)
+ if tree.root == ".":
+ destpath = dest
+ else:
+ destpath = os.path.join(dest, tree.root)
+ opts['rev'] = tree.revs
+ try:
+ qclone(ui=ui,
+ source=srcpath, sroot=None,
+ dest=destpath, rpath=util.pconvert(tree.root),
+ opts=opts)
+ except util.Abort, err:
+ ui.warn(_("skipped: %s\n") % err)
+ ui.status("\n")
def snapshot(ui, repo, snapfile=None, tip=False, walkhg='', **opts):
@@ -1105,10 +1097,11 @@ def uisetup(ui):
(seed,
[('', 'root', '',
_("create root as well as children under <root>")),
+ snapfileopts,
('t', 'tip', False,
_("use tip instead of revisions stored in the snapshot file"))]
+ cmd_options(ui, 'clone', remove=('r',)),
- _('hg fseed [OPTIONS] SNAPSHOT-FILE [PATH-ALIAS]')),
+ _('hg fseed [OPTION]... SNAPSHOT-FILE [PATH-ALIAS]')),
"fsnap" :
(snapshot,
[('t', 'tip', False,
diff -r a45213137945 -r 0c80cfba6b38 test-forest
--- a/test-forest Mon Aug 27 13:43:43 2007 -0400
+++ b/test-forest Mon Aug 27 13:45:18 2007 -0400
@@ -70,7 +70,7 @@ hg clone toplevel newtop
hg clone toplevel newtop
hg fseed -R newtop top-snap default
rm -rf newtop
-hg fseed --root newtop top-snap default >/dev/null
+hg fseed --traceback --root newtop top-snap default >/dev/null
hg fsnap --cwd newtop | sed "s@\(/private\)*$HGTMP at HGTMP@g"
rm -rf newtop
@@ -114,7 +114,7 @@ hg fseed --root named top-snap-named def
hg fseed --root named top-snap-named default
hg ftrees --cwd named --convert
# pull (should find nothing)
-hg fpull --cwd named ../top-snap-named default \
+hg fpull --cwd named ../top-snap-named default 2>&1 \
| sed "s@\(/private\)*$HGTMP at HGTMP@g"
rm -rf named
diff -r a45213137945 -r 0c80cfba6b38 test-forest.out
--- a/test-forest.out Mon Aug 27 13:43:43 2007 -0400
+++ b/test-forest.out Mon Aug 27 13:45:18 2007 -0400
@@ -99,19 +99,35 @@ summary: new line
# fseed
4 files updated, 0 files merged, 0 files removed, 0 files unresolved
[d/d/t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[e/d]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t/t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[e/d]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t/t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[tree1]
@@ -281,19 +297,35 @@ added 1 changesets with 1 changes to 1 f
# fseed and fpull, missing section
[.]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 3 changes to 3 files
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[e/d]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t/t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[e/d]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t/t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
.
@@ -301,15 +333,27 @@ t
t
t/t
[e/d]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t/t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t/t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
.
@@ -338,27 +382,50 @@ no changes found
[t/t]
pulling from HGTMP/test-forest/toplevel/t/t
searching for changes
-no changes found
+adding changesets
+transaction abort!
+rollback completed
+skipped: received changelog group is empty
# fseed and fpull, named section
[.]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 3 changes to 3 files
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[d/d/t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[e/d]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-[t/t]
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[d/d/t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[e/d]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+[t/t]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
.
@@ -369,7 +436,10 @@ t/t
[.]
pulling from HGTMP/test-forest/toplevel
searching for changes
-no changes found
+adding changesets
+transaction abort!
+rollback completed
+skipped: received changelog group is empty
[d/d/t]
pulling from HGTMP/test-forest/toplevel/d/d/t
@@ -389,7 +459,10 @@ no changes found
[t/t]
pulling from HGTMP/test-forest/toplevel/t/t
searching for changes
-no changes found
+adding changesets
+transaction abort!
+rollback completed
+skipped: received changelog group is empty
# fstatus + mq
[.]
More information about the CIG-COMMITS
mailing list