Rev 2462: Document behaviour of tree.path2id("path/"). in file:///home/robertc/source/baz/dirstate/
Robert Collins
robertc at robertcollins.net
Thu Mar 1 05:18:10 GMT 2007
At file:///home/robertc/source/baz/dirstate/
------------------------------------------------------------
revno: 2462
revision-id: robertc at robertcollins.net-20070301051807-3qz6wj0jtjsieyj2
parent: robertc at robertcollins.net-20070301050247-ufh99m2ze45d7mol
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate
timestamp: Thu 2007-03-01 16:18:07 +1100
message:
Document behaviour of tree.path2id("path/").
modified:
bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'bzrlib/tests/workingtree_implementations/test_workingtree.py'
--- a/bzrlib/tests/workingtree_implementations/test_workingtree.py 2007-02-25 17:20:22 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_workingtree.py 2007-03-01 05:18:07 +0000
@@ -740,3 +740,13 @@
self.assertEqual(expected_results, list(tree.walkdirs()))
finally:
tree.unlock()
+
+ def test_path2id(self):
+ tree = self.make_branch_and_tree('.')
+ self.build_tree(['foo'])
+ tree.add(['foo'], ['foo-id'])
+ self.assertEqual('foo-id', tree.path2id('foo'))
+ # the next assertion is for backwards compatability with WorkingTree3,
+ # though its probably a bad idea, it makes things work. Perhaps
+ # it should raise a deprecation warning?
+ self.assertEqual('foo-id', tree.path2id('foo/'))
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-03-01 03:20:19 +0000
+++ b/bzrlib/workingtree_4.py 2007-03-01 05:18:07 +0000
@@ -666,6 +666,7 @@
@needs_read_lock
def path2id(self, path):
"""Return the id for path in this tree."""
+ path = path.strip('/')
entry = self._get_entry(path=path)
if entry == (None, None):
return None
More information about the bazaar-commits
mailing list