aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-04 23:55:11 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-04 23:55:11 -0500
commite023e7b980f8cfb4c02a0442a39774311e1c5a99 (patch)
treef96490526bc1c818f039b37f36335d25acda3bc5
parenta04fc28b3b840541dde0366b81fc6758823cfca7 (diff)
parentefb79f10cec777dfa7fdced96947f7f75119ba69 (diff)
downloadbugseverywhere-e023e7b980f8cfb4c02a0442a39774311e1c5a99.tar.gz
Merged `be diff --dir DIR` functionality
-rw-r--r--NEWS3
-rw-r--r--becommands/diff.py20
-rw-r--r--libbe/diff.py4
3 files changed, 21 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index ab962d4..669bed2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
-December 4, 2009:
+December 4, 2009
* new commands:
email-bugs
* broke `be comment --xml` out and extended into `be import-xml`
+ * added --dir option to `be diff'
* new XML format <be-xml>
* interfaces/email/interactive:
* added support for [be-bug:xml] interface
diff --git a/becommands/diff.py b/becommands/diff.py
index 6477934..8e6c0f8 100644
--- a/becommands/diff.py
+++ b/becommands/diff.py
@@ -65,9 +65,19 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False):
if bd.vcs.versioned == False:
print "This directory is not revision-controlled."
else:
- if revision == None: # get the most recent revision
- revision = bd.vcs.revision_id(-1)
- old_bd = bd.duplicate_bugdir(revision)
+ 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:
+ 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()
@@ -87,6 +97,8 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False):
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")
@@ -102,6 +114,8 @@ def get_parser():
help = s[2]
parser.add_option(short, long, action="store_true",
default=False, dest=attr, help=help)
+ parser.add_option("-d", "--dir", dest="dir", metavar="DIR",
+ help="Compare with repository in DIR instead of the current directory.")
return parser
longhelp="""
diff --git a/libbe/diff.py b/libbe/diff.py
index 4c22597..c25f7a7 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -263,8 +263,8 @@ class Diff (object):
modified.append((old_comment, new_comment))
for uuid in old_comment_ids:
if uuid not in new_comment_ids:
- new_comment = new.comment_from_uuid(uuid)
- removed.append(new_comment)
+ old_comment = old.comment_from_uuid(uuid)
+ removed.append(old_comment)
self.__changed_comments[new.uuid] = (added, modified, removed)
return self.__changed_comments[new.uuid]
def _attribute_changes(self, old, new, attributes):