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
1=== modified file 'index.py'
2--- index.py 2011-03-14 22:42:42 +0000
3+++ index.py 2011-08-14 16:19:23 +0000
4@@ -108,14 +108,7 @@
5 transport = branch.bzrdir.transport
6 transport.mkdir('bzr-search')
7 index_transport = transport.clone('bzr-search')
8- else:
9- # We don't know how to handle this format.
10- try:
11- from bzrlib.plugins.svn.branch import SvnBranch
12- except ImportError:
13- SvnBranch = None
14- if type(branch) != SvnBranch:
15- raise errors.CannotIndex(branch)
16+ elif branch._format.network_name() == 'subversion':
17 # We can't write to the 'bzrdir' as it is virtual
18 uuid = branch.repository.uuid
19 branch_path = branch.get_branch_path()
20@@ -127,6 +120,8 @@
21 transport = transport.clone(path)
22 transport.ensure_base()
23 index_transport = transport
24+ else:
25+ raise errors.CannotIndex(branch)
26 lockdir = LockDir(index_transport, 'names-lock')
27 lockdir.create()
28 lockdir.lock_write()
29@@ -201,11 +196,7 @@
30 :param branch: The branch to get an index for.
31 :raises: NoSearchIndex if no index can be located.
32 """
33- try:
34- from bzrlib.plugins.svn.branch import SvnBranch
35- except (ImportError, IncompatibleAPI):
36- SvnBranch = None
37- if type(branch) == SvnBranch:
38+ if branch._format.network_name() == 'subversion':
39 # We can't write to the 'bzrdir' as it is virtual
40 uuid = branch.repository.uuid
41 branch_path = branch.get_branch_path()

Subscribers

People subscribed via source and target branches

to all changes: