[Patch] Support for multiple revisions for diff command

John A Meinel john at arbash-meinel.com
Wed May 11 01:29:21 BST 2005


Michael Ellerman wrote:
> Hi Martin,
>
> This is a implementation of 'bzr diff -r foo -r2 bar'. I opted against using
> the -r option twice because it's kind of ambiguous, and it seemed kind of
> hard given the current option parsing scheme :D
>
> Hmm, is it a feature or a "feature" that diff accepts (some) negative values
> for revision number? It is kind of cool.
>
> It's a little counter intertuitive (perhaps) but to get the diff for revno
> 440 you have to run 'bzr diff -r 439 -r2 440'.

Why not use one of the other syntaxes. Such as

bzr diff ./@439 ./@440
bzr diff @439 @440
(mabye bzr diff 439 440 but these could be filenames)
bzr diff -r 439:440
etc.

The first one is nice, because then you could do:

bzr diff branch1/@443 branch2/@445

Just some ideas. It is very nice to see this command implemented, at
least in some form. Especially since you can do an rsync with dev, and
pull across a bunch of patches, without having an easy way to review
what changed.

John
=:->

>
> cheers
>
> *** modified file 'bzrlib/commands.py'
> --- bzrlib/commands.py
> +++ bzrlib/commands.py
> @@ -425,8 +425,6 @@
>      If files are listed, only the changes in those files are listed.
>      Otherwise, all changes for the tree are listed.
>
> -    TODO: Given two revision arguments, show the difference between them.
> -
>      TODO: Allow diff across branches.
>
>      TODO: Option to use external diff command; could be GNU diff, wdiff,
> @@ -444,13 +442,13 @@
>      """
>
>      takes_args = ['file*']
> -    takes_options = ['revision']
> +    takes_options = ['revision', 'target-revision']
>      aliases = ['di']
>
> -    def run(self, revision=None, file_list=None):
> +    def run(self, revision=None, target_revision=None, file_list=None):
>          from bzrlib.diff import show_diff
>
> -        show_diff(Branch('.'), revision, file_list)
> +        show_diff(Branch('.'), revision, target_revision, file_list)
>
>
>
> @@ -861,7 +859,6 @@
>  ######################################################################
>  # main routine
>
> -
>  # list of all available options; the rhs can be either None for an
>  # option that takes no argument, or a constructor function that checks
>  # the type.
> @@ -872,6 +869,7 @@
>      'message':                unicode,
>      'profile':                None,
>      'revision':               int,
> +    'target-revision':        int,
>      'show-ids':               None,
>      'timezone':               str,
>      'verbose':                None,
> @@ -883,6 +881,7 @@
>      'm':                      'message',
>      'F':                      'file',
>      'r':                      'revision',
> +    'r2':                     'target-revision',
>      'v':                      'verbose',
>  }
>
>
> *** modified file 'bzrlib/diff.py'
> --- bzrlib/diff.py
> +++ bzrlib/diff.py
> @@ -140,15 +140,18 @@
>
>
>
> -def show_diff(b, revision, file_list):
> +def show_diff(b, revision, target_revision, file_list):
>      import difflib, sys, types
>
>      if revision == None:
>          old_tree = b.basis_tree()
>      else:
>          old_tree = b.revision_tree(b.lookup_revision(revision))
> -
> -    new_tree = b.working_tree()
> +
> +    if target_revision == None:
> +        new_tree = b.working_tree()
> +    else:
> +        new_tree = b.revision_tree(b.lookup_revision(target_revision))
>
>      # TODO: Options to control putting on a prefix or suffix, perhaps as a format string
>      old_label = ''
>
> *** modified file 'testbzr'
> --- testbzr
> +++ testbzr
> @@ -281,6 +281,11 @@
>      f.close()
>
>      runcmd('bzr commit -F msg.tmp')
> +
> +    runcmd('bzr diff -r 0 -r2 1')
> +
> +    out = backtick('bzr diff -r 0 -r2 1').split('\n')[0]
> +    assert out == "*** added file 'hello.txt'"
>
>      assert backtick('bzr revno') == '5\n'
>      runcmd('bzr export -r 5 export-5.tmp')
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050510/bc1225a2/attachment.pgp 


More information about the bazaar mailing list