Merge lp:~jameinel/bzr/2.3.1-track-bytes into lp:bzr/2.3

Proposed by John A Meinel
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5620
Proposed branch: lp:~jameinel/bzr/2.3.1-track-bytes
Merge into: lp:bzr/2.3
Diff against target: 92 lines (+33/-9)
3 files modified
bzrlib/commands.py (+5/-4)
bzrlib/tests/blackbox/test_debug.py (+24/-5)
doc/en/release-notes/bzr-2.3.txt (+4/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.3.1-track-bytes
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+48675@code.launchpad.net

Commit message

Fix bug #713258, restore logging of bytes transferred for a given command.

Description of the change

This restores the logging of bytes transferred for a given command, and adds a test that it is shown when using '-Dbytes'.

I'm not positive that 'test_debug' is the best place for it, but it seemed reasonable to test that a -D flag has an effect.

I suppose the only other bit I *could* test, is that it doesn't report 0 bytes, but that is a bit tricky, since you could search for [^0]kB, but then if it was exactly 10kB the test would fail again. (Right now it is 4kB in my testing.)

I'm proposing this for bzr/2.3 and then we'll merge up to bzr core from there.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Thanks for fixing that, and for adding a test.

I am a bit reluctant to make the test use a subprocess though. It may not show up much for this particular test, but if in general we start running tests in subprocesses things will eventually get very slow, especially on Windows. I thought we already had, or could easily add, an option to run things with a more realistic ui factory.

It seems like the null progress view could easily at least record the activity, even if it doesn't display it.

So 'needs fixing' but I'm open to negotiation.

review: Needs Fixing
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/6/2011 11:58 PM, Martin Pool wrote:
> Review: Needs Fixing
> Thanks for fixing that, and for adding a test.
>
> I am a bit reluctant to make the test use a subprocess though. It may not show up much for this particular test, but if in general we start running tests in subprocesses things will eventually get very slow, especially on Windows. I thought we already had, or could easily add, an option to run things with a more realistic ui factory.
>
> It seems like the null progress view could easily at least record the activity, even if it doesn't display it.
>
> So 'needs fixing' but I'm open to negotiation.

The existing code tracks the transfer, but isn't logging it. And the
specific bug is that it is also not getting displayed (though that is
because it ends up at 0 bytes, which is intentionally suppressed, so
stuff like local 'bzr st' doesn't spit out Transferred 0kB...)

I agree things could be better, but

a) In a very real sense, this was an integration failure.
b) Tests actually use TestUIFactory, not TextUIFactory or
SilentUIFactory, so we really wouldn't be testing what we think we are.
I could make TestUIFactory do what I want, but it would pretty much be
unrelated to the fix.

I had thought about doing a minimal 'spawn' version for 2.3, and then
doing more invasive changes for bzr.dev, but I honestly couldn't come up
with a better way to test it.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1QZ0AACgkQJdeBCYSNAAMjLwCg0LwXaVNpy2eqcLlZYR0BzJSS
6PYAnREbHzczYjLhyp/poWgTncSZjRR1
=C5H7
-----END PGP SIGNATURE-----

Revision history for this message
Martin Pool (mbp) wrote :

On 8 February 2011 08:42, John Arbash Meinel <email address hidden> wrote:
> a) In a very real sense, this was an integration failure.

True; this is close to being something where we want to measure the
behavior as the process exits.

  vote approve

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/commands.py'
2--- bzrlib/commands.py 2010-10-29 17:07:42 +0000
3+++ bzrlib/commands.py 2011-02-04 22:37:53 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2005-2010 Canonical Ltd
6+# Copyright (C) 2005-2011 Canonical Ltd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10@@ -691,7 +691,10 @@
11 return self.run(**all_cmd_args)
12 finally:
13 # reset it, so that other commands run in the same process won't
14- # inherit state
15+ # inherit state. Before we reset it, log any activity, so that it
16+ # gets properly tracked.
17+ ui.ui_factory.log_transport_activity(
18+ display=('bytes' in debug.debug_flags))
19 trace.set_verbosity_level(0)
20
21 def _setup_run(self):
22@@ -1202,8 +1205,6 @@
23 argv = _specified_or_unicode_argv(argv)
24 _register_builtin_commands()
25 ret = run_bzr_catch_errors(argv)
26- bzrlib.ui.ui_factory.log_transport_activity(
27- display=('bytes' in debug.debug_flags))
28 trace.mutter("return code %d", ret)
29 return ret
30
31
32=== modified file 'bzrlib/tests/blackbox/test_debug.py'
33--- bzrlib/tests/blackbox/test_debug.py 2010-02-17 17:11:16 +0000
34+++ bzrlib/tests/blackbox/test_debug.py 2011-02-04 22:37:53 +0000
35@@ -1,4 +1,4 @@
36-# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
37+# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
38 #
39 # This program is free software; you can redistribute it and/or modify
40 # it under the terms of the GNU General Public License as published by
41@@ -21,10 +21,10 @@
42 import sys
43 import time
44
45-from bzrlib.tests import TestCaseInTempDir
46-
47-
48-class TestDebugOption(TestCaseInTempDir):
49+from bzrlib import debug, tests
50+
51+
52+class TestDebugOption(tests.TestCaseInTempDir):
53
54 def test_dash_derror(self):
55 """With -Derror, tracebacks are shown even for user errors"""
56@@ -39,3 +39,22 @@
57 # With -Dlock, locking and unlocking is recorded into the log
58 self.run_bzr("-Dlock init foo")
59 self.assertContainsRe(self.get_log(), "lock_write")
60+
61+
62+class TestDebugBytes(tests.TestCaseWithTransport):
63+
64+ def test_bytes_reports_activity(self):
65+ tree = self.make_branch_and_tree('tree')
66+ self.build_tree(['tree/one'])
67+ tree.add('one')
68+ rev_id = tree.commit('first')
69+ remote_trans = self.make_smart_server('.')
70+ # I would like to avoid run_bzr_subprocess here, but we need it to be
71+ # connected to a real TextUIFactory. The NullProgressView always
72+ # ignores transport activity.
73+ env = {'BZR_PROGRESS_BAR': 'text'}
74+ out, err = self.run_bzr_subprocess('branch -Dbytes %s/tree target'
75+ % (remote_trans.base,),
76+ env_changes=env)
77+ self.assertContainsRe(err, 'Branched 1 revision')
78+ self.assertContainsRe(err, 'Transferred:.*kB')
79
80=== modified file 'doc/en/release-notes/bzr-2.3.txt'
81--- doc/en/release-notes/bzr-2.3.txt 2011-02-04 14:10:48 +0000
82+++ doc/en/release-notes/bzr-2.3.txt 2011-02-04 22:37:53 +0000
83@@ -32,6 +32,10 @@
84 .. Fixes for situations where bzr would previously crash or give incorrect
85 or undesirable results.
86
87+* Restore proper logging of bytes transferred. We accidentally reset the
88+ counter when commands finished before we logged the total transferred.
89+ (John Arbash Meinel, #713258)
90+
91 Documentation
92 *************
93

Subscribers

People subscribed via source and target branches