~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_uncommit.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011, 2013, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
22
22
from bzrlib.bzrdir import BzrDirMetaFormat1
23
23
from bzrlib.errors import BoundBranchOutOfDate
24
24
from bzrlib.tests import TestCaseWithTransport
 
25
from bzrlib.tests.matchers import ContainsNoVfsCalls
25
26
from bzrlib.tests.script import (
26
27
    run_script,
27
28
    ScriptRunner,
62
63
        # This should look like we are back in revno 1
63
64
        self.assertEqual(['a1'], wt.get_parent_ids())
64
65
        out, err = self.run_bzr('status')
65
 
        self.assertEquals(out, 'modified:\n  a\n')
 
66
        self.assertEqual(out, 'modified:\n  a\n')
66
67
 
67
68
    def test_uncommit_interactive(self):
68
69
        """Uncommit seeks confirmation, and doesn't proceed without it."""
72
73
        $ bzr uncommit
73
74
        ...
74
75
        The above revision(s) will be removed.
75
 
        2>Uncommit these revisions? [y/n]: 
 
76
        2>Uncommit these revisions? ([y]es, [n]o): no
76
77
        <n
77
78
        Canceled
78
79
        """)
104
105
 
105
106
        # uncommit in a checkout should uncommit the parent branch
106
107
        # (but doesn't effect the other working tree)
107
 
        self.assertEquals(['a1'], checkout_tree.get_parent_ids())
108
 
        self.assertEquals('a1', wt.branch.last_revision())
109
 
        self.assertEquals(['a2'], wt.get_parent_ids())
 
108
        self.assertEqual(['a1'], checkout_tree.get_parent_ids())
 
109
        self.assertEqual('a1', wt.branch.last_revision())
 
110
        self.assertEqual(['a2'], wt.get_parent_ids())
110
111
 
111
112
    def test_uncommit_bound(self):
112
113
        os.mkdir('a')
119
120
        t_a.commit('commit 3')
120
121
        b = t_a.branch.create_checkout('b').branch
121
122
        uncommit.uncommit(b)
122
 
        self.assertEqual(len(b.revision_history()), 2)
123
 
        self.assertEqual(len(t_a.branch.revision_history()), 2)
 
123
        self.assertEqual(b.last_revision_info()[0], 2)
 
124
        self.assertEqual(t_a.branch.last_revision_info()[0], 2)
124
125
        # update A's tree to not have the uncommitted revision referenced.
125
126
        t_a.update()
126
127
        t_a.commit('commit 3b')
286
287
        revid = tree.commit('message')
287
288
        tree.branch.tags.set_tag("atag", revid)
288
289
        out, err = self.run_bzr('uncommit --force tree')
289
 
        self.assertEquals({}, tree.branch.tags.get_tag_dict())
 
290
        self.assertEqual({}, tree.branch.tags.get_tag_dict())
290
291
 
291
292
    def test_uncommit_keep_tags(self):
292
293
        tree = self.make_branch_and_tree('tree')
293
294
        revid = tree.commit('message')
294
295
        tree.branch.tags.set_tag("atag", revid)
295
296
        out, err = self.run_bzr('uncommit --keep-tags --force tree')
296
 
        self.assertEquals({"atag": revid}, tree.branch.tags.get_tag_dict())
 
297
        self.assertEqual({"atag": revid}, tree.branch.tags.get_tag_dict())
 
298
 
 
299
 
 
300
class TestSmartServerUncommit(TestCaseWithTransport):
 
301
 
 
302
    def test_uncommit(self):
 
303
        self.setup_smart_server_with_call_log()
 
304
        t = self.make_branch_and_tree('from')
 
305
        for count in range(2):
 
306
            t.commit(message='commit %d' % count)
 
307
        self.reset_smart_call_log()
 
308
        out, err = self.run_bzr(['uncommit', '--force', self.get_url('from')])
 
309
        # This figure represent the amount of work to perform this use case. It
 
310
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
311
        # being too low. If rpc_count increases, more network roundtrips have
 
312
        # become necessary for this use case. Please do not adjust this number
 
313
        # upwards without agreement from bzr's network support maintainers.
 
314
        self.assertLength(14, self.hpss_calls)
 
315
        self.assertLength(1, self.hpss_connections)
 
316
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
317
 
 
318
 
 
319
class TestInconsistentDelta(TestCaseWithTransport):
 
320
    # See https://bugs.launchpad.net/bzr/+bug/855155
 
321
    # See https://bugs.launchpad.net/bzr/+bug/1100385
 
322
    # bzr uncommit may result in error
 
323
    # 'An inconsistent delta was supplied involving'
 
324
 
 
325
    def test_inconsistent_delta(self):
 
326
        # Script taken from https://bugs.launchpad.net/bzr/+bug/855155/comments/26
 
327
        wt = self.make_branch_and_tree('test')
 
328
        self.build_tree(['test/a/', 'test/a/b', 'test/a/c'])
 
329
        wt.add(['a', 'a/b', 'a/c'])
 
330
        wt.commit('initial commit', rev_id='a1')
 
331
        wt.remove(['a/b', 'a/c'])
 
332
        wt.commit('remove b and c', rev_id='a2')
 
333
        self.run_bzr("uncommit --force test")