Rev 2644: Raise NoSuchId when get_file_sha1 is invoked with a baed file id in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sat Jul 21 00:37:43 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2644
revision-id: pqm at pqm.ubuntu.com-20070720233740-hjfxo6dx2ytwkros
parent: pqm at pqm.ubuntu.com-20070720194822-smqttk05w6efypf0
parent: abentley at panoramicfeedback.com-20070720202707-x6qb9p0ib510s5x7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2007-07-21 00:37:40 +0100
message:
  Raise NoSuchId when get_file_sha1 is invoked with a baed file id
modified:
  bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.56
    merged: abentley at panoramicfeedback.com-20070720202707-x6qb9p0ib510s5x7
    parent: abentley at panoramicfeedback.com-20070720201437-svhxdzhjte77mga4
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Fri 2007-07-20 16:27:07 -0400
    message:
      Raise NoSuchId when get_file_sha1 is invoked with a baed file id
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.55
    merged: abentley at panoramicfeedback.com-20070720201437-svhxdzhjte77mga4
    parent: abentley at panoramicfeedback.com-20070720125633-9wek52fpzqtatsfh
    parent: pqm at pqm.ubuntu.com-20070720194822-smqttk05w6efypf0
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Fri 2007-07-20 16:14:37 -0400
    message:
      Merge bzr.dev
=== modified file 'bzrlib/tests/workingtree_implementations/test_workingtree.py'
--- a/bzrlib/tests/workingtree_implementations/test_workingtree.py	2007-07-11 16:42:37 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_workingtree.py	2007-07-20 20:27:07 +0000
@@ -836,3 +836,15 @@
         tree.commit('file added')
         os.unlink('file')
         self.assertIs(None, tree.get_file_sha1('file-id'))
+
+    def test_no_file_sha1(self):
+        """If a file is not present, get_file_sha1 should raise NoSuchId"""
+        tree = self.make_branch_and_tree('.')
+        tree.lock_write()
+        self.addCleanup(tree.unlock)
+        self.assertRaises(errors.NoSuchId, tree.get_file_sha1, 'file-id')
+        self.build_tree(['file'])
+        tree.add('file', 'file-id')
+        tree.commit('foo')
+        tree.remove('file')
+        self.assertRaises(errors.NoSuchId, tree.get_file_sha1, 'file-id')

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-07-20 17:34:48 +0000
+++ b/bzrlib/workingtree_4.py	2007-07-20 20:27:07 +0000
@@ -408,7 +408,8 @@
     def get_file_sha1(self, file_id, path=None, stat_value=None):
         # check file id is valid unconditionally.
         entry = self._get_entry(file_id=file_id, path=path)
-        assert entry[0] is not None, 'what error should this raise'
+        if entry[0] is None:
+            raise errors.NoSuchId(self, file_id)
         if path is None:
             path = pathjoin(entry[0][0], entry[0][1]).decode('utf8')
 




More information about the bazaar-commits mailing list