--- /dev/null
+from popen2 import Popen4
+import os
+
+def invoke(args):
+ q=Popen4(args)
+ output = q.fromchild.read()
+ status = q.wait()
+ if os.WIFEXITED(status):
+ return (os.WEXITSTATUS(status))
+
+def add_id(filename):
+ return invoke(("tla", "add-id", filename))
+
+def delete_id(filename):
+ return invoke(("tla", "delete-id", filename))
import cmdutil
import errno
import names
+import rcs
class NoBugDir(cmdutil.UserError):
def __init__(self, path):
def create_bug_dir(path):
root = os.path.join(path, ".be")
- os.mkdir(root)
- os.mkdir(os.path.join(root, "bugs"))
- f = file(os.path.join(root, "version"), "wb")
- f.write("Bugs Everywhere Tree 0 0\n")
+ rcs.mkdir(root)
+ rcs.mkdir(os.path.join(root, "bugs"))
+ rcs.set_file_contents(os.path.join(root, "version"),
+ "Bugs Everywhere Tree 0 0\n")
+
return BugDir(path)
class BugDir:
def new_bug(self):
uuid = names.uuid()
path = os.path.join(self.bugs_path, uuid)
- os.mkdir(path)
+ rcs.mkdir(path)
return Bug(self.bugs_path, uuid)
def _set_value(self, name, value):
if value is None:
- os.unlink(self.get_path(name))
- file(self.get_path(name), "wb").write("%s\n" % value)
+ rcs.unlink(self.get_path(name))
+ rcs.set_file_contents(self.get_path(name), "%s\n" % value)
--- /dev/null
+from arch import *
+def mkdir(path):
+ os.mkdir(path)
+ add_id(path)
+
+def set_file_contents(path, contents):
+ add = not os.path.exists(path)
+ file(path, "wb").write(contents)
+ if add:
+ add_id(path)
+
+def unlink(path):
+ os.unlink(path)
+ delete_id(filename)