Merge lp:~spiv/bzr-loom/bzr-2.3-compat into lp:bzr-loom

Proposed by Andrew Bennetts on 2010-12-16
Status: Merged
Merged at revision: 127
Proposed branch: lp:~spiv/bzr-loom/bzr-2.3-compat
Merge into: lp:bzr-loom
Diff against target: 62 lines (+17/-4)
2 files modified
NEWS (+4/-0)
branch.py (+13/-4)
To merge this branch: bzr merge lp:~spiv/bzr-loom/bzr-2.3-compat
Reviewer Review Type Date Requested Status
Martin Pool (community) 2010-12-16 Approve on 2010-12-16
Review via email: mp+43851@code.launchpad.net

Commit Message

Fix compatibility with bzr trunk (which will become bzr 2.3).

Description of the Change

A recent patch I landed on lp:bzr broke plugins that implement their own branch formats. This is a small patch to make looms support the new API (without breaking compatibility with 2.2).

To post a comment you must log in.
Martin Pool (mbp) wrote :

That looks reasonable to me.

Perhaps in general it's better to check the bzrlib version than whether the parameter is None, because it makes it more obvious why we have it there, and it's less likely to cause trouble if for instance new code does pass None for that value.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-07-16 08:30:13 +0000
3+++ NEWS 2010-12-16 01:36:08 +0000
4@@ -31,6 +31,10 @@
5 IMPROVEMENTS
6 ------------
7
8+* bzr-loom is now compatible with bzr 2.3b5 and newer. There were some API
9+ additions bzr-loom needed to support. Compatibility with earlier versions is
10+ unaffected. (Andrew Bennetts)
11+
12 * Loom now takes advantage of lazy loading of bzr objects (though not to a
13 complete degree), reducing the overhead of having it installed.
14 (Robert Collins)
15
16=== modified file 'branch.py'
17--- branch.py 2010-07-16 08:30:13 +0000
18+++ branch.py 2010-12-16 01:36:08 +0000
19@@ -749,11 +749,17 @@
20 # A mixin is not ideal because it is tricky to test, but it seems to be the
21 # best solution for now.
22
23- def initialize(self, a_bzrdir, name=None):
24+ def initialize(self, a_bzrdir, name=None, repository=None):
25 """Create a branch of this format in a_bzrdir."""
26 if name is not None:
27 raise bzrlib.errors.NoColocatedBranchSupport(self)
28- super(LoomFormatMixin, self).initialize(a_bzrdir, name=None)
29+ if repository is None:
30+ super(LoomFormatMixin, self).initialize(a_bzrdir, name=None)
31+ else:
32+ # The 'repository' optional keyword arg is new in bzr 2.3, so don't
33+ # pass it unless it was passed in.
34+ super(LoomFormatMixin, self).initialize(a_bzrdir, name=None,
35+ repository=repository)
36 branch_transport = a_bzrdir.get_branch_transport(self)
37 files = []
38 state = loom_state.LoomState()
39@@ -772,7 +778,8 @@
40 control_files.unlock()
41 return self.open(a_bzrdir, _found=True, )
42
43- def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
44+ def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
45+ found_repository=None):
46 """Return the branch object for a_bzrdir
47
48 _found is a private parameter, do not use it. It is used to indicate
49@@ -790,10 +797,12 @@
50 transport = a_bzrdir.get_branch_transport(None)
51 control_files = bzrlib.lockable_files.LockableFiles(
52 transport, 'lock', bzrlib.lockdir.LockDir)
53+ if found_repository is None:
54+ found_repository = a_bzrdir.find_repository()
55 return self._branch_class(_format=self,
56 _control_files=control_files,
57 a_bzrdir=a_bzrdir,
58- _repository=a_bzrdir.find_repository(),
59+ _repository=found_repository,
60 ignore_fallbacks=ignore_fallbacks)
61
62 def take_over(self, branch):

Subscribers

People subscribed via source and target branches