~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_log.py

  • Committer: Vincent Ladeuil
  • Date: 2009-10-06 14:40:37 UTC
  • mto: (4728.1.2 integration)
  • mto: This revision was merged to the branch mainline in revision 4731.
  • Revision ID: v.ladeuil+lp@free.fr-20091006144037-o76rgosv9hj3td0y
Simplify mutable_tree.has_changes() and update call sites.

* bzrlib/workingtree.py:
(WorkingTree.merge_from_branch): Add a force parameter. Replace
the check_basis() call by the corresponding code, taken the new
'force' parameter into account.

* bzrlib/tests/test_status.py:
(TestStatus.make_multiple_pending_tree): Add force=True on
supplementary merges.

* bzrlib/tests/test_reconfigure.py:
(TestReconfigure): Add a test for pending merges.

* bzrlib/tests/test_msgeditor.py:
(MsgEditorTest.make_multiple_pending_tree): Add force=True on
supplementary merges.

* bzrlib/tests/blackbox/test_uncommit.py:
(TestUncommit.test_uncommit_octopus_merge): Add force=True on
supplementary merges.

* bzrlib/send.py:
(send): Use the simplified has_changes(). Fix typo in comment too.

* bzrlib/reconfigure.py:
(Reconfigure._check): Use the simplified has_changes().

* bzrlib/mutabletree.py:
(MutableTree.has_changes): Make the tree parameter optional but
retain it for tests. Add a pending merges check.

* bzrlib/merge.py:
(Merger.ensure_revision_trees, Merger.file_revisions,
Merger.check_basis, Merger.compare_basis): Deprecate.

* bzrlib/bundle/apply_bundle.py:
(merge_bundle): Replace the check_basis() call by the
corresponding code.

* bzrlib/builtins.py:
(cmd_remove_tree.run, cmd_push.run, cmd_merge.run): Use the
simplified has_changes().
(cmd_merge.run): Replace the check_basis call() by the corresponding
code (minus the alredy done has_changes() check).

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for tree transform performance"""
18
18
 
26
26
from bzrlib.transform import TreeTransform
27
27
from bzrlib.workingtree import WorkingTree
28
28
 
 
29
 
29
30
class LinesDone(Exception):
 
31
    """Raised when `LineConsumer` reaches the required number of lines."""
30
32
    pass
31
33
 
 
34
 
32
35
class LineConsumer(object):
 
36
    """Count lines that are produced.
 
37
 
 
38
    When the required number of lines have been reached, raise `LinesDone`.
 
39
    """
33
40
 
34
41
    def __init__(self, required_lines):
 
42
        """Create a new consumer.
 
43
 
 
44
        :param required_lines: How many lines must be produced.
 
45
        :type required_lines: integer
 
46
        """
35
47
        self.required_lines = required_lines
36
48
 
37
49
    def write(self, text):
 
50
        """Write some text to the black hole.
 
51
 
 
52
        But count how many lines have been written.
 
53
 
 
54
        :param text: A string that would be written.
 
55
        :raise LinesDone: when the required number of lines has been reached.
 
56
        :return: None
 
57
        """
38
58
        self.required_lines -= text.count('\n')
39
59
        if self.required_lines < 0:
40
60
            raise LinesDone()
41
 
        
 
61
 
42
62
 
43
63
class LogBenchmark(Benchmark):
 
64
    """Benchmarks for ``'bzr log'`` performance."""
44
65
 
45
66
    def test_log(self):
46
 
        """Run log in a many-commit tree.""" 
 
67
        """Run log in a many-commit tree."""
47
68
        tree = self.make_many_commit_tree(hardlink=True)
48
69
        lf = log_formatter('long', to_file=StringIO())
49
70
        self.time(show_log, tree.branch, lf, direction='reverse')
80
101
        self.time(log_screenful)
81
102
 
82
103
    def test_cmd_log(self):
83
 
        """Test execution of the log command.""" 
 
104
        """Test execution of the log command."""
84
105
        tree = self.make_many_commit_tree(hardlink=True)
85
 
        self.time(self.run_bzr, 'log', '-r', '-4..')
 
106
        self.time(self.run_bzr, ['log', '-r', '-4..'])
86
107
 
87
108
    def test_cmd_log_subprocess(self):
88
 
        """Text startup and execution of the log command.""" 
 
109
        """Text startup and execution of the log command."""
89
110
        tree = self.make_many_commit_tree(hardlink=True)
90
111
        self.time(self.run_bzr_subprocess, 'log', '-r', '-4..')
91
112