Rev 2396: Don't show or calculate revision store size by default in info in http://sourcefrog.net/bzr/info-no-sizes
Martin Pool
mbp at sourcefrog.net
Wed Apr 4 11:24:16 BST 2007
At http://sourcefrog.net/bzr/info-no-sizes
------------------------------------------------------------
revno: 2396
revision-id: mbp at sourcefrog.net-20070404102414-wxn8bua0805b050e
parent: pqm at pqm.ubuntu.com-20070404022946-b93fc2e49b3bb195
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: info-no-sizes
timestamp: Wed 2007-04-04 20:24:14 +1000
message:
Don't show or calculate revision store size by default in info
modified:
bzrlib/info.py info.py-20050323235939-6bbfe7d9700b0b9b
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
bzrlib/tests/repository_implementations/test_statistics.py test_statistics.py-20070203082432-6738e8fl0mm7ikre-1
=== modified file 'bzrlib/info.py'
--- a/bzrlib/info.py 2007-03-23 01:41:37 +0000
+++ b/bzrlib/info.py 2007-04-04 10:24:14 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007 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
@@ -229,7 +229,8 @@
print
print 'Branch history:'
print ' %8d revision%s' % (revno, plural(revno))
- stats = branch.repository.gather_stats(head, committers=verbose)
+ stats = branch.repository.gather_stats(head, committers=verbose,
+ sizes=verbose)
if verbose:
committers = stats['committers']
print ' %8d committer%s' % (committers, plural(committers))
@@ -264,12 +265,6 @@
print ' %8d KiB' % (stats['size']/1024)
- at deprecated_function(zero_eight)
-def show_info(b):
- """Please see show_bzrdir_info."""
- return show_bzrdir_info(b.bzrdir)
-
-
def show_bzrdir_info(a_bzrdir, verbose=False):
"""Output to stdout the 'info' for a_bzrdir."""
try:
@@ -349,5 +344,5 @@
_show_format_info(control, repository)
_show_locking_info(repository)
_show_repository_info(repository)
- stats = repository.gather_stats()
+ stats = repository.gather_stats(sizes=verbose)
_show_repository_stats(stats)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-04-01 06:19:16 +0000
+++ b/bzrlib/repository.py 2007-04-04 10:24:14 +0000
@@ -241,13 +241,15 @@
return self.control_files.get_physical_lock_status()
@needs_read_lock
- def gather_stats(self, revid=None, committers=None):
+ def gather_stats(self, revid=None, committers=None,
+ sizes=False):
"""Gather statistics from a revision id.
:param revid: The revision id to gather statistics from, if None, then
no revision specific statistics are gathered.
:param committers: Optional parameter controlling whether to grab
a count of committers from the revision specific statistics.
+ :param sizes: If true, also count the size of revision storage.
:return: A dictionary of statistics. Currently this contains:
committers: The number of committers if requested.
firstrev: A tuple with timestamp, timezone for the penultimate left
@@ -284,7 +286,7 @@
last_revision.timezone)
# now gather global repository information
- if self.bzrdir.root_transport.listable():
+ if sizes and self.bzrdir.root_transport.listable():
c, t = self._revision_store.total_size(self.get_transaction())
result['revisions'] = c
result['size'] = t
=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py 2007-03-06 02:04:08 +0000
+++ b/bzrlib/tests/blackbox/test_info.py 2007-04-04 10:24:14 +0000
@@ -48,35 +48,60 @@
self.build_tree(['standalone/a'])
tree1.add('a')
branch1 = tree1.branch
- out, err = self.runbzr('info standalone')
- self.assertEqualDiff(
-"""Location:
- branch root: %s
-
-Format:
- control: All-in-one format 6
- working tree: Working tree format 2
- branch: Branch format 4
- repository: Weave repository format 6
-
-In the working tree:
- 0 unchanged
- 0 modified
- 1 added
- 0 removed
- 0 renamed
- 0 unknown
- 0 ignored
- 0 versioned subdirectories
-
-Branch history:
- 0 revisions
-
-Revision store:
- 0 revisions
- 0 KiB
-""" % branch1.bzrdir.root_transport.base, out)
- self.assertEqual('', err)
+
+ out, err = self.runbzr('info standalone')
+ self.assertEqualDiff(
+"""Location:
+ branch root: %s
+
+Format:
+ control: All-in-one format 6
+ working tree: Working tree format 2
+ branch: Branch format 4
+ repository: Weave repository format 6
+
+In the working tree:
+ 0 unchanged
+ 0 modified
+ 1 added
+ 0 removed
+ 0 renamed
+ 0 unknown
+ 0 ignored
+ 0 versioned subdirectories
+
+Branch history:
+ 0 revisions
+""" % branch1.bzrdir.root_transport.base, out)
+ self.assertEqual('', err)
+
+ # and verbose, with commit count and repository size
+ out, err = self.runbzr('info standalone')
+ self.assertEqualDiff(
+"""Location:
+ branch root: %s
+
+Format:
+ control: All-in-one format 6
+ working tree: Working tree format 2
+ branch: Branch format 4
+ repository: Weave repository format 6
+
+In the working tree:
+ 0 unchanged
+ 0 modified
+ 1 added
+ 0 removed
+ 0 renamed
+ 0 unknown
+ 0 ignored
+ 0 versioned subdirectories
+
+Branch history:
+ 0 revisions
+""" % branch1.bzrdir.root_transport.base, out)
+ self.assertEqual('', err)
+
tree1.commit('commit one')
rev = branch1.repository.get_revision(branch1.revision_history()[0])
datestring_first = format_date(rev.timestamp, rev.timezone)
@@ -84,7 +109,7 @@
# Branch standalone with push location
branch2 = branch1.bzrdir.sprout('branch').open_branch()
branch2.set_push_location(branch1.bzrdir.root_transport.base)
- out, err = self.runbzr('info branch --verbose')
+ out, err = self.runbzr('info branch')
self.assertEqualDiff(
"""Location:
branch root: %s
@@ -111,23 +136,14 @@
Branch history:
1 revision
- 1 committer
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- %d KiB
""" % (branch2.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
datestring_first, datestring_first,
- # poking at _revision_store isn't all that clean, but neither is
- # having the ui test dependent on the exact overhead of a given store.
- branch2.repository._revision_store.total_size(
- branch2.repository.get_transaction())[1] / 1024,
- ), out)
+ ), out)
self.assertEqual('', err)
# Branch and bind to standalone, needs upgrade to metadir
@@ -168,10 +184,6 @@
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- %d KiB
""" % (branch3.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
@@ -179,10 +191,6 @@
branch3._format.get_format_description(),
branch3.repository._format.get_format_description(),
datestring_first, datestring_first,
- # poking at _revision_store isn't all that clean, but neither is
- # having the ui test dependent on the exact overhead of a given store.
- branch3.repository._revision_store.total_size(
- branch3.repository.get_transaction())[1] / 1024,
), out)
self.assertEqual('', err)
@@ -191,7 +199,7 @@
format=knit1_format)
branch4.bind(branch1)
branch4.bzrdir.open_workingtree().update()
- out, err = self.runbzr('info checkout --verbose')
+ out, err = self.runbzr('info checkout')
self.assertEqualDiff(
"""Location:
checkout root: %s
@@ -215,22 +223,13 @@
Branch history:
1 revision
- 1 committer
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- %d KiB
""" % (branch4.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
branch4.repository._format.get_format_description(),
datestring_first, datestring_first,
- # poking at _revision_store isn't all that clean, but neither is
- # having the ui test dependent on the exact overhead of a given store.
- branch4.repository._revision_store.total_size(
- branch4.repository.get_transaction())[1] / 1024,
), out)
self.assertEqual('', err)
@@ -264,10 +263,6 @@
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- 0 KiB
""" % (tree5.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
datestring_first, datestring_first,
@@ -312,10 +307,6 @@
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- 0 KiB
""" % (branch2.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
@@ -356,10 +347,6 @@
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- %d KiB
""" % (branch3.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
@@ -367,8 +354,6 @@
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
- branch3.repository._revision_store.total_size(
- branch3.repository.get_transaction())[1] / 1024,
), out)
self.assertEqual('', err)
@@ -402,23 +387,17 @@
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- %d KiB
""" % (branch4.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
branch4.repository._format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
- branch4.repository._revision_store.total_size(
- branch4.repository.get_transaction())[1] / 1024,
), out)
self.assertEqual('', err)
# Out of date lightweight checkout
- out, err = self.runbzr('info lightcheckout --verbose')
+ out, err = self.runbzr('info lightcheckout')
self.assertEqualDiff(
"""Location:
light checkout root: %s
@@ -444,14 +423,9 @@
Branch history:
2 revisions
- 1 committer
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 2 revisions
- 0 KiB
""" % (tree5.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
datestring_first, datestring_last,
@@ -475,10 +449,6 @@
Branch history:
0 revisions
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (branch.bzrdir.root_transport.base,
format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
@@ -500,10 +470,6 @@
Format:
control: Meta directory format 1
repository: %s
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (repo.bzrdir.root_transport.base,
format.repository_format.get_format_description(),
), out)
@@ -526,10 +492,6 @@
Branch history:
0 revisions
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (repo.bzrdir.root_transport.base,
format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
@@ -627,10 +589,6 @@
Branch history:
0 revisions
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (tree3.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
format.get_branch_format().get_format_description(),
@@ -767,7 +725,7 @@
self.assertEqual('', err)
# Show info about repository with revisions
- out, err = self.runbzr('info repo')
+ out, err = self.runbzr('info repo --verbose')
self.assertEqualDiff(
"""Location:
shared repository: %s
@@ -804,10 +762,6 @@
repository: %s
Create working tree for new branches inside the repository.
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (repo.bzrdir.root_transport.base,
format.repository_format.get_format_description(),
), out)
@@ -889,17 +843,12 @@
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- %d KiB
""" % (repo.bzrdir.root_transport.base,
format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
- repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
), out)
self.assertEqual('', err)
@@ -979,10 +928,6 @@
0 days old
first revision: %s
latest revision: %s
-
-Revision store:
- 1 revision
- %d KiB
""" % (repo.bzrdir.root_transport.base,
branch1.bzrdir.root_transport.base,
format.get_branch_format().get_format_description(),
@@ -990,12 +935,11 @@
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
- repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
), out)
self.assertEqual('', err)
# Show info about repository with revisions
- out, err = self.runbzr('info repo')
+ out, err = self.runbzr('info repo -v')
self.assertEqualDiff(
"""Location:
shared repository: %s
@@ -1035,10 +979,6 @@
repository: %s
Create working tree for new branches inside the repository.
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (repo.bzrdir.root_transport.base,
format.repository_format.get_format_description(),
), out)
@@ -1072,10 +1012,6 @@
Branch history:
0 revisions
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (repo.bzrdir.root_transport.base,
format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
@@ -1146,7 +1082,12 @@
lco_tree.branch.bzrdir.root_transport.base)
if verbose:
- verbose_info = ' 0 committers\n'
+ verbose_info = ''' 0 committers
+
+Revision store:
+ 0 revisions
+ 0 KiB
+'''
else:
verbose_info = ''
@@ -1172,10 +1113,7 @@
Branch history:
0 revisions
-%s
-Revision store:
- 0 revisions
- 0 KiB
+%s\
""" % (tree_data,
branch_data,
lco_tree._format.get_format_description(),
@@ -1322,10 +1260,6 @@
Branch history:
0 revisions
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (tree.bzrdir.root_transport.base,
tree.branch.repository._format.get_format_description(),
), out)
@@ -1355,10 +1289,6 @@
Branch history:
0 revisions
-
-Revision store:
- 0 revisions
- 0 KiB
""" % (tree.bzrdir.root_transport.base,
tree.branch.repository._format.get_format_description(),
), out)
=== modified file 'bzrlib/tests/repository_implementations/test_statistics.py'
--- a/bzrlib/tests/repository_implementations/test_statistics.py 2007-02-03 10:56:04 +0000
+++ b/bzrlib/tests/repository_implementations/test_statistics.py 2007-04-04 10:24:14 +0000
@@ -47,7 +47,8 @@
tree.unlock()
# now, in the same repository, asking for stats with/without the
# committers flag generates the same date information.
- stats = tree.branch.repository.gather_stats(rev2, committers=False)
+ stats = tree.branch.repository.gather_stats(rev2, committers=False,
+ sizes=True)
self.check_stats_has_size(stats)
self.assertEqual({
'firstrev': (1170491381.0, 0),
@@ -55,7 +56,8 @@
'revisions': 3,
},
stats)
- stats = tree.branch.repository.gather_stats(rev2, committers=True)
+ stats = tree.branch.repository.gather_stats(rev2, committers=True,
+ sizes=True)
self.check_stats_has_size(stats)
self.assertEqual({
'committers': 2,
@@ -64,6 +66,10 @@
'revisions': 3,
},
stats)
+ # now get stats without the size
+ stats = tree.branch.repository.gather_stats(rev2, sizes=False,
+ committers=False)
+ self.assertFalse('size' in stats)
def test_gather_stats_norevid_gets_size(self):
"""Without a revid, repository size is still gathered."""
@@ -74,7 +80,7 @@
rev1 = tree.commit('first post')
tree.unlock()
# now ask for global repository stats.
- stats = tree.branch.repository.gather_stats()
+ stats = tree.branch.repository.gather_stats(sizes=True)
self.check_stats_has_size(stats)
self.assertEqual({
'revisions': 1
@@ -85,7 +91,7 @@
"""An empty repository still has size and revisions."""
tree = self.make_branch_and_memory_tree('.')
# now ask for global repository stats.
- stats = tree.branch.repository.gather_stats()
+ stats = tree.branch.repository.gather_stats(sizes=True)
self.check_stats_has_size(stats)
self.assertEqual({
'revisions': 0
More information about the bazaar-commits
mailing list