[cig-commits] commit: drop support for traversing .hg directories

Mercurial hg at geodynamics.org
Mon Nov 24 11:26:58 PST 2008


changeset:   31:bfb2a805b490
user:        Robin Farine <robin.farine at terminus.org>
date:        Sun Dec 17 15:34:50 2006 +0100
files:       forest.py test-forest test-forest.out
description:
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.


diff -r ddf24d7eb625 -r bfb2a805b490 forest.py
--- 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
 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 @@ def cmd_options(ui, cmd, remove=None):
     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 @@ def enumerate_repos(ui, top='', **opts):
         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 @@ class ForestSnapshot(object):
 
         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 @@ def clone(ui, source, dest, **opts):
     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):
 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):
 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 @@ def uisetup(ui):
              [('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]'),
         }
diff -r ddf24d7eb625 -r bfb2a805b490 test-forest
--- 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 @@ hg fpull --cwd topcopy -u ../top-snap de
 
 echo "# fpush + mq"
 hg fpush --cwd topcopy ../top-snap default | sed "s@$HGTMP at 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
diff -r ddf24d7eb625 -r bfb2a805b490 test-forest.out
--- a/test-forest.out	Sun Dec 17 12:17:24 2006 +0100
+++ b/test-forest.out	Sun Dec 17 15:34:50 2006 +0100
@@ -212,16 +212,3 @@ searching for changes
 searching for changes
 no changes found
 
-# walk **/.hg
-.
-a
-.
-.hg/h
-a
-a/.hg/h
-.
-.hg/h
-a
-a/.hg/h
-.
-a



More information about the CIG-COMMITS mailing list