Merge lp:~jelmer/brz/per-tree-git-revtree into lp:brz

Proposed by Jelmer Vernooij on 2018-09-09
Status: Merged
Approved by: Jelmer Vernooij on 2018-09-15
Approved revision: 7105
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/per-tree-git-revtree
Merge into: lp:brz
Diff against target: 470 lines (+139/-58)
9 files modified
breezy/git/mapping.py (+1/-1)
breezy/git/tests/test_mapping.py (+1/-1)
breezy/git/tree.py (+69/-23)
breezy/tests/per_tree/__init__.py (+15/-3)
breezy/tests/per_tree/test_list_files.py (+1/-1)
breezy/tests/per_tree/test_path_content_summary.py (+6/-2)
breezy/tests/per_tree/test_test_trees.py (+3/-3)
breezy/tests/per_tree/test_walkdirs.py (+30/-23)
breezy/tests/test_selftest.py (+13/-1)
To merge this branch: bzr merge lp:~jelmer/brz/per-tree-git-revtree
Reviewer Review Type Date Requested Status
Martin Packman 2018-09-09 Approve on 2018-09-14
Review via email: mp+354530@code.launchpad.net

Commit message

Run per_tree tests against GitRevisionTree.

Description of the change

Run per_tree tests against GitRevisionTree.

To post a comment you must log in.
Martin Packman (gz) wrote :

Changes look reasonable enough to me.

review: Approve
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/475/

The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/481/

The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/482/

lp:~jelmer/brz/per-tree-git-revtree updated on 2018-09-15
7105. By Jelmer Vernooij on 2018-09-15

Fix scenarios test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/git/mapping.py'
--- breezy/git/mapping.py 2018-08-04 17:32:58 +0000
+++ breezy/git/mapping.py 2018-09-15 00:21:08 +0000
@@ -429,7 +429,7 @@
429 parents.append(lookup_parent_revid(p))429 parents.append(lookup_parent_revid(p))
430 except KeyError:430 except KeyError:
431 parents.append(self.revision_id_foreign_to_bzr(p))431 parents.append(self.revision_id_foreign_to_bzr(p))
432 rev.parent_ids = tuple(parents)432 rev.parent_ids = list(parents)
433 unknown_extra_fields = []433 unknown_extra_fields = []
434 extra_lines = []434 extra_lines = []
435 for k, v in commit.extra:435 for k, v in commit.extra:
436436
=== modified file 'breezy/git/tests/test_mapping.py'
--- breezy/git/tests/test_mapping.py 2018-08-04 17:32:58 +0000
+++ breezy/git/tests/test_mapping.py 2018-09-15 00:21:08 +0000
@@ -117,7 +117,7 @@
117 self.assertEqual(u"Committer", rev.committer)117 self.assertEqual(u"Committer", rev.committer)
118 self.assertEqual(u"Author", rev.properties[u'author'])118 self.assertEqual(u"Author", rev.properties[u'author'])
119 self.assertEqual(300, rev.timezone)119 self.assertEqual(300, rev.timezone)
120 self.assertEqual((), rev.parent_ids)120 self.assertEqual([], rev.parent_ids)
121 self.assertEqual("5", rev.properties[u'author-timestamp'])121 self.assertEqual("5", rev.properties[u'author-timestamp'])
122 self.assertEqual("180", rev.properties[u'author-timezone'])122 self.assertEqual("180", rev.properties[u'author-timezone'])
123 self.assertEqual(b"git-v1:" + c.id, rev.revision_id)123 self.assertEqual(b"git-v1:" + c.id, rev.revision_id)
124124
=== modified file 'breezy/git/tree.py'
--- breezy/git/tree.py 2018-08-18 21:01:10 +0000
+++ breezy/git/tree.py 2018-09-15 00:21:08 +0000
@@ -19,6 +19,7 @@
1919
20from __future__ import absolute_import20from __future__ import absolute_import
2121
22from collections import deque
22import errno23import errno
23from io import BytesIO24from io import BytesIO
24import os25import os
@@ -289,7 +290,7 @@
289 try:290 try:
290 revid = self.get_file_revision(path, file_id)291 revid = self.get_file_revision(path, file_id)
291 except KeyError:292 except KeyError:
292 raise _mod_tree.FileTimestampUnavailable(path)293 raise errors.NoSuchFile(path)
293 try:294 try:
294 rev = self._repository.get_revision(revid)295 rev = self._repository.get_revision(revid)
295 except errors.NoSuchRevision:296 except errors.NoSuchRevision:
@@ -311,13 +312,15 @@
311 def path2id(self, path):312 def path2id(self, path):
312 if self.mapping.is_special_file(path):313 if self.mapping.is_special_file(path):
313 return None314 return None
315 if not self.is_versioned(path):
316 return None
314 return self._fileid_map.lookup_file_id(osutils.safe_unicode(path))317 return self._fileid_map.lookup_file_id(osutils.safe_unicode(path))
315318
316 def all_file_ids(self):319 def all_file_ids(self):
317 return set(self._fileid_map.all_file_ids())320 return {self.path2id(path) for path in self.all_versioned_paths()}
318321
319 def all_versioned_paths(self):322 def all_versioned_paths(self):
320 ret = set()323 ret = {u''}
321 todo = [(self.store, b'', self.tree)]324 todo = [(self.store, b'', self.tree)]
322 while todo:325 while todo:
323 (store, path, tree_id) = todo.pop()326 (store, path, tree_id) = todo.pop()
@@ -326,10 +329,9 @@
326 tree = store[tree_id]329 tree = store[tree_id]
327 for name, mode, hexsha in tree.items():330 for name, mode, hexsha in tree.items():
328 subpath = posixpath.join(path, name)331 subpath = posixpath.join(path, name)
332 ret.add(subpath.decode('utf-8'))
329 if stat.S_ISDIR(mode):333 if stat.S_ISDIR(mode):
330 todo.append((store, subpath, hexsha))334 todo.append((store, subpath, hexsha))
331 else:
332 ret.add(subpath.decode('utf-8'))
333 return ret335 return ret
334336
335 def get_root_id(self):337 def get_root_id(self):
@@ -393,32 +395,33 @@
393 if mode is None: # Root395 if mode is None: # Root
394 root_ie = self._get_dir_ie(b"", None)396 root_ie = self._get_dir_ie(b"", None)
395 else:397 else:
396 parent_path = posixpath.dirname(from_dir.encode("utf-8"))398 parent_path = posixpath.dirname(from_dir)
397 parent_id = self._fileid_map.lookup_file_id(parent_path)399 parent_id = self._fileid_map.lookup_file_id(parent_path)
398 if mode_kind(mode) == 'directory':400 if mode_kind(mode) == 'directory':
399 root_ie = self._get_dir_ie(from_dir.encode("utf-8"), parent_id)401 root_ie = self._get_dir_ie(from_dir.encode("utf-8"), parent_id)
400 else:402 else:
401 root_ie = self._get_file_ie(store, from_dir.encode("utf-8"),403 root_ie = self._get_file_ie(store, from_dir.encode("utf-8"),
402 posixpath.basename(from_dir), mode, hexsha)404 posixpath.basename(from_dir), mode, hexsha)
403 if from_dir != "" or include_root:405 if include_root:
404 yield (from_dir, "V", root_ie.kind, root_ie.file_id, root_ie)406 yield (from_dir, "V", root_ie.kind, root_ie.file_id, root_ie)
405 todo = []407 todo = []
406 if root_ie.kind == 'directory':408 if root_ie.kind == 'directory':
407 todo.append((store, from_dir.encode("utf-8"), hexsha, root_ie.file_id))409 todo.append((store, from_dir.encode("utf-8"), b"", hexsha, root_ie.file_id))
408 while todo:410 while todo:
409 (store, path, hexsha, parent_id) = todo.pop()411 (store, path, relpath, hexsha, parent_id) = todo.pop()
410 tree = store[hexsha]412 tree = store[hexsha]
411 for name, mode, hexsha in tree.iteritems():413 for name, mode, hexsha in tree.iteritems():
412 if self.mapping.is_special_file(name):414 if self.mapping.is_special_file(name):
413 continue415 continue
414 child_path = posixpath.join(path, name)416 child_path = posixpath.join(path, name)
417 child_relpath = posixpath.join(relpath, name)
415 if stat.S_ISDIR(mode):418 if stat.S_ISDIR(mode):
416 ie = self._get_dir_ie(child_path, parent_id)419 ie = self._get_dir_ie(child_path, parent_id)
417 if recursive:420 if recursive:
418 todo.append((store, child_path, hexsha, ie.file_id))421 todo.append((store, child_path, child_relpath, hexsha, ie.file_id))
419 else:422 else:
420 ie = self._get_file_ie(store, child_path, name, mode, hexsha, parent_id)423 ie = self._get_file_ie(store, child_path, name, mode, hexsha, parent_id)
421 yield child_path.decode('utf-8'), "V", ie.kind, ie.file_id, ie424 yield child_relpath.decode('utf-8'), "V", ie.kind, ie.file_id, ie
422425
423 def _get_file_ie(self, store, path, name, mode, hexsha, parent_id):426 def _get_file_ie(self, store, path, name, mode, hexsha, parent_id):
424 if not isinstance(path, bytes):427 if not isinstance(path, bytes):
@@ -449,7 +452,7 @@
449 def iter_child_entries(self, path, file_id=None):452 def iter_child_entries(self, path, file_id=None):
450 (store, mode, tree_sha) = self._lookup_path(path)453 (store, mode, tree_sha) = self._lookup_path(path)
451454
452 if not stat.S_ISDIR(mode):455 if mode is not None and not stat.S_ISDIR(mode):
453 return456 return
454457
455 encoded_path = path.encode('utf-8')458 encoded_path = path.encode('utf-8')
@@ -476,25 +479,38 @@
476 specific_files = None479 specific_files = None
477 else:480 else:
478 specific_files = set([p.encode('utf-8') for p in specific_files])481 specific_files = set([p.encode('utf-8') for p in specific_files])
479 todo = [(self.store, b"", self.tree, None)]482 todo = deque([(self.store, b"", self.tree, self.get_root_id())])
483 if specific_files is None or u"" in specific_files:
484 yield u"", self._get_dir_ie(b"", None)
480 while todo:485 while todo:
481 store, path, tree_sha, parent_id = todo.pop()486 store, path, tree_sha, parent_id = todo.popleft()
482 ie = self._get_dir_ie(path, parent_id)
483 if specific_files is None or path in specific_files:
484 yield path.decode("utf-8"), ie
485 tree = store[tree_sha]487 tree = store[tree_sha]
488 extradirs = []
486 for name, mode, hexsha in tree.iteritems():489 for name, mode, hexsha in tree.iteritems():
487 if self.mapping.is_special_file(name):490 if self.mapping.is_special_file(name):
488 continue491 continue
489 child_path = posixpath.join(path, name)492 child_path = posixpath.join(path, name)
493 child_path_decoded = child_path.decode('utf-8')
490 if stat.S_ISDIR(mode):494 if stat.S_ISDIR(mode):
491 if (specific_files is None or495 if (specific_files is None or
492 any(filter(lambda p: p.startswith(child_path), specific_files))):496 any(filter(lambda p: p.startswith(child_path), specific_files))):
493 todo.append((store, child_path, hexsha, ie.file_id))497 extradirs.append(
494 elif specific_files is None or child_path in specific_files:498 (store, child_path, hexsha, self.path2id(child_path_decoded)))
495 yield (child_path.decode("utf-8"),499 if specific_files is None or child_path in specific_files:
496 self._get_file_ie(store, child_path, name, mode, hexsha,500 if stat.S_ISDIR(mode):
497 ie.file_id))501 yield (child_path_decoded,
502 self._get_dir_ie(child_path, parent_id))
503 else:
504 yield (child_path_decoded,
505 self._get_file_ie(store, child_path, name, mode,
506 hexsha, parent_id))
507 todo.extendleft(reversed(extradirs))
508
509 def iter_references(self):
510 if self.supports_tree_reference():
511 for path, entry in self.iter_entries_by_dir():
512 if entry.kind == 'tree-reference':
513 yield path, self.mapping.generate_file_id(b'')
498514
499 def get_revision_id(self):515 def get_revision_id(self):
500 """See RevisionTree.get_revision_id."""516 """See RevisionTree.get_revision_id."""
@@ -509,6 +525,12 @@
509 (store, mode, hexsha) = self._lookup_path(path)525 (store, mode, hexsha) = self._lookup_path(path)
510 return ("GIT", hexsha)526 return ("GIT", hexsha)
511527
528 def get_file_size(self, path, file_id=None):
529 (store, mode, hexsha) = self._lookup_path(path)
530 if stat.S_ISREG(mode):
531 return len(store[hexsha].data)
532 return None
533
512 def get_file_text(self, path, file_id=None):534 def get_file_text(self, path, file_id=None):
513 """See RevisionTree.get_file_text."""535 """See RevisionTree.get_file_text."""
514 (store, mode, hexsha) = self._lookup_path(path)536 (store, mode, hexsha) = self._lookup_path(path)
@@ -551,7 +573,7 @@
551 contents = store[hexsha].data573 contents = store[hexsha].data
552 return (kind, len(contents), executable, osutils.sha_string(contents))574 return (kind, len(contents), executable, osutils.sha_string(contents))
553 elif kind == 'symlink':575 elif kind == 'symlink':
554 return (kind, None, None, store[hexsha].data)576 return (kind, None, None, store[hexsha].data.decode('utf-8'))
555 elif kind == 'tree-reference':577 elif kind == 'tree-reference':
556 nested_repo = self._get_nested_repository(path)578 nested_repo = self._get_nested_repository(path)
557 return (kind, None, None,579 return (kind, None, None,
@@ -605,6 +627,30 @@
605 for key, line in annotator.annotate_flat(this_key)]627 for key, line in annotator.annotate_flat(this_key)]
606 return annotations628 return annotations
607629
630 def _get_rules_searcher(self, default_searcher):
631 return default_searcher
632
633 def walkdirs(self, prefix=u""):
634 (store, mode, hexsha) = self._lookup_path(prefix)
635 todo = deque([(store, prefix.encode('utf-8'), hexsha, self.path2id(prefix))])
636 while todo:
637 store, path, tree_sha, parent_id = todo.popleft()
638 path_decoded = path.decode('utf-8')
639 tree = store[tree_sha]
640 children = []
641 for name, mode, hexsha in tree.iteritems():
642 if self.mapping.is_special_file(name):
643 continue
644 child_path = posixpath.join(path, name)
645 file_id = self.path2id(child_path.decode('utf-8'))
646 if stat.S_ISDIR(mode):
647 todo.append((store, child_path, hexsha, file_id))
648 children.append(
649 (child_path.decode('utf-8'), name.decode('utf-8'),
650 mode_kind(mode), None,
651 file_id, mode_kind(mode)))
652 yield (path_decoded, parent_id), children
653
608654
609def tree_delta_from_git_changes(changes, mapping,655def tree_delta_from_git_changes(changes, mapping,
610 fileid_maps, specific_files=None,656 fileid_maps, specific_files=None,
611657
=== modified file 'breezy/tests/per_tree/__init__.py'
--- breezy/tests/per_tree/__init__.py 2018-09-14 14:13:30 +0000
+++ breezy/tests/per_tree/__init__.py 2018-09-15 00:21:08 +0000
@@ -31,6 +31,8 @@
31 transform,31 transform,
32 transport,32 transport,
33 )33 )
34from breezy.git.tree import GitRevisionTree
35from breezy.git.workingtree import GitWorkingTreeFormat
34from breezy.tests.per_controldir.test_controldir import TestCaseWithControlDir36from breezy.tests.per_controldir.test_controldir import TestCaseWithControlDir
35from breezy.tests.per_workingtree import (37from breezy.tests.per_workingtree import (
36 make_scenarios as wt_make_scenarios,38 make_scenarios as wt_make_scenarios,
@@ -91,10 +93,15 @@
9193
92class TestTreeImplementationSupport(tests.TestCaseWithTransport):94class TestTreeImplementationSupport(tests.TestCaseWithTransport):
9395
96 def test_revision_tree_from_workingtree_bzr(self):
97 tree = self.make_branch_and_tree('.', format='bzr')
98 tree = revision_tree_from_workingtree(self, tree)
99 self.assertIsInstance(tree, RevisionTree)
100
94 def test_revision_tree_from_workingtree(self):101 def test_revision_tree_from_workingtree(self):
95 tree = self.make_branch_and_tree('.')102 tree = self.make_branch_and_tree('.', format='git')
96 tree = revision_tree_from_workingtree(self, tree)103 tree = revision_tree_from_workingtree(self, tree)
97 self.assertIsInstance(tree, RevisionTree)104 self.assertIsInstance(tree, GitRevisionTree)
98105
99106
100class TestCaseWithTree(TestCaseWithControlDir):107class TestCaseWithTree(TestCaseWithControlDir):
@@ -279,6 +286,8 @@
279 DirStateRevisionTree by committing a working tree to create the revision286 DirStateRevisionTree by committing a working tree to create the revision
280 tree.287 tree.
281 """288 """
289 # TODO(jelmer): Test MemoryTree here
290 # TODO(jelmer): Test GitMemoryTree here
282 scenarios = wt_make_scenarios(transport_server, transport_readonly_server,291 scenarios = wt_make_scenarios(transport_server, transport_readonly_server,
283 formats)292 formats)
284 # now adjust the scenarios and add the non-working-tree tree scenarios.293 # now adjust the scenarios and add the non-working-tree tree scenarios.
@@ -290,6 +299,9 @@
290 scenarios.append((RevisionTree.__name__,299 scenarios.append((RevisionTree.__name__,
291 create_tree_scenario(transport_server, transport_readonly_server,300 create_tree_scenario(transport_server, transport_readonly_server,
292 workingtree_format, revision_tree_from_workingtree,)))301 workingtree_format, revision_tree_from_workingtree,)))
302 scenarios.append((GitRevisionTree.__name__,
303 create_tree_scenario(transport_server, transport_readonly_server,
304 GitWorkingTreeFormat(), revision_tree_from_workingtree,)))
293305
294 # also test WorkingTree4/5's RevisionTree implementation which is306 # also test WorkingTree4/5's RevisionTree implementation which is
295 # specialised.307 # specialised.
@@ -347,7 +359,7 @@
347 'walkdirs',359 'walkdirs',
348 ]360 ]
349 submod_tests = loader.loadTestsFromModuleNames(361 submod_tests = loader.loadTestsFromModuleNames(
350 ['breezy.tests.per_tree.test_' + name362 [__name__ + '.test_' + name
351 for name in per_tree_mod_names])363 for name in per_tree_mod_names])
352 scenarios = make_scenarios(364 scenarios = make_scenarios(
353 tests.default_transport,365 tests.default_transport,
354366
=== modified file 'breezy/tests/per_tree/test_list_files.py'
--- breezy/tests/per_tree/test_list_files.py 2018-02-26 13:36:15 +0000
+++ breezy/tests/per_tree/test_list_files.py 2018-09-15 00:21:08 +0000
@@ -92,7 +92,7 @@
92 try:92 try:
93 actual = [(path, status, kind, file_id)93 actual = [(path, status, kind, file_id)
94 for path, status, kind, file_id, ie in94 for path, status, kind, file_id, ie in
95 tree.list_files(from_dir='b')]95 tree.list_files(from_dir=u'b')]
96 finally:96 finally:
97 tree.unlock()97 tree.unlock()
98 self.assertEqual(expected, actual)98 self.assertEqual(expected, actual)
9999
=== modified file 'breezy/tests/per_tree/test_path_content_summary.py'
--- breezy/tests/per_tree/test_path_content_summary.py 2018-07-27 18:57:21 +0000
+++ breezy/tests/per_tree/test_path_content_summary.py 2018-09-15 00:21:08 +0000
@@ -142,8 +142,12 @@
142 tree = self.make_branch_and_tree('tree')142 tree = self.make_branch_and_tree('tree')
143 self.build_tree(['tree/path/'])143 self.build_tree(['tree/path/'])
144 tree.add(['path'])144 tree.add(['path'])
145 summary = self._convert_tree(tree).path_content_summary('path')145 converted_tree = self._convert_tree(tree)
146 self.assertEqual(('directory', None, None, None), summary)146 summary = converted_tree.path_content_summary('path')
147 if converted_tree.has_versioned_directories() or converted_tree.has_filename('path'):
148 self.assertEqual(('directory', None, None, None), summary)
149 else:
150 self.assertEqual(('missing', None, None, None), summary)
147151
148 def test_tree_content_summary(self):152 def test_tree_content_summary(self):
149 tree = self.make_branch_and_tree('tree')153 tree = self.make_branch_and_tree('tree')
150154
=== modified file 'breezy/tests/per_tree/test_test_trees.py'
--- breezy/tests/per_tree/test_test_trees.py 2018-07-27 18:57:21 +0000
+++ breezy/tests/per_tree/test_test_trees.py 2018-09-15 00:21:08 +0000
@@ -141,7 +141,7 @@
141 self.addCleanup(tree.unlock)141 self.addCleanup(tree.unlock)
142 self.assertEqual([], tree.get_parent_ids())142 self.assertEqual([], tree.get_parent_ids())
143 self.assertEqual([], tree.conflicts())143 self.assertEqual([], tree.conflicts())
144 if tree.has_versioned_directories():144 if tree.has_versioned_directories() or not tree.has_filename('b'):
145 self.assertEqual([], list(tree.unknowns()))145 self.assertEqual([], list(tree.unknowns()))
146 else:146 else:
147 self.assertEqual(['b'], list(tree.unknowns()))147 self.assertEqual(['b'], list(tree.unknowns()))
@@ -169,7 +169,7 @@
169 self.addCleanup(tree.unlock)169 self.addCleanup(tree.unlock)
170 self.assertEqual([], tree.get_parent_ids())170 self.assertEqual([], tree.get_parent_ids())
171 self.assertEqual([], tree.conflicts())171 self.assertEqual([], tree.conflicts())
172 if tree.has_versioned_directories():172 if tree.has_versioned_directories() or not tree.has_filename('1top-dir/1dir-in-1topdir'):
173 self.assertEqual([], list(tree.unknowns()))173 self.assertEqual([], list(tree.unknowns()))
174 else:174 else:
175 self.assertEqual(['1top-dir/1dir-in-1topdir'], list(tree.unknowns()))175 self.assertEqual(['1top-dir/1dir-in-1topdir'], list(tree.unknowns()))
@@ -218,7 +218,7 @@
218 self.addCleanup(tree.unlock)218 self.addCleanup(tree.unlock)
219 self.assertEqual([], tree.get_parent_ids())219 self.assertEqual([], tree.get_parent_ids())
220 self.assertEqual([], tree.conflicts())220 self.assertEqual([], tree.conflicts())
221 if tree.has_versioned_directories():221 if tree.has_versioned_directories() or not tree.has_filename('1top-dir/1dir-in-1topdir'):
222 self.assertEqual([], list(tree.unknowns()))222 self.assertEqual([], list(tree.unknowns()))
223 else:223 else:
224 self.assertEqual(['1top-dir/1dir-in-1topdir'], list(tree.unknowns()))224 self.assertEqual(['1top-dir/1dir-in-1topdir'], list(tree.unknowns()))
225225
=== modified file 'breezy/tests/per_tree/test_walkdirs.py'
--- breezy/tests/per_tree/test_walkdirs.py 2018-03-17 21:00:51 +0000
+++ breezy/tests/per_tree/test_walkdirs.py 2018-09-15 00:21:08 +0000
@@ -19,6 +19,7 @@
19import os19import os
2020
21from breezy import tests21from breezy import tests
22from breezy.mutabletree import MutableTree
22from breezy.osutils import has_symlinks23from breezy.osutils import has_symlinks
23from breezy.tests.per_tree import TestCaseWithTree24from breezy.tests.per_tree import TestCaseWithTree
2425
@@ -26,36 +27,42 @@
26class TestWalkdirs(TestCaseWithTree):27class TestWalkdirs(TestCaseWithTree):
2728
28 def get_all_subdirs_expected(self, tree, symlinks):29 def get_all_subdirs_expected(self, tree, symlinks):
29 dirblocks = [30 empty_dirs_present = (tree.has_versioned_directories() or
30 (('', tree.path2id('')),31 isinstance(tree, MutableTree))
31 [('0file', '0file', 'file', None, tree.path2id('0file'), 'file'),32 empty_dirs_are_versioned = tree.has_versioned_directories()
32 ('1top-dir', '1top-dir', 'directory', None,33 dirblocks = {}
33 tree.path2id('1top-dir'), 'directory'),34
34 (u'2utf\u1234file', u'2utf\u1234file', 'file', None,35 dirblocks[''] = [
35 tree.path2id(u'2utf\u1234file'), 'file'),36 ('0file', '0file', 'file', None,
36 ]),37 tree.path2id('0file'), 'file'),
37 (('1top-dir', tree.path2id('1top-dir')),38 ('1top-dir', '1top-dir', 'directory', None,
38 [('1top-dir/0file-in-1topdir', '0file-in-1topdir',39 tree.path2id('1top-dir'), 'directory'),
39 'file', None, tree.path2id('1top-dir/0file-in-1topdir'), 'file'),40 (u'2utf\u1234file', u'2utf\u1234file', 'file', None,
40 ('1top-dir/1dir-in-1topdir', '1dir-in-1topdir',41 tree.path2id(u'2utf\u1234file'), 'file')]
41 'directory',42
42 None if tree.has_versioned_directories() else os.stat(tree.abspath('1top-dir/1dir-in-1topdir')),43 dirblocks['1top-dir'] = [
44 ('1top-dir/0file-in-1topdir', '0file-in-1topdir',
45 'file', None, tree.path2id('1top-dir/0file-in-1topdir'), 'file')]
46 if empty_dirs_present:
47 dirblocks['1top-dir'].append(
48 ('1top-dir/1dir-in-1topdir', '1dir-in-1topdir', 'directory',
49 None if empty_dirs_are_versioned else os.stat(tree.abspath('1top-dir/1dir-in-1topdir')),
43 tree.path2id('1top-dir/1dir-in-1topdir'),50 tree.path2id('1top-dir/1dir-in-1topdir'),
44 'directory' if tree.has_versioned_directories() else None,51 'directory' if empty_dirs_are_versioned else None))
45 )]),52 dirblocks['1top-dir/1dir-in-1topdir'] = []
46 (('1top-dir/1dir-in-1topdir', tree.path2id('1top-dir/1dir-in-1topdir')),
47 []),
48 ]
49 if symlinks:53 if symlinks:
50 dirblocks[0][1].append(('symlink', 'symlink', 'symlink', None,54 dirblocks[''].append(
51 tree.path2id('symlink'), 'symlink'))55 ('symlink', 'symlink', 'symlink', None,
52 return dirblocks56 tree.path2id('symlink'), 'symlink'))
57 return [((path, tree.path2id(path)), list(sorted(entries)))
58 for (path, entries) in dirblocks.items()]
5359
54 def test_walkdir_root(self):60 def test_walkdir_root(self):
55 tree = self.get_tree_with_subdirs_and_all_supported_content_types(61 tree = self.get_tree_with_subdirs_and_all_supported_content_types(
56 has_symlinks())62 has_symlinks())
57 tree.lock_read()63 tree.lock_read()
58 expected_dirblocks = self.get_all_subdirs_expected(tree, has_symlinks())64 expected_dirblocks = self.get_all_subdirs_expected(
65 tree, has_symlinks())
59 # test that its iterable by iterating66 # test that its iterable by iterating
60 result = []67 result = []
61 for dirinfo, block in tree.walkdirs():68 for dirinfo, block in tree.walkdirs():
6269
=== modified file 'breezy/tests/test_selftest.py'
--- breezy/tests/test_selftest.py 2018-08-26 14:16:26 +0000
+++ breezy/tests/test_selftest.py 2018-09-15 00:21:08 +0000
@@ -64,6 +64,9 @@
64from ..bzr import (64from ..bzr import (
65 groupcompress_repo,65 groupcompress_repo,
66 )66 )
67from ..git import (
68 workingtree as git_workingtree,
69 )
67from ..sixish import (70from ..sixish import (
68 PY3,71 PY3,
69 StringIO,72 StringIO,
@@ -402,11 +405,12 @@
402 formats = [workingtree_4.WorkingTreeFormat4(),405 formats = [workingtree_4.WorkingTreeFormat4(),
403 workingtree_3.WorkingTreeFormat3(),]406 workingtree_3.WorkingTreeFormat3(),]
404 scenarios = make_scenarios(server1, server2, formats)407 scenarios = make_scenarios(server1, server2, formats)
405 self.assertEqual(8, len(scenarios))408 self.assertEqual(9, len(scenarios))
406 default_wt_format = workingtree.format_registry.get_default()409 default_wt_format = workingtree.format_registry.get_default()
407 wt4_format = workingtree_4.WorkingTreeFormat4()410 wt4_format = workingtree_4.WorkingTreeFormat4()
408 wt5_format = workingtree_4.WorkingTreeFormat5()411 wt5_format = workingtree_4.WorkingTreeFormat5()
409 wt6_format = workingtree_4.WorkingTreeFormat6()412 wt6_format = workingtree_4.WorkingTreeFormat6()
413 git_wt_format = git_workingtree.GitWorkingTreeFormat()
410 expected_scenarios = [414 expected_scenarios = [
411 ('WorkingTreeFormat4',415 ('WorkingTreeFormat4',
412 {'bzrdir_format': formats[0]._matchingcontroldir,416 {'bzrdir_format': formats[0]._matchingcontroldir,
@@ -438,6 +442,14 @@
438 'transport_server': 'a',442 'transport_server': 'a',
439 'workingtree_format': default_wt_format,443 'workingtree_format': default_wt_format,
440 }),444 }),
445 ('GitRevisionTree',
446 {'_workingtree_to_test_tree': revision_tree_from_workingtree,
447 'bzrdir_format': git_wt_format._matchingcontroldir,
448 'transport_readonly_server': 'b',
449 'transport_server': 'a',
450 'workingtree_format': git_wt_format,
451 }
452 ),
441 ('DirStateRevisionTree,WT4',453 ('DirStateRevisionTree,WT4',
442 {'_workingtree_to_test_tree': _dirstate_tree_from_workingtree,454 {'_workingtree_to_test_tree': _dirstate_tree_from_workingtree,
443 'bzrdir_format': wt4_format._matchingcontroldir,455 'bzrdir_format': wt4_format._matchingcontroldir,

Subscribers

People subscribed via source and target branches