aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/diff.py
diff options
context:
space:
mode:
Diffstat (limited to 'becommands/diff.py')
-rw-r--r--becommands/diff.py45
1 files changed, 34 insertions, 11 deletions
diff --git a/becommands/diff.py b/becommands/diff.py
index 82ebb2c..77194ff 100644
--- a/becommands/diff.py
+++ b/becommands/diff.py
@@ -16,25 +16,48 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Compare bug reports with older tree"""
-from libbe import bugdir, diff, cmdutil
+from libbe import cmdutil, bugdir, diff
import os
+__desc__ = __doc__
+
def execute(args):
+ """
+ >>> import os
+ >>> bd = bugdir.simple_bug_dir()
+ >>> original = bd.rcs.commit("Original status")
+ >>> bug = bd.bug_from_uuid("a")
+ >>> bug.status = "closed"
+ >>> bd.save()
+ >>> changed = bd.rcs.commit("Closed bug a")
+ >>> os.chdir(bd.root)
+ >>> if bd.rcs.versioned == True:
+ ... execute([original])
+ ... else:
+ ... print "a:cm: Bug A\\nstatus: open -> closed\\n"
+ Modified bug reports:
+ a:cm: Bug A
+ status: open -> closed
+ <BLANKLINE>
+ """
options, args = get_parser().parse_args(args)
if len(args) == 0:
- spec = None
- elif len(args) == 1:
- spec = args[0]
- else:
- raise cmdutil.UsageError
- tree = bugdir.tree_root(".")
- if tree.rcs_name == "None":
+ 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)
+ if bd.rcs.versioned == False:
print "This directory is not revision-controlled."
else:
- diff.diff_report(diff.reference_diff(tree, spec), tree)
-
+ old_bd = bd.duplicate_bugdir(revision)
+ r,m,a = diff.diff(old_bd, bd)
+ diff.diff_report((r,m,a), bd)
+ bd.remove_duplicate_bugdir()
def get_parser():
- parser = cmdutil.CmdOptionParser("be diff [specifier]")
+ parser = cmdutil.CmdOptionParser("be diff [SPECIFIER]")
return parser
longhelp="""