Rev 4: Added ``index.index_url`` convenience function for creating/updating an in http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk

Robert Collins robertc at robertcollins.net
Sun Jun 8 07:43:25 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk

------------------------------------------------------------
revno: 4
revision-id: robertc at robertcollins.net-20080608064253-onrz4jo2slam32o3
parent: robertc at robertcollins.net-20080608062127-2gk12epf1s2ah0yg
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Sun 2008-06-08 16:42:53 +1000
message:
  Added ``index.index_url`` convenience function for creating/updating an
  index. (Robert Collins)
modified:
  NEWS                           news-20080608052041-z5bahsl8kwl0uf4x-2
  commands.py                    commands.py-20080608052041-z5bahsl8kwl0uf4x-5
  index.py                       index.py-20080608055509-hnimeek7q8tctkqf-2
  tests/test_blackbox.py         test_blackbox.py-20080608052041-z5bahsl8kwl0uf4x-9
  tests/test_index.py            test_index.py-20080608055509-hnimeek7q8tctkqf-4
=== modified file 'NEWS'
--- a/NEWS	2008-06-08 06:21:27 +0000
+++ b/NEWS	2008-06-08 06:42:53 +0000
@@ -29,6 +29,10 @@
 
   INTERNALS:
 
+    * Added ``index.open_index_url`` and ``index.index_url`` convenience
+      functions for obtaining an index and creating/updating an index.
+      (Robert Collins)
+
     * New modules: ``commands``, ``errors``, ``index``. These contain the
       console ui, exceptions, and the search index core respectively.
       (Robert Collins)

=== modified file 'commands.py'
--- a/commands.py	2008-06-08 06:21:27 +0000
+++ b/commands.py	2008-06-08 06:42:53 +0000
@@ -33,7 +33,8 @@
     takes_args = ['url']
 
     def run(self, url):
-        pass
+        trans = get_transport(url)
+        _mod_index.index_url(trans.base)
 
 
 class cmd_search(bzrlib.commands.Command):

=== modified file 'index.py'
--- a/index.py	2008-06-08 05:57:24 +0000
+++ b/index.py	2008-06-08 06:42:53 +0000
@@ -17,9 +17,19 @@
 
 """The core logic for search."""
 
+from bzrlib import branch as _mod_branch
 from bzrlib.plugins.search import errors
 
 
+def index_url(url):
+    """Create or update an index at url.
+
+    :param url: The url to index.
+    :return: The resulting search index.
+    """
+    branch = _mod_branch.Branch.open(url)
+
+
 def open_index_url(url):
     """Open a search index at url.
 

=== modified file 'tests/test_blackbox.py'
--- a/tests/test_blackbox.py	2008-06-08 06:21:27 +0000
+++ b/tests/test_blackbox.py	2008-06-08 06:42:53 +0000
@@ -36,3 +36,6 @@
         out, error = self.run_bzr(['index', 'a-branch'])
         self.assertEqual('', error)
         self.assertEqual('', out)
+
+    def test_index_no_branch(self):
+        self.run_bzr_error(['Not a branch'], ['index', '.'])

=== modified file 'tests/test_index.py'
--- a/tests/test_index.py	2008-06-08 05:57:24 +0000
+++ b/tests/test_index.py	2008-06-08 06:42:53 +0000
@@ -17,13 +17,18 @@
 
 """Tests for the index layer."""
 
+from bzrlib.errors import NotBranchError
 from bzrlib.plugins.search import errors, index
 from bzrlib.tests import TestCaseWithTransport
 
 
 class TestIndex(TestCaseWithTransport):
 
-    def test_no_index_error(self):
+    def test_open_no_index_error(self):
         err = self.assertRaises(errors.NoSearchIndex, index.open_index_url,
             self.get_url())
         self.assertEqual(self.get_url(), err.url)
+
+    def test_index_url_not_branch(self):
+        self.assertRaises(NotBranchError, index.index_url,
+            self.get_url())




More information about the bazaar-commits mailing list