[PATCH] Re: [new] diffstat plugin
Wouter van Heyst
larstiq at larstiq.dyndns.org
Thu Dec 1 17:21:13 GMT 2005
<snip>
> > It doesn't accept revision parameters: bzr ds -r5..8 fails.
>
> ...but after some minor hacking it does:
The patch below uses a slightly different approach, bzrlib/builtins.py cmd_diff
matches the style Wouter used, is that a recommended bzr coding style?
While testing if it still worked, I noticed some difference between
external and internal diffstat:
newie%~/.bazaar/plugins/diffstat> bzr diff -r -2.. | diffstat
__init__.py | 29 --------------------
diffstat.py | 87 ------------------------------------------------------------
2 files changed, 116 deletions(-)
newie%~/.bazaar/plugins/diffstat> bzr ds -r -2..
diffstat.py | 87 +-------------------------------------------
__init__.py | 29 +--------------
2 files changed, 0 insertions(+), 116 deletions(-)
How important is trying to achieve the exact same output?
Wouter van Heyst
-------------- next part --------------
=== modified file '__init__.py'
--- __init__.py
+++ __init__.py
@@ -6,8 +6,9 @@
class cmd_diffstat(bzrlib.commands.Command):
"""diffstat - show stats about changes to the working tree"""
takes_args = ['file*']
+ takes_options = ['revision']
aliases = ['ds']
- def run(self, file_list=None):
+ def run(self, revision=None, file_list=None):
from diffstat import DiffStat
from bzrlib.branch import Branch
from StringIO import StringIO
@@ -21,7 +22,15 @@
b = Branch.open_containing(location)[0]
out = StringIO()
- show_diff(b, None, specific_files=file_list, output=out)
+
+ if not revision:
+ revs = [None, None]
+ elif len(revision) == 1:
+ revs = revision + [None]
+ elif len(revision) == 2:
+ revs = revision
+
+ show_diff(b, from_spec=revs[0], revision2=revs[1], specific_files=file_list, output=out)
out.seek(0)
ds = str(DiffStat(out.readlines()))
if len(ds):
More information about the bazaar
mailing list