[PATCH 1 of 2] match: delay import of fileset module

Angel Ezquerra angel.ezquerra at gmail.com
Wed Apr 11 14:07:08 CDT 2012


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1334141104 -7200
# Node ID 2c32ff4561f6594957596cb711fe853c42f9bd38
# Parent  063c5b7ded78b03f7b9b765dde2dade81fcfd6ac
match: delay import of fileset module

This reduces the impact of creating a circular import between the fileset and
the match modules.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -6,23 +6,9 @@
 # GNU General Public License version 2 or any later version.
 
 import re
-import scmutil, util, fileset
+import scmutil, util
 from i18n import _
 
-def _expandsets(pats, ctx):
-    '''convert set: patterns into a list of files in the given context'''
-    fset = set()
-    other = []
-
-    for kind, expr in pats:
-        if kind == 'set':
-            if not ctx:
-                raise util.Abort("fileset expression with no context")
-            s = fileset.getfileset(ctx, expr)
-            fset.update(s)
-            continue
-        other.append((kind, expr))
-    return fset, other
 
 class match(object):
     def __init__(self, root, cwd, patterns, include=[], exclude=[],
@@ -335,3 +321,20 @@
     for kind, name in patterns:
         if kind in ('glob', 're', 'relglob', 'relre', 'set'):
             return True
+
+def _expandsets(pats, ctx):
+    '''convert set: patterns into a list of files in the given context'''
+    import fileset # avoid start-up nasties
+
+    fset = set()
+    other = []
+
+    for kind, expr in pats:
+        if kind == 'set':
+            if not ctx:
+                raise util.Abort("fileset expression with no context")
+            s = fileset.getfileset(ctx, expr)
+            fset.update(s)
+            continue
+        other.append((kind, expr))
+    return fset, other


More information about the Mercurial-devel mailing list