From: Aaron Bentley Date: Thu, 19 May 2005 16:40:33 +0000 (+0000) Subject: Distinguished between 'paranoid' and non-paranoid add-id X-Git-Tag: 1.0.0~279 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a2c9b6f19c4e8669fa328757211b68fcd0243cf7;p=be.git Distinguished between 'paranoid' and non-paranoid add-id 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. --- diff --git a/libbe/arch.py b/libbe/arch.py index e2d867f..3152073 100644 --- a/libbe/arch.py +++ b/libbe/arch.py @@ -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) diff --git a/libbe/bugdir.py b/libbe/bugdir.py index c6a9b5b..20b6d9b 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -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) diff --git a/libbe/bzr.py b/libbe/bzr.py index e4e49d1..c653b2a 100644 --- a/libbe/bzr.py +++ b/libbe/bzr.py @@ -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) diff --git a/libbe/no_rcs.py b/libbe/no_rcs.py index 9e4c47b..1c02725 100644 --- a/libbe/no_rcs.py +++ b/libbe/no_rcs.py @@ -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)