Rev 3387: (abentley) Get _PreviewTree under test in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Apr 28 19:44:06 BST 2008


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

------------------------------------------------------------
revno: 3387
revision-id:pqm at pqm.ubuntu.com-20080428184356-qic5mhqzrgxlwwhs
parent: pqm at pqm.ubuntu.com-20080428083317-x033hd0yn73mqaj7
parent: aaron at aaronbentley.com-20080428030701-5axl03chky7p1qg9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2008-04-28 19:43:56 +0100
message:
  (abentley) Get _PreviewTree under test
modified:
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
  bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
  bzrlib/tests/tree_implementations/test_inv.py test_inv.py-20070312023226-0cdvk5uwhutis9vg-1
  bzrlib/tests/tree_implementations/test_test_trees.py test_tree_trees.py-20060720091921-3nwi5h21lf06vf5p-1
  bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 3363.1.1.1.11
    revision-id:aaron at aaronbentley.com-20080428030701-5axl03chky7p1qg9
    parent: aaron at aaronbentley.com-20080413223554-3i4daoy80ooqvdz2
    parent: aaron at aaronbentley.com-20080428030347-j81zva7jb3tcg889
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree-changed
    timestamp: Sun 2008-04-27 23:07:01 -0400
    message:
      Merge with preview-tree
    removed:
      bzrlib/tests/tree_implementations/test_inv_alternatives.py test_inv_alternative-20080412183215-pjhfu9bxgasz3orh-1
      bzrlib/xml6.py                 xml6.py-20060823042456-dbaaq4atrche7xy5-1
    added:
      bzrlib/xml5.py                 xml5.py-20080328030717-t9guwinq8hom0ar3-1
      bzrlib/xml6.py                 xml6.py-20080327235607-1skmbg4o9cd1o636-1
      doc/developers/tortoise-strategy.txt tortoisestrategy.txt-20080403024510-2ahdqrvnwqrb5p5t-1
    renamed:
      bzrlib/xml5.py => bzrlib/xml8.py xml5.py-20050907032657-aac8f960815b66b1
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
      bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
      bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
      bzrlib/msgeditor.py            msgeditor.py-20050901111708-ef6d8de98f5d8f2f
      bzrlib/plugins/launchpad/lp_directory.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
      bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
      bzrlib/reconfigure.py          reconfigure.py-20070908040425-6ykgo7escxhyrg9p-1
      bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/revisionspec.py         revisionspec.py-20050907152633-17567659fd5c0ddb
      bzrlib/smart/repository.py     repository.py-20061128022038-vr5wy5bubyb8xttk-1
      bzrlib/smart/server.py         server.py-20061110062051-chzu10y32vx8gvur-1
      bzrlib/tests/blackbox/test_reconfigure.py test_reconfigure.py-20070908173426-khfo5fi2rgzgtwj3-1
      bzrlib/tests/interrepository_implementations/test_interrepository.py test_interrepository.py-20060220061411-1ec13fa99e5e3eee
      bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
      bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
      bzrlib/tests/test_reconfigure.py test_reconfigure.py-20070908040425-6ykgo7escxhyrg9p-2
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
      bzrlib/tests/test_xml.py       test_xml.py-20050905091053-80b45588931a9b35
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
      bzrlib/tests/tree_implementations/test_inv.py test_inv.py-20070312023226-0cdvk5uwhutis9vg-1
      bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
      bzrlib/xml_serializer.py       xml.py-20050309040759-57d51586fdec365d
      doc/en/user-guide/controlling_registration.txt controlling_registra-20071121073725-0corxykv5irjal00-3
      doc/en/user-guide/sending_changes.txt sending_changes.txt-20071123154453-dk2mjhrg1vpjm5w2-4
      bzrlib/xml8.py                 xml5.py-20050907032657-aac8f960815b66b1
        ------------------------------------------------------------
        revno: 3363.1.1.1.9.1.2
        revision-id:aaron at aaronbentley.com-20080428030347-j81zva7jb3tcg889
        parent: aaron at aaronbentley.com-20080428030242-7pc7ce0c1trnsnxv
        parent: pqm at pqm.ubuntu.com-20080428012318-g5zq9wl2flua3r2s
        committer: Aaron Bentley <aaron at aaronbentley.com>
        branch nick: preview-tree
        timestamp: Sun 2008-04-27 23:03:47 -0400
        message:
          Merge bzr.dev
        removed:
          bzrlib/xml6.py                 xml6.py-20060823042456-dbaaq4atrche7xy5-1
        added:
          bzrlib/xml5.py                 xml5.py-20080328030717-t9guwinq8hom0ar3-1
          bzrlib/xml6.py                 xml6.py-20080327235607-1skmbg4o9cd1o636-1
          doc/developers/tortoise-strategy.txt tortoisestrategy.txt-20080403024510-2ahdqrvnwqrb5p5t-1
        renamed:
          bzrlib/xml5.py => bzrlib/xml8.py xml5.py-20050907032657-aac8f960815b66b1
        modified:
          NEWS                           NEWS-20050323055033-4e00b5db738777ff
          bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
          bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
          bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
          bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
          bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
          bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
          bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
          bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
          bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
          bzrlib/msgeditor.py            msgeditor.py-20050901111708-ef6d8de98f5d8f2f
          bzrlib/plugins/launchpad/lp_directory.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
          bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
          bzrlib/reconfigure.py          reconfigure.py-20070908040425-6ykgo7escxhyrg9p-1
          bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
          bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
          bzrlib/revisionspec.py         revisionspec.py-20050907152633-17567659fd5c0ddb
          bzrlib/smart/repository.py     repository.py-20061128022038-vr5wy5bubyb8xttk-1
          bzrlib/smart/server.py         server.py-20061110062051-chzu10y32vx8gvur-1
          bzrlib/tests/blackbox/test_reconfigure.py test_reconfigure.py-20070908173426-khfo5fi2rgzgtwj3-1
          bzrlib/tests/interrepository_implementations/test_interrepository.py test_interrepository.py-20060220061411-1ec13fa99e5e3eee
          bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
          bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
          bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
          bzrlib/tests/test_reconfigure.py test_reconfigure.py-20070908040425-6ykgo7escxhyrg9p-2
          bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
          bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
          bzrlib/tests/test_xml.py       test_xml.py-20050905091053-80b45588931a9b35
          bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
          bzrlib/xml_serializer.py       xml.py-20050309040759-57d51586fdec365d
          doc/en/user-guide/controlling_registration.txt controlling_registra-20071121073725-0corxykv5irjal00-3
          doc/en/user-guide/sending_changes.txt sending_changes.txt-20071123154453-dk2mjhrg1vpjm5w2-4
          bzrlib/xml8.py                 xml5.py-20050907032657-aac8f960815b66b1
        ------------------------------------------------------------
        revno: 3363.1.1.1.9.1.1
        revision-id:aaron at aaronbentley.com-20080428030242-7pc7ce0c1trnsnxv
        parent: aaron at aaronbentley.com-20080413210615-9341l9rt0fnezvpn
        committer: Aaron Bentley <aaron at aaronbentley.com>
        branch nick: preview-tree
        timestamp: Sun 2008-04-27 23:02:42 -0400
        message:
          Combine test_inv_alternatives and test_inv
        removed:
          bzrlib/tests/tree_implementations/test_inv_alternatives.py test_inv_alternative-20080412183215-pjhfu9bxgasz3orh-1
        modified:
          bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
          bzrlib/tests/tree_implementations/test_inv.py test_inv.py-20070312023226-0cdvk5uwhutis9vg-1
    ------------------------------------------------------------
    revno: 3363.1.1.1.10
    revision-id:aaron at aaronbentley.com-20080413223554-3i4daoy80ooqvdz2
    parent: aaron at aaronbentley.com-20080413210615-9341l9rt0fnezvpn
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree-changed
    timestamp: Sun 2008-04-13 18:35:54 -0400
    message:
      Refactor _prepare_revert_transform out of revert
    modified:
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
    ------------------------------------------------------------
    revno: 3363.1.1.1.9
    revision-id:aaron at aaronbentley.com-20080413210615-9341l9rt0fnezvpn
    parent: aaron at aaronbentley.com-20080412205828-eooqv88548wcbl1l
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Sun 2008-04-13 17:06:15 -0400
    message:
      Fix up some refactorings
    modified:
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
    ------------------------------------------------------------
    revno: 3363.1.1.1.8
    revision-id:aaron at aaronbentley.com-20080412205828-eooqv88548wcbl1l
    parent: aaron at aaronbentley.com-20080412194313-qtygleydrwk8tfz7
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Sat 2008-04-12 16:58:28 -0400
    message:
      All tests passing
    modified:
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
    ------------------------------------------------------------
    revno: 3363.1.1.1.7
    revision-id:aaron at aaronbentley.com-20080412194313-qtygleydrwk8tfz7
    parent: aaron at aaronbentley.com-20080412181107-t14j2lxb8acxdnlr
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Sat 2008-04-12 15:43:13 -0400
    message:
      Implement alterntative-to-inventory tests
    added:
      bzrlib/tests/tree_implementations/test_inv_alternatives.py test_inv_alternative-20080412183215-pjhfu9bxgasz3orh-1
    modified:
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
      bzrlib/tests/tree_implementations/test_inv.py test_inv.py-20070312023226-0cdvk5uwhutis9vg-1
      bzrlib/tests/tree_implementations/test_test_trees.py test_tree_trees.py-20060720091921-3nwi5h21lf06vf5p-1
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 3363.1.1.1.6
    revision-id:aaron at aaronbentley.com-20080412181107-t14j2lxb8acxdnlr
    parent: aaron at aaronbentley.com-20080412180956-1x4hw9gp4xsssgsr
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Sat 2008-04-12 14:11:07 -0400
    message:
      Fix adatation test
    modified:
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
    ------------------------------------------------------------
    revno: 3363.1.1.1.5
    revision-id:aaron at aaronbentley.com-20080412180956-1x4hw9gp4xsssgsr
    parent: aaron at aaronbentley.com-20080411221115-fg6fpa16ay4dco3a
    parent: aaron at aaronbentley.com-20080412060329-qprwz8yqyxkp2m09
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Sat 2008-04-12 14:09:56 -0400
    message:
      Merge from refactor-intertree
    modified:
      bzrlib/tests/intertree_implementations/__init__.py __init__.py-20060724101752-09ysswo1a92uqyoz-3
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
      bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
    ------------------------------------------------------------
    revno: 3363.1.1.1.4
    revision-id:aaron at aaronbentley.com-20080411221115-fg6fpa16ay4dco3a
    parent: aaron at aaronbentley.com-20080411194738-g1j30d0j9sv4s2u1
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Fri 2008-04-11 18:11:15 -0400
    message:
      Get significant portions of PreviewTree implemented and passing tests
    modified:
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
    ------------------------------------------------------------
    revno: 3363.1.1.1.3
    revision-id:aaron at aaronbentley.com-20080411194738-g1j30d0j9sv4s2u1
    parent: aaron at aaronbentley.com-20080411193701-oqfs6tvwaycyr9a7
    parent: aaron at aaronbentley.com-20080411194715-tmr73uvu8ycyoo4r
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Fri 2008-04-11 15:47:38 -0400
    message:
      Merge with lower thread
    modified:
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
    ------------------------------------------------------------
    revno: 3363.1.1.1.2
    revision-id:aaron at aaronbentley.com-20080411193701-oqfs6tvwaycyr9a7
    parent: aaron at aaronbentley.com-20080411193607-14nbd5258sss9o7m
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Fri 2008-04-11 15:37:01 -0400
    message:
      Add PreviewTree pre scenarios
    modified:
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
    ------------------------------------------------------------
    revno: 3363.1.1.1.1
    revision-id:aaron at aaronbentley.com-20080411193607-14nbd5258sss9o7m
    parent: aaron at aaronbentley.com-20080411191850-g4h43o2d8dwpqmco
    parent: aaron at aaronbentley.com-20080411193418-lzpzicebh5is2nd7
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: preview-tree
    timestamp: Fri 2008-04-11 15:36:07 -0400
    message:
      Merge converter parameter usage
    modified:
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2008-04-11 23:05:02 +0000
+++ b/bzrlib/tests/test_selftest.py	2008-04-12 18:11:07 +0000
@@ -502,7 +502,9 @@
         adapter = TreeTestProviderAdapter(server1, server2, formats)
         suite = adapter.adapt(input_test)
         tests = list(iter(suite))
-        self.assertEqual(4, len(tests))
+        # XXX We should not have tests fail as we add more scenarios
+        # abentley 20080412
+        self.assertEqual(5, len(tests))
         # this must match the default format setp up in
         # TreeTestProviderAdapter.adapt
         default_format = WorkingTreeFormat3

=== modified file 'bzrlib/tests/tree_implementations/__init__.py'
--- a/bzrlib/tests/tree_implementations/__init__.py	2008-04-12 06:03:29 +0000
+++ b/bzrlib/tests/tree_implementations/__init__.py	2008-04-28 03:02:42 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007 Canonical Ltd
+# Copyright (C) 2006, 2007, 2008 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -45,6 +45,7 @@
     WorkingTreeTestProviderAdapter,
     )
 from bzrlib.revisiontree import RevisionTree
+from bzrlib.transform import TransformPreview
 from bzrlib.workingtree import (
     WorkingTreeFormat,
     WorkingTreeFormat3,
@@ -72,6 +73,12 @@
     return tree.basis_tree()
 
 
+def preview_tree_pre(testcase, tree):
+    tt = TransformPreview(tree)
+    testcase.addCleanup(tt.finalize)
+    return tt.get_preview_tree()
+
+
 class TestTreeImplementationSupport(TestCaseWithTransport):
 
     def test_revision_tree_from_workingtree(self):
@@ -314,6 +321,8 @@
         self.scenarios.append(self.create_tree_scenario(
             DirStateRevisionTree.__name__, _dirstate_tree_from_workingtree,
             WorkingTreeFormat4()))
+        self.scenarios.append(self.create_tree_scenario('PreviewTree',
+            preview_tree_pre))
 
     def create_tree_scenario(self, name, converter, workingtree_format=None):
         """Create a scenario for the specified converter

=== modified file 'bzrlib/tests/tree_implementations/test_inv.py'
--- a/bzrlib/tests/tree_implementations/test_inv.py	2007-12-18 15:22:47 +0000
+++ b/bzrlib/tests/tree_implementations/test_inv.py	2008-04-28 03:02:42 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Canonical Ltd
+# Copyright (C) 2007, 2008 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -26,9 +26,14 @@
 from bzrlib.symbol_versioning import zero_ninetyone, one_zero
 from bzrlib.tests import SymlinkFeature, TestSkipped
 from bzrlib.tests.tree_implementations import TestCaseWithTree
+from bzrlib.transform import _PreviewTree
 from bzrlib.uncommit import uncommit
 
 
+def get_entry(tree, file_id):
+    return tree.iter_entries_by_dir([file_id]).next()[1]
+
+
 class TestEntryDiffing(TestCaseWithTree):
 
     def setUp(self):
@@ -55,12 +60,11 @@
         self.tree_2 = self.workingtree_to_test_tree(self.wt)
         self.tree_2.lock_read()
         self.addCleanup(self.tree_2.unlock)
-        self.inv_2 = self.tree_2.inventory
-        self.file_2 = self.inv_2['fileid']
-        self.file_2b = self.inv_2['binfileid']
+        self.file_2 = get_entry(self.tree_2, 'fileid')
+        self.file_2b = get_entry(self.tree_2, 'binfileid')
         if has_symlinks():
             self.link_1 = self.inv_1['linkid']
-            self.link_2 = self.inv_2['linkid']
+            self.link_2 = get_entry(self.tree_2, 'linkid')
 
     def test_file_diff_deleted(self):
         output = StringIO()
@@ -104,7 +108,7 @@
                                             "-foo\n"
                                             "+bar\n"
                                             "\n")
-        
+
     def test_file_diff_binary(self):
         output = StringIO()
         self.applyDeprecated(one_zero,
@@ -113,7 +117,7 @@
                              "/dev/null", self.tree_1,
                              "new_label", self.file_2b, self.tree_2,
                              output)
-        self.assertEqual(output.getvalue(), 
+        self.assertEqual(output.getvalue(),
                          "Binary files /dev/null and new_label differ\n")
 
     def test_link_diff_deleted(self):
@@ -182,17 +186,17 @@
         self.tree = self.workingtree_to_test_tree(self.wt)
         self.tree.lock_read()
         self.addCleanup(self.tree.unlock)
-        self.file_active = self.tree.inventory['fileid']
+        self.file_active = get_entry(self.tree, 'fileid')
         self.weave = self.branch.repository.weave_store.get_weave('fileid',
             self.branch.repository.get_transaction())
-        
+
     def get_previous_heads(self, inventories):
         return self.applyDeprecated(zero_ninetyone,
             self.file_active.find_previous_heads,
             inventories,
             self.branch.repository.weave_store,
             self.branch.repository.get_transaction())
-        
+
     def test_fileid_in_no_inventory(self):
         self.assertEqual({}, self.get_previous_heads([self.inv_A]))
 
@@ -218,7 +222,7 @@
         self.assertEqual({'D':self.inv_D['fileid']},
                          self.get_previous_heads([self.inv_D, self.inv_B]))
 
-    # TODO: test two inventories with the same file revision 
+    # TODO: test two inventories with the same file revision
 
 
 class TestInventory(TestCaseWithTree):
@@ -227,21 +231,32 @@
         self.tree = self.get_tree_with_subdirs_and_all_content_types()
         self.tree.lock_read()
         self.addCleanup(self.tree.unlock)
-        # Commenting out the following line still fails.
-        self.inv = self.tree.inventory
 
     def test_symlink_target(self):
         self.requireFeature(SymlinkFeature)
         self._set_up()
-        if isinstance(self.tree, MutableTree):
+        if isinstance(self.tree, (MutableTree, _PreviewTree)):
             raise TestSkipped(
-                'symlinks not accurately represented in working trees')
-        entry = self.inv[self.inv.path2id('symlink')]
+                'symlinks not accurately represented in working trees and'
+                ' preview trees')
+        entry = get_entry(self.tree, self.tree.path2id('symlink'))
         self.assertEqual(entry.symlink_target, 'link-target')
 
+    def test_symlink_target_tree(self):
+        self.requireFeature(SymlinkFeature)
+        self._set_up()
+        self.assertEqual('link-target',
+                         self.tree.get_symlink_target('symlink'))
+
+    def test_kind_symlink(self):
+        self.requireFeature(SymlinkFeature)
+        self._set_up()
+        self.assertEqual('symlink', self.tree.kind('symlink'))
+        self.assertIs(None, self.tree.get_file_size('symlink'))
+
     def test_symlink(self):
         self.requireFeature(SymlinkFeature)
         self._set_up()
-        entry = self.inv[self.inv.path2id('symlink')]
+        entry = get_entry(self.tree, self.tree.path2id('symlink'))
         self.assertEqual(entry.kind, 'symlink')
         self.assertEqual(None, entry.text_size)

=== modified file 'bzrlib/tests/tree_implementations/test_test_trees.py'
--- a/bzrlib/tests/tree_implementations/test_test_trees.py	2007-11-01 09:52:45 +0000
+++ b/bzrlib/tests/tree_implementations/test_test_trees.py	2008-04-12 19:43:13 +0000
@@ -51,7 +51,7 @@
             [('', 'root-id'), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
             [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
         self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
-        self.assertFalse(tree.is_executable('c-id'))
+        self.assertFalse(tree.is_executable('c-id', path='b/c'))
 
     def test_abc_tree_content_2_no_parents(self):
         tree = self.make_branch_and_tree('.')

=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py	2008-04-04 04:20:19 +0000
+++ b/bzrlib/transform.py	2008-04-13 22:35:54 +0000
@@ -25,7 +25,8 @@
     bzrdir,
     delta,
     errors,
-    inventory
+    inventory,
+    revision as _mod_revision,
     )
 """)
 from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
@@ -1359,11 +1360,30 @@
             yield self.trans_id_tree_path(childpath)
 
 
-class _PreviewTree(object):
+class _PreviewTree(tree.Tree):
     """Partial implementation of Tree to support show_diff_trees"""
 
     def __init__(self, transform):
         self._transform = transform
+        self._final_paths = FinalPaths(transform)
+
+    def _changes(self, file_id):
+        for changes in self._transform.iter_changes():
+            if changes[0] == file_id:
+                return changes
+
+    def _content_change(self, file_id):
+        changes = self._changes(file_id)
+        return (changes is not None and changes[2])
+
+    def _get_file_revision(self, file_id, vf, tree_revision):
+        return self._transform._tree._get_file_revision(file_id, vf,
+                                                        tree_revision)
+
+    def _stat_limbo_file(self, file_id):
+        trans_id = self._transform.trans_id_file_id(file_id)
+        name = self._transform._limbo_name(trans_id)
+        return os.lstat(name)
 
     def lock_read(self):
         # Perhaps in theory, this should lock the TreeTransform?
@@ -1372,6 +1392,72 @@
     def unlock(self):
         pass
 
+    @property
+    def inventory(self):
+        """This Tree does not use inventory as its backing data."""
+        raise NotImplementedError(_PreviewTree.inventory)
+
+    def get_root_id(self):
+        return self._transform.final_file_id(self._transform.root)
+
+    def all_file_ids(self):
+        return self._transform._tree.all_file_ids()
+
+    def __iter__(self):
+        return iter(self.all_file_ids())
+
+    def paths2ids(self, specific_files, trees=None, require_versioned=False):
+        """See Tree.paths2ids"""
+        to_find = set(specific_files)
+        result = set()
+        for (file_id, paths, changed, versioned, parent, name, kind,
+             executable) in self._transform.iter_changes():
+            if paths[1] in to_find:
+                result.append(file_id)
+                to_find.remove(paths[1])
+        result.update(self._transform._tree.paths2ids(to_find,
+                      trees=[], require_versioned=require_versioned))
+        return result
+
+    def path2id(self, path):
+        return self._transform._tree.path2id(path)
+
+    def id2path(self, file_id):
+        trans_id = self._transform.trans_id_file_id(file_id)
+        try:
+            return self._final_paths._determine_path(trans_id)
+        except NoFinalPath:
+            raise errors.NoSuchId(self, file_id)
+
+    def iter_entries_by_dir(self, specific_file_ids=None):
+        return self._transform._tree.iter_entries_by_dir(specific_file_ids)
+
+    def kind(self, file_id):
+        trans_id = self._transform.trans_id_file_id(file_id)
+        return self._transform.final_kind(trans_id)
+
+    def stored_kind(self, file_id):
+        return self._transform._tree.stored_kind(file_id)
+
+    def get_file_mtime(self, file_id, path=None):
+        """See Tree.get_file_mtime"""
+        if not self._content_change(file_id):
+            return self._transform._tree.get_file_mtime(file_id, path)
+        return self._stat_limbo_file(file_id).st_mtime
+
+    def get_file_size(self, file_id):
+        if self.kind(file_id) == 'file':
+            return self._transform._tree.get_file_size(file_id)
+
+    def get_file_sha1(self, file_id, path=None, stat_value=None):
+        return self._transform._tree.get_file_sha1(file_id)
+
+    def is_executable(self, file_id, path=None):
+        return self._transform._tree.is_executable(file_id, path)
+
+    def path_content_summary(self, path):
+        return self._transform._tree.path_content_summary(path)
+
     def iter_changes(self, from_tree, include_unchanged=False,
                       specific_files=None, pb=None, extra_trees=None,
                       require_versioned=True, want_unversioned=False):
@@ -1391,31 +1477,45 @@
             raise ValueError('want_unversioned is not supported')
         return self._transform.iter_changes()
 
-    def kind(self, file_id):
-        trans_id = self._transform.trans_id_file_id(file_id)
-        return self._transform.final_kind(trans_id)
-
-    def get_file_mtime(self, file_id, path=None):
-        """See Tree.get_file_mtime"""
-        trans_id = self._transform.trans_id_file_id(file_id)
-        name = self._transform._limbo_name(trans_id)
-        return os.stat(name).st_mtime
-
-    def get_file(self, file_id):
+    def get_file(self, file_id, path=None):
         """See Tree.get_file"""
+        if not self._content_change(file_id):
+            return self._transform._tree.get_file(file_id, path)
         trans_id = self._transform.trans_id_file_id(file_id)
         name = self._transform._limbo_name(trans_id)
         return open(name, 'rb')
 
+    def get_file_text(self, file_id):
+        text_file = self.get_file(file_id)
+        try:
+            return text_file.read()
+        finally:
+            text_file.close()
+
+    def annotate_iter(self, file_id,
+                      default_revision=_mod_revision.CURRENT_REVISION):
+        return self._transform._tree.annotate_iter(file_id,
+            default_revision=default_revision)
+
     def get_symlink_target(self, file_id):
         """See Tree.get_symlink_target"""
+        if not self._content_change(file_id):
+            return self._transform._tree.get_symlink_target(file_id)
         trans_id = self._transform.trans_id_file_id(file_id)
         name = self._transform._limbo_name(trans_id)
         return os.readlink(name)
 
-    def paths2ids(self, specific_files, trees=None, require_versioned=False):
-        """See Tree.paths2ids"""
-        return 'not_empty'
+    def list_files(self, include_root=False):
+        return self._transform._tree.list_files(include_root)
+
+    def walkdirs(self, prefix=""):
+        return self._transform._tree.walkdirs(prefix)
+
+    def get_parent_ids(self):
+        return self._transform._tree.get_parent_ids()
+
+    def get_revision_tree(self, revision_id):
+        return self._transform._tree.get_revision_tree(revision_id)
 
 
 def joinpath(parent, child):
@@ -1839,21 +1939,8 @@
     tt = TreeTransform(working_tree, pb)
     try:
         pp = ProgressPhase("Revert phase", 3, pb)
-        pp.next_phase()
-        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
-        try:
-            merge_modified = _alter_files(working_tree, target_tree, tt,
-                                          child_pb, filenames, backups)
-        finally:
-            child_pb.finished()
-        pp.next_phase()
-        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
-        try:
-            raw_conflicts = resolve_conflicts(tt, child_pb,
-                lambda t, c: conflict_pass(t, c, target_tree))
-        finally:
-            child_pb.finished()
-        conflicts = cook_conflicts(raw_conflicts, tt)
+        conflicts, merge_modified = _prepare_revert_transform(
+            working_tree, target_tree, tt, filenames, backups, pp)
         if change_reporter:
             change_reporter = delta._ChangeReporter(
                 unversioned_filter=working_tree.is_ignored)
@@ -1870,6 +1957,26 @@
     return conflicts
 
 
+def _prepare_revert_transform(working_tree, target_tree, tt, filenames,
+                              backups, pp):
+    pp.next_phase()
+    child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
+    try:
+        merge_modified = _alter_files(working_tree, target_tree, tt,
+                                      child_pb, filenames, backups)
+    finally:
+        child_pb.finished()
+    pp.next_phase()
+    child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
+    try:
+        raw_conflicts = resolve_conflicts(tt, child_pb,
+            lambda t, c: conflict_pass(t, c, target_tree))
+    finally:
+        child_pb.finished()
+    conflicts = cook_conflicts(raw_conflicts, tt)
+    return conflicts, merge_modified
+
+
 def _alter_files(working_tree, target_tree, tt, pb, specific_files,
                  backups):
     merge_modified = working_tree.merge_modified()

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2008-03-15 14:07:55 +0000
+++ b/bzrlib/workingtree.py	2008-04-12 19:43:13 +0000
@@ -618,7 +618,13 @@
     __contains__ = has_id
 
     def get_file_size(self, file_id):
-        return os.path.getsize(self.id2abspath(file_id))
+        try:
+            return os.path.getsize(self.id2abspath(file_id))
+        except OSError, e:
+            if e.errno != errno.ENOENT:
+                raise
+            else:
+                return None
 
     @needs_read_lock
     def get_file_sha1(self, file_id, path=None, stat_value=None):




More information about the bazaar-commits mailing list