Rev 4938: (nmb, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jan 7 06:11:16 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4938 [merge]
revision-id: pqm at pqm.ubuntu.com-20100107061115-hsurc86kqu9z5vq0
parent: pqm at pqm.ubuntu.com-20100107005919-3jl4nwntr1qgvtfl
parent: andrew.bennetts at canonical.com-20100107052246-016t0jzmc0j9g7dl
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-01-07 06:11:15 +0000
message:
  (nmb,
  	Guillermo Gonzalez) Show bug information (from 'ci --fixed=...') in
  	log output. (#251729)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
  bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
=== modified file 'NEWS'
--- a/NEWS	2010-01-06 20:48:26 +0000
+++ b/NEWS	2010-01-07 05:22:46 +0000
@@ -17,6 +17,9 @@
 New Features
 ************
 
+* Add bug information to log output when available.
+  (Neil Martinsen-Burrell, Guillermo Gonzalez, #251729)
+
 * ``bzr update`` now takes a ``--revision`` argument. This lets you
   change the revision of the working tree to any revision in the
   ancestry of the current or master branch. (Matthieu Moy, Mark Hammond,

=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py	2009-12-09 05:47:32 +0000
+++ b/bzrlib/log.py	2010-01-05 02:13:02 +0000
@@ -1980,6 +1980,21 @@
 
 properties_handler_registry = registry.Registry()
 
+# Use the properties handlers to print out bug information if available
+def _bugs_properties_handler(revision):
+    if revision.properties.has_key('bugs'):
+        bug_lines = revision.properties['bugs'].split('\n')
+        bug_rows = [line.split(' ', 1) for line in bug_lines]
+        fixed_bug_urls = [row[0] for row in bug_rows if
+                          len(row) > 1 and row[1] == 'fixed']
+        
+        if fixed_bug_urls:
+            return {'fixes bug(s)': ' '.join(fixed_bug_urls)}
+    return {}
+
+properties_handler_registry.register('bugs_properties_handler',
+                                     _bugs_properties_handler)
+
 
 # adapters which revision ids to log are filtered. When log is called, the
 # log_rev_iterator is adapted through each of these factory methods.

=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py	2009-12-03 19:54:38 +0000
+++ b/bzrlib/tests/test_log.py	2010-01-05 02:13:02 +0000
@@ -1527,3 +1527,90 @@
         log.show_branch_change(tree.branch, s, 3, '3b')
         self.assertContainsRe(s.getvalue(), 'Removed Revisions:')
         self.assertNotContainsRe(s.getvalue(), 'Added Revisions:')
+
+
+
+class TestLogWithBugs(TestCaseForLogFormatter):
+
+    def setUp(self):
+        TestCaseForLogFormatter.setUp(self)
+        log.properties_handler_registry.register(
+            'bugs_properties_handler',
+            log._bugs_properties_handler)
+
+    def make_commits_with_bugs(self):
+        """Helper method for LogFormatter tests"""
+        tree = self.make_branch_and_tree(u'.')
+        self.build_tree(['a', 'b'])
+        tree.add('a')
+        tree.commit('simple log message', rev_id='a1',
+                    timestamp=1132586655.459960938, timezone=-6*3600,
+                    committer='Joe Foo <joe at foo.com>',
+                    revprops={'bugs': 'test://bug/id fixed'})
+        tree.add('b')
+        tree.commit('multiline\nlog\nmessage\n', rev_id='a2',
+                    timestamp=1132586842.411175966, timezone=-6*3600,
+                    committer='Joe Foo <joe at foo.com>',
+                    authors=['Joe Bar <joe at bar.com>'],
+                    revprops={'bugs': 'test://bug/id fixed\n'
+                                      'test://bug/2 fixed'})
+        return tree
+
+
+    def test_long_bugs(self):
+        tree = self.make_commits_with_bugs()
+        self.assertFormatterResult("""\
+------------------------------------------------------------
+revno: 2
+fixes bug(s): test://bug/id test://bug/2
+author: Joe Bar <joe at bar.com>
+committer: Joe Foo <joe at foo.com>
+branch nick: work
+timestamp: Mon 2005-11-21 09:27:22 -0600
+message:
+  multiline
+  log
+  message
+------------------------------------------------------------
+revno: 1
+fixes bug(s): test://bug/id
+committer: Joe Foo <joe at foo.com>
+branch nick: work
+timestamp: Mon 2005-11-21 09:24:15 -0600
+message:
+  simple log message
+""",
+            tree.branch, log.LongLogFormatter)
+
+    def test_short_bugs(self):
+        tree = self.make_commits_with_bugs()
+        self.assertFormatterResult("""\
+    2 Joe Bar\t2005-11-21
+      fixes bug(s): test://bug/id test://bug/2
+      multiline
+      log
+      message
+
+    1 Joe Foo\t2005-11-21
+      fixes bug(s): test://bug/id
+      simple log message
+
+""",
+            tree.branch, log.ShortLogFormatter)
+
+    def test_wrong_bugs_property(self):
+        tree = self.make_branch_and_tree(u'.')
+        self.build_tree(['foo'])
+        tree.commit('simple log message', rev_id='a1',
+              timestamp=1132586655.459960938, timezone=-6*3600,
+              committer='Joe Foo <joe at foo.com>',
+              revprops={'bugs': 'test://bug/id invalid_value'})
+        self.assertFormatterResult("""\
+    1 Joe Foo\t2005-11-21
+      simple log message
+
+""",
+            tree.branch, log.ShortLogFormatter)
+
+    def test_bugs_handler_present(self):
+        self.properties_handler_registry.get('bugs_properties_handler')




More information about the bazaar-commits mailing list