Rev 46: Handle file paths with spaces. in http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk
Robert Collins
robertc at robertcollins.net
Fri Jul 11 13:41:09 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk
------------------------------------------------------------
revno: 46
revision-id: robertc at robertcollins.net-20080711124046-hz7wpek62n2fjnw0
parent: robertc at robertcollins.net-20080629223307-wa3i8yi04sd2ay8e
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Fri 2008-07-11 22:40:46 +1000
message:
Handle file paths with spaces.
modified:
index.py index.py-20080608055509-hnimeek7q8tctkqf-2
tests/test_index.py test_index.py-20080608055509-hnimeek7q8tctkqf-4
=== modified file 'index.py'
--- a/index.py 2008-06-29 22:33:07 +0000
+++ b/index.py 2008-07-11 12:40:46 +0000
@@ -28,6 +28,8 @@
import bzrlib.config
from bzrlib.errors import NotBranchError, NoSuchFile, UnknownFormatError
from bzrlib.index import CombinedGraphIndex, GraphIndex, InMemoryGraphIndex
+#from bzrlib.plugins.index2.btree_index import BTreeGraphIndex as GraphIndex
+#from bzrlib.plugins.index2.repofmt import InMemoryBTree as InMemoryGraphIndex
from bzrlib.lockdir import LockDir
from bzrlib.osutils import split_lines
from bzrlib.pack import ContainerWriter
@@ -158,7 +160,7 @@
transport = get_transport(bzrlib.config.config_dir())
path = 'bzr-search/svn-lookaside/' + uuid + '/' + branch_path
transport = transport.clone(path)
- commits_only = True
+ commits_only = False
else:
transport = branch.bzrdir.transport.clone('bzr-search')
commits_only = False
@@ -242,7 +244,7 @@
for index, doc_ids in indices.items():
doc_index = self._term_doc_indices[index]
for node in doc_index.iter_entries(doc_ids):
- yield tuple(node[2].split(' '))
+ yield tuple(node[2].split(' ', 2))
def index_branch(self, branch, tip_revision):
"""Index revisions from a branch.
@@ -858,7 +860,7 @@
"""
indices = {}
for node in self.document_index.iter_entries(doc_ids):
- yield tuple(node[2].split(' '))
+ yield tuple(node[2].split(' ', 2))
def indexed_revisions(self):
"""Return the revision_keys that this index contains terms for."""
@@ -1046,7 +1048,7 @@
self.component_docids[component] = component_docs
for node in component.document_index.iter_all_entries():
# duplication with _document_ids_to_keys
- document_key = tuple(node[2].split(' '))
+ document_key = tuple(node[2].split(' ', 2))
doc_id = self.add_document(document_key)
# Map from the old doc id to the new doc it
component_docs[node[1]] = doc_id
=== modified file 'tests/test_index.py'
--- a/tests/test_index.py 2008-06-29 22:33:07 +0000
+++ b/tests/test_index.py 2008-07-11 12:40:46 +0000
@@ -467,6 +467,29 @@
self.assertEqual(set([('rev1',), ('rev2',), ('rev-common',)]),
set(combined.indexed_revisions()))
+ def test_combine_two_components_path_spaces(self):
+ # create one component:
+ transport = self.get_transport()
+ components = []
+ builder = index.ComponentIndexBuilder()
+ builder.add_revision('revid')
+ builder.add_term(("file", "revid"), [('p', '', 'file path')])
+ name, value, elements = builder.upload_index(transport)
+ component1 = index.ComponentIndex(name, value, transport)
+ components.append(component1)
+ builder = index.ComponentIndexBuilder()
+ builder.add_revision('revid1')
+ name, value, elements = builder.upload_index(transport)
+ component2 = index.ComponentIndex(name, value, transport)
+ components.append(component2)
+ combiner = index.ComponentCombiner(components, transport)
+ name, value, elements = combiner.combine()
+ combined = index.ComponentIndex(name, value, transport)
+ terms = {('file', 'revid'): set([('p', '', 'file path')])}
+ self.assertEqual(terms, combined.all_terms())
+ self.assertEqual(set([('revid',), ('revid1',)]),
+ set(combined.indexed_revisions()))
+
class TestAutoIndex(TestCaseWithTransport):
More information about the bazaar-commits
mailing list