Merge lp:~jelmer/bzr-search/no-svn-import into lp:bzr-search

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 87
Merged at revision: 88
Proposed branch: lp:~jelmer/bzr-search/no-svn-import
Merge into: lp:bzr-search
Diff against target: 41 lines (+4/-13)
1 file modified
index.py (+4/-13)
To merge this branch: bzr merge lp:~jelmer/bzr-search/no-svn-import
Reviewer Review Type Date Requested Status
Bazaar Developers Pending
Robert Collins Pending
Review via email: mp+71489@code.launchpad.net

Description of the change

bzr-search currently imports SvnBranch from the svn plugin to see if a given branch is a svn branch.

As bzr-search installs a hook that runs whenever the branch tip changes, this
currently means that every branch change (including e.g. push or commit) will
load the svn plugin and its dependencies.

This MP changes it to use the branch format network name instead.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

I don't understand - its already guarded to only run on unknown formats...

The change looks fine, I just don't understand the why of it.

-Rob

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> I don't understand - its already guarded to only run on unknown formats...
>
> The change looks fine, I just don't understand the why of it.
There are two checks. The first, which is used when creating the index, only imports bzr-svn if the bzrdir isn't a meta1 dir, so it's fairly harmless. It will still trigger for remote bzrdirs and other non-meta1 formats (git, hg, ..).

In the other place (line 29 in the diff), when trying to open a index, bzr-svn is imported before bzr-search checks for a meta1 directory. This codepath is used by the post-branch-tip-change hook, which means that bzr-svn gets imported every time bzr changes a branch tip.

Revision history for this message
Robert Collins (lifeless) wrote :

+1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'index.py'
--- index.py 2011-03-14 22:42:42 +0000
+++ index.py 2011-08-14 16:19:23 +0000
@@ -108,14 +108,7 @@
108 transport = branch.bzrdir.transport108 transport = branch.bzrdir.transport
109 transport.mkdir('bzr-search')109 transport.mkdir('bzr-search')
110 index_transport = transport.clone('bzr-search')110 index_transport = transport.clone('bzr-search')
111 else:111 elif branch._format.network_name() == 'subversion':
112 # We don't know how to handle this format.
113 try:
114 from bzrlib.plugins.svn.branch import SvnBranch
115 except ImportError:
116 SvnBranch = None
117 if type(branch) != SvnBranch:
118 raise errors.CannotIndex(branch)
119 # We can't write to the 'bzrdir' as it is virtual112 # We can't write to the 'bzrdir' as it is virtual
120 uuid = branch.repository.uuid113 uuid = branch.repository.uuid
121 branch_path = branch.get_branch_path()114 branch_path = branch.get_branch_path()
@@ -127,6 +120,8 @@
127 transport = transport.clone(path)120 transport = transport.clone(path)
128 transport.ensure_base()121 transport.ensure_base()
129 index_transport = transport122 index_transport = transport
123 else:
124 raise errors.CannotIndex(branch)
130 lockdir = LockDir(index_transport, 'names-lock')125 lockdir = LockDir(index_transport, 'names-lock')
131 lockdir.create()126 lockdir.create()
132 lockdir.lock_write()127 lockdir.lock_write()
@@ -201,11 +196,7 @@
201 :param branch: The branch to get an index for.196 :param branch: The branch to get an index for.
202 :raises: NoSearchIndex if no index can be located.197 :raises: NoSearchIndex if no index can be located.
203 """198 """
204 try:199 if branch._format.network_name() == 'subversion':
205 from bzrlib.plugins.svn.branch import SvnBranch
206 except (ImportError, IncompatibleAPI):
207 SvnBranch = None
208 if type(branch) == SvnBranch:
209 # We can't write to the 'bzrdir' as it is virtual200 # We can't write to the 'bzrdir' as it is virtual
210 uuid = branch.repository.uuid201 uuid = branch.repository.uuid
211 branch_path = branch.get_branch_path()202 branch_path = branch.get_branch_path()

Subscribers

People subscribed via source and target branches

to all changes: