Added RCS integration
authorAaron Bentley <abentley@panoramicfeedback.com>
Wed, 9 Mar 2005 22:08:45 +0000 (22:08 +0000)
committerAaron Bentley <abentley@panoramicfeedback.com>
Wed, 9 Mar 2005 22:08:45 +0000 (22:08 +0000)
.be/bugs/3613e6e9-db9e-4775-8914-f31f0b4b81ac/status
libbe/arch.py [new file with mode: 0644]
libbe/bugdir.py
libbe/rcs.py [new file with mode: 0644]

index f510327578a4562e26a7c64bdf061e4a49f85ee6..1ac208286a54bf10746bac5466010b15663a0a6e 100644 (file)
@@ -1 +1 @@
-open
+closed
diff --git a/libbe/arch.py b/libbe/arch.py
new file mode 100644 (file)
index 0000000..6cc3dbb
--- /dev/null
@@ -0,0 +1,15 @@
+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))
index 7fc1edab56f2ecb7a82270359b23904acbae9be5..fd7b0f65f01b493d3e404916cd79e53a08a4bc99 100644 (file)
@@ -3,6 +3,7 @@ import os.path
 import cmdutil
 import errno
 import names
+import rcs
 
 class NoBugDir(cmdutil.UserError):
     def __init__(self, path):
@@ -28,10 +29,11 @@ def test_version(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:
@@ -49,7 +51,7 @@ 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)
 
 
@@ -101,6 +103,6 @@ class Bug(object):
 
     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)
 
diff --git a/libbe/rcs.py b/libbe/rcs.py
new file mode 100644 (file)
index 0000000..0da1513
--- /dev/null
@@ -0,0 +1,14 @@
+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)