[Pkg-bazaar-commits] ./bzr/unstable r567: - New form 'bzr log -r FROM:TO'
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:19:32 UTC 2009
------------------------------------------------------------
revno: 567
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-05-27 02:58:09 +1000
message:
- New form 'bzr log -r FROM:TO'
patch from John A Meinel
modified:
NEWS
bzrlib/commands.py
bzrlib/log.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2005-05-19 11:11:53 +0000
+++ b/NEWS 2005-05-26 16:58:09 +0000
@@ -59,6 +59,9 @@
* New form ``bzr commit SELECTED`` to commit only selected files.
+ * New form ``bzr log -r FROM:TO`` shows changes in selected
+ range; contributed by John A Meinel.
+
BUG FIXES:
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-05-26 15:13:20 +0000
+++ b/bzrlib/commands.py 2005-05-26 16:58:09 +0000
@@ -37,6 +37,40 @@
assert cmd.startswith("cmd_")
return cmd[4:].replace('_','-')
+def _parse_revision_str(revstr):
+ """This handles a revision string -> revno.
+
+ There are several possibilities:
+
+ '234' -> 234
+ '234:345' -> [234, 345]
+ ':234' -> [None, 234]
+ '234:' -> [234, None]
+
+ In the future we will also support:
+ 'uuid:blah-blah-blah' -> ?
+ 'hash:blahblahblah' -> ?
+ potentially:
+ 'tag:mytag' -> ?
+ """
+ if revstr.find(':') != -1:
+ revs = revstr.split(':')
+ if len(revs) > 2:
+ raise ValueError('More than 2 pieces not supported for --revision: %r' % revstr)
+
+ if not revs[0]:
+ revs[0] = None
+ else:
+ revs[0] = int(revs[0])
+
+ if not revs[1]:
+ revs[1] = None
+ else:
+ revs[1] = int(revs[1])
+ else:
+ revs = int(revstr)
+ return revs
+
def get_all_cmds():
"""Return canonical name and class for all registered commands."""
for k, v in globals().iteritems():
@@ -594,16 +628,22 @@
class cmd_log(Command):
"""Show log of this branch.
- TODO: Option to limit range.
+ To request a range of logs, you can use the command -r begin:end
+ -r revision requests a specific revision, -r :end or -r begin: are
+ also valid.
+
+ TODO: Make --revision support uuid: and hash: [future tag:] notation.
+
"""
takes_args = ['filename?']
- takes_options = ['forward', 'timezone', 'verbose', 'show-ids']
+ takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision']
def run(self, filename=None, timezone='original',
verbose=False,
show_ids=False,
- forward=False):
+ forward=False,
+ revision=None):
from bzrlib import show_log, find_branch
import codecs
@@ -620,6 +660,16 @@
b = find_branch('.', lock_mode='r')
file_id = None
+ if revision == None:
+ revision = [None, None]
+ elif isinstance(revision, int):
+ revision = [revision, revision]
+ else:
+ # pair of revisions?
+ pass
+
+ assert len(revision) == 2
+
mutter('encoding log as %r' % bzrlib.user_encoding)
outf = codecs.getwriter(bzrlib.user_encoding)(sys.stdout)
@@ -628,7 +678,9 @@
verbose=verbose,
show_ids=show_ids,
to_file=outf,
- direction=direction)
+ direction=direction,
+ start_revision=revision[0],
+ end_revision=revision[1])
@@ -982,7 +1034,7 @@
'forward': None,
'message': unicode,
'profile': None,
- 'revision': int,
+ 'revision': _parse_revision_str,
'show-ids': None,
'timezone': str,
'verbose': None,
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2005-05-18 12:08:22 +0000
+++ b/bzrlib/log.py 2005-05-26 16:58:09 +0000
@@ -89,7 +89,9 @@
verbose=False,
show_ids=False,
to_file=None,
- direction='reverse'):
+ direction='reverse',
+ start_revision=None,
+ end_revision=None):
"""Write out human-readable log of commits to this branch.
specific_fileid
@@ -113,6 +115,12 @@
direction
'reverse' (default) is latest to earliest;
'forward' is earliest to latest.
+
+ start_revision
+ If not None, only show revisions >= start_revision
+
+ end_revision
+ If not None, only show revisions <= end_revision
"""
from osutils import format_date
from errors import BzrCheckError
@@ -140,6 +148,12 @@
if specific_fileid:
if not delta.touches_file_id(specific_fileid):
continue
+
+ if start_revision is not None and revno < start_revision:
+ continue
+
+ if end_revision is not None and revno > end_revision:
+ continue
if not verbose:
# although we calculated it, throw it away without display
More information about the Pkg-bazaar-commits
mailing list