aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-05 01:00:35 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-05 01:00:35 -0500
commit1bbf068f28a6c05da563bc1224a4456f635227a4 (patch)
tree08cd3d9d0e7504e24c4abfa4b348cb76e775e8e6 /becommands
parent282d5cf934eec5c0ae02a01c345c38d0ad7c9fa7 (diff)
downloadbugseverywhere-1bbf068f28a6c05da563bc1224a4456f635227a4.tar.gz
`be diff` raises UsageError if required revision control not possible.
It had previously printed an message and exitted without error.
Diffstat (limited to 'becommands')
-rw-r--r--becommands/diff.py71
1 files changed, 37 insertions, 34 deletions
diff --git a/becommands/diff.py b/becommands/diff.py
index 8e6c0f8..f581ace 100644
--- a/becommands/diff.py
+++ b/becommands/diff.py
@@ -63,42 +63,45 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False):
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
if bd.vcs.versioned == False:
- print "This directory is not revision-controlled."
+ raise cmdutil.UsageError("This directory is not revision-controlled.")
+ if options.dir == None:
+ if revision == None: # get the most recent revision
+ revision = bd.vcs.revision_id(-1)
+ old_bd = bd.duplicate_bugdir(revision)
else:
- if options.dir == None:
- if revision == None: # get the most recent revision
- revision = bd.vcs.revision_id(-1)
- old_bd = bd.duplicate_bugdir(revision)
+ cwd = os.getcwd()
+ os.chdir(options.dir)
+ old_bd_current = bugdir.BugDir(from_disk=True,
+ manipulate_encodings=False)
+ if revision == None: # use the current working state
+ old_bd = old_bd_current
else:
- cwd = os.getcwd()
- os.chdir(options.dir)
- old_bd_current = bugdir.BugDir(from_disk=True, manipulate_encodings=False)
- if revision == None: # use the current working state
- old_bd = old_bd_current
- else:
- old_bd = old_bd_current.duplicate_bugdir(revision)
- os.chdir(cwd)
- d = diff.Diff(old_bd, bd)
- tree = d.report_tree()
+ if old_bd_current.vcs.versioned == False:
+ raise cmdutil.UsageError("%s is not revision-controlled."
+ % options.dir)
+ old_bd = old_bd_current.duplicate_bugdir(revision)
+ os.chdir(cwd)
+ d = diff.Diff(old_bd, bd)
+ tree = d.report_tree()
- uuids = []
- if options.all == True:
- options.new = options.modified = options.removed = True
- if options.new == True:
- uuids.extend([c.name for c in tree.child_by_path("/bugs/new")])
- if options.modified == True:
- uuids.extend([c.name for c in tree.child_by_path("/bugs/mod")])
- if options.removed == True:
- uuids.extend([c.name for c in tree.child_by_path("/bugs/rem")])
- if (options.new or options.modified or options.removed) == True:
- print "\n".join(uuids)
- else :
- rep = tree.report_string()
- if rep != None:
- print rep
- bd.remove_duplicate_bugdir()
- if options.dir != None and revision != None:
- old_bd_current.remove_duplicate_bugdir()
+ uuids = []
+ if options.all == True:
+ options.new = options.modified = options.removed = True
+ if options.new == True:
+ uuids.extend([c.name for c in tree.child_by_path("/bugs/new")])
+ if options.modified == True:
+ uuids.extend([c.name for c in tree.child_by_path("/bugs/mod")])
+ if options.removed == True:
+ uuids.extend([c.name for c in tree.child_by_path("/bugs/rem")])
+ if (options.new or options.modified or options.removed) == True:
+ print "\n".join(uuids)
+ else :
+ rep = tree.report_string()
+ if rep != None:
+ print rep
+ bd.remove_duplicate_bugdir()
+ if options.dir != None and revision != None:
+ old_bd_current.remove_duplicate_bugdir()
def get_parser():
parser = cmdutil.CmdOptionParser("be diff [options] REVISION")
@@ -128,7 +131,7 @@ For Arch your specifier must be a fully-qualified revision name.
Besides the standard summary output, you can use the options to output
UUIDS for the different categories. This output can be used as the
-input to 'be show' to get and understanding of the current status.
+input to 'be show' to get an understanding of the current status.
"""
def help():