Mercurial > hg > hgforest
changeset 31:bfb2a805b490
drop support for traversing .hg directories
I could not find a satisfying way of handling this case correctly
without adding overly complicate code to Mercurial core code or
depending on Mercurial internals to avoid needless traversal of the
storage directory.
author | Robin Farine <robin.farine@terminus.org> |
---|---|
date | Sun, 17 Dec 2006 15:34:50 +0100 |
parents | ddf24d7eb625 |
children | 8732cc34aea6 |
files | forest.py test-forest test-forest.out |
diffstat | 3 files changed, 13 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/forest.py Sun Dec 17 12:17:24 2006 +0100 +++ b/forest.py Sun Dec 17 15:34:50 2006 +0100 @@ -22,19 +22,6 @@ The 'fsnap' command generates or updates such a file based on a forest in the file system. Other commands use this information to populate a forest or to pull/push changes. - - -Configuration - -This extension recognizes the following item in the forest -configuration section: - -walkhg = (0|no|false|1|yes|true) - - Whether repositories under a .hg directory should be skipped - (0|no|false) or not (1|yes|true). The default value is 0. Some - commands accept the --walkhg command-line option to override the - behavior selected by this item. """ import ConfigParser @@ -57,17 +44,9 @@ return res -def enumerate_repos(ui, top='', **opts): +def enumerate_repos(ui, top=''): """Generate a lexicographically sorted list of repository roots.""" - walkhg = opts['walkhg'] - if walkhg == '': - walkhg = ui.config('forest', 'walkhg', 'false') - try: - walkhg = { '0' : False, 'false' : False, 'no' : False, - '1' : True, 'true' : True, 'yes' : True }[walkhg.lower()] - except KeyError: - raise util.Abort(_("invalid value for 'walkhg': %s" % walkhg)) dirs = ['.'] while dirs: root = dirs.pop() @@ -75,16 +54,13 @@ entries.sort() entries.reverse() for e in entries: - if e == 'data' and os.path.split(root)[1] == '.hg': - continue path = os.path.join(root, e) if not os.path.isdir(os.path.join(top, path)): continue if e == '.hg': yield util.normpath(root) - if not walkhg: - continue - dirs.append(path) + else: + dirs.append(path) def mq_patches_applied(rootpath): @@ -201,7 +177,7 @@ rootmap = {} self.trees = [] - for root in enumerate_repos(ui, **opts): + for root in enumerate_repos(ui): if mq_patches_applied(root): raise util.Abort(_("'%s' has mq patches applied") % root) if root != '.': @@ -236,7 +212,7 @@ dest = os.path.normpath(dest) opts['rev'] = [] roots = [] - for root in enumerate_repos(ui, source, **opts): + for root in enumerate_repos(ui, source): if root == '.': srcpath = source destpath = dest @@ -351,7 +327,7 @@ def status(ui, repo, *pats, **opts): """Display the status of a forest of working directories.""" - for root in enumerate_repos(ui, **opts): + for root in enumerate_repos(ui): mqflag = "" if mq_patches_applied(root): mqflag = " *mq*" @@ -364,19 +340,16 @@ def trees(ui, *unused, **opts): """List the roots of the repositories.""" - for root in enumerate_repos(ui, '', **opts): + for root in enumerate_repos(ui, ''): ui.write(root + '\n') def uisetup(ui): global cmdtable - walkhgopt = ('', 'walkhg', '', - _("whether to walk (1|yes|true) repositories under '.hg' or " - "not (0|no|false)")) cmdtable = { "fclone" : (clone, - [walkhgopt] + cmd_options(ui, 'clone', remove=('r',)), + cmd_options(ui, 'clone', remove=('r',)), _('hg fclone [OPTIONS] SOURCE DESTINATION')), "fpull" : (pull, @@ -391,20 +364,19 @@ [('t', 'tip', None, _("use tip instead of revisions stored in the snapshot file")), ('', 'root', '', - _("create root as well as children under <root>")), - walkhgopt] + cmd_options(ui, 'clone', remove=('r',)), + _("create root as well as children under <root>"))] + + cmd_options(ui, 'clone', remove=('r',)), _('hg fseed [OPTIONS] SNAPSHOT-FILE [PATH-ALIAS]')), "fsnap" : (snapshot, [('t', 'tip', None, - _("record tip instead of actual child revisions")), - walkhgopt], + _("record tip instead of actual child revisions"))], 'hg fsnap [OPTIONS] [SNAPSHOT-FILE]'), "fstatus" : (status, - [walkhgopt] + cmd_options(ui, 'status'), + cmd_options(ui, 'status'), _('hg fstatus [OPTIONS]')), "ftrees" : - (trees, [walkhgopt], + (trees, '', 'hg ftrees [OPTIONS]'), }
--- a/test-forest Sun Dec 17 12:17:24 2006 +0100 +++ b/test-forest Sun Dec 17 15:34:50 2006 +0100 @@ -90,15 +90,3 @@ echo "# fpush + mq" hg fpush --cwd topcopy ../top-snap default | sed "s@$HGTMP@HGTMP@g" - -echo "# walk **/.hg" -hg init walkhg -hg init walkhg/.hg/h -hg init walkhg/a -hg init walkhg/a/.hg/h -hg ftrees --cwd walkhg -hg ftrees --cwd walkhg --walkhg=1 -echo "[forest]" >> walkhg/.hg/hgrc -echo "walkhg = Yes" >> walkhg/.hg/hgrc -hg ftrees --cwd walkhg -hg ftrees --cwd walkhg --walkhg=FALSE