Rev 3735: Fix bug #248427 by adding a --change option to log. in lp:~vila/bzr/248427-log-c

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Sep 24 14:43:53 BST 2008


At lp:~vila/bzr/248427-log-c

------------------------------------------------------------
revno: 3735
revision-id: v.ladeuil+lp at free.fr-20080924134348-s1tz1xjuxppe2caw
parent: pqm at pqm.ubuntu.com-20080924081540-ecfvp6xq4x9gs81n
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 248427-log-c
timestamp: Wed 2008-09-24 15:43:48 +0200
message:
  Fix bug #248427 by adding a --change option to log.
  
  * bzrlib/tests/blackbox/test_log.py:
  (TestLog.test_log_change_revno,
  TestLog.test_log_change_single_revno,
  TestLog.test_log_change_incompatible_with_revision):
  Add tests specific to log --change behaviour.
  
  * bzrlib/builtins.py:
  (cmd_log): Add a 'change' option with a behaviour tailored to log.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-09-24 06:52:03 +0000
+++ b/NEWS	2008-09-24 13:43:48 +0000
@@ -51,6 +51,9 @@
       repository now preserves the repository format.
       (Andrew Bennetts, #269214)
 
+    * ``bzr log`` now accepts a ``--change`` option.
+      (Vincent Ladeuil, #248427)
+
     * ``bzr missing`` now accepts an ``--include-merges`` option.
       (Vincent Ladeuil, #233817)
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-09-24 06:52:03 +0000
+++ b/bzrlib/builtins.py	2008-09-24 13:43:48 +0000
@@ -1689,6 +1689,11 @@
                    help='Show files changed in each revision.'),
             'show-ids',
             'revision',
+            Option('change',
+                   type=bzrlib.option._parse_revision_str,
+                   short_name='c',
+                   help='Show just the specified revision.'
+                   ' See also "help revisionspec".'),
             'log-format',
             Option('message',
                    short_name='m',
@@ -1709,12 +1714,22 @@
             show_ids=False,
             forward=False,
             revision=None,
+            change=None,
             log_format=None,
             message=None,
             limit=None):
         from bzrlib.log import show_log
         direction = (forward and 'forward') or 'reverse'
-        
+
+        if change is not None:
+            if len(change) > 1:
+                raise errors.RangeInChangeOption()
+            if revision is not None:
+                raise errors.BzrCommandError(
+                    '--revision and --change are mutually exclusive')
+            else:
+                revision = change
+
         # log everything
         file_id = None
         if location:

=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- a/bzrlib/tests/blackbox/test_log.py	2008-09-01 00:56:53 +0000
+++ b/bzrlib/tests/blackbox/test_log.py	2008-09-24 13:43:48 +0000
@@ -138,7 +138,25 @@
         self.assertTrue('revno: 2\n' not in log)
         self.assertTrue('branch nick: branch2\n' in log)
         self.assertTrue('branch nick: branch1\n' not in log)
-        
+
+    def test_log_change_revno(self):
+        self._prepare()
+        expected_log = self.run_bzr("log -r 1")[0]
+        log = self.run_bzr("log -c 1")[0]
+        self.assertEqualDiff(expected_log, log)
+
+    def test_log_change_single_revno(self):
+        self._prepare()
+        self.run_bzr_error('bzr: ERROR: Option --change does not'
+                           ' accept revision ranges',
+                           ['log', '--change', '2..3'])
+
+    def test_log_change_incompatible_with_revision(self):
+        self._prepare()
+        self.run_bzr_error('bzr: ERROR: --revision and --change'
+                           ' are mutually exclusive',
+                           ['log', '--change', '2', '--revision', '3'])
+
     def test_log_nonexistent_file(self):
         # files that don't exist in either the basis tree or working tree
         # should give an error



More information about the bazaar-commits mailing list