[PATCH] Trivial: bzr log fails when start/end_revision is the latest one

Aaron Bentley aaron.bentley at utoronto.ca
Tue Aug 16 17:13:24 BST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The patch looks correct, but all of this code violates DRY.  There
should be one and only one way to determine whether a given revno exists
in the branch.

Aaron

Bartosz Oler wrote:
> Hi!
> 
> Patch attached.
> 
> -- Bartosz
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> *** modified file 'bzrlib/log.py'
> --- bzrlib/log.py 
> +++ bzrlib/log.py 
> @@ -162,12 +162,12 @@
>      
>      if start_revision is None:
>          start_revision = 1
> -    elif start_revision < 1 or start_revision >= len(which_revs):
> +    elif start_revision < 1 or start_revision > len(which_revs):
>          raise InvalidRevisionNumber(start_revision)
>      
>      if end_revision is None:
>          end_revision = len(which_revs)
> -    elif end_revision < 1 or end_revision >= len(which_revs):
> +    elif end_revision < 1 or end_revision > len(which_revs):
>          raise InvalidRevisionNumber(end_revision)
>  
>      # list indexes are 0-based; revisions are 1-based
> 
> *** modified file 'bzrlib/selftest/testlog.py'
> --- bzrlib/selftest/testlog.py 
> +++ bzrlib/selftest/testlog.py 
> @@ -19,6 +19,7 @@
>  from bzrlib.selftest import BzrTestBase
>  from bzrlib.log import LogFormatter, show_log, LongLogFormatter
>  from bzrlib.branch import Branch
> +from bzrlib.errors import InvalidRevisionNumber
>  
>  class _LogEntry(object):
>      # should probably move into bzrlib.log?
> @@ -106,4 +107,15 @@
>          d = logentry.delta
>          self.log('log 2 delta: %r' % d)
>          # self.checkDelta(d, added=['hello'])
> -        
> +
> +        # check if we don't fail when requested start/end_revision
> +        # is the last revision
> +        lf = LogCatcher()
> +        show_log(b, lf, verbose=True)
> +        lastrev = lf.logs[0].revno
> +        try:
> +            show_log(b, LogCatcher(), end_revision=lastrev, verbose=True)
> +            show_log(b, LogCatcher(), start_revision=lastrev, verbose=True)
> +        except InvalidRevisionNumber, e:
> +            self.fail(e)
> +
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDAhCk0F+nu1YWqI0RAqf0AJ0XIF51qS+mkZQ6md3E1EZERFnRWgCfSIor
zkVauxEyn4+Zm+xJvpG5L30=
=rO4e
-----END PGP SIGNATURE-----




More information about the bazaar mailing list