Merge lp:~jelmer/brz/is-versioned into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 6856
Proposed branch: lp:~jelmer/brz/is-versioned
Merge into: lp:brz
Diff against target: 796 lines (+100/-105)
31 files modified
breezy/builtins.py (+1/-1)
breezy/bzr/bzrdir.py (+1/-1)
breezy/bzr/workingtree.py (+3/-2)
breezy/ignores.py (+1/-1)
breezy/plugins/fastimport/tests/test_generic_processor.py (+2/-4)
breezy/rename_map.py (+1/-1)
breezy/tests/__init__.py (+2/-2)
breezy/tests/blackbox/test_mv.py (+6/-6)
breezy/tests/blackbox/test_remove.py (+1/-1)
breezy/tests/blackbox/test_repair_workingtree.py (+2/-2)
breezy/tests/per_intertree/__init__.py (+1/-1)
breezy/tests/per_tree/test_test_trees.py (+3/-0)
breezy/tests/per_tree/test_tree.py (+5/-4)
breezy/tests/per_workingtree/test_get_file_mtime.py (+1/-4)
breezy/tests/per_workingtree/test_inv.py (+1/-1)
breezy/tests/per_workingtree/test_read_working_inventory.py (+1/-4)
breezy/tests/per_workingtree/test_smart_add.py (+14/-15)
breezy/tests/per_workingtree/test_symlinks.py (+8/-8)
breezy/tests/per_workingtree/test_unversion.py (+3/-4)
breezy/tests/per_workingtree/test_workingtree.py (+4/-8)
breezy/tests/test_bundle.py (+7/-7)
breezy/tests/test_commit.py (+3/-7)
breezy/tests/test_inv.py (+3/-3)
breezy/tests/test_merge.py (+1/-1)
breezy/tests/test_transform.py (+7/-7)
breezy/tests/test_uncommit.py (+1/-1)
breezy/tests/test_upstream_import.py (+5/-5)
breezy/tests/test_workingtree_4.py (+2/-2)
breezy/tree.py (+8/-0)
breezy/upstream_import.py (+1/-1)
breezy/workingtree.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/is-versioned
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+337827@code.launchpad.net

Description of the change

Add Tree.is_versioned().

Another step twoards removing file_ids from the public API.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks sensible. Probably work an assert helper for all versioned or similar at some point?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/builtins.py'
--- breezy/builtins.py 2017-12-23 10:48:42 +0000
+++ breezy/builtins.py 2018-02-15 22:17:55 +0000
@@ -875,7 +875,7 @@
875875
876 @classmethod876 @classmethod
877 def add_file_with_parents(cls, wt, relpath):877 def add_file_with_parents(cls, wt, relpath):
878 if wt.path2id(relpath) is not None:878 if wt.is_versioned(relpath):
879 return879 return
880 cls.add_file_with_parents(wt, osutils.dirname(relpath))880 cls.add_file_with_parents(wt, osutils.dirname(relpath))
881 wt.add([relpath])881 wt.add([relpath])
882882
=== modified file 'breezy/bzr/bzrdir.py'
--- breezy/bzr/bzrdir.py 2017-11-23 20:02:55 +0000
+++ breezy/bzr/bzrdir.py 2018-02-15 22:17:55 +0000
@@ -451,7 +451,7 @@
451 hardlink=hardlink, from_branch=result_branch)451 hardlink=hardlink, from_branch=result_branch)
452 wt.lock_write()452 wt.lock_write()
453 try:453 try:
454 if wt.path2id('') is None:454 if not wt.is_versioned(''):
455 try:455 try:
456 wt.set_root_id(self.open_workingtree.get_root_id())456 wt.set_root_id(self.open_workingtree.get_root_id())
457 except errors.NoWorkingTree:457 except errors.NoWorkingTree:
458458
=== modified file 'breezy/bzr/workingtree.py'
--- breezy/bzr/workingtree.py 2017-12-22 16:24:08 +0000
+++ breezy/bzr/workingtree.py 2018-02-15 22:17:55 +0000
@@ -943,7 +943,7 @@
943 self.add_parent_tree_id(parent_id)943 self.add_parent_tree_id(parent_id)
944 other_tree.controldir.retire_bzrdir()944 other_tree.controldir.retire_bzrdir()
945945
946 def extract(self, file_id, format=None):946 def extract(self, sub_path, file_id=None, format=None):
947 """Extract a subtree from this tree.947 """Extract a subtree from this tree.
948948
949 A new branch will be created, relative to the path for this tree.949 A new branch will be created, relative to the path for this tree.
@@ -958,7 +958,6 @@
958958
959 with self.lock_tree_write():959 with self.lock_tree_write():
960 self.flush()960 self.flush()
961 sub_path = self.id2path(file_id)
962 branch_transport = mkdirs(sub_path)961 branch_transport = mkdirs(sub_path)
963 if format is None:962 if format is None:
964 format = self.controldir.cloning_metadir()963 format = self.controldir.cloning_metadir()
@@ -985,6 +984,8 @@
985 # FIXME: Support nested trees984 # FIXME: Support nested trees
986 my_inv = self.root_inventory985 my_inv = self.root_inventory
987 child_inv = inventory.Inventory(root_id=None)986 child_inv = inventory.Inventory(root_id=None)
987 if file_id is None:
988 file_id = self.path2id(sub_path)
988 new_root = my_inv[file_id]989 new_root = my_inv[file_id]
989 my_inv.remove_recursive_id(file_id)990 my_inv.remove_recursive_id(file_id)
990 new_root.parent_id = None991 new_root.parent_id = None
991992
=== modified file 'breezy/ignores.py'
--- breezy/ignores.py 2017-11-12 13:31:49 +0000
+++ breezy/ignores.py 2018-02-15 22:17:55 +0000
@@ -225,5 +225,5 @@
225 finally:225 finally:
226 f.close()226 f.close()
227227
228 if not tree.path2id(breezy.IGNORE_FILENAME):228 if not tree.is_versioned(breezy.IGNORE_FILENAME):
229 tree.add([breezy.IGNORE_FILENAME])229 tree.add([breezy.IGNORE_FILENAME])
230230
=== modified file 'breezy/plugins/fastimport/tests/test_generic_processor.py'
--- breezy/plugins/fastimport/tests/test_generic_processor.py 2018-01-22 02:23:22 +0000
+++ breezy/plugins/fastimport/tests/test_generic_processor.py 2018-02-15 22:17:55 +0000
@@ -173,14 +173,12 @@
173 str(expected_kind_changed_entry), kind_changed_files))173 str(expected_kind_changed_entry), kind_changed_files))
174174
175 def assertContent(self, branch, tree, path, content):175 def assertContent(self, branch, tree, path, content):
176 file_id = tree.path2id(path)
177 with branch.lock_read():176 with branch.lock_read():
178 self.assertEqual(tree.get_file_text(path, file_id), content)177 self.assertEqual(tree.get_file_text(path), content)
179178
180 def assertSymlinkTarget(self, branch, tree, path, target):179 def assertSymlinkTarget(self, branch, tree, path, target):
181 file_id = tree.path2id(path)
182 with branch.lock_read():180 with branch.lock_read():
183 self.assertEqual(tree.get_symlink_target(path, file_id), target)181 self.assertEqual(tree.get_symlink_target(path), target)
184182
185 def assertExecutable(self, branch, tree, path, executable):183 def assertExecutable(self, branch, tree, path, executable):
186 with branch.lock_read():184 with branch.lock_read():
187185
=== modified file 'breezy/rename_map.py'
--- breezy/rename_map.py 2017-11-12 17:53:35 +0000
+++ breezy/rename_map.py 2018-02-15 22:17:55 +0000
@@ -146,7 +146,7 @@
146 while True:146 while True:
147 child = path147 child = path
148 path = osutils.dirname(path)148 path = osutils.dirname(path)
149 if self.tree.path2id(path) is not None:149 if self.tree.is_versioned(path):
150 break150 break
151 required_parents.setdefault(path, []).append(child)151 required_parents.setdefault(path, []).append(child)
152 require_ids = {}152 require_ids = {}
153153
=== modified file 'breezy/tests/__init__.py'
--- breezy/tests/__init__.py 2017-11-12 13:53:51 +0000
+++ breezy/tests/__init__.py 2018-02-15 22:17:55 +0000
@@ -2865,7 +2865,7 @@
2865 for p in path:2865 for p in path:
2866 self.assertInWorkingTree(p, tree=tree)2866 self.assertInWorkingTree(p, tree=tree)
2867 else:2867 else:
2868 self.assertIsNot(tree.path2id(path), None,2868 self.assertTrue(tree.is_versioned(path),
2869 path+' not in working tree.')2869 path+' not in working tree.')
28702870
2871 def assertNotInWorkingTree(self, path, root_path='.', tree=None):2871 def assertNotInWorkingTree(self, path, root_path='.', tree=None):
@@ -2876,7 +2876,7 @@
2876 for p in path:2876 for p in path:
2877 self.assertNotInWorkingTree(p, tree=tree)2877 self.assertNotInWorkingTree(p, tree=tree)
2878 else:2878 else:
2879 self.assertIs(tree.path2id(path), None, path+' in working tree.')2879 self.assertFalse(tree.is_versioned(path), path+' in working tree.')
28802880
28812881
2882class TestCaseWithTransport(TestCaseInTempDir):2882class TestCaseWithTransport(TestCaseInTempDir):
28832883
=== modified file 'breezy/tests/blackbox/test_mv.py'
--- breezy/tests/blackbox/test_mv.py 2017-11-12 13:53:51 +0000
+++ breezy/tests/blackbox/test_mv.py 2018-02-15 22:17:55 +0000
@@ -453,8 +453,8 @@
453 self.assertEqual(out, '')453 self.assertEqual(out, '')
454 self.assertEqual(err, 'a => b\nc => d\n')454 self.assertEqual(err, 'a => b\nc => d\n')
455 tree = workingtree.WorkingTree.open('tree')455 tree = workingtree.WorkingTree.open('tree')
456 self.assertIsNot(None, tree.path2id('b'))456 self.assertTrue(tree.is_versioned('b'))
457 self.assertIsNot(None, tree.path2id('d'))457 self.assertTrue(tree.is_versioned('d'))
458458
459 def test_mv_auto_one_path(self):459 def test_mv_auto_one_path(self):
460 self.make_abcd_tree()460 self.make_abcd_tree()
@@ -462,8 +462,8 @@
462 self.assertEqual(out, '')462 self.assertEqual(out, '')
463 self.assertEqual(err, 'a => b\nc => d\n')463 self.assertEqual(err, 'a => b\nc => d\n')
464 tree = workingtree.WorkingTree.open('tree')464 tree = workingtree.WorkingTree.open('tree')
465 self.assertIsNot(None, tree.path2id('b'))465 self.assertTrue(tree.is_versioned('b'))
466 self.assertIsNot(None, tree.path2id('d'))466 self.assertTrue(tree.is_versioned('d'))
467467
468 def test_mv_auto_two_paths(self):468 def test_mv_auto_two_paths(self):
469 self.make_abcd_tree()469 self.make_abcd_tree()
@@ -477,8 +477,8 @@
477 self.assertEqual(out, '')477 self.assertEqual(out, '')
478 self.assertEqual(err, 'a => b\nc => d\n')478 self.assertEqual(err, 'a => b\nc => d\n')
479 tree = workingtree.WorkingTree.open('tree')479 tree = workingtree.WorkingTree.open('tree')
480 self.assertIsNot(None, tree.path2id('a'))480 self.assertTrue(tree.is_versioned('a'))
481 self.assertIsNot(None, tree.path2id('c'))481 self.assertTrue(tree.is_versioned('c'))
482482
483 def test_mv_no_auto_dry_run(self):483 def test_mv_no_auto_dry_run(self):
484 self.make_abcd_tree()484 self.make_abcd_tree()
485485
=== modified file 'breezy/tests/blackbox/test_remove.py'
--- breezy/tests/blackbox/test_remove.py 2017-11-12 13:53:51 +0000
+++ breezy/tests/blackbox/test_remove.py 2018-02-15 22:17:55 +0000
@@ -106,7 +106,7 @@
106 tree.commit('save foo and bar')106 tree.commit('save foo and bar')
107 os.unlink('bar')107 os.unlink('bar')
108 self.run_bzr(['rm'])108 self.run_bzr(['rm'])
109 self.assertEqual(None, tree.path2id('bar'))109 self.assertFalse(tree.is_versioned('bar'))
110 # Running rm with a deleted file does not error.110 # Running rm with a deleted file does not error.
111 out, err = self.run_bzr(['rm'])111 out, err = self.run_bzr(['rm'])
112 self.assertEqual('', out)112 self.assertEqual('', out)
113113
=== modified file 'breezy/tests/blackbox/test_repair_workingtree.py'
--- breezy/tests/blackbox/test_repair_workingtree.py 2017-08-26 13:58:53 +0000
+++ breezy/tests/blackbox/test_repair_workingtree.py 2018-02-15 22:17:55 +0000
@@ -65,10 +65,10 @@
65 def test_repair_forced(self):65 def test_repair_forced(self):
66 tree = self.make_initial_tree()66 tree = self.make_initial_tree()
67 tree.rename_one('dir', 'alt_dir')67 tree.rename_one('dir', 'alt_dir')
68 self.assertIsNot(None, tree.path2id('alt_dir'))68 self.assertTrue(tree.is_versioned('alt_dir'))
69 self.run_bzr('repair-workingtree -d tree --force')69 self.run_bzr('repair-workingtree -d tree --force')
70 # This requires the tree has reloaded the working state70 # This requires the tree has reloaded the working state
71 self.assertIs(None, tree.path2id('alt_dir'))71 self.assertFalse(tree.is_versioned('alt_dir'))
72 self.assertPathExists('tree/alt_dir')72 self.assertPathExists('tree/alt_dir')
7373
74 def test_repair_corrupted_dirstate(self):74 def test_repair_corrupted_dirstate(self):
7575
=== modified file 'breezy/tests/per_intertree/__init__.py'
--- breezy/tests/per_intertree/__init__.py 2017-11-12 13:53:51 +0000
+++ breezy/tests/per_intertree/__init__.py 2018-02-15 22:17:55 +0000
@@ -62,7 +62,7 @@
62 raise tests.TestNotApplicable('cannot represent unversioned files')62 raise tests.TestNotApplicable('cannot represent unversioned files')
6363
64 def not_applicable_if_missing_in(self, relpath, tree):64 def not_applicable_if_missing_in(self, relpath, tree):
65 if not tree.path2id(relpath):65 if not tree.is_versioned(relpath):
66 # The locked test trees conversion could not preserve the missing66 # The locked test trees conversion could not preserve the missing
67 # file status. This is normal (e.g. InterDirstateTree falls back67 # file status. This is normal (e.g. InterDirstateTree falls back
68 # to InterTree if the basis is not a DirstateRevisionTree, and68 # to InterTree if the basis is not a DirstateRevisionTree, and
6969
=== modified file 'breezy/tests/per_tree/test_test_trees.py'
--- breezy/tests/per_tree/test_test_trees.py 2018-02-03 13:39:29 +0000
+++ breezy/tests/per_tree/test_test_trees.py 2018-02-15 22:17:55 +0000
@@ -49,6 +49,9 @@
49 self.assertEqual(49 self.assertEqual(
50 {'', 'a', 'b', 'b/c'},50 {'', 'a', 'b', 'b/c'},
51 set(tree.all_versioned_paths()))51 set(tree.all_versioned_paths()))
52 self.assertTrue(tree.is_versioned('a'))
53 self.assertTrue(tree.is_versioned('b'))
54 self.assertTrue(tree.is_versioned('b/c'))
52 self.assertEqual(55 self.assertEqual(
53 [(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']],56 [(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']],
54 [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])57 [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
5558
=== modified file 'breezy/tests/per_tree/test_tree.py'
--- breezy/tests/per_tree/test_tree.py 2018-01-12 08:52:43 +0000
+++ breezy/tests/per_tree/test_tree.py 2018-02-15 22:17:55 +0000
@@ -116,6 +116,10 @@
116 if root_id is not None:116 if root_id is not None:
117 self.assertIsInstance(root_id, str)117 self.assertIsInstance(root_id, str)
118118
119 def test_is_versioned(self):
120 self.assertTrue(tree.is_versioned(''))
121 self.assertFalse(tree.is_versioned('blah'))
122
119123
120class TestFileIds(TestCaseWithTree):124class TestFileIds(TestCaseWithTree):
121125
@@ -124,13 +128,10 @@
124 work_tree = self.make_branch_and_tree('wt')128 work_tree = self.make_branch_and_tree('wt')
125 tree = self.get_tree_no_parents_abc_content(work_tree)129 tree = self.get_tree_no_parents_abc_content(work_tree)
126 a_id = tree.path2id('a')130 a_id = tree.path2id('a')
127 tree.lock_read()131 with tree.lock_read():
128 try:
129 self.assertEqual(u'a', tree.id2path(a_id))132 self.assertEqual(u'a', tree.id2path(a_id))
130 # other ids give an error- don't return None for this case133 # other ids give an error- don't return None for this case
131 self.assertRaises(errors.NoSuchId, tree.id2path, 'a')134 self.assertRaises(errors.NoSuchId, tree.id2path, 'a')
132 finally:
133 tree.unlock()
134135
135 def test_all_file_ids(self):136 def test_all_file_ids(self):
136 work_tree = self.make_branch_and_tree('wt')137 work_tree = self.make_branch_and_tree('wt')
137138
=== modified file 'breezy/tests/per_workingtree/test_get_file_mtime.py'
--- breezy/tests/per_workingtree/test_get_file_mtime.py 2018-01-12 08:52:43 +0000
+++ breezy/tests/per_workingtree/test_get_file_mtime.py 2018-02-15 22:17:55 +0000
@@ -111,9 +111,6 @@
111 one_id = tree.path2id('one')111 one_id = tree.path2id('one')
112112
113 os.remove('tree/one')113 os.remove('tree/one')
114 tree.lock_read()114 with tree.lock_read():
115 try:
116 self.assertRaises(errors.NoSuchFile, tree.get_file_mtime, 'one')115 self.assertRaises(errors.NoSuchFile, tree.get_file_mtime, 'one')
117 finally:
118 tree.unlock()
119116
120117
=== modified file 'breezy/tests/per_workingtree/test_inv.py'
--- breezy/tests/per_workingtree/test_inv.py 2017-11-24 09:25:13 +0000
+++ breezy/tests/per_workingtree/test_inv.py 2018-02-15 22:17:55 +0000
@@ -68,7 +68,7 @@
68 wt.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])68 wt.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
69 wt.apply_inventory_delta([('foo', None, 'foo-id', None),69 wt.apply_inventory_delta([('foo', None, 'foo-id', None),
70 ('foo/bar', None, 'bar-id', None)])70 ('foo/bar', None, 'bar-id', None)])
71 self.assertIs(None, wt.path2id('foo'))71 self.assertFalse(wt.is_versioned('foo'))
7272
73 def test_rename_dir_with_children(self):73 def test_rename_dir_with_children(self):
74 wt = self.make_branch_and_tree('.')74 wt = self.make_branch_and_tree('.')
7575
=== modified file 'breezy/tests/per_workingtree/test_read_working_inventory.py'
--- breezy/tests/per_workingtree/test_read_working_inventory.py 2017-06-10 01:39:46 +0000
+++ breezy/tests/per_workingtree/test_read_working_inventory.py 2018-02-15 22:17:55 +0000
@@ -41,8 +41,7 @@
41 "non-inventory working trees")41 "non-inventory working trees")
42 # prepare for a series of changes that will modify the42 # prepare for a series of changes that will modify the
43 # inventory43 # inventory
44 tree.lock_write()44 with tree.lock_write():
45 try:
46 tree.set_root_id('new-root')45 tree.set_root_id('new-root')
47 # having dirtied the inventory, we can now expect an46 # having dirtied the inventory, we can now expect an
48 # InventoryModified exception when doing a read_working_inventory()47 # InventoryModified exception when doing a read_working_inventory()
@@ -53,5 +52,3 @@
53 pass52 pass
54 else:53 else:
55 self.assertEqual('new-root', tree.path2id(''))54 self.assertEqual('new-root', tree.path2id(''))
56 finally:
57 tree.unlock()
5855
=== modified file 'breezy/tests/per_workingtree/test_smart_add.py'
--- breezy/tests/per_workingtree/test_smart_add.py 2018-02-03 13:39:29 +0000
+++ breezy/tests/per_workingtree/test_smart_add.py 2018-02-15 22:17:55 +0000
@@ -84,7 +84,7 @@
84 wt.unlock()84 wt.unlock()
85 # and the disk state should be the same - reopen to check.85 # and the disk state should be the same - reopen to check.
86 wt = wt.controldir.open_workingtree()86 wt = wt.controldir.open_workingtree()
87 self.assertEqual(wt.path2id('file'), None)87 self.assertFalse(wt.is_versioned('file'))
8888
89 def test_add_dot_from_root(self):89 def test_add_dot_from_root(self):
90 """Test adding . from the root of the tree."""90 """Test adding . from the root of the tree."""
@@ -93,7 +93,7 @@
93 wt = self.make_branch_and_tree('.')93 wt = self.make_branch_and_tree('.')
94 wt.smart_add((u".",))94 wt.smart_add((u".",))
95 for path in paths:95 for path in paths:
96 self.assertNotEqual(wt.path2id(path), None)96 self.assertTrue(wt.is_versioned(path))
9797
98 def test_skip_nested_trees(self):98 def test_skip_nested_trees(self):
99 """Test smart-adding a nested tree ignors it and warns."""99 """Test smart-adding a nested tree ignors it and warns."""
@@ -104,7 +104,7 @@
104 warnings.append(args[0] % args[1:])104 warnings.append(args[0] % args[1:])
105 self.overrideAttr(trace, 'warning', warning)105 self.overrideAttr(trace, 'warning', warning)
106 wt.smart_add((u".",))106 wt.smart_add((u".",))
107 self.assertIs(wt.path2id("nested"), None)107 self.assertFalse(wt.is_versioned("nested"))
108 self.assertEqual(108 self.assertEqual(
109 ['skipping nested tree %r' % nested_wt.basedir], warnings)109 ['skipping nested tree %r' % nested_wt.basedir], warnings)
110110
@@ -115,7 +115,7 @@
115 wt = self.make_branch_and_tree('.')115 wt = self.make_branch_and_tree('.')
116 wt.smart_add((u".",))116 wt.smart_add((u".",))
117 for path in paths:117 for path in paths:
118 self.assertNotEqual(wt.path2id(path), None)118 self.assertTrue(wt.is_versioned(path))
119119
120 def test_add_tree_from_above_tree(self):120 def test_add_tree_from_above_tree(self):
121 """Test adding a tree from above the tree."""121 """Test adding a tree from above the tree."""
@@ -126,7 +126,7 @@
126 wt = self.make_branch_and_tree('branch')126 wt = self.make_branch_and_tree('branch')
127 wt.smart_add(("branch",))127 wt.smart_add(("branch",))
128 for path in paths:128 for path in paths:
129 self.assertNotEqual(wt.path2id(path), None)129 self.assertTrue(wt.is_versioned(path))
130130
131 def test_add_above_tree_preserves_tree(self):131 def test_add_above_tree_preserves_tree(self):
132 """Test nested trees are not affect by an add above them."""132 """Test nested trees are not affect by an add above them."""
@@ -144,13 +144,13 @@
144 child_tree = self.make_branch_and_tree('original/child')144 child_tree = self.make_branch_and_tree('original/child')
145 wt.smart_add((".",))145 wt.smart_add((".",))
146 for path in paths:146 for path in paths:
147 self.assertNotEqual((path, wt.path2id(path)),147 self.assertNotEqual((path, wt.is_versioned(path)),
148 (path, None))148 (path, False))
149 for path in full_child_paths:149 for path in full_child_paths:
150 self.assertEqual((path, wt.path2id(path)),150 self.assertEqual((path, wt.is_versioned(path)),
151 (path, None))151 (path, False))
152 for path in child_paths:152 for path in child_paths:
153 self.assertEqual(child_tree.path2id(path), None)153 self.assertFalse(child_tree.is_versioned(path))
154154
155 def test_add_paths(self):155 def test_add_paths(self):
156 """Test smart-adding a list of paths."""156 """Test smart-adding a list of paths."""
@@ -159,7 +159,7 @@
159 wt = self.make_branch_and_tree('.')159 wt = self.make_branch_and_tree('.')
160 wt.smart_add(paths)160 wt.smart_add(paths)
161 for path in paths:161 for path in paths:
162 self.assertNotEqual(wt.path2id(path), None)162 self.assertTrue(wt.is_versioned(path))
163163
164 def test_add_ignored_nested_paths(self):164 def test_add_ignored_nested_paths(self):
165 """Test smart-adding a list of paths which includes ignored ones."""165 """Test smart-adding a list of paths which includes ignored ones."""
@@ -170,8 +170,7 @@
170 self.build_tree(tree_shape)170 self.build_tree(tree_shape)
171 wt.smart_add(add_paths)171 wt.smart_add(add_paths)
172 for path in expected_paths:172 for path in expected_paths:
173 self.assertNotEqual(wt.path2id(path), None,173 self.assertTrue(wt.is_versioned(path), "No id added for %s" % path)
174 "No id added for %s" % path)
175174
176 def test_add_non_existant(self):175 def test_add_non_existant(self):
177 """Test smart-adding a file that does not exist."""176 """Test smart-adding a file that does not exist."""
@@ -206,10 +205,10 @@
206 wt.smart_add(['file1', 'file2', 'dir1', 'dir2'])205 wt.smart_add(['file1', 'file2', 'dir1', 'dir2'])
207206
208 for path in added_paths:207 for path in added_paths:
209 self.assertNotEqual(None, wt.path2id(path.rstrip('/')),208 self.assertTrue(wt.is_versioned(path.rstrip('/')),
210 'Failed to add path: %s' % (path,))209 'Failed to add path: %s' % (path,))
211 for path in not_added:210 for path in not_added:
212 self.assertEqual(None, wt.path2id(path.rstrip('/')),211 self.assertFalse(wt.is_versioned(path.rstrip('/')),
213 'Accidentally added path: %s' % (path,))212 'Accidentally added path: %s' % (path,))
214213
215 def test_add_file_in_unknown_dir(self):214 def test_add_file_in_unknown_dir(self):
216215
=== modified file 'breezy/tests/per_workingtree/test_symlinks.py'
--- breezy/tests/per_workingtree/test_symlinks.py 2017-11-12 20:07:32 +0000
+++ breezy/tests/per_workingtree/test_symlinks.py 2018-02-15 22:17:55 +0000
@@ -42,8 +42,8 @@
42 ('tree/link@', 'target'),42 ('tree/link@', 'target'),
43 ])43 ])
44 tree.smart_add(['tree/link'])44 tree.smart_add(['tree/link'])
45 self.assertIsNot(None, tree.path2id('link'))45 self.assertTrue(tree.is_versioned('link'))
46 self.assertIs(None, tree.path2id('target'))46 self.assertFalse(tree.is_versioned('target'))
47 self.assertEqual('symlink', tree.kind('link'))47 self.assertEqual('symlink', tree.kind('link'))
4848
49 def test_smart_add_symlink_pointing_outside(self):49 def test_smart_add_symlink_pointing_outside(self):
@@ -52,8 +52,8 @@
52 ('tree/link@', '../../../../target'),52 ('tree/link@', '../../../../target'),
53 ])53 ])
54 tree.smart_add(['tree/link'])54 tree.smart_add(['tree/link'])
55 self.assertIsNot(None, tree.path2id('link'))55 self.assertTrue(tree.is_versioned('link'))
56 self.assertIs(None, tree.path2id('target'))56 self.assertFalse(tree.is_versioned('target'))
57 self.assertEqual('symlink', tree.kind('link'))57 self.assertEqual('symlink', tree.kind('link'))
5858
59 def test_add_file_under_symlink(self):59 def test_add_file_under_symlink(self):
@@ -70,10 +70,10 @@
70 ([u'dir', u'dir/file'], {}))70 ([u'dir', u'dir/file'], {}))
71 # should add the actual parent directory, not the apparent parent71 # should add the actual parent directory, not the apparent parent
72 # (which is actually a symlink)72 # (which is actually a symlink)
73 self.assertTrue(tree.path2id('dir/file'))73 self.assertTrue(tree.is_versioned('dir/file'))
74 self.assertTrue(tree.path2id('dir'))74 self.assertTrue(tree.is_versioned('dir'))
75 self.assertIs(None, tree.path2id('link'))75 self.assertFalse(tree.is_versioned('link'))
76 self.assertIs(None, tree.path2id('link/file'))76 self.assertFalse(tree.is_versioned('link/file'))
7777
7878
79class TestKindChanges(TestCaseWithWorkingTree):79class TestKindChanges(TestCaseWithWorkingTree):
8080
=== modified file 'breezy/tests/per_workingtree/test_unversion.py'
--- breezy/tests/per_workingtree/test_unversion.py 2017-12-22 16:24:08 +0000
+++ breezy/tests/per_workingtree/test_unversion.py 2018-02-15 22:17:55 +0000
@@ -61,7 +61,9 @@
61 c_id = tree.path2id('c')61 c_id = tree.path2id('c')
62 # within a lock unversion should take effect62 # within a lock unversion should take effect
63 tree.lock_write()63 tree.lock_write()
64 self.assertTrue(tree.is_versioned('a'))
64 tree.unversion(['a', 'b'])65 tree.unversion(['a', 'b'])
66 self.assertFalse(tree.is_versioned('a'))
65 self.assertFalse(tree.has_id(a_id))67 self.assertFalse(tree.has_id(a_id))
66 self.assertFalse(tree.has_id(b_id))68 self.assertFalse(tree.has_id(b_id))
67 self.assertTrue(tree.has_id(c_id))69 self.assertTrue(tree.has_id(c_id))
@@ -111,8 +113,7 @@
111 b_id = tree.path2id('a/b')113 b_id = tree.path2id('a/b')
112 c_id = tree.path2id('a/c')114 c_id = tree.path2id('a/c')
113 d_id = tree.path2id('d')115 d_id = tree.path2id('d')
114 tree.lock_write()116 with tree.lock_write():
115 try:
116 tree.unversion(['a/b', 'a'])117 tree.unversion(['a/b', 'a'])
117 self.assertFalse(tree.has_id(a_id))118 self.assertFalse(tree.has_id(a_id))
118 self.assertFalse(tree.has_id(b_id))119 self.assertFalse(tree.has_id(b_id))
@@ -123,8 +124,6 @@
123 self.assertTrue(tree.has_filename('a/b'))124 self.assertTrue(tree.has_filename('a/b'))
124 self.assertTrue(tree.has_filename('a/c'))125 self.assertTrue(tree.has_filename('a/c'))
125 self.assertTrue(tree.has_filename('d'))126 self.assertTrue(tree.has_filename('d'))
126 finally:
127 tree.unlock()
128127
129 def test_unversion_renamed(self):128 def test_unversion_renamed(self):
130 tree = self.make_branch_and_tree('a')129 tree = self.make_branch_and_tree('a')
131130
=== modified file 'breezy/tests/per_workingtree/test_workingtree.py'
--- breezy/tests/per_workingtree/test_workingtree.py 2018-01-15 06:07:39 +0000
+++ breezy/tests/per_workingtree/test_workingtree.py 2018-02-15 22:17:55 +0000
@@ -420,9 +420,9 @@
420 self.assertFalse(cloned_transport.has('deleted'))420 self.assertFalse(cloned_transport.has('deleted'))
421 self.assertTrue(cloned_transport.has('added'))421 self.assertTrue(cloned_transport.has('added'))
422 self.assertFalse(cloned_transport.has('notadded'))422 self.assertFalse(cloned_transport.has('notadded'))
423 self.assertIsNot(None, cloned.path2id('added'))423 self.assertTrue(cloned.is_versioned('added'))
424 self.assertEqual(None, cloned.path2id('deleted'))424 self.assertFalse(cloned.is_versioned('deleted'))
425 self.assertEqual(None, cloned.path2id('notadded'))425 self.assertFalse(cloned.is_versioned('notadded'))
426426
427 def test_basis_tree_returns_last_revision(self):427 def test_basis_tree_returns_last_revision(self):
428 wt = self.make_branch_and_tree('.')428 wt = self.make_branch_and_tree('.')
@@ -687,15 +687,12 @@
687 # merge_modified stores a map from file id to hash687 # merge_modified stores a map from file id to hash
688 tree = self.make_branch_and_tree('tree')688 tree = self.make_branch_and_tree('tree')
689 self.build_tree_contents([('tree/somefile', 'hello')])689 self.build_tree_contents([('tree/somefile', 'hello')])
690 tree.lock_write()690 with tree.lock_write():
691 try:
692 tree.add(['somefile'])691 tree.add(['somefile'])
693 d = {tree.path2id('somefile'): osutils.sha_string('hello')}692 d = {tree.path2id('somefile'): osutils.sha_string('hello')}
694 tree.set_merge_modified(d)693 tree.set_merge_modified(d)
695 mm = tree.merge_modified()694 mm = tree.merge_modified()
696 self.assertEqual(mm, d)695 self.assertEqual(mm, d)
697 finally:
698 tree.unlock()
699 mm = tree.merge_modified()696 mm = tree.merge_modified()
700 self.assertEqual(mm, d)697 self.assertEqual(mm, d)
701698
@@ -971,7 +968,6 @@
971 'nonexistant')968 'nonexistant')
972 self.build_tree(['file'])969 self.build_tree(['file'])
973 tree.add('file')970 tree.add('file')
974 file_id = tree.path2id('file')
975 tree.commit('foo')971 tree.commit('foo')
976 tree.remove('file')972 tree.remove('file')
977 self.assertRaises(errors.NoSuchFile, tree.get_file_sha1,973 self.assertRaises(errors.NoSuchFile, tree.get_file_sha1,
978974
=== modified file 'breezy/tests/test_bundle.py'
--- breezy/tests/test_bundle.py 2017-11-24 09:25:13 +0000
+++ breezy/tests/test_bundle.py 2018-02-15 22:17:55 +0000
@@ -219,14 +219,14 @@
219 self.assertEqual(btree.path2id("grandparent/parent"), "b")219 self.assertEqual(btree.path2id("grandparent/parent"), "b")
220 self.assertEqual(btree.path2id("grandparent/parent/file"), "c")220 self.assertEqual(btree.path2id("grandparent/parent/file"), "c")
221221
222 self.assertTrue(btree.path2id("grandparent2") is None)222 self.assertIs(btree.path2id("grandparent2"), None)
223 self.assertTrue(btree.path2id("grandparent2/parent") is None)223 self.assertIs(btree.path2id("grandparent2/parent"), None)
224 self.assertTrue(btree.path2id("grandparent2/parent/file") is None)224 self.assertIs(btree.path2id("grandparent2/parent/file"), None)
225225
226 btree.note_rename("grandparent", "grandparent2")226 btree.note_rename("grandparent", "grandparent2")
227 self.assertTrue(btree.old_path("grandparent") is None)227 self.assertIs(btree.old_path("grandparent"), None)
228 self.assertTrue(btree.old_path("grandparent/parent") is None)228 self.assertIs(btree.old_path("grandparent/parent"), None)
229 self.assertTrue(btree.old_path("grandparent/parent/file") is None)229 self.assertIs(btree.old_path("grandparent/parent/file"), None)
230230
231 self.assertEqual(btree.id2path("a"), "grandparent2")231 self.assertEqual(btree.id2path("a"), "grandparent2")
232 self.assertEqual(btree.id2path("b"), "grandparent2/parent")232 self.assertEqual(btree.id2path("b"), "grandparent2/parent")
@@ -351,7 +351,7 @@
351 self.assertEqual(btree.get_file(btree.id2path("c")).read(), "Hello\n")351 self.assertEqual(btree.get_file(btree.id2path("c")).read(), "Hello\n")
352 btree.note_deletion("grandparent/parent/file")352 btree.note_deletion("grandparent/parent/file")
353 self.assertTrue(btree.id2path("c") is None)353 self.assertTrue(btree.id2path("c") is None)
354 self.assertTrue(btree.path2id("grandparent/parent/file") is None)354 self.assertFalse(btree.is_versioned("grandparent/parent/file"))
355355
356 def sorted_ids(self, tree):356 def sorted_ids(self, tree):
357 ids = sorted(tree.all_file_ids())357 ids = sorted(tree.all_file_ids())
358358
=== modified file 'breezy/tests/test_commit.py'
--- breezy/tests/test_commit.py 2017-11-13 22:52:33 +0000
+++ breezy/tests/test_commit.py 2018-02-15 22:17:55 +0000
@@ -89,7 +89,6 @@
89 with open('hello', 'w') as f: f.write('hello world')89 with open('hello', 'w') as f: f.write('hello world')
90 wt.add('hello')90 wt.add('hello')
91 rev1 = wt.commit(message='add hello')91 rev1 = wt.commit(message='add hello')
92 file_id = wt.path2id('hello')
9392
94 with open('hello', 'w') as f: f.write('version 2')93 with open('hello', 'w') as f: f.write('version 2')
95 rev2 = wt.commit(message='commit 2')94 rev2 = wt.commit(message='commit 2')
@@ -616,12 +615,9 @@
616 tree.remove(['a', 'b'])615 tree.remove(['a', 'b'])
617 tree.commit('removed a', specific_files='a')616 tree.commit('removed a', specific_files='a')
618 basis = tree.basis_tree()617 basis = tree.basis_tree()
619 tree.lock_read()618 with tree.lock_read():
620 try:619 self.assertFalse(basis.is_versioned('a'))
621 self.assertIs(None, basis.path2id('a'))620 self.assertTrue(basis.is_versioned('b'))
622 self.assertFalse(basis.path2id('b') is None)
623 finally:
624 tree.unlock()
625621
626 def test_commit_saves_1ms_timestamp(self):622 def test_commit_saves_1ms_timestamp(self):
627 """Passing in a timestamp is saved with 1ms resolution"""623 """Passing in a timestamp is saved with 1ms resolution"""
628624
=== modified file 'breezy/tests/test_inv.py'
--- breezy/tests/test_inv.py 2018-01-14 05:14:06 +0000
+++ breezy/tests/test_inv.py 2018-02-15 22:17:55 +0000
@@ -622,7 +622,7 @@
622 inv.add(file1)622 inv.add(file1)
623 delta = [(u'path', None, 'file-id', None)]623 delta = [(u'path', None, 'file-id', None)]
624 res_inv = self.apply_delta(self, inv, delta, invalid_delta=False)624 res_inv = self.apply_delta(self, inv, delta, invalid_delta=False)
625 self.assertEqual(None, res_inv.path2id('path'))625 self.assertFalse(res_inv.is_versioned('path'))
626 self.assertRaises(errors.NoSuchId, res_inv.id2path, 'file-id')626 self.assertRaises(errors.NoSuchId, res_inv.id2path, 'file-id')
627627
628 def test_rename_file(self):628 def test_rename_file(self):
@@ -632,7 +632,7 @@
632 file2 = self.make_file_ie(name='path2', parent_id=inv.root.file_id)632 file2 = self.make_file_ie(name='path2', parent_id=inv.root.file_id)
633 delta = [(u'path', 'path2', 'file-id', file2)]633 delta = [(u'path', 'path2', 'file-id', file2)]
634 res_inv = self.apply_delta(self, inv, delta, invalid_delta=False)634 res_inv = self.apply_delta(self, inv, delta, invalid_delta=False)
635 self.assertEqual(None, res_inv.path2id('path'))635 self.assertFalse(res_inv.is_versioned('path'))
636 self.assertEqual('file-id', res_inv.path2id('path2'))636 self.assertEqual('file-id', res_inv.path2id('path2'))
637637
638 def test_replaced_at_new_path(self):638 def test_replaced_at_new_path(self):
@@ -676,7 +676,7 @@
676 res_inv = self.apply_delta(self, inv, delta, invalid_delta=False)676 res_inv = self.apply_delta(self, inv, delta, invalid_delta=False)
677 # The file should be accessible under the new path677 # The file should be accessible under the new path
678 self.assertEqual('file-id-1', res_inv.path2id('dir2/name1'))678 self.assertEqual('file-id-1', res_inv.path2id('dir2/name1'))
679 self.assertEqual(None, res_inv.path2id('dir2/name2'))679 self.assertFalse(res_inv.is_versioned('dir2/name2'))
680 self.assertEqual('file-id-2', res_inv.path2id('name2'))680 self.assertEqual('file-id-2', res_inv.path2id('name2'))
681681
682 def test_is_root(self):682 def test_is_root(self):
683683
=== modified file 'breezy/tests/test_merge.py'
--- breezy/tests/test_merge.py 2017-11-24 09:25:13 +0000
+++ breezy/tests/test_merge.py 2018-02-15 22:17:55 +0000
@@ -2300,7 +2300,7 @@
2300 wt.set_parent_ids(['D-id'])2300 wt.set_parent_ids(['D-id'])
2301 wt.branch.set_last_revision_info(3, 'D-id')2301 wt.branch.set_last_revision_info(3, 'D-id')
2302 wt.revert()2302 wt.revert()
2303 self.assertIs(None, wt.path2id('foo'))2303 self.assertFalse(wt.is_versioned('foo'))
2304 conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')2304 conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')
2305 self.assertEqual(0, conflicts)2305 self.assertEqual(0, conflicts)
2306 self.assertEqual('foo-id', wt.path2id('foo'))2306 self.assertEqual('foo-id', wt.path2id('foo'))
23072307
=== modified file 'breezy/tests/test_transform.py'
--- breezy/tests/test_transform.py 2017-11-12 20:07:32 +0000
+++ breezy/tests/test_transform.py 2018-02-15 22:17:55 +0000
@@ -920,7 +920,7 @@
920 self.assertEqual([NonDirectoryParent('Created directory', 'parent.new',920 self.assertEqual([NonDirectoryParent('Created directory', 'parent.new',
921 'parent-id')], cooked_conflicts)921 'parent-id')], cooked_conflicts)
922 tt.apply()922 tt.apply()
923 self.assertEqual(None, self.wt.path2id('parent'))923 self.assertFalse(self.wt.is_versioned('parent'))
924 self.assertEqual('parent-id', self.wt.path2id('parent.new'))924 self.assertEqual('parent-id', self.wt.path2id('parent.new'))
925925
926 def test_resolve_conflicts_wrong_new_parent_kind(self):926 def test_resolve_conflicts_wrong_new_parent_kind(self):
@@ -936,7 +936,7 @@
936 self.assertEqual({('non-directory parent', 'Created directory',936 self.assertEqual({('non-directory parent', 'Created directory',
937 'new-3')}, raw_conflicts)937 'new-3')}, raw_conflicts)
938 tt.apply()938 tt.apply()
939 self.assertEqual(None, self.wt.path2id('parent'))939 self.assertFalse(self.wt.is_versioned('parent'))
940 self.assertEqual('parent-id', self.wt.path2id('parent.new'))940 self.assertEqual('parent-id', self.wt.path2id('parent.new'))
941941
942 def test_resolve_conflicts_wrong_parent_kind_unversioned(self):942 def test_resolve_conflicts_wrong_parent_kind_unversioned(self):
@@ -950,8 +950,8 @@
950 tt.create_file('contents', parent_id)950 tt.create_file('contents', parent_id)
951 resolve_conflicts(tt)951 resolve_conflicts(tt)
952 tt.apply()952 tt.apply()
953 self.assertIs(None, self.wt.path2id('parent'))953 self.assertFalse(self.wt.is_versioned('parent'))
954 self.assertIs(None, self.wt.path2id('parent.new'))954 self.assertFalse(self.wt.is_versioned('parent.new'))
955955
956 def test_resolve_conflicts_missing_parent(self):956 def test_resolve_conflicts_missing_parent(self):
957 wt = self.make_branch_and_tree('.')957 wt = self.make_branch_and_tree('.')
@@ -2896,7 +2896,7 @@
2896 preview.unversion_file(preview.trans_id_file_id('deleted-id'))2896 preview.unversion_file(preview.trans_id_file_id('deleted-id'))
2897 preview_tree = preview.get_preview_tree()2897 preview_tree = preview.get_preview_tree()
2898 self.assertEqual('unchanged-id', preview_tree.path2id('unchanged'))2898 self.assertEqual('unchanged-id', preview_tree.path2id('unchanged'))
2899 self.assertIs(None, preview_tree.path2id('deleted'))2899 self.assertFalse(preview_tree.is_versioned('deleted'))
29002900
2901 def test_path2id_created(self):2901 def test_path2id_created(self):
2902 tree = self.make_branch_and_tree('tree')2902 tree = self.make_branch_and_tree('tree')
@@ -2921,7 +2921,7 @@
2921 preview.adjust_path('child', new_parent,2921 preview.adjust_path('child', new_parent,
2922 preview.trans_id_file_id('child-id'))2922 preview.trans_id_file_id('child-id'))
2923 preview_tree = preview.get_preview_tree()2923 preview_tree = preview.get_preview_tree()
2924 self.assertIs(None, preview_tree.path2id('old_parent/child'))2924 self.assertFalse(preview_tree.is_versioned('old_parent/child'))
2925 self.assertEqual('child-id', preview_tree.path2id('new_parent/child'))2925 self.assertEqual('child-id', preview_tree.path2id('new_parent/child'))
29262926
2927 def test_path2id_renamed_parent(self):2927 def test_path2id_renamed_parent(self):
@@ -2934,7 +2934,7 @@
2934 preview.adjust_path('new_name', preview.root,2934 preview.adjust_path('new_name', preview.root,
2935 preview.trans_id_file_id('parent-id'))2935 preview.trans_id_file_id('parent-id'))
2936 preview_tree = preview.get_preview_tree()2936 preview_tree = preview.get_preview_tree()
2937 self.assertIs(None, preview_tree.path2id('old_name/child'))2937 self.assertFalse(preview_tree.is_versioned('old_name/child'))
2938 self.assertEqual('child-id', preview_tree.path2id('new_name/child'))2938 self.assertEqual('child-id', preview_tree.path2id('new_name/child'))
29392939
2940 def assertMatchingIterEntries(self, tt, specific_file_ids=None):2940 def assertMatchingIterEntries(self, tt, specific_file_ids=None):
29412941
=== modified file 'breezy/tests/test_uncommit.py'
--- breezy/tests/test_uncommit.py 2017-06-10 00:17:06 +0000
+++ breezy/tests/test_uncommit.py 2018-02-15 22:17:55 +0000
@@ -51,7 +51,7 @@
51 # The file should not be removed51 # The file should not be removed
52 self.assertPathExists('tree/two')52 self.assertPathExists('tree/two')
53 # And it should still be listed as added53 # And it should still be listed as added
54 self.assertIsNot(None, tree.path2id('two'))54 self.assertTrue(tree.is_versioned('two'))
5555
56 def test_uncommit_bound(self):56 def test_uncommit_bound(self):
57 tree, history = self.make_linear_tree()57 tree, history = self.make_linear_tree()
5858
=== modified file 'breezy/tests/test_upstream_import.py'
--- breezy/tests/test_upstream_import.py 2017-11-12 20:07:32 +0000
+++ breezy/tests/test_upstream_import.py 2018-02-15 22:17:55 +0000
@@ -233,8 +233,8 @@
233 tree.lock_write()233 tree.lock_write()
234 try:234 try:
235 importer(tree, archive_file)235 importer(tree, archive_file)
236 self.assertTrue(tree.path2id('README') is not None)236 self.assertTrue(tree.is_versioned('README'))
237 self.assertTrue(tree.path2id('FEEDME') is not None)237 self.assertTrue(tree.is_versioned('FEEDME'))
238 self.assertTrue(os.path.isfile(tree.abspath('README')))238 self.assertTrue(os.path.isfile(tree.abspath('README')))
239 self.assertEqual(tree.stored_kind('README'), 'file')239 self.assertEqual(tree.stored_kind('README'), 'file')
240 self.assertEqual(tree.stored_kind('FEEDME'), 'file')240 self.assertEqual(tree.stored_kind('FEEDME'), 'file')
@@ -246,7 +246,7 @@
246 warnings.simplefilter('ignore')246 warnings.simplefilter('ignore')
247 archive_file = self.make_archive2(builder, subdir)247 archive_file = self.make_archive2(builder, subdir)
248 importer(tree, archive_file)248 importer(tree, archive_file)
249 self.assertTrue(tree.path2id('README') is not None)249 self.assertTrue(tree.is_versioned('README'))
250 # Ensure the second version of the file is used.250 # Ensure the second version of the file is used.
251 self.assertEqual(tree.get_file_text('README'), 'Wow?')251 self.assertEqual(tree.get_file_text('README'), 'Wow?')
252 self.assertTrue(not os.path.exists(tree.abspath('FEEDME')))252 self.assertTrue(not os.path.exists(tree.abspath('FEEDME')))
@@ -258,13 +258,13 @@
258 tar_file = self.make_messed_tar()258 tar_file = self.make_messed_tar()
259 tree = BzrDir.create_standalone_workingtree('tree')259 tree = BzrDir.create_standalone_workingtree('tree')
260 import_tar(tree, tar_file)260 import_tar(tree, tar_file)
261 self.assertTrue(tree.path2id('project-0.1/README') is not None)261 self.assertTrue(tree.is_versioned('project-0.1/README'))
262262
263 def test_untar_gzip(self):263 def test_untar_gzip(self):
264 tar_file = self.make_tar(mode='w:gz')264 tar_file = self.make_tar(mode='w:gz')
265 tree = BzrDir.create_standalone_workingtree('tree')265 tree = BzrDir.create_standalone_workingtree('tree')
266 import_tar(tree, tar_file)266 import_tar(tree, tar_file)
267 self.assertTrue(tree.path2id('README') is not None)267 self.assertTrue(tree.is_versioned('README'))
268268
269 def test_no_crash_with_bzrdir(self):269 def test_no_crash_with_bzrdir(self):
270 tar_file = self.make_tar_with_bzrdir()270 tar_file = self.make_tar_with_bzrdir()
271271
=== modified file 'breezy/tests/test_workingtree_4.py'
--- breezy/tests/test_workingtree_4.py 2017-11-19 18:35:20 +0000
+++ breezy/tests/test_workingtree_4.py 2018-02-15 22:17:55 +0000
@@ -303,7 +303,7 @@
303 state.update_basis_by_delta = log_update_basis_by_delta303 state.update_basis_by_delta = log_update_basis_by_delta
304 basis = tree.basis_tree()304 basis = tree.basis_tree()
305 self.assertEqual('a-id', basis.path2id('a'))305 self.assertEqual('a-id', basis.path2id('a'))
306 self.assertEqual(None, basis.path2id('b'))306 self.assertFalse(basis.is_versioned('b'))
307 def fail_set_parent_trees(trees, ghosts):307 def fail_set_parent_trees(trees, ghosts):
308 raise AssertionError('dirstate.set_parent_trees() was called')308 raise AssertionError('dirstate.set_parent_trees() was called')
309 state.set_parent_trees = fail_set_parent_trees309 state.set_parent_trees = fail_set_parent_trees
@@ -341,7 +341,7 @@
341 # Re-open with the new reference341 # Re-open with the new reference
342 wt = wt.controldir.open_workingtree()342 wt = wt.controldir.open_workingtree()
343 wt.set_parent_trees([('C', b_c.repository.revision_tree('C'))])343 wt.set_parent_trees([('C', b_c.repository.revision_tree('C'))])
344 self.assertEqual(None, wt.basis_tree().path2id('b'))344 self.assertFalse(wt.basis_tree().is_versioned('b'))
345345
346 def test_new_dirstate_on_new_lock(self):346 def test_new_dirstate_on_new_lock(self):
347 # until we have detection for when a dirstate can be reused, we347 # until we have detection for when a dirstate can be reused, we
348348
=== modified file 'breezy/tree.py'
--- breezy/tree.py 2018-01-12 08:52:43 +0000
+++ breezy/tree.py 2018-02-15 22:17:55 +0000
@@ -533,6 +533,14 @@
533 """Return the id for path in this tree."""533 """Return the id for path in this tree."""
534 raise NotImplementedError(self.path2id)534 raise NotImplementedError(self.path2id)
535535
536 def is_versioned(self, path):
537 """Check whether path is versioned.
538
539 :param path: Path to check
540 :return: boolean
541 """
542 return (self.path2id(path) is not None)
543
536 def paths2ids(self, paths, trees=[], require_versioned=True):544 def paths2ids(self, paths, trees=[], require_versioned=True):
537 """Return all the ids that can be reached by walking from paths.545 """Return all the ids that can be reached by walking from paths.
538546
539547
=== modified file 'breezy/upstream_import.py'
--- breezy/upstream_import.py 2017-09-26 00:55:04 +0000
+++ breezy/upstream_import.py 2018-02-15 22:17:55 +0000
@@ -182,7 +182,7 @@
182182
183183
184def do_directory(tt, trans_id, tree, relative_path, path):184def do_directory(tt, trans_id, tree, relative_path, path):
185 if isdir(path) and tree.path2id(relative_path) is not None:185 if isdir(path) and tree.is_versioned(relative_path):
186 tt.cancel_deletion(trans_id)186 tt.cancel_deletion(trans_id)
187 else:187 else:
188 tt.create_directory(trans_id)188 tt.create_directory(trans_id)
189189
=== modified file 'breezy/workingtree.py'
--- breezy/workingtree.py 2018-01-15 06:07:39 +0000
+++ breezy/workingtree.py 2018-02-15 22:17:55 +0000
@@ -813,7 +813,7 @@
813 # checkout in a subdirectory. This can be avoided by not adding813 # checkout in a subdirectory. This can be avoided by not adding
814 # it. mbp 20070306814 # it. mbp 20070306
815815
816 def extract(self, file_id, format=None):816 def extract(self, path, file_id=None, format=None):
817 """Extract a subtree from this tree.817 """Extract a subtree from this tree.
818818
819 A new branch will be created, relative to the path for this tree.819 A new branch will be created, relative to the path for this tree.

Subscribers

People subscribed via source and target branches