Implemented set-root command
authorAaron Bentley <abentley@panoramicfeedback.com>
Wed, 9 Mar 2005 20:28:18 +0000 (20:28 +0000)
committerAaron Bentley <abentley@panoramicfeedback.com>
Wed, 9 Mar 2005 20:28:18 +0000 (20:28 +0000)
be
libbe/bugdir.py

diff --git a/be b/be
index 47eec40c4b5e9dffa4c97fa7b532ef19ca33d254..d88c43e84c8cd320c2f8aca0dd058b1754442173 100755 (executable)
--- a/be
+++ b/be
@@ -7,7 +7,7 @@ be comment: append a comment to a bug
 be set-root: assign the root directory for bug tracking
 """
 from libbe.cmdutil import *
-from libbe.bugdir import tree_root
+from libbe.bugdir import tree_root, create_bug_dir
 from libbe import names
 import sys
 import os
@@ -34,6 +34,10 @@ def list_bugs(args):
             target = " target: %s" % target
         print "id: %s severity: %s%s\n%s\n" % (unique_name(bug, bugs), 
                                              bug.severity, target, bug.summary)
+def set_root(args):
+    if len(args) != 1:
+        raise UserError("Please supply a directory path")
+    create_bug_dir(args[0])
 
 def new_bug(args):
     if len(args) != 1:
@@ -62,6 +66,7 @@ else:
         try:
             cmd = {
                 "list": list_bugs,
+                "set-root": set_root,
                 "new": new_bug,
                 "close": close_bug,
                 "open": open_bug,
index 5e1d4094f87eb581a00dac63e389bdab35f06968..7fc1edab56f2ecb7a82270359b23904acbae9be5 100644 (file)
@@ -26,6 +26,14 @@ def tree_root(dir):
 def test_version(path):
     assert (file(path, "rb").read() == "Bugs Everywhere Tree 0 0\n")
 
+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")
+    return BugDir(path)
+
 class BugDir:
     def __init__(self, dir):
         self.dir = dir