aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/arch.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/arch.py')
-rw-r--r--libbe/arch.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/libbe/arch.py b/libbe/arch.py
index b1b88fd..7e1cd1f 100644
--- a/libbe/arch.py
+++ b/libbe/arch.py
@@ -24,3 +24,35 @@ def add_id(filename):
def delete_id(filename):
invoke_client("delete-id", filename)
+
+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):
+ try:
+ os.unlink(path)
+ delete_id(path)
+ except OSError, e:
+ if e.errno != 2:
+ raise
+
+
+def detect(path):
+ """Detect whether a directory is revision-controlled using Arch"""
+ path = os.path.realpath(path)
+ while True:
+ if os.path.exists(os.path.join(path, "{arch}")):
+ return True
+ if path == "/":
+ return False
+ path = os.path.dirname(path)
+
+
+name = "Arch"