Distinguished between 'paranoid' and non-paranoid add-id
authorAaron Bentley <abentley@panoramicfeedback.com>
Thu, 19 May 2005 16:40:33 +0000 (16:40 +0000)
committerAaron Bentley <abentley@panoramicfeedback.com>
Thu, 19 May 2005 16:40:33 +0000 (16:40 +0000)
The paranoid adds are only used for the .be root.  Paranoia is a big time-suck
on Arch trees, because they require a full inventory.

libbe/arch.py
libbe/bugdir.py
libbe/bzr.py
libbe/no_rcs.py

index e2d867f47a434dfca836a9f59bce4ab979ffd8b8..3152073f42137692a697f7168ffadfa793ab133b 100644 (file)
@@ -89,7 +89,7 @@ def add_dir_rule(rule, dirname, root):
     inv_filename = os.path.join(dirname, '.arch-inventory')
     file(inv_filename, "ab").write(rule)
     if os.path.realpath(inv_filename) not in list_added(root):
-        add_id(inv_filename, no_force=True)
+        add_id(inv_filename, paranoid=False)
 
 def force_source(filename, root):
     rule = "source %s\n" % rel_filename(filename, root)
@@ -97,10 +97,10 @@ def force_source(filename, root):
     if os.path.realpath(filename) not in list_added(root):
         raise CantAddFile(filename)
 
-def add_id(filename, no_force=False):
+def add_id(filename, paranoid=False):
     invoke_client("add-id", filename)
     root = tree_root(filename)
-    if os.path.realpath(filename) not in list_added(root) and not no_force:
+    if paranoid and os.path.realpath(filename) not in list_added(root):
         force_source(filename, root)
 
 
@@ -112,29 +112,29 @@ def test_helper(type):
     dirname = os.path.join(t, ".boo")
     return dirname, t
 
-def mkdir(path):
+def mkdir(path, paranoid=False):
     """
     >>> import shutil
     >>> dirname,t = test_helper("easy")
-    >>> mkdir(dirname)
+    >>> mkdir(dirname, paranoid=False)
     >>> assert os.path.realpath(dirname) in list_added(t)
     >>> assert not os.path.exists(os.path.join(t, ".arch-inventory"))
     >>> shutil.rmtree(t)
     >>> dirname,t = test_helper("tricky")
-    >>> mkdir(dirname)
+    >>> mkdir(dirname, paranoid=True)
     >>> assert os.path.realpath(dirname) in list_added(t)
     >>> assert os.path.exists(os.path.join(t, ".arch-inventory"))
     >>> shutil.rmtree(t)
     >>> dirname,t = test_helper("impossible")
     >>> try:
-    ...     mkdir(dirname)
+    ...     mkdir(dirname, paranoid=True)
     ... except CantAddFile, e:
     ...     print "Can't add file"
     Can't add file
     >>> shutil.rmtree(t)
     """
     os.mkdir(path)
-    add_id(path)
+    add_id(path, paranoid=paranoid)
 
 def set_file_contents(path, contents):
     add = not os.path.exists(path)
index c6a9b5b7a9a09c4057cf8b63b420b87127769e12..20b6d9bb892dca7f8cc5f71e911f971c39667d07 100644 (file)
@@ -86,7 +86,7 @@ def create_bug_dir(path, rcs):
     """
     root = os.path.join(path, ".be")
     try:
-        rcs.mkdir(root)
+        rcs.mkdir(root, paranoid=True)
     except OSError, e:
         if e.errno == errno.ENOENT:
             raise NoRootEntry(path)
index e4e49d1aab8cb190e71029de8bdad2b727488908..c653b2aea51b8a0ac25cf507a85fbea7256b673c 100644 (file)
@@ -35,13 +35,13 @@ def invoke_client(*args, **kwargs):
         raise Exception("Command failed: %s" % error)
     return output
 
-def add_id(filename):
+def add_id(filename, paranoid=False):
     invoke_client("add", filename)
 
 def delete_id(filename):
     invoke_client("remove", filename)
 
-def mkdir(path):
+def mkdir(path, paranoid=False):
     os.mkdir(path)
     add_id(path)
 
index 9e4c47b30f3ccbaced22dff7149a1d7620d08579..1c02725d77160f725d545490c8c7e156119ba8e8 100644 (file)
@@ -17,9 +17,9 @@
 from popen2 import Popen4
 import os
 import config
-from os import mkdir, unlink
+from os import unlink
 
-def add_id(filename):
+def add_id(filename, paranoid=False):
     """Compatibility function"""
     pass
 
@@ -27,6 +27,9 @@ def delete_id(filename):
     """Compatibility function"""
     pass
 
+def mkdir(path, paranoid=False):
+    os.mkdir(path)
+
 def set_file_contents(path, contents):
     add = not os.path.exists(path)
     file(path, "wb").write(contents)