]> thyrsus.com Git - src.git/commitdiff
Small change in behavior - no ? status reported except for explicit args.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 13 Nov 2014 22:42:03 +0000 (17:42 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 13 Nov 2014 22:42:03 +0000 (17:42 -0500)
Factor out ignore().  Soon CommandContext() will use it.

Regression tests pass.

src

diff --git a/src b/src
index d319294d1212df62dad26e6744f7cb3052dd6b01..ff8638cb0d50223c29e4f387aa55144b0f60c40a 100755 (executable)
--- a/src
+++ b/src
@@ -417,6 +417,19 @@ def parse_as_revspec(token):
     else:
         return False
 
+ignorable = None
+
+def ignore(filename):
+    "Should the specified file be ignored?"
+    global ignorable
+    if ignorable is None:
+        ignorable = []
+        if os.path.exists(".srcignore"):
+            for line in open(".srcignore"):
+                if not line.startswith("#") and line.strip():
+                    ignorable += glob.glob(line.strip())
+    return filename in ignorable
+
 class CommandContext:
     "Consume a revision specification or range from an argument list"
     def __init__(self, cmd, args,
@@ -744,19 +757,15 @@ def status_method(*args):
     else:
         candidates = [f for f in os.listdir(".") if f != repodir]
     pairs = []
-    ignorable = []
-    if os.path.exists(".srcignore"):
-        for line in open(".srcignore"):
-            if not line.startswith("#") and line.strip():
-                ignorable += glob.glob(line.strip())
     for fn in candidates:
-        if fn in ignorable:
+        if ignore(fn):
             if fn in args:
                 pairs.append((fn, "I"))
             continue
         masterbase = os.path.basename(backend.history(fn))
         if masterbase not in registered:
-            pairs.append((fn, "?"))
+            if fn in args:
+                pairs.append((fn, "?"))
         elif not os.path.exists(fn):
             pairs.append((fn, "!"))
         # Relies on the fact that we touch the file with utimes(2)