Rev 5963: (vila) Allow -S as shorthand for --log-format=short (Martin von Gagern) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jun 8 13:51:33 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5963 [merge]
revision-id: pqm at pqm.ubuntu.com-20110608135130-lmzibvvzxrxwci0t
parent: pqm at pqm.ubuntu.com-20110607183938-ir1i1e5ofmn31krv
parent: martin.vgagern at gmx.net-20110603084954-ny2brqbgz1ny38pj
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-06-08 13:51:30 +0000
message:
(vila) Allow -S as shorthand for --log-format=short (Martin von Gagern)
modified:
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
bzrlib/tests/blackbox/test_missing.py test_missing.py-20051211212735-a2cf4c1840bb84c4
bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
doc/en/whats-new/whats-new-in-2.4.txt whatsnewin2.4.txt-20110114044330-nipk1og7j729fy89-1
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2011-01-14 05:14:04 +0000
+++ b/bzrlib/option.py 2011-06-01 08:37:45 +0000
@@ -312,7 +312,7 @@
def __init__(self, name, help, registry=None, converter=None,
value_switches=False, title=None, enum_switch=True,
- lazy_registry=None, short_name=None):
+ lazy_registry=None, short_name=None, short_value_switches=None):
"""
Constructor.
@@ -328,6 +328,8 @@
which takes a value.
:param lazy_registry: A tuple of (module name, attribute name) for a
registry to be lazily loaded.
+ :param short_name: The short name for the enum switch, if any
+ :param short_value_switches: A dict mapping values to short names
"""
Option.__init__(self, name, help, type=self.convert, short_name=short_name)
self._registry = registry
@@ -344,6 +346,7 @@
self.converter = converter
self.value_switches = value_switches
self.enum_switch = enum_switch
+ self.short_value_switches = short_value_switches
self.title = title
if self.title is None:
self.title = name
@@ -387,6 +390,10 @@
help = optparse.SUPPRESS_HELP
else:
help = self.registry.get_help(key)
+ if (self.short_value_switches and
+ key in self.short_value_switches):
+ option_strings.append('-%s' %
+ self.short_value_switches[key])
parser.add_option(action='callback',
callback=self._optparse_value_callback(key),
help=help,
@@ -555,7 +562,8 @@
_global_option('update')
_global_registry_option('log-format', "Use specified log format.",
lazy_registry=('bzrlib.log', 'log_formatter_registry'),
- value_switches=True, title='Log format')
+ value_switches=True, title='Log format',
+ short_value_switches={'short': 'S'})
_global_option('long', help='Use detailed log format. Same as --log-format long',
short_name='l')
_global_option('short', help='Use moderately short log format. Same as --log-format short')
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- a/bzrlib/tests/blackbox/test_log.py 2011-05-26 08:05:45 +0000
+++ b/bzrlib/tests/blackbox/test_log.py 2011-06-03 08:45:36 +0000
@@ -463,6 +463,9 @@
def test_log_short_verbose(self):
self.assertUseShortDeltaFormat(['log', '--short', '-v'])
+ def test_log_s_verbose(self):
+ self.assertUseShortDeltaFormat(['log', '-S', '-v'])
+
def test_log_short_verbose_verbose(self):
self.assertUseLongDeltaFormat(['log', '--short', '-vv'])
=== modified file 'bzrlib/tests/blackbox/test_missing.py'
--- a/bzrlib/tests/blackbox/test_missing.py 2010-06-17 09:23:19 +0000
+++ b/bzrlib/tests/blackbox/test_missing.py 2011-06-03 08:45:36 +0000
@@ -113,6 +113,9 @@
lines4 = self.run_bzr('missing ../a --short', retcode=1)[0]
lines4 = lines4.splitlines()
self.assertEqual(4, len(lines4))
+ lines4a = self.run_bzr('missing ../a -S', retcode=1)[0]
+ lines4a = lines4a.splitlines()
+ self.assertEqual(lines4, lines4a)
lines5 = self.run_bzr('missing ../a --line', retcode=1)[0]
lines5 = lines5.splitlines()
self.assertEqual(2, len(lines5))
=== modified file 'bzrlib/tests/blackbox/test_status.py'
--- a/bzrlib/tests/blackbox/test_status.py 2011-05-18 14:59:24 +0000
+++ b/bzrlib/tests/blackbox/test_status.py 2011-06-03 08:45:36 +0000
@@ -637,10 +637,10 @@
self.assertContainsRe(result, "[+]N hello.txt\n")
self.build_tree(['world.txt'])
- result = self.run_bzr("status --short -r 0")[0]
+ result = self.run_bzr("status -S -r 0")[0]
self.assertContainsRe(result, "[+]N hello.txt\n" \
"[?] world.txt\n")
- result2 = self.run_bzr("status --short -r 0..")[0]
+ result2 = self.run_bzr("status -S -r 0..")[0]
self.assertEquals(result2, result)
def test_status_versioned(self):
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2011-01-19 18:40:15 +0000
+++ b/bzrlib/tests/test_options.py 2011-06-01 07:01:17 +0000
@@ -22,6 +22,7 @@
controldir,
errors,
option,
+ registry,
)
from bzrlib.builtins import cmd_commit
from bzrlib.commands import parse_args
@@ -412,6 +413,17 @@
self.assertEqual('suggest lottery numbers', my_opt.help)
self.assertEqual(orig_help, the_opt.help)
+ def test_short_value_switches(self):
+ reg = registry.Registry()
+ reg.register('short', 'ShortChoice')
+ reg.register('long', 'LongChoice')
+ ropt = option.RegistryOption('choice', '', reg, value_switches=True,
+ short_value_switches={'short': 's'})
+ opts, args = parse([ropt], ['--short'])
+ self.assertEqual('ShortChoice', opts.choice)
+ opts, args = parse([ropt], ['-s'])
+ self.assertEqual('ShortChoice', opts.choice)
+
class TestVerboseQuietLinkage(TestCase):
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-06-07 18:39:38 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-06-08 13:51:30 +0000
@@ -24,6 +24,9 @@
exception caused while running bzr serve. (Jonathan Riddell,
#274578)
+* Support ``-S`` as an alias for ``--short`` for the ``log`` and
+ ``missing`` commands. (Martin von Gagern, #38655)
+
Improvements
************
=== modified file 'doc/en/whats-new/whats-new-in-2.4.txt'
--- a/doc/en/whats-new/whats-new-in-2.4.txt 2011-06-06 17:08:37 +0000
+++ b/doc/en/whats-new/whats-new-in-2.4.txt 2011-06-08 13:51:30 +0000
@@ -49,6 +49,12 @@
Two built-in synonyms for ``bzr branch`` have been deprecated: ``clone`` and
``get``.
+Command options
+***************
+
+* The ``bzr log`` and ``bzr missing`` commands now accept ``-S`` as a
+ shorthand for ``--short``.
+
Configuration files
*******************
More information about the bazaar-commits
mailing list