Rev 5620: Fix bug #713258. Restore logging of bytes transferred. in http://bazaar.launchpad.net/~jameinel/bzr/2.3.1-track-bytes

John Arbash Meinel john at arbash-meinel.com
Fri Feb 4 22:26:15 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.3.1-track-bytes

------------------------------------------------------------
revno: 5620
revision-id: john at arbash-meinel.com-20110204222559-e25nlgfei7uawnvz
parent: pqm at pqm.ubuntu.com-20110204160120-7zsob6cew4xpi9cj
fixes bug(s): https://launchpad.net/bugs/713258
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3.1-track-bytes
timestamp: Fri 2011-02-04 16:25:59 -0600
message:
  Fix bug #713258. Restore logging of bytes transferred.
  When Martin fixed the test isolation issue with --verbose, he accidentally
  made it so that we reset the bytes-transferred right before we logged
  the total transfer. This changes where we log bytes transferred earlier.
  The test is a little bit ugly, because we need a real TextUIFactory hooked
  up to a real ProgressView. However, it should help avoid regressing again.
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2010-10-29 17:07:42 +0000
+++ b/bzrlib/commands.py	2011-02-04 22:25:59 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 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
@@ -691,7 +691,10 @@
             return self.run(**all_cmd_args)
         finally:
             # reset it, so that other commands run in the same process won't
-            # inherit state
+            # inherit state. Before we reset it, log any activity, so that it
+            # gets properly tracked.
+            ui.ui_factory.log_transport_activity(
+                display=('bytes' in debug.debug_flags))
             trace.set_verbosity_level(0)
 
     def _setup_run(self):
@@ -1202,8 +1205,6 @@
     argv = _specified_or_unicode_argv(argv)
     _register_builtin_commands()
     ret = run_bzr_catch_errors(argv)
-    bzrlib.ui.ui_factory.log_transport_activity(
-        display=('bytes' in debug.debug_flags))
     trace.mutter("return code %d", ret)
     return ret
 

=== modified file 'bzrlib/tests/blackbox/test_debug.py'
--- a/bzrlib/tests/blackbox/test_debug.py	2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/blackbox/test_debug.py	2011-02-04 22:25:59 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
+# Copyright (C) 2006, 2007, 2009, 2010, 2011 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
@@ -21,10 +21,10 @@
 import sys
 import time
 
-from bzrlib.tests import TestCaseInTempDir
-
-
-class TestDebugOption(TestCaseInTempDir):
+from bzrlib import debug, tests
+
+
+class TestDebugOption(tests.TestCaseInTempDir):
 
     def test_dash_derror(self):
         """With -Derror, tracebacks are shown even for user errors"""
@@ -39,3 +39,22 @@
         # With -Dlock, locking and unlocking is recorded into the log
         self.run_bzr("-Dlock init foo")
         self.assertContainsRe(self.get_log(), "lock_write")
+
+
+class TestDebugBytes(tests.TestCaseWithTransport):
+
+    def test_bytes_reports_activity(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree(['tree/one'])
+        tree.add('one')
+        rev_id = tree.commit('first')
+        remote_trans = self.make_smart_server('.')
+        # I would like to avoid run_bzr_subprocess here, but we need it to be
+        # connected to a real TextUIFactory. The NullProgressView always
+        # ignores transport activity.
+        env = {'BZR_PROGRESS_BAR': 'text'}
+        out, err = self.run_bzr_subprocess('branch -Dbytes %s/tree target'
+                                           % (remote_trans.base,),
+                                           env_changes=env)
+        self.assertContainsRe(err, 'Branched 1 revision')
+        self.assertContainsRe(err, 'Transferred:.*kB')

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2011-02-04 14:10:48 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2011-02-04 22:25:59 +0000
@@ -32,6 +32,10 @@
 .. Fixes for situations where bzr would previously crash or give incorrect
    or undesirable results.
 
+* Restore proper logging of bytes transferred. We accidentally reset the
+  counter when commands finished before we logged the total transferred.
+  (John Arbash Meinel, #713258)
+
 Documentation
 *************
 



More information about the bazaar-commits mailing list