diff options
Diffstat (limited to 'becommands/diff.py')
-rw-r--r-- | becommands/diff.py | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/becommands/diff.py b/becommands/diff.py index 77194ff..c090fa8 100644 --- a/becommands/diff.py +++ b/becommands/diff.py @@ -20,7 +20,7 @@ from libbe import cmdutil, bugdir, diff import os __desc__ = __doc__ -def execute(args): +def execute(args, test=False): """ >>> import os >>> bd = bugdir.simple_bug_dir() @@ -31,7 +31,7 @@ def execute(args): >>> changed = bd.rcs.commit("Closed bug a") >>> os.chdir(bd.root) >>> if bd.rcs.versioned == True: - ... execute([original]) + ... execute([original], test=True) ... else: ... print "a:cm: Bug A\\nstatus: open -> closed\\n" Modified bug reports: @@ -39,25 +39,52 @@ def execute(args): status: open -> closed <BLANKLINE> """ - options, args = get_parser().parse_args(args) + parser = get_parser() + options, args = parser.parse_args(args) + cmdutil.default_complete(options, args, parser) if len(args) == 0: revision = None if len(args) == 1: revision = args[0] if len(args) > 1: - help() - raise cmdutil.UserError("Too many arguments.") - bd = bugdir.BugDir(from_disk=True) + raise cmdutil.UsageError("Too many arguments.") + bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) if bd.rcs.versioned == False: print "This directory is not revision-controlled." else: old_bd = bd.duplicate_bugdir(revision) r,m,a = diff.diff(old_bd, bd) - diff.diff_report((r,m,a), bd) + + optbugs = [] + if options.all == True: + options.new = options.modified = options.removed = True + if options.new == True: + optbugs.extend(a) + if options.modified == True: + optbugs.extend([new for old,new in m]) + if options.removed == True: + optbugs.extend(r) + if len(optbugs) > 0: + for bug in optbugs: + print bug.uuid + else : + print diff.diff_report((r,m,a), bd).encode(bd.encoding) bd.remove_duplicate_bugdir() def get_parser(): - parser = cmdutil.CmdOptionParser("be diff [SPECIFIER]") + parser = cmdutil.CmdOptionParser("be diff [options] REVISION") + # boolean options + bools = (("n", "new", "Print UUIDS for new bugs"), + ("m", "modified", "Print UUIDS for modified bugs"), + ("r", "removed", "Print UUIDS for removed bugs"), + ("a", "all", "Print UUIDS for all changed bugs")) + for s in bools: + attr = s[1].replace('-','_') + short = "-%c" % s[0] + long = "--%s" % s[1] + help = s[2] + parser.add_option(short, long, action="store_true", + dest=attr, help=help) return parser longhelp=""" @@ -65,7 +92,11 @@ Uses the RCS to compare the current tree with a previous tree, and prints a pretty report. If specifier is given, it is a specifier for the particular previous tree to use. Specifiers are specific to their RCS. -For Arch: a fully-qualified revision name +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. """ def help(): |