~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_memorytree.py

  • Committer: Vincent Ladeuil
  • Date: 2009-07-02 13:07:14 UTC
  • mto: (4524.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4525.
  • Revision ID: v.ladeuil+lp@free.fr-20090702130714-hsyqfusi8vn3a11m
Use tree.has_changes() where appropriate (the test suite caught a
bug in has_changes() (not filtering out the root) in an impressive
number of tests)

* bzrlib/send.py:
(send): Use tree.has_changes() instead of tree.changes_from().

* bzrlib/reconfigure.py:
(Reconfigure._check): Use tree.has_changes() instead of
tree.changes_from().

* bzrlib/merge.py:
(Merger.ensure_revision_trees, Merger.compare_basis): Use
tree.has_changes() instead of tree.changes_from().

* bzrlib/builtins.py:
(cmd_remove_tree.run, cmd_push.run, cmd_merge.run): Use
tree.has_changes() instead of tree.changes_from().

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
"""Tests for the MemoryTree class."""
19
19
 
24
24
 
25
25
 
26
26
class TestMemoryTree(TestCaseWithTransport):
27
 
    
 
27
 
28
28
    def test_create_on_branch(self):
29
29
        """Creating a mutable tree on a trivial branch works."""
30
30
        branch = self.make_branch('branch')
32
32
        self.assertEqual(branch.bzrdir, tree.bzrdir)
33
33
        self.assertEqual(branch, tree.branch)
34
34
        self.assertEqual([], tree.get_parent_ids())
35
 
    
 
35
 
36
36
    def test_create_on_branch_with_content(self):
37
37
        """Creating a mutable tree on a non-trivial branch works."""
38
38
        branch = self.make_branch('branch')
96
96
        branch = self.make_branch('branch')
97
97
        tree = MemoryTree.create_on_branch(branch)
98
98
        tree.lock_write()
99
 
        tree.add(['', 'afile', 'adir'], None, 
 
99
        tree.add(['', 'afile', 'adir'], None,
100
100
                 ['directory', 'file', 'directory'])
101
101
        self.assertEqual('afile', tree.id2path(tree.path2id('afile')))
102
102
        self.assertEqual('adir', tree.id2path(tree.path2id('adir')))
108
108
        branch = self.make_branch('branch')
109
109
        tree = MemoryTree.create_on_branch(branch)
110
110
        tree.lock_write()
111
 
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
111
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'],
112
112
                  kinds=['directory', 'file'])
113
113
        tree.put_file_bytes_non_atomic('foo-id', 'barshoom')
114
114
        self.assertEqual('barshoom', tree.get_file('foo-id').read())
118
118
        branch = self.make_branch('branch')
119
119
        tree = MemoryTree.create_on_branch(branch)
120
120
        tree.lock_write()
121
 
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
121
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'],
122
122
                 kinds=['directory', 'file'])
123
123
        tree.put_file_bytes_non_atomic('foo-id', 'first-content')
124
124
        tree.put_file_bytes_non_atomic('foo-id', 'barshoom')
150
150
        branch = self.make_branch('branch')
151
151
        tree = MemoryTree.create_on_branch(branch)
152
152
        tree.lock_write()
153
 
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
153
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'],
154
154
                 kinds=['directory', 'file'])
155
155
        tree.put_file_bytes_non_atomic('foo-id', 'barshoom')
156
156
        revision_id = tree.commit('message baby')
168
168
        branch = self.make_branch('branch')
169
169
        tree = MemoryTree.create_on_branch(branch)
170
170
        tree.lock_write()
171
 
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
171
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'],
172
172
                 kinds=['directory', 'file'])
173
173
        tree.unversion(['foo-id'])
174
174
        self.assertFalse(tree.has_id('foo-id'))