/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/fetch_ghosts.py

  • Committer: Jelmer Vernooij
  • Date: 2018-06-14 17:59:16 UTC
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180614175916-a2e2xh5k533guq1x
Move breezy.plugins.git to breezy.git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
import contextlib
 
17
from __future__ import absolute_import
18
18
 
19
19
from .branch import Branch
20
20
from .trace import note
21
 
from .errors import NoSuchRevision, CommandError
 
21
from .errors import NoSuchRevision, BzrCommandError
22
22
 
23
23
 
24
24
class GhostFetcher(object):
29
29
        if other is None:
30
30
            other = this_branch.get_parent()
31
31
            if other is None:
32
 
                raise CommandError('No branch specified and no location'
 
32
                raise BzrCommandError('No branch specified and no location'
33
33
                                      ' saved.')
34
34
            else:
35
35
                note("Using saved location %s.", other)
42
42
 
43
43
    def run(self):
44
44
        lock_other = self.this_branch.base != self.other_branch.base
45
 
        with contextlib.ExitStack() as exit_stack:
46
 
            exit_stack.enter_context(self.this_branch.lock_write())
 
45
        with self.this_branch.lock_write():
47
46
            if lock_other:
48
 
                exit_stack.enter_context(self.other_branch.lock_read())
49
 
            return self._run_locked()
 
47
                self.other_branch.lock_read()
 
48
            try:
 
49
                return self._run_locked()
 
50
            finally:
 
51
                if lock_other:
 
52
                    self.other_branch.unlock()
50
53
 
51
54
    def iter_ghosts(self):
52
55
        """Find all ancestors that aren't stored in this branch."""