Rev 4086: (mbp) debug_flags configuration option in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Mar 6 06:48:30 GMT 2009


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

------------------------------------------------------------
revno: 4086
revision-id: pqm at pqm.ubuntu.com-20090306064825-kbpwggw21dygeix6
parent: pqm at pqm.ubuntu.com-20090306041815-ce2pd0ulkcih0jxq
parent: mbp at sourcefrog.net-20090306055219-vuzlite420uxq4xa
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-03-06 06:48:25 +0000
message:
  (mbp) debug_flags configuration option
added:
  bzrlib/tests/test_debug.py     test_debug.py-20090303053802-01e8mlv24odmpgix-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
  bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
  bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
  bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
  bzrlib/smart/message.py        message.py-20080222013625-ncqmh3nrxjkxab87-1
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
  doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
    ------------------------------------------------------------
    revno: 4070.8.6
    revision-id: mbp at sourcefrog.net-20090306055219-vuzlite420uxq4xa
    parent: mbp at sourcefrog.net-20090306055120-i2ddnzt8c98w11nq
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-config
    timestamp: Fri 2009-03-06 16:52:19 +1100
    message:
      Make test_debug use standard methods to create config files
    modified:
      bzrlib/tests/test_debug.py     test_debug.py-20090303053802-01e8mlv24odmpgix-1
    ------------------------------------------------------------
    revno: 4070.8.5
    revision-id: mbp at sourcefrog.net-20090306055120-i2ddnzt8c98w11nq
    parent: mbp at sourcefrog.net-20090306045954-yboelzz4hs9os28s
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-config
    timestamp: Fri 2009-03-06 16:51:20 +1100
    message:
      Add help about debug_flags to configuration topic
    modified:
      bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
    ------------------------------------------------------------
    revno: 4070.8.4
    revision-id: mbp at sourcefrog.net-20090306045954-yboelzz4hs9os28s
    parent: mbp at sourcefrog.net-20090303054006-z8l6mwile5g7wyar
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-config
    timestamp: Fri 2009-03-06 15:59:54 +1100
    message:
      Apparent configobject automatically splits comma-separated lists
    modified:
      bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
      bzrlib/tests/test_debug.py     test_debug.py-20090303053802-01e8mlv24odmpgix-1
    ------------------------------------------------------------
    revno: 4070.8.3
    revision-id: mbp at sourcefrog.net-20090303054006-z8l6mwile5g7wyar
    parent: mbp at sourcefrog.net-20090303050236-zkt3ey71f301vhae
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-config
    timestamp: Tue 2009-03-03 16:40:06 +1100
    message:
      Finish debug_flags support and add a test case
    added:
      bzrlib/tests/test_debug.py     test_debug.py-20090303053802-01e8mlv24odmpgix-1
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
    ------------------------------------------------------------
    revno: 4070.8.2
    revision-id: mbp at sourcefrog.net-20090303050236-zkt3ey71f301vhae
    parent: mbp at sourcefrog.net-20090303044950-vbzc12q7z03owa2a
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-config
    timestamp: Tue 2009-03-03 16:02:36 +1100
    message:
      Initial support for debug_flags config option
    modified:
      bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
      bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
      bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
      doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
    ------------------------------------------------------------
    revno: 4070.8.1
    revision-id: mbp at sourcefrog.net-20090303044950-vbzc12q7z03owa2a
    parent: pqm at pqm.ubuntu.com-20090302155409-89pygn9tisbc0lir
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-config
    timestamp: Tue 2009-03-03 15:49:50 +1100
    message:
      Remove 'try -Dhpss' from error messages
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
      bzrlib/smart/message.py        message.py-20080222013625-ncqmh3nrxjkxab87-1
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
=== modified file 'NEWS'
--- a/NEWS	2009-03-06 03:30:20 +0000
+++ b/NEWS	2009-03-06 06:48:25 +0000
@@ -21,6 +21,9 @@
       options to change the default tree-creation policy of shared
       repositories.  (Matthew Fuller, Marius Kruger, #145033)
 
+    * Debug flags can now be set in ``~/.bazaar/bazaar.conf``.
+      (Martin Pool)
+
     * Filtered views provide a mask over the tree so that users can focus
       on a subset of a tree when doing their work. See ``Filtered views``
       in chapter 7 of the User Guide and ``bzr help view`` for details.

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2009-02-23 15:42:47 +0000
+++ b/bzrlib/commands.py	2009-03-03 05:02:36 +0000
@@ -809,6 +809,8 @@
             argv_copy.append(a)
         i += 1
 
+    debug.set_debug_flags_from_config()
+
     argv = argv_copy
     if (not argv):
         from bzrlib.builtins import cmd_help

=== modified file 'bzrlib/debug.py'
--- a/bzrlib/debug.py	2009-02-23 15:29:35 +0000
+++ b/bzrlib/debug.py	2009-03-06 04:59:54 +0000
@@ -17,10 +17,29 @@
 
 """Set of flags that enable different debug behaviour.
 
-These are set with eg ``-Dlock`` on the bzr command line.
+These are set with eg ``-Dlock`` on the bzr command line or in
+~/.bazaar/bazaar.conf debug_flags.
 
 See "bzr help global-options" or bzrlib/help_topics/__init__.py
 for a list of the available options.
 """
 
+
 debug_flags = set()
+
+
+def set_debug_flags_from_config():
+    """Turn on debug flags based on the global configuration"""
+
+    from bzrlib.config import GlobalConfig
+
+    c = GlobalConfig()
+    value = c.get_user_option("debug_flags")
+    if value is not None:
+        # configobject gives us either a string if there's just one or a list
+        # if there's multiple
+        if isinstance(value, basestring):
+            value = [value]
+        for w in value:
+            w = w.strip()
+            debug_flags.add(w)

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2009-02-23 15:42:47 +0000
+++ b/bzrlib/errors.py	2009-03-03 04:49:50 +0000
@@ -1634,6 +1634,8 @@
             self.port = ':%s' % port
 
 
+# XXX: This is also used for unexpected end of file, which is different at the
+# TCP level from "connection reset".
 class ConnectionReset(TransportError):
 
     _fmt = "Connection closed: %(msg)s %(orig_error)s"

=== modified file 'bzrlib/help_topics/__init__.py'
--- a/bzrlib/help_topics/__init__.py	2009-02-23 15:29:35 +0000
+++ b/bzrlib/help_topics/__init__.py	2009-03-03 05:02:36 +0000
@@ -318,6 +318,8 @@
 -Dmerge           Emit information for debugging merges.
 -Dpack            Emit information about pack operations.
 -Dsftp            Trace SFTP internals.
+
+These can also be set in the debug_flags configuration variable.
 """
 
 _standard_options = \

=== modified file 'bzrlib/help_topics/en/configuration.txt'
--- a/bzrlib/help_topics/en/configuration.txt	2009-01-30 08:32:26 +0000
+++ b/bzrlib/help_topics/en/configuration.txt	2009-03-06 05:51:20 +0000
@@ -1,10 +1,6 @@
 Configuration Settings
 =======================
 
-.. TODO: Should have some explanation of why you'd want things in
-.. branch.conf.
-
-
 Environment settings
 ---------------------
 
@@ -228,6 +224,15 @@
 Common variable options
 -----------------------
 
+debug_flags
+~~~~~~~~~~~
+
+A comma-separated list of debugging options to turn on.  The same values
+can be used as with the -D command-line option (see `help global-options`).
+For example::
+
+    debug_flags = hpss
+
 email
 ~~~~~
 

=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py	2009-02-23 15:29:35 +0000
+++ b/bzrlib/smart/medium.py	2009-03-03 04:49:50 +0000
@@ -460,8 +460,7 @@
         if not line.endswith('\n'):
             # end of file encountered reading from server
             raise errors.ConnectionReset(
-                "please check connectivity and permissions",
-                "(and try -Dhpss if further diagnosis is required)")
+                "please check connectivity and permissions")
         return line
 
     def _read_line(self):

=== modified file 'bzrlib/smart/message.py'
--- a/bzrlib/smart/message.py	2009-02-23 15:29:35 +0000
+++ b/bzrlib/smart/message.py	2009-03-03 04:49:50 +0000
@@ -283,8 +283,7 @@
                     self._protocol_decoder._get_in_buffer()[:10],
                     self._protocol_decoder.state_accept.__name__)
             raise errors.ConnectionReset(
-                "please check connectivity and permissions",
-                "(and try -Dhpss if further diagnosis is required)")
+                "please check connectivity and permissions")
         self._protocol_decoder.accept_bytes(bytes)
 
     def protocol_error(self, exception):

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-03-04 06:56:23 +0000
+++ b/bzrlib/tests/__init__.py	2009-03-06 06:48:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -2923,6 +2923,7 @@
                    'bzrlib.tests.test_counted_lock',
                    'bzrlib.tests.test_decorators',
                    'bzrlib.tests.test_delta',
+                   'bzrlib.tests.test_debug',
                    'bzrlib.tests.test_deprecated_graph',
                    'bzrlib.tests.test_diff',
                    'bzrlib.tests.test_directory_service',

=== added file 'bzrlib/tests/test_debug.py'
--- a/bzrlib/tests/test_debug.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/test_debug.py	2009-03-06 05:52:19 +0000
@@ -0,0 +1,63 @@
+# Copyright (C) 2009 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for bzrlib.debug"""
+
+
+import os
+
+
+from bzrlib import debug
+from bzrlib.config import config_filename, ensure_config_dir_exists
+from bzrlib.transport import get_transport
+from bzrlib.tests import TestCaseInTempDir
+
+
+class TestDebugFlags(TestCaseInTempDir):
+
+    def test_set_debug_flags_from_config(self):
+        # test both combinations because configobject automatically splits up
+        # comma-separated lists
+        if os.path.isfile(config_filename()):
+            # Something is wrong in environment,
+            # we risk overwriting users config
+            self.assert_(config_filename() + "exists, abort")
+
+        self.try_debug_flags(
+            """debug_flags = hpss, error\n""",
+            set(['hpss', 'error']))
+
+        self.try_debug_flags(
+            """debug_flags = hpss\n""",
+            set(['hpss']))
+
+    def try_debug_flags(self, conf_bytes, expected_flags):
+        ensure_config_dir_exists()
+        f = open(config_filename(), 'wb')
+        try:
+            f.write(conf_bytes)
+        finally:
+            f.close()
+        saved_debug = set(debug.debug_flags)
+        debug.debug_flags.clear()
+        try:
+            debug.set_debug_flags_from_config()
+            self.assertEqual(expected_flags,
+                debug.debug_flags)
+        finally:
+            # restore without rebinding the variable
+            debug.debug_flags.clear()
+            debug.debug_flags.update(saved_debug)

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2009-03-05 06:24:02 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2009-03-06 06:48:25 +0000
@@ -1528,8 +1528,8 @@
         ex = self.assertRaises(errors.ConnectionReset,
             response_handler.read_response_tuple)
         self.assertEqual("Connection closed: "
-            "please check connectivity and permissions "
-            "(and try -Dhpss if further diagnosis is required)", str(ex))
+            "please check connectivity and permissions ",
+            str(ex))
 
     def test_server_offset_serialisation(self):
         """The Smart protocol serialises offsets as a comma and \n string.

=== modified file 'doc/developers/HACKING.txt'
--- a/doc/developers/HACKING.txt	2009-02-23 15:29:35 +0000
+++ b/doc/developers/HACKING.txt	2009-03-03 05:02:36 +0000
@@ -1079,6 +1079,14 @@
 
 Run ``bzr help global-options`` to see them all.
 
+These flags may also be set as a comma-separated list in the
+``debug_flags`` option in e.g.  ``~/.bazaar/bazaar.conf``.  (Note that it
+must be in this global file, not in the branch or location configuration,
+because it's currently only loaded at startup time.)  For instance you may
+want to always record hpss traces and to see full error tracebacks::
+
+    debug_flags = hpss, error
+
 
 Jargon
 ======




More information about the bazaar-commits mailing list