~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_add.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-12 16:54:35 UTC
  • mto: (5148.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5151.
  • Revision ID: v.ladeuil+lp@free.fr-20100412165435-gzdnwuybj9rvddiz
Fix bug #519319 by defaulting to a warning for dirty trees.

* bzrlib/mutabletree.py:
(MutableTree.warn_if_changed_or_out_of_date): Factor out the
checks done by send, push and dpush.

* bzrlib/send.py:
(send): Use warn_if_changed_or_out_of_date().

* bzrlib/foreign.py:
(cmd_dpush.run): Use warn_if_changed_or_out_of_date().

* bzrlib/builtins.py:
(cmd_push.run): Use warn_if_changed_or_out_of_date().

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        # The first part just logs if appropriate
31
31
        # Now generate a custom id
32
32
        file_id = osutils.safe_file_id(kind + '-'
33
 
                                       + path.replace('/', '%'),
 
33
                                       + path.raw_path.replace('/', '%'),
34
34
                                       warn=False)
35
35
        if self.should_print:
36
36
            self._to_file.write('added %s with id %s\n'
37
 
                                % (path, file_id))
 
37
                                % (path.raw_path, file_id))
38
38
        return file_id
39
39
 
40
40
 
115
115
        self.assertNotEqual(None, c_id)
116
116
        self.base_tree.lock_read()
117
117
        self.addCleanup(self.base_tree.unlock)
118
 
        self.assertFalse(self.base_tree.has_id(c_id))
 
118
        self.failIf(c_id in self.base_tree)
119
119
 
120
120
        d_id = new_tree.path2id('subdir/d')
121
121
        self.assertNotEqual(None, d_id)
122
 
        self.assertFalse(self.base_tree.has_id(d_id))
 
122
        self.failIf(d_id in self.base_tree)
123
123
 
124
124
    def test_copy_existing_dir(self):
125
125
        self.make_base_tree()
140
140
        self.assertNotEqual(None, a_id)
141
141
        self.base_tree.lock_read()
142
142
        self.addCleanup(self.base_tree.unlock)
143
 
        self.assertFalse(self.base_tree.has_id(a_id))
 
143
        self.failIf(a_id in self.base_tree)
144
144
 
145
145
 
146
146
class TestAddActions(tests.TestCase):
152
152
        self.run_action("adding path\n")
153
153
 
154
154
    def run_action(self, output):
 
155
        from bzrlib.mutabletree import _FastPath
155
156
        inv = inventory.Inventory()
156
157
        stdout = StringIO()
157
158
        action = add.AddAction(to_file=stdout, should_print=bool(output))
158
159
 
159
160
        self.apply_redirected(None, stdout, None, action, inv, None,
160
 
            'path', 'file')
 
161
            _FastPath('path'), 'file')
161
162
        self.assertEqual(stdout.getvalue(), output)