Rev 2776: Introduce -c option for diff and status in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sat Sep 1 17:04:49 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2776
revision-id: pqm at pqm.ubuntu.com-20070901160444-hcr66zejwyy0jezc
parent: pqm at pqm.ubuntu.com-20070831085255-w43drl9sistvl5dl
parent: lalinsky at gmail.com-20070825171512-sblhcmnl410w816g
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2007-09-01 17:04:44 +0100
message:
Introduce -c option for diff and status
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/blackbox/test_diff.py test_diff.py-20060110203741-aa99ac93e633d971
bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
------------------------------------------------------------
revno: 2745.4.5
merged: lalinsky at gmail.com-20070825171512-sblhcmnl410w816g
parent: lalinsky at gmail.com-20070825160141-hoeroer1ggao6jv7
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: changeset
timestamp: Sat 2007-08-25 19:15:12 +0200
message:
'..' in the revision string doesn't always mean a range, so parse the string using _parse_revision_str and then check the number of returned revisions
------------------------------------------------------------
revno: 2745.4.4
merged: lalinsky at gmail.com-20070825160141-hoeroer1ggao6jv7
parent: lalinsky at gmail.com-20070825141012-yeuv0gwo0djp5st2
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: changeset
timestamp: Sat 2007-08-25 18:01:41 +0200
message:
- Make the description of --change more general
- Raise more specific error for a revision range passed to --change
------------------------------------------------------------
revno: 2745.4.3
merged: lalinsky at gmail.com-20070825141012-yeuv0gwo0djp5st2
parent: lalinsky at gmail.com-20070825135428-6gfms099o3txnonp
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: changeset
timestamp: Sat 2007-08-25 16:10:12 +0200
message:
Change -C to -c.
------------------------------------------------------------
revno: 2745.4.2
merged: lalinsky at gmail.com-20070825135428-6gfms099o3txnonp
parent: lalinsky at gmail.com-20070823194135-sd784wf9vhbuplv2
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: changeset
timestamp: Sat 2007-08-25 15:54:28 +0200
message:
Allow options to be stored in attributes that differ from their 'name' and use this to let '--change' and '--revision' to override each other.
------------------------------------------------------------
revno: 2745.4.1
merged: lalinsky at gmail.com-20070823194135-sd784wf9vhbuplv2
parent: pqm at pqm.ubuntu.com-20070823005013-ada9x55rc31yiwou
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: changeset
timestamp: Thu 2007-08-23 21:41:35 +0200
message:
New option -C/--change for diff and status to show changes in one revision. (#56299)
=== modified file 'NEWS'
--- a/NEWS 2007-08-31 08:52:55 +0000
+++ b/NEWS 2007-09-01 16:04:44 +0000
@@ -107,6 +107,9 @@
rather than looking it up again, making it faster.
(Ian Clatworthy)
+ * New option ``-c``/``--change`` for ``diff`` and ``status`` to show
+ changes in one revision. (Lukáš Lalinský)
+
API BREAKS:
* ``Branch.append_revision`` is removed altogether; please use
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-08-31 05:32:00 +0000
+++ b/bzrlib/builtins.py 2007-09-01 16:04:44 +0000
@@ -167,7 +167,7 @@
# TODO: --no-recurse, --recurse options
takes_args = ['file*']
- takes_options = ['show-ids', 'revision',
+ takes_options = ['show-ids', 'revision', 'change',
Option('short', help='Give short SVN-style status lines.'),
Option('versioned', help='Only show versioned files.')]
aliases = ['st', 'stat']
@@ -180,6 +180,10 @@
versioned=False):
from bzrlib.status import show_tree_status
+ if revision and len(revision) > 2:
+ raise errors.BzrCommandError('bzr status --revision takes exactly'
+ ' one or two revision specifiers')
+
tree, file_list = tree_files(file_list)
show_tree_status(tree, show_ids=show_ids,
@@ -1417,6 +1421,7 @@
help='Set prefixes to added to old and new filenames, as '
'two values separated by a colon. (eg "old/:new/").'),
'revision',
+ 'change',
]
aliases = ['di', 'dif']
encoding_type = 'exact'
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2007-08-30 08:11:54 +0000
+++ b/bzrlib/errors.py 2007-09-01 16:04:44 +0000
@@ -1000,6 +1000,11 @@
new_revision=new_revision)
+class RangeInChangeOption(BzrError):
+
+ _fmt = "Option --change does not accept revision ranges"
+
+
class NoSuchRevisionSpec(BzrError):
_fmt = "No namespace registered for string: %(spec)r"
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2007-08-28 05:58:53 +0000
+++ b/bzrlib/option.py 2007-09-01 16:04:44 +0000
@@ -100,6 +100,24 @@
return revs
+def _parse_change_str(revstr):
+ """Parse the revision string and return a tuple with left-most
+ parent of the revision.
+
+ >>> _parse_change_str('123')
+ (<RevisionSpec_before before:123>, <RevisionSpec_revno 123>)
+ >>> _parse_change_str('123..124')
+ Traceback (most recent call last):
+ ...
+ RangeInChangeOption: Option --change does not accept revision ranges
+ """
+ revs = _parse_revision_str(revstr)
+ if len(revs) > 1:
+ raise errors.RangeInChangeOption()
+ return (revisionspec.RevisionSpec.from_string('before:' + revstr),
+ revs[0])
+
+
def _parse_merge_type(typestring):
return get_merge_type(typestring)
@@ -129,12 +147,12 @@
OPTIONS = {}
def __init__(self, name, help='', type=None, argname=None,
- short_name=None):
+ short_name=None, param_name=None):
"""Make a new command option.
name -- regular name of the command, used in the double-dash
form and also as the parameter to the command's run()
- method.
+ method (unless param_name is specified).
help -- help message displayed in command help
@@ -142,6 +160,9 @@
None (default) if this option doesn't take an argument.
argname -- name of option argument, if any
+
+ param_name -- name of the parameter which will be passed to
+ the command's run() method.
"""
self.name = name
self.help = help
@@ -152,6 +173,10 @@
elif argname is None:
argname = 'ARG'
self.argname = argname
+ if param_name is None:
+ self._param_name = self.name
+ else:
+ self._param_name = param_name
def short_name(self):
if self._short_name:
@@ -189,7 +214,7 @@
*option_strings)
def _optparse_callback(self, option, opt, value, parser):
- setattr(parser.values, self.name, self.type(value))
+ setattr(parser.values, self._param_name, self.type(value))
def iter_switches(self):
"""Iterate through the list of switches provided by the option
@@ -398,7 +423,12 @@
_global_option('revision',
type=_parse_revision_str,
short_name='r',
- help='See \'help revisionspec\' for details.')
+ help='See "help revisionspec" for details.')
+_global_option('change',
+ type=_parse_change_str,
+ short_name='c',
+ param_name='revision',
+ help='Select changes introduced by the specified revision. See also "help revisionspec".')
_global_option('show-ids',
help='Show internal object ids.')
_global_option('timezone',
=== modified file 'bzrlib/tests/blackbox/test_diff.py'
--- a/bzrlib/tests/blackbox/test_diff.py 2007-08-23 18:09:50 +0000
+++ b/bzrlib/tests/blackbox/test_diff.py 2007-09-01 16:04:44 +0000
@@ -57,8 +57,11 @@
tree.commit(message='fixing hello')
output = self.run_bzr('diff -r 2..3', retcode=1)[0]
self.assert_('\n+hello world!' in output)
- output = self.run_bzr('diff -r last:3..last:1',
- retcode=1)[0]
+ output = self.run_bzr('diff -c 3', retcode=1)[0]
+ self.assert_('\n+hello world!' in output)
+ output = self.run_bzr('diff -r last:3..last:1', retcode=1)[0]
+ self.assert_('\n+baz' in output)
+ output = self.run_bzr('diff -c last:2', retcode=1)[0]
self.assert_('\n+baz' in output)
self.build_tree(['moo'])
tree.add('moo')
=== modified file 'bzrlib/tests/blackbox/test_status.py'
--- a/bzrlib/tests/blackbox/test_status.py 2007-08-28 14:37:01 +0000
+++ b/bzrlib/tests/blackbox/test_status.py 2007-09-01 16:04:44 +0000
@@ -317,6 +317,9 @@
result = self.run_bzr("status -r 0..1")[0]
self.assertContainsRe(result, "added:\n hello.txt\n")
+ result = self.run_bzr("status -c 1")[0]
+ self.assertContainsRe(result, "added:\n hello.txt\n")
+
self.build_tree(['world.txt'])
result = self.run_bzr("status -r 0")[0]
self.assertContainsRe(result, "added:\n hello.txt\n" \
@@ -386,6 +389,10 @@
rmdir('directory')
self.assertStatusContains('RD file => directory')
+ def test_status_illegal_revision_specifiers(self):
+ out, err = self.run_bzr('status -r 1..23..123', retcode=3)
+ self.assertContainsRe(err, 'one or two revision specifiers')
+
class TestStatusEncodings(TestCaseWithTransport):
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2007-08-28 05:17:58 +0000
+++ b/bzrlib/tests/test_options.py 2007-09-01 16:04:44 +0000
@@ -134,6 +134,18 @@
self.assertRaises(errors.BzrCommandError, self.parse, options,
['--format', 'two'])
+ def test_override(self):
+ options = [option.Option('hello', type=str),
+ option.Option('hi', type=str, param_name='hello')]
+ opts, args = self.parse(options, ['--hello', 'a', '--hello', 'b'])
+ self.assertEqual('b', opts.hello)
+ opts, args = self.parse(options, ['--hello', 'b', '--hello', 'a'])
+ self.assertEqual('a', opts.hello)
+ opts, args = self.parse(options, ['--hello', 'a', '--hi', 'b'])
+ self.assertEqual('b', opts.hello)
+ opts, args = self.parse(options, ['--hi', 'b', '--hello', 'a'])
+ self.assertEqual('a', opts.hello)
+
def test_registry_converter(self):
options = [option.RegistryOption('format', '',
bzrdir.format_registry, bzrdir.format_registry.make_bzrdir)]
More information about the bazaar-commits
mailing list