diff options
author | W. Trevor King <wking@drexel.edu> | 2009-07-27 05:14:49 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-07-27 05:14:49 -0400 |
commit | e21a427afbc7369cfa3a3f786e51aaa1e3e01999 (patch) | |
tree | 8a7ba397e499b20ca0ebdd2535e2d8c6b6fc86c7 /becommands/diff.py | |
parent | 58e2b9fe7a13e7cd99e085059867453496712593 (diff) | |
download | bugseverywhere-e21a427afbc7369cfa3a3f786e51aaa1e3e01999.tar.gz |
Major rewrite of libbe.diff introduces DiffTree and Diff classes.
To make the interface proposed by becommands/subscribers.py easier to
implement, I've moved the libbe.diff functionality into classes. Now
it should be easy two tweak the output as desired by subclassing these
classes. The basic idea is that Diff.report_tree() generates a
diff_tree tree of changes between two bugdirs, where diff_tree is some
subclass of DiffTree. Each type of change has a default .*_string()
method producing a string summary of the change. DiffTree.report()
moves through and generates a report by joining all those summary
strings to a single root, and DiffTree.report_string() serialized the
report to produce e.g. the output of becommands/diff.py.
Diffstat (limited to 'becommands/diff.py')
-rw-r--r-- | becommands/diff.py | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/becommands/diff.py b/becommands/diff.py index 07b3b1c..1ab2135 100644 --- a/becommands/diff.py +++ b/becommands/diff.py @@ -33,10 +33,21 @@ def execute(args, manipulate_encodings=True): >>> if bd.rcs.versioned == True: ... execute([original], manipulate_encodings=False) ... else: - ... print "a:cm: Bug A\\nstatus: open -> closed\\n" - Modified bug reports: - a:cm: Bug A - status: open -> closed + ... print "Modified bugs:\\n a:cm: Bug A\\n Changed bug settings:\\n status: open -> closed" + Modified bugs: + a:cm: Bug A + Changed bug settings: + status: open -> closed + >>> if bd.rcs.versioned == True: + ... execute(["--modified", original], manipulate_encodings=False) + ... else: + ... print "a" + a + >>> if bd.rcs.versioned == False: + ... execute([original], manipulate_encodings=False) + ... else: + ... print "This directory is not revision-controlled." + This directory is not revision-controlled. """ parser = get_parser() options, args = parser.parse_args(args) @@ -55,23 +66,23 @@ def execute(args, manipulate_encodings=True): if revision == None: # get the most recent revision revision = bd.rcs.revision_id(-1) old_bd = bd.duplicate_bugdir(revision) - r,m,a = diff.bug_diffs(old_bd, bd) - - optbugs = [] + 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: - optbugs.extend(a) + uuids.extend([c.name for c in tree.child_by_path("/bugs/new")]) if options.modified == True: - optbugs.extend([new for old,new in m]) + uuids.extend([c.name for c in tree.child_by_path("/bugs/mod")]) if options.removed == True: - optbugs.extend(r) - if len(optbugs) > 0: - for bug in optbugs: - print bug.uuid + 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 = diff.diff_report((r,m,a), old_bd, bd).encode(bd.encoding) - if len(rep) > 0: + rep = tree.report_string() + if rep != None: print rep bd.remove_duplicate_bugdir() @@ -88,7 +99,7 @@ def get_parser(): long = "--%s" % s[1] help = s[2] parser.add_option(short, long, action="store_true", - dest=attr, help=help) + default=False, dest=attr, help=help) return parser longhelp=""" |