Rev 5413: (gz) Permit non-integer bug ids for generic bug trackers (Alexandre Garnier) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Sep 8 23:52:40 BST 2010


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

------------------------------------------------------------
revno: 5413 [merge]
revision-id: pqm at pqm.ubuntu.com-20100908225236-xeoi280xsalha219
parent: pqm at pqm.ubuntu.com-20100908133517-0cuy5kiuvb3dhtyx
parent: zigouigoui.garnier at laposte.net-20100906191252-ksjca664hefqydke
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-09-08 23:52:36 +0100
message:
  (gz) Permit non-integer bug ids for generic bug trackers (Alexandre Garnier)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bugtracker.py           bugtracker.py-20070410073305-vu1vu1qosjurg8kb-1
  bzrlib/tests/test_bugtracker.py test_bugtracker.py-20070410073305-vu1vu1qosjurg8kb-2
=== modified file 'NEWS'
--- a/NEWS	2010-09-08 11:09:22 +0000
+++ b/NEWS	2010-09-08 22:52:36 +0000
@@ -91,6 +91,9 @@
 * Allow using both --using and --diff-options. 
   (Matthäus G. Chajdas, #234708)
 
+* Allow using non-integer bug ID with generic bug trackers.
+  (Alexandre Garnier, #440472)
+
 * ``bzr add SYMLINK/FILE`` now works properly when the symlink points to a
   previously-unversioned directory within the tree: the directory is
   marked versioned too.  

=== modified file 'bzrlib/bugtracker.py'
--- a/bzrlib/bugtracker.py	2010-04-30 11:03:59 +0000
+++ b/bzrlib/bugtracker.py	2010-09-04 16:58:28 +0000
@@ -127,7 +127,13 @@
 
     bugtracker_cpan_url = http://rt.cpan.org/Public/Bug/Display.html?id={id}
 
-for CPAN's RT bug tracker.
+would allow ``bzr commit --fixes cpan:1234`` to mark bug 1234 in CPAN's
+RT bug tracker as fixed, or::
+
+    bugtracker_hudson_url = http://issues.hudson-ci.org/browse/{id}
+
+would allow ``bzr commit --fixes hudson:HUDSON-1234`` to mark bug HUDSON-1234
+in Hudson's JIRA bug tracker as fixed.
 """
 
 
@@ -228,14 +234,13 @@
     UniqueIntegerBugTracker('gnome', 'http://bugzilla.gnome.org/show_bug.cgi?id='))
 
 
-class URLParametrizedIntegerBugTracker(IntegerBugTracker):
+class URLParametrizedBugTracker(BugTracker):
     """A type of bug tracker that can be found on a variety of different sites,
     and thus needs to have the base URL configured.
 
     Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
-    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
-    and `abbreviation` is a short name for the particular instance (e.g.
-    'squid' or 'apache').
+    `type_name` is the name of the type of tracker and `abbreviation`
+    is a short name for the particular instance.
     """
 
     def get(self, abbreviation, branch):
@@ -256,6 +261,16 @@
         return urlutils.join(self._base_url, self._bug_area) + str(bug_id)
 
 
+class URLParametrizedIntegerBugTracker(IntegerBugTracker, URLParametrizedBugTracker):
+    """A type of bug tracker that can be found on a variety of different sites,
+    and thus needs to have the base URL configured, but only allows integer bug IDs.
+
+    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
+    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
+    and `abbreviation` is a short name for the particular instance (e.g.
+    'squid' or 'apache').
+    """
+
 tracker_registry.register(
     'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))
 
@@ -264,7 +279,7 @@
     URLParametrizedIntegerBugTracker('bugzilla', 'show_bug.cgi?id='))
 
 
-class GenericBugTracker(URLParametrizedIntegerBugTracker):
+class GenericBugTracker(URLParametrizedBugTracker):
     """Generic bug tracker specified by an URL template."""
 
     def __init__(self):

=== modified file 'bzrlib/tests/test_bugtracker.py'
--- a/bzrlib/tests/test_bugtracker.py	2010-01-25 15:55:48 +0000
+++ b/bzrlib/tests/test_bugtracker.py	2010-09-06 19:12:52 +0000
@@ -117,6 +117,14 @@
         self.assertEqual('http://bugs.com/1234/view.html',
                          tracker.get_bug_url('1234'))
 
+    def test_generic_registered_non_integer(self):
+        branch = self.make_branch('some_branch')
+        config = branch.get_config()
+        config.set_user_option('bugtracker_foo_url', 'http://bugs.com/{id}/view.html')
+        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
+        self.assertEqual('http://bugs.com/ABC-1234/view.html',
+                         tracker.get_bug_url('ABC-1234'))
+
     def test_generic_incorrect_url(self):
         branch = self.make_branch('some_branch')
         config = branch.get_config()
@@ -173,15 +181,13 @@
         self.assertRaises(
             errors.MalformedBugIdentifier, tracker.check_bug_id, 'red')
 
-
-class TestURLParametrizedIntegerBugTracker(TestCaseWithMemoryTransport):
-    """Tests for TracTracker."""
+class TestURLParametrizedBugTracker(TestCaseWithMemoryTransport):
+    """Tests for URLParametrizedBugTracker."""
 
     def setUp(self):
         TestCaseWithMemoryTransport.setUp(self)
         self.url = 'http://twistedmatrix.com/trac'
-        self.tracker = bugtracker.URLParametrizedIntegerBugTracker('some',
-                                                                   'ticket/')
+        self.tracker = bugtracker.URLParametrizedBugTracker('some', 'ticket/')
 
     def test_get_with_unsupported_tag(self):
         """If asked for an unrecognized or unconfigured tag, return None."""
@@ -203,6 +209,22 @@
             urlutils.join(self.url, 'ticket/') + '1234',
             tracker.get_bug_url('1234'))
 
+    def test_get_bug_url_for_integer_id(self):
+        self.tracker.check_bug_id('1234')
+
+    def test_get_bug_url_for_non_integer_id(self):
+        self.tracker.check_bug_id('ABC-1234')
+
+
+class TestURLParametrizedIntegerBugTracker(TestCaseWithMemoryTransport):
+    """Tests for URLParametrizedIntegerBugTracker."""
+
+    def setUp(self):
+        TestCaseWithMemoryTransport.setUp(self)
+        self.url = 'http://twistedmatrix.com/trac'
+        self.tracker = bugtracker.URLParametrizedIntegerBugTracker('some',
+                                                                   'ticket/')
+
     def test_get_bug_url_for_bad_bug(self):
         """When given a bug identifier that is invalid for Trac, get_bug_url
         should raise an error.




More information about the bazaar-commits mailing list