Rev 1862: Merge in Wouter's work. in http://bzr.arbash-meinel.com/branches/bzr/1.3-dev/nested-trees
John Arbash Meinel
john at arbash-meinel.com
Thu Mar 6 17:01:54 GMT 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.3-dev/nested-trees
------------------------------------------------------------
revno: 1862
revision-id:john at arbash-meinel.com-20080306170152-ch0jfmfr69030395
parent: john at arbash-meinel.com-20080304181430-a0xgc9xosic2u4ul
parent: larstiq at larstiq.dyndns.org-20080306104526-irywn0hm3n0qgn3q
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: nested-trees
timestamp: Thu 2008-03-06 17:01:52 +0000
message:
Merge in Wouter's work.
modified:
bzrlib/composite_tree.py composite_tree.py-20070308204230-4dam0jvsu2y8b17j-1
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_composite_tree.py test_composite_tree.-20070308204230-4dam0jvsu2y8b17j-2
------------------------------------------------------------
revno: 1859.1.6
revision-id:larstiq at larstiq.dyndns.org-20080306104526-irywn0hm3n0qgn3q
parent: larstiq at larstiq.dyndns.org-20080305224012-tvbfooaknl7lw056
parent: larstiq at larstiq.dyndns.org-20071120103322-wx65wh56normuerl
committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
branch nick: wacky
timestamp: Thu 2008-03-06 11:45:26 +0100
message:
Merge relabsfix
modified:
bzrlib/composite_tree.py composite_tree.py-20070308204230-4dam0jvsu2y8b17j-1
------------------------------------------------------------
revno: 1857.1.1
revision-id:larstiq at larstiq.dyndns.org-20071120103322-wx65wh56normuerl
parent: larstiq at larstiq.dyndns.org-20070713155213-i3jd7jevxf32rydb
committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
branch nick: nt-relabsfix
timestamp: Tue 2007-11-20 11:33:22 +0100
message:
Instrument NestedTrees to squash all conflicting relative/absolute usages of NestedTrees._subtrees_by_path
modified:
bzrlib/composite_tree.py composite_tree.py-20070308204230-4dam0jvsu2y8b17j-1
------------------------------------------------------------
revno: 1859.1.5
revision-id:larstiq at larstiq.dyndns.org-20080305224012-tvbfooaknl7lw056
parent: larstiq at larstiq.dyndns.org-20080305222203-jy6e5yav4gmd6n7m
committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
branch nick: wacky
timestamp: Wed 2008-03-05 23:40:12 +0100
message:
local test mods
modified:
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
------------------------------------------------------------
revno: 1859.1.4
revision-id:larstiq at larstiq.dyndns.org-20080305222203-jy6e5yav4gmd6n7m
parent: larstiq at larstiq.dyndns.org-20080305221940-g8xp0d20an5i3fy3
committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
branch nick: nested-trees
timestamp: Wed 2008-03-05 23:22:03 +0100
message:
Fix braindead never working implementation of CompositeTree.kind()
modified:
bzrlib/composite_tree.py composite_tree.py-20070308204230-4dam0jvsu2y8b17j-1
------------------------------------------------------------
revno: 1859.1.3
revision-id:larstiq at larstiq.dyndns.org-20080305221940-g8xp0d20an5i3fy3
parent: larstiq at larstiq.dyndns.org-20080305221553-md1izi3pegrfb0s2
committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
branch nick: nested-trees
timestamp: Wed 2008-03-05 23:19:40 +0100
message:
Make _get_tree_to_diff return composite trees
modified:
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
------------------------------------------------------------
revno: 1859.1.2
revision-id:larstiq at larstiq.dyndns.org-20080305221553-md1izi3pegrfb0s2
parent: larstiq at larstiq.dyndns.org-20080304232652-ulnesen4fuhdfrr0
committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
branch nick: nested-trees
timestamp: Wed 2008-03-05 23:15:53 +0100
message:
Actually supply the after argument to composite.move() when testing move_after
modified:
bzrlib/tests/test_composite_tree.py test_composite_tree.-20070308204230-4dam0jvsu2y8b17j-2
------------------------------------------------------------
revno: 1859.1.1
revision-id:larstiq at larstiq.dyndns.org-20080304232652-ulnesen4fuhdfrr0
parent: larstiq at larstiq.dyndns.org-20080304165541-byfqyg3kvgge91wf
committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
branch nick: nested-trees
timestamp: Wed 2008-03-05 00:26:52 +0100
message:
Fix some shameful errors
modified:
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
-------------- next part --------------
=== modified file 'bzrlib/composite_tree.py'
--- a/bzrlib/composite_tree.py 2008-03-04 17:12:18 +0000
+++ b/bzrlib/composite_tree.py 2008-03-06 17:01:52 +0000
@@ -24,6 +24,9 @@
tree,
)
+class Trapper:
+ def __getattr__(self, key):
+ import pdb; pdb.set_trace()
class NestedTrees(object):
"""Provide data about a collection of nested trees.
@@ -36,7 +39,10 @@
def __init__(self, root_tree, root_branch):
self.root_tree = root_tree
self.root_branch = root_branch
- self._subtrees_by_path = {}
+ self._subtrees_by_path = Trapper()
+ self._subtrees_by_relpath = {}
+ self._subtrees_by_compositepath = {}
+ self._register_tree_compositepath(root_tree, '')
self._all_trees_scanned = False
self.id_tree_branch = {}
self.lock_count = 0
@@ -119,6 +125,7 @@
return self.get_tree_path(file_id)[0]
def get_tree_path(self, file_id, skip_references=False):
+ """FIXME: really really needs a docstring"""
try:
tree, branch, path = self.id_tree_branch[file_id]
except KeyError:
@@ -132,8 +139,8 @@
raise errors.NoSuchId(self, file_id)
else:
if skip_references and tree.kind(file_id) == 'tree-reference':
- tree = self._subtrees_by_path[os.pathjoin(path,
- tree.id2path(file_id))]
+ tree = self._get_tree_by_relpath(os.pathjoin(path,
+ tree.id2path(file_id)))
return tree, path
def get_path_tree(self, path):
@@ -166,15 +173,36 @@
def _scan_subtrees(self):
self._must_be_locked()
- def do_scan(prefix, tree, branch):
- self._subtrees_by_path[prefix] = tree
+ def do_scan(prefix, relpath, tree, containing_tree, branch):
+ self._register_both(tree, prefix, containing_tree, relpath)
for path, file_id in tree.iter_references():
tree_path = tree.id2path(file_id)
composite_path = osutils.pathjoin(prefix, tree_path)
subtree, subbranch = self.get_tree_branch(branch, tree,
file_id, tree_path)
- do_scan(composite_path, subtree, subbranch)
- do_scan('', self.root_tree, self.root_branch)
+ do_scan(composite_path, tree_path, subtree, tree, subbranch)
+ do_scan('', '', self.root_tree, None, self.root_branch)
+
+ def _register_tree_relpath(self, tree, containing_tree, relpath):
+ tree_relpaths = self._subtrees_by_relpath.get(containing_tree, {})
+ tree_relpaths[relpath] = tree
+ self._subtrees_by_relpath[containing_tree] = tree_relpaths
+
+ def _register_tree_compositepath(self, tree, compositepath):
+ self._subtrees_by_compositepath[compositepath] = tree
+
+ def _register_both(self, tree, compositepath, containing_tree, relpath):
+ self._register_tree_compositepath(tree, compositepath)
+ # special case root
+ if tree is not None:
+ self._register_tree_relpath(tree, containing_tree, relpath)
+
+ def _get_tree_by_relpath(self, containing_tree, relpath):
+ tree = self._subtrees_by_relpath[containing_tree][relpath]
+ return tree
+
+ def _get_tree_by_compositepath(self, compositepath):
+ return self._subtrees_by_compositepath[compositepath]
def get_tree_branch(self, branch, tree, file_id, path):
"""Retrieve the tree and branch for a subtree
@@ -186,7 +214,7 @@
"""
subbranch = branch.reference_parent(file_id, path)
try:
- subtree = self._subtrees_by_path[path]
+ subtree = self._get_tree_by_relpath(tree, path)
except KeyError:
subtree = tree.get_nested_tree(file_id, branch)
if self.lock_type is not None:
@@ -197,14 +225,21 @@
elif self.lock_type == 'tree_write':
subtree.lock_tree_write()
self._locked_trees.append(subtree)
- self._subtrees_by_path[path] = subtree
+
+ composite_path = ''
+ for cp, t in self._subtrees_by_compositepath.items():
+ if t == tree:
+ composite_path = osutils.pathjoin(cp, path)
+ break
+ assert composite_path != ''
+ self._register_both(subtree, composite_path, tree, path)
return subtree, subbranch
def all_trees(self):
if not self._all_trees_scanned:
self._scan_subtrees()
self._all_trees_scanned = True
- return self._subtrees_by_path
+ return self._subtrees_by_compositepath
class CompositeInventory(object):
@@ -466,7 +501,8 @@
return tree.is_ignored(filename)
def kind(self, file_id):
- return osutils.file_kind(self.id2path(file_id))
+ # Doing a lookup on file_id twice? Hmm.
+ return self._nested_trees.get_tree_path(file_id)[0].kind(file_id)
def has_filename(self, filename):
tree, prefix, filename = self._nested_trees.get_path_tree(filename)
@@ -523,7 +559,8 @@
new_tree, new_tree_path = \
self._nested_trees.get_tree_path(new_entry.parent_id,
skip_references=True)
- new_path = new_path[len(new_tree_path)+1:]
+ if new_tree_path != '':
+ new_path = new_path[len(new_tree_path)+1:]
new_root_id = new_tree.get_root_id()
else:
new_tree_path = None
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2008-03-04 16:55:41 +0000
+++ b/bzrlib/diff.py 2008-03-05 22:19:40 +0000
@@ -443,15 +443,15 @@
if spec is None or spec.spec is None:
if basis_is_default:
if tree is not None:
- return tree.basis_tree()
+ tree = tree.basis_tree()
else:
- return branch.basis_tree()
- else:
- return tree
- revision = spec.in_store(branch)
- revision_id = revision.rev_id
- rev_branch = revision.branch
- return rev_branch.repository.revision_tree(revision_id)
+ tree = branch.basis_tree()
+ else:
+ revision = spec.in_store(branch)
+ revision_id = revision.rev_id
+ branch = revision.branch
+ tree = branch.repository.revision_tree(revision_id)
+ return composite_tree.CompositeTree(tree, branch)
def _relative_paths_in_tree(tree, paths):
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2008-03-04 16:55:41 +0000
+++ b/bzrlib/tests/__init__.py 2008-03-05 22:40:12 +0000
@@ -279,6 +279,7 @@
unittest.TestResult.addError(self, test, err)
self.error_count += 1
self.report_error(test, err)
+ self.erroredTestNames.append(test.id())
if self.stop_early:
self.stop()
@@ -296,6 +297,7 @@
unittest.TestResult.addFailure(self, test, err)
self.failure_count += 1
self.report_failure(test, err)
+ self.failedTestNames.append(test.id())
if self.stop_early:
self.stop()
@@ -574,6 +576,8 @@
num_tests=test.countTestCases(),
)
result.stop_early = self.stop_on_failure
+ result.failedTestNames = []
+ result.erroredTestNames = []
result.report_starting()
if self.list_only:
if self.verbosity >= 2:
@@ -621,6 +625,10 @@
for feature, count in sorted(result.unsupported.items()):
self.stream.writeln("Missing feature '%s' skipped %d tests." %
(feature, count))
+ if result.failures or result.errors:
+ faillog = open('failed-tests', 'w')
+ faillog.write("\n\t".join(["\nList of failed/errored test results:"] + result.failedTestNames + result.erroredTestNames + ['']))
+ faillog.close()
result.finished()
return result
=== modified file 'bzrlib/tests/test_composite_tree.py'
--- a/bzrlib/tests/test_composite_tree.py 2007-05-21 00:06:02 +0000
+++ b/bzrlib/tests/test_composite_tree.py 2008-03-05 22:15:53 +0000
@@ -97,7 +97,7 @@
tree, subtree = self.make_tree_files()
os.rename('file', 'subtree/file')
composite = composite_tree.CompositeTree(tree, tree.branch)
- composite.move(['file'], 'subtree')
+ composite.move(['file'], 'subtree', after=True)
self.assertIs(None, tree.path2id('file'))
self.assertEqual('file-id', subtree.path2id('file'))
More information about the bazaar-commits
mailing list