Rev 6124: (jelmer) Add a ``bugtracker`` configuration option. (Jelmer Vernooij) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Sep 2 10:40:58 UTC 2011


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

------------------------------------------------------------
revno: 6124 [merge]
revision-id: pqm at pqm.ubuntu.com-20110902104055-csssd63vy3q6cz49
parent: pqm at pqm.ubuntu.com-20110902083451-ucpbb8ydrk5upxwv
parent: jelmer at samba.org-20110902073852-q12ynl2j1nlk8ece
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2011-09-02 10:40:55 +0000
message:
  (jelmer) Add a ``bugtracker`` configuration option. (Jelmer Vernooij)
modified:
  bzrlib/bugtracker.py           bugtracker.py-20070410073305-vu1vu1qosjurg8kb-1
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/bugtracker.py'
--- a/bzrlib/bugtracker.py	2011-02-25 12:12:39 +0000
+++ b/bzrlib/bugtracker.py	2011-09-01 15:26:30 +0000
@@ -48,8 +48,14 @@
 
     bzr commit --fixes <tracker>:<id>
 
+or::
+
+    bzr commit --fixes <id>
+
 where "<tracker>" is an identifier for the bug tracker, and "<id>" is the
 identifier for that bug within the bugtracker, usually the bug number.
+If "<tracker>" is not specified the ``bugtracker`` set in the branch
+or global configuration is used.
 
 Bazaar knows about a few bug trackers that have many users. If
 you use one of these bug trackers then there is no setup required to

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2011-08-31 15:25:11 +0000
+++ b/bzrlib/builtins.py	2011-09-02 10:40:55 +0000
@@ -3236,15 +3236,31 @@
     aliases = ['ci', 'checkin']
 
     def _iter_bug_fix_urls(self, fixes, branch):
+        default_bugtracker  = None
         # Configure the properties for bug fixing attributes.
         for fixed_bug in fixes:
             tokens = fixed_bug.split(':')
-            if len(tokens) != 2:
+            if len(tokens) == 1:
+                if default_bugtracker is None:
+                    branch_config = branch.get_config()
+                    default_bugtracker = branch_config.get_user_option(
+                        "bugtracker")
+                if default_bugtracker is None:
+                    raise errors.BzrCommandError(
+                        "No tracker specified for bug %s. Use the form "
+                        "'tracker:id' or specify a default bug tracker "
+                        "using the `bugtracker` option.\nSee "
+                        "\"bzr help bugs\" for more information on this "
+                        "feature. Commit refused." % fixed_bug)
+                tag = default_bugtracker
+                bug_id = tokens[0]
+            elif len(tokens) != 2:
                 raise errors.BzrCommandError(
                     "Invalid bug %s. Must be in the form of 'tracker:id'. "
                     "See \"bzr help bugs\" for more information on this "
                     "feature.\nCommit refused." % fixed_bug)
-            tag, bug_id = tokens
+            else:
+                tag, bug_id = tokens
             try:
                 yield bugtracker.get_bug_url(tag, branch, bug_id)
             except errors.UnknownBugTrackerAbbreviation:

=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- a/bzrlib/tests/blackbox/test_commit.py	2011-08-17 10:56:42 +0000
+++ b/bzrlib/tests/blackbox/test_commit.py	2011-09-02 07:38:52 +0000
@@ -596,6 +596,25 @@
             'commit -m add-b --fixes=xxx:123',
             working_dir='tree')
 
+    def test_fixes_bug_with_default_tracker(self):
+        """commit --fixes=234 uses the default bug tracker."""
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree(['tree/hello.txt'])
+        tree.add('hello.txt')
+        self.run_bzr_error(
+            ["bzr: ERROR: No tracker specified for bug 123. Use the form "
+            "'tracker:id' or specify a default bug tracker using the "
+            "`bugtracker` option.\n"
+            "See \"bzr help bugs\" for more information on this feature. "
+            "Commit refused."],
+            'commit -m add-b --fixes=123',
+            working_dir='tree')
+        tree.branch.get_config().set_user_option("bugtracker", "lp")
+        self.run_bzr('commit -m hello --fixes=234 tree/hello.txt')
+        last_rev = tree.branch.repository.get_revision(tree.last_revision())
+        self.assertEqual('https://launchpad.net/bugs/234 fixed',
+                         last_rev.properties['bugs'])
+
     def test_fixes_invalid_bug_number(self):
         tree = self.make_branch_and_tree('tree')
         self.build_tree(['tree/hello.txt'])
@@ -613,10 +632,10 @@
         self.build_tree(['tree/hello.txt'])
         tree.add('hello.txt')
         self.run_bzr_error(
-            [r"Invalid bug orange. Must be in the form of 'tracker:id'\. "
-             r"See \"bzr help bugs\" for more information on this feature.\n"
-             r"Commit refused\."],
-            'commit -m add-b --fixes=orange',
+            [r"Invalid bug orange:apples:bananas. Must be in the form of "
+             r"'tracker:id'\. See \"bzr help bugs\" for more information on "
+             r"this feature.\nCommit refused\."],
+            'commit -m add-b --fixes=orange:apples:bananas',
             working_dir='tree')
 
     def test_no_author(self):

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-09-01 18:11:38 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-09-02 10:40:55 +0000
@@ -116,6 +116,10 @@
 
 * Do not run i18n initialisation twice. (Jonathan Riddell)
 
+* Support a ``bugtracker`` option which is used by ``bzr commit --fixes``
+  if no bug tracker was specified on the command line.
+  (Jelmer Vernooij, #334860)
+
 Bug Fixes
 *********
 




More information about the bazaar-commits mailing list