/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: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

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
 
from __future__ import absolute_import
 
17
import contextlib
18
18
 
19
19
from .branch import Branch
20
20
from .trace import note
42
42
 
43
43
    def run(self):
44
44
        lock_other = self.this_branch.base != self.other_branch.base
45
 
        self.this_branch.lock_write()
46
 
        try:
 
45
        with contextlib.ExitStack() as exit_stack:
 
46
            exit_stack.enter_context(self.this_branch.lock_write())
47
47
            if lock_other:
48
 
                self.other_branch.lock_read()
49
 
            try:
50
 
                return self._run_locked()
51
 
            finally:
52
 
                if lock_other:
53
 
                    self.other_branch.unlock()
54
 
        finally:
55
 
            self.this_branch.unlock()
 
48
                exit_stack.enter_context(self.other_branch.lock_read())
 
49
            return self._run_locked()
56
50
 
57
51
    def iter_ghosts(self):
58
52
        """Find all ancestors that aren't stored in this branch."""