~bzr-loom-devs/bzr-loom/1.3

« back to all changes in this revision

Viewing changes to tree.py

  • Committer: Robert Collins
  • Date: 2008-02-28 16:09:37 UTC
  • mfrom: (73.2.2 loom)
  • Revision ID: robert.collins@canonical.com-20080228160937-o1lk5eyouq4bjega
Merge up-thread performance improvements from Aaron Bentley.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    def up_thread(self):
52
52
        """Move one thread up in the loom."""
53
53
        if self.tree.last_revision() != self.tree.branch.last_revision():
54
 
            raise BzrCommandError('cannot switch threads with an out of '
55
 
                'date tree. Please run bzr update.')
 
54
            raise bzrlib.errors.BzrCommandError('cannot switch threads with an'
 
55
            'out of date tree. Please run bzr update.')
56
56
        # set it up:
57
57
        current_revision = self.tree.last_revision()
58
58
        threadname = self.tree.branch.nick
78
78
            # done
79
79
            return 0
80
80
        result = 0
81
 
        try:
82
 
            if new_thread_rev == EMPTY_REVISION:
83
 
                new_thread_rev = bzrlib.revision.NULL_REVISION
84
 
            if old_thread_rev == EMPTY_REVISION:
85
 
                old_thread_rev = bzrlib.revision.NULL_REVISION
86
 
            base_rev_id = bzrlib.revision.common_ancestor(
87
 
                new_thread_rev,
88
 
                old_thread_rev,
89
 
                self.tree.branch.repository)
90
 
        except bzrlib.errors.NoCommonAncestor:
91
 
            raise BzrCommandError('corrupt loom: thread %s has no common'
92
 
                ' ancestor with thread %s' % (new_thread_name, threadname))
 
81
        if new_thread_rev == EMPTY_REVISION:
 
82
            new_thread_rev = bzrlib.revision.NULL_REVISION
 
83
        if old_thread_rev == EMPTY_REVISION:
 
84
            old_thread_rev = bzrlib.revision.NULL_REVISION
 
85
        graph = self.tree.branch.repository.get_graph()
 
86
        base_rev_id = graph.find_unique_lca(new_thread_rev,
 
87
            old_thread_rev)
 
88
        if (base_rev_id == bzrlib.revision.NULL_REVISION and
 
89
            new_thread_rev != bzrlib.revision.NULL_REVISION):
 
90
            raise bzrlib.errors.BzrCommandError('corrupt loom: thread %s has'
 
91
                ' no common ancestor with thread %s'
 
92
                % (new_thread_name, threadname))
93
93
            base_rev_id = None
94
94
        # change the branch
95
95
        self.tree.branch.generate_revision_history(new_thread_rev)
127
127
            the thread to move to.
128
128
        """
129
129
        if self.tree.last_revision() != self.tree.branch.last_revision():
130
 
            raise BzrCommandError('cannot switch threads with an out of '
131
 
                'date tree. Please run bzr update.')
 
130
            raise bzrlib.errors.BzrCommandError('cannot switch threads with an'
 
131
                ' out of date tree. Please run bzr update.')
132
132
        current_revision = self.tree.last_revision()
133
133
        threadname = self.tree.branch.nick
134
134
        threads = self.tree.branch.get_loom_state().get_threads()
177
177
        :param thread: Only revert a single thread.
178
178
        """
179
179
        if self.tree.last_revision() != self.tree.branch.last_revision():
180
 
            raise BzrCommandError('cannot switch threads with an out of '
181
 
                'date tree. Please run bzr update.')
 
180
            raise bzrlib.errors.BzrCommandError('cannot switch threads with an'
 
181
                ' out of date tree. Please run bzr update.')
182
182
        current_thread = self.branch.nick
183
183
        last_rev = self.tree.last_revision()
184
184
        state = self.branch.get_loom_state()