Rev 13: Merge, adjusting for try-finally correctness, Martin Albisetti's restrict-revisions-to-branch patch. in http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk
Robert Collins
robertc at robertcollins.net
Mon Jun 9 08:41:37 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk
------------------------------------------------------------
revno: 13
revision-id: robertc at robertcollins.net-20080609074136-sm0apl2chj8r2alp
parent: robertc at robertcollins.net-20080609073726-h6urz1q3hnjz1a9k
parent: argentina at gmail.com-20080609023947-mawknh5dq7tr5ioe
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Mon 2008-06-09 17:41:36 +1000
message:
Merge, adjusting for try-finally correctness, Martin Albisetti's restrict-revisions-to-branch patch.
modified:
index.py index.py-20080608055509-hnimeek7q8tctkqf-2
------------------------------------------------------------
revno: 11.1.1
revision-id: argentina at gmail.com-20080609023947-mawknh5dq7tr5ioe
parent: robertc at robertcollins.net-20080608234217-e3v0a9e8kak9jas7
committer: Martin Albisetti <argentina at gmail.com>
branch nick: search.beuno
timestamp: Sun 2008-06-08 23:39:47 -0300
message:
* Don't fetch all revisions in the repository
* Use searcher instead
modified:
index.py index.py-20080608055509-hnimeek7q8tctkqf-2
=== modified file 'index.py'
--- a/index.py 2008-06-09 07:37:26 +0000
+++ b/index.py 2008-06-09 07:41:36 +0000
@@ -26,6 +26,7 @@
from bzrlib.index import CombinedGraphIndex, GraphIndex, InMemoryGraphIndex
from bzrlib.lockdir import LockDir
from bzrlib.plugins.search import errors
+from bzrlib.revision import NULL_REVISION
_FORMAT_1 = 'bzr-search search folder 1\n'
@@ -70,18 +71,28 @@
:param url: The url to index.
:return: The resulting search index.
"""
+ revs_to_index = set()
branch = _mod_branch.Branch.open(url)
branch.lock_read()
try:
+ _last_revid = branch.last_revision()
+ graph = branch.repository.get_graph()
+ searcher = graph._make_breadth_first_searcher([_last_revid])
try:
index = open_index_url(url)
# TODO: find the unindexed revisions by searching.
- # This will index everything in the repo - bad.
- revs_to_index = branch.repository.all_revision_ids()
except errors.NoSearchIndex:
index = init_index(branch)
- # This will index everything in the repo - bad.
- revs_to_index = branch.repository.all_revision_ids()
+
+ while True:
+ try:
+ next_revs, ghosts = searcher.next_with_ghosts()
+ except StopIteration:
+ break
+ revs_to_index.update(next_revs)
+
+ revs_to_index.remove(NULL_REVISION)
+
index.index_revisions(branch, revs_to_index)
finally:
branch.unlock()
More information about the bazaar-commits
mailing list