Rev 3982: (mbp) better and less redundant debug flag docs in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Feb 5 05:42:33 GMT 2009


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

------------------------------------------------------------
revno: 3982
revision-id: pqm at pqm.ubuntu.com-20090205054228-3qyiv92vtgs94e0c
parent: pqm at pqm.ubuntu.com-20090204125611-m7kqmwruvndk7yrv
parent: mbp at sourcefrog.net-20090127172741-kg1zwh7roiokob7r
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-02-05 05:42:28 +0000
message:
  (mbp) better and less redundant debug flag docs
modified:
  bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
  bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
  bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
  bzrlib/transport/sftp.py       sftp.py-20051019050329-ab48ce71b7e32dfe
  doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
    ------------------------------------------------------------
    revno: 3959.1.5
    revision-id: mbp at sourcefrog.net-20090127172741-kg1zwh7roiokob7r
    parent: mbp at sourcefrog.net-20090127171557-wblksjk0fhwecq8v
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-sftp
    timestamp: Tue 2009-01-27 15:27:41 -0200
    message:
      pep8 correctness (maybe) for global variables
    modified:
      bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
    ------------------------------------------------------------
    revno: 3959.1.4
    revision-id: mbp at sourcefrog.net-20090127171557-wblksjk0fhwecq8v
    parent: mbp at sourcefrog.net-20090126180413-n0ue2d54zgiqe7jy
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-sftp
    timestamp: Tue 2009-01-27 15:15:57 -0200
    message:
      test_resource_string shouldn't depend on the precise source file contents
    modified:
      bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
    ------------------------------------------------------------
    revno: 3959.1.3
    revision-id: mbp at sourcefrog.net-20090126180413-n0ue2d54zgiqe7jy
    parent: mbp at sourcefrog.net-20090126180113-24hunvris7gp1gb8
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-sftp
    timestamp: Mon 2009-01-26 16:04:13 -0200
    message:
      Guard common sftp mutter statements by debug flags
    modified:
      bzrlib/transport/sftp.py       sftp.py-20051019050329-ab48ce71b7e32dfe
    ------------------------------------------------------------
    revno: 3959.1.2
    revision-id: mbp at sourcefrog.net-20090126180113-24hunvris7gp1gb8
    parent: mbp at sourcefrog.net-20090126175753-cxw1l1o09bffd4kr
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-sftp
    timestamp: Mon 2009-01-26 16:01:13 -0200
    message:
      Brief developer docs about debug flags
    modified:
      doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
    ------------------------------------------------------------
    revno: 3959.1.1
    revision-id: mbp at sourcefrog.net-20090126175753-cxw1l1o09bffd4kr
    parent: pqm at pqm.ubuntu.com-20090126115928-bzzqlmw316iv8o3k
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: debug-sftp
    timestamp: Mon 2009-01-26 15:57:53 -0200
    message:
      Remove redundant description of debug flags from debug.py
    modified:
      bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
      bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
=== modified file 'bzrlib/debug.py'
--- a/bzrlib/debug.py	2008-05-07 22:47:56 +0000
+++ b/bzrlib/debug.py	2009-01-27 17:27:41 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 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
@@ -15,29 +15,12 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
-# NOTE: If update these, please also update the help for global-options in
-#       bzrlib/help_topics/__init__.py
-
-debug_flags = set()
 """Set of flags that enable different debug behaviour.
 
 These are set with eg ``-Dlock`` on the bzr command line.
 
-Options include:
- 
- * auth - show authentication sections used
- * error - show stack traces for all top level exceptions
- * evil - capture call sites that do expensive or badly-scaling operations.
- * fetch - trace history copying between repositories
- * graph - trace graph traversal information
- * hashcache - log every time a working file is read to determine its hash
- * hooks - trace hook execution
- * hpss - trace smart protocol requests and responses
- * http - trace http connections, requests and responses
- * index - trace major index operations
- * knit - trace knit operations
- * lock - trace when lockdir locks are taken or released
- * merge - emit information for debugging merges
- * pack - emit information about pack operations
-
+See "bzr help global-options" or bzrlib/help_topics/__init__.py
+for a list of the available options.
 """
+
+debug_flags = set()

=== modified file 'bzrlib/help_topics/__init__.py'
--- a/bzrlib/help_topics/__init__.py	2009-01-28 15:28:13 +0000
+++ b/bzrlib/help_topics/__init__.py	2009-02-05 05:42:28 +0000
@@ -307,6 +307,7 @@
 -Devil            Capture call sites that do expensive or badly-scaling
                   operations.
 -Dfetch           Trace history copying between repositories.
+-Dgraph           Trace graph traversal.
 -Dhashcache       Log every time a working file is read to determine its hash.
 -Dhooks           Trace hook execution.
 -Dhpss            Trace smart protocol requests and responses.
@@ -316,6 +317,7 @@
 -Dlock            Trace when lockdir locks are taken or released.
 -Dmerge           Emit information for debugging merges.
 -Dpack            Emit information about pack operations.
+-Dsftp            Trace SFTP internals.
 """
 
 _standard_options = \

=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2009-01-26 18:12:48 +0000
+++ b/bzrlib/tests/test_osutils.py	2009-02-05 05:42:28 +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
@@ -1471,59 +1471,12 @@
         self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))
 
 
-_debug_text = \
-r'''# Copyright (C) 2005, 2006 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
-
-
-# NOTE: If update these, please also update the help for global-options in
-#       bzrlib/help_topics/__init__.py
-
-debug_flags = set()
-"""Set of flags that enable different debug behaviour.
-
-These are set with eg ``-Dlock`` on the bzr command line.
-
-Options include:
- 
- * auth - show authentication sections used
- * error - show stack traces for all top level exceptions
- * evil - capture call sites that do expensive or badly-scaling operations.
- * fetch - trace history copying between repositories
- * graph - trace graph traversal information
- * hashcache - log every time a working file is read to determine its hash
- * hooks - trace hook execution
- * hpss - trace smart protocol requests and responses
- * http - trace http connections, requests and responses
- * index - trace major index operations
- * knit - trace knit operations
- * lock - trace when lockdir locks are taken or released
- * merge - emit information for debugging merges
- * pack - emit information about pack operations
-
-"""
-'''
-
-
 class TestResourceLoading(TestCaseInTempDir):
 
     def test_resource_string(self):
         # test resource in bzrlib
         text = osutils.resource_string('bzrlib', 'debug.py')
-        self.assertEquals(_debug_text, text)
+        self.assertContainsRe(text, "debug_flags = set()")
         # test resource under bzrlib
         text = osutils.resource_string('bzrlib.ui', 'text.py')
         self.assertContainsRe(text, "class TextUIFactory")

=== modified file 'bzrlib/transport/sftp.py'
--- a/bzrlib/transport/sftp.py	2009-01-19 11:59:11 +0000
+++ b/bzrlib/transport/sftp.py	2009-01-26 18:04:13 +0000
@@ -39,6 +39,7 @@
 
 from bzrlib import (
     config,
+    debug,
     errors,
     urlutils,
     )
@@ -182,9 +183,10 @@
                 requests.append((start, next_size))
                 size -= next_size
                 start += next_size
-        mutter('SFTP.readv(%s) %s offsets => %s coalesced => %s requests',
-               self.relpath, len(sorted_offsets), len(coalesced),
-               len(requests))
+        if 'sftp' in debug.debug_flags:
+            mutter('SFTP.readv(%s) %s offsets => %s coalesced => %s requests',
+                self.relpath, len(sorted_offsets), len(coalesced),
+                len(requests))
         return requests
 
     def request_and_yield_offsets(self, fp):
@@ -286,8 +288,9 @@
             del buffered_data[:]
             data_chunks.append((input_start, buffered))
         if data_chunks:
-            mutter('SFTP readv left with %d out-of-order bytes',
-                   sum(map(lambda x: len(x[1]), data_chunks)))
+            if 'sftp' in debug.debug_flags:
+                mutter('SFTP readv left with %d out-of-order bytes',
+                    sum(map(lambda x: len(x[1]), data_chunks)))
             # We've processed all the readv data, at this point, anything we
             # couldn't process is in data_chunks. This doesn't happen often, so
             # this code path isn't optimized
@@ -446,7 +449,8 @@
             readv = getattr(fp, 'readv', None)
             if readv:
                 return self._sftp_readv(fp, offsets, relpath)
-            mutter('seek and read %s offsets', len(offsets))
+            if 'sftp' in debug.debug_flags:
+                mutter('seek and read %s offsets', len(offsets))
             return self._seek_and_read(fp, offsets, relpath)
         except (IOError, paramiko.SSHException), e:
             self._translate_io_exception(e, path, ': error retrieving')

=== modified file 'doc/developers/HACKING.txt'
--- a/doc/developers/HACKING.txt	2008-12-12 01:24:50 +0000
+++ b/doc/developers/HACKING.txt	2009-01-26 18:01:13 +0000
@@ -1062,6 +1062,20 @@
 by setting the environment variable ``BZR_SIGQUIT_PDB=0``.
 
 
+Debug Flags
+===========
+
+Bazaar accepts some global options starting with ``-D`` such as
+``-Dhpss``.  These set a value in `bzrlib.debug.debug_flags`, and
+typically cause more information to be written to the trace file.  Most
+`mutter` calls should be guarded by a check of those flags so that we
+don't write out too much information if it's not needed.
+
+Debug flags may have effects other than just emitting trace messages.
+
+Run ``bzr help global-options`` to see them all.
+
+
 Jargon
 ======
 




More information about the bazaar-commits mailing list