aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/set_root.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2008-11-21 14:56:05 -0500
committerW. Trevor King <wking@drexel.edu>2008-11-21 14:56:05 -0500
commit23179f50092d91dbeab97ad2b88cdaadb79b615f (patch)
tree4a5579d686c573d6d438214aa0d2100f01083bef /becommands/set_root.py
parenta2bdbab9ccd9ca24ce470d2beeea86afb7ede2ae (diff)
downloadbugseverywhere-23179f50092d91dbeab97ad2b88cdaadb79b615f.tar.gz
Another major rewrite. Now BugDir, Bug, and Comment are more distinct.
I pushed a lot of the little helper functions into the main classes, which makes it easier for me to keep track of what's going on. I'm now at the point where I can run through `python test.py` with each of the backends (by changing the search order in rcs.py _get_matching_rcs) without any unexpected errors for each backend (except Arch). I can also run `test_usage.sh` without non-Arch errors either. However, don't consider this a stable commit yet. The bzr backend is *really*slow*, and the other's aren't blazingly fast either. I think I'm rewriting the entire database every time I save it :p. Still, it passes the checks. and I don't like it when zounds of changes build up.
Diffstat (limited to 'becommands/set_root.py')
-rw-r--r--becommands/set_root.py51
1 files changed, 30 insertions, 21 deletions
diff --git a/becommands/set_root.py b/becommands/set_root.py
index 1c731da..d8fcdf3 100644
--- a/becommands/set_root.py
+++ b/becommands/set_root.py
@@ -16,32 +16,34 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Assign the root directory for bug tracking"""
import os.path
-from libbe import bugdir, cmdutil, rcs
+from libbe import cmdutil, bugdir
__desc__ = __doc__
def execute(args):
"""
- >>> from libbe import utility
+ >>> from libbe import utility, rcs
>>> import os
>>> dir = utility.Dir()
>>> try:
- ... bugdir.tree_root(dir.path)
+ ... bugdir.BugDir(dir.path)
... except bugdir.NoBugDir, e:
... True
True
>>> execute([dir.path])
No revision control detected.
Directory initialized.
- >>> bd = bugdir.tree_root(dir.path)
- >>> bd.root = dir.path
- >>> dir_rcs = rcs.installed_rcs()
- >>> dir_rcs.init(bd.dir)
- >>> bd.rcs_name = dir_rcs.name
- >>> del(dir_rcs)
- >>> os.chdir(bd.dir)
- >>> execute(['.'])
+ >>> del(dir)
+
+ >>> dir = utility.Dir()
+ >>> os.chdir(dir.path)
+ >>> rcs = rcs.installed_rcs()
+ >>> rcs.init('.')
+ >>> print rcs.name
+ Arch
+ >>> execute([])
Using Arch for revision control.
Directory initialized.
+
>>> try:
... execute(['.'])
... except cmdutil.UserError, e:
@@ -50,29 +52,34 @@ def execute(args):
>>> execute(['/highly-unlikely-to-exist'])
Traceback (most recent call last):
UserError: No such directory: /highly-unlikely-to-exist
+ >>> os.chdir('/')
"""
options, args = get_parser().parse_args(args)
- basedir = args[0]
- if len(args) != 1:
- raise cmdutil.UsageError
+ if len(args) > 1:
+ print help()
+ raise cmdutil.UserError, "Too many arguments"
+ if len(args) == 1:
+ basedir = args[0]
+ else:
+ basedir = "."
if os.path.exists(basedir) == False:
- raise cmdutil.UserError, "No such directory: %s" % basedir
- dir_rcs = rcs.detect_rcs(basedir)
- dir_rcs.root(basedir)
+ pass
+ #raise cmdutil.UserError, "No such directory: %s" % basedir
try:
- bugdir.create_bug_dir(basedir, dir_rcs)
+ bd = bugdir.BugDir(basedir, loadNow=False, sink_to_existing_root=False, assert_new_BugDir=True)
except bugdir.NoRootEntry:
raise cmdutil.UserError("No such directory: %s" % basedir)
except bugdir.AlreadyInitialized:
raise cmdutil.UserError("Directory already initialized: %s" % basedir)
- if dir_rcs.name is not "None":
- print "Using %s for revision control." % dir_rcs.name
+ bd.save()
+ if bd.rcs.name is not "None":
+ print "Using %s for revision control." % bd.rcs.name
else:
print "No revision control detected."
print "Directory initialized."
def get_parser():
- parser = cmdutil.CmdOptionParser("be set-root DIRECTORY")
+ parser = cmdutil.CmdOptionParser("be set-root [DIRECTORY]")
return parser
longhelp="""
@@ -80,6 +87,8 @@ This command initializes Bugs Everywhere support for the specified directory
and all its subdirectories. It will auto-detect any supported revision control
system. You can use "be set rcs_name" to change the rcs being used.
+DIRECTORY defaults to your current working directory.
+
It is usually a good idea to put the Bugs Everywhere root at the source code
root, but you can put it anywhere. If you run "be set-root" in a subdirectory,
then only bugs created in that subdirectory (and its children) will appear