~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2007-06-26 20:32:49 UTC
  • mto: (2581.1.1 cleanup-runbzr)
  • mto: This revision was merged to the branch mainline in revision 2588.
  • Revision ID: v.ladeuil+lp@free.fr-20070626203249-sqm4afiai5dxofum
Deprecate the varargs syntax and fix the tests.

* bzrlib/tests/__init__.py:
(TestCase.run_bzr): Activate the deprecation warning.
(TestCase.run_bzr_error): Add error_regexes to kwargs or run_bzr
get confused.

* bzrlib/tests/blackbox/test_selftest.py:
(TestRunBzr.test_args): Activate.

* bzrlib/tests/blackbox/test_inventory.py:
(TestInventory.assertInventoryEqual): Build the command from args
if not None.

* bzrlib/tests/blackbox/test_ls.py:
(TestLS.ls_equals): Build the command from args if not None.

* bzrlib/tests/blackbox/test_remove_tree.py:
(TestRemoveTree.test_remove_tree_lightweight_checkout_explicit):
Nice catch, we were calling run_bzr instead of run_bzr_error. This
went unnoticed for some time...

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        self.assertContainsRe(out, 'Create a tag')
44
44
 
45
45
    def test_cannot_tag_range(self):
46
 
        out, err = self.run_bzr('tag', '-r1..10', 'name', retcode=3)
 
46
        out, err = self.run_bzr('tag -r1..10 name', retcode=3)
47
47
        self.assertContainsRe(err,
48
48
            "Tags can only be placed on a single revision")
49
49
 
52
52
        t.commit(allow_pointless=True, message='initial commit',
53
53
            rev_id='first-revid')
54
54
        # make a tag through the command line
55
 
        out, err = self.run_bzr('tag', '-d', 'branch', 'NEWTAG')
 
55
        out, err = self.run_bzr('tag -d branch NEWTAG')
56
56
        self.assertContainsRe(out, 'Created tag NEWTAG.')
57
57
        # tag should be observable through the api
58
58
        self.assertEquals(t.branch.tags.get_tag_dict(),
59
59
                dict(NEWTAG='first-revid'))
60
60
        # can also create tags using -r
61
 
        self.run_bzr('tag', '-d', 'branch', 'tag2', '-r1')
 
61
        self.run_bzr('tag -d branch tag2 -r1')
62
62
        self.assertEquals(t.branch.tags.lookup_tag('tag2'), 'first-revid')
63
63
        # regression test: make sure a unicode revision from the user
64
64
        # gets turned into a str object properly. The use of a unicode
65
65
        # object for the revid is intentional.
66
 
        self.run_bzr('tag', '-d', 'branch', 'tag3', u'-rrevid:first-revid')
 
66
        self.run_bzr(['tag', '-d', 'branch', 'tag3', u'-rrevid:first-revid'])
67
67
        self.assertEquals(t.branch.tags.lookup_tag('tag3'), 'first-revid')
68
68
        # can also delete an existing tag
69
 
        out, err = self.run_bzr('tag', '--delete', '-d', 'branch', 'tag2')
 
69
        out, err = self.run_bzr('tag --delete -d branch tag2')
70
70
        # cannot replace an existing tag normally
71
 
        out, err = self.run_bzr('tag', '-d', 'branch', 'NEWTAG', retcode=3)
 
71
        out, err = self.run_bzr('tag -d branch NEWTAG', retcode=3)
72
72
        self.assertContainsRe(err, 'Tag NEWTAG already exists\\.')
73
73
        # ... but can if you use --force
74
 
        out, err = self.run_bzr('tag', '-d', 'branch', 'NEWTAG', '--force')
 
74
        out, err = self.run_bzr('tag -d branch NEWTAG --force')
75
75
 
76
76
    def test_branch_push_pull_merge_copies_tags(self):
77
77
        t = self.make_branch_and_tree('branch1')
80
80
        b1 = t.branch
81
81
        b1.tags.set_tag('tag1', 'first-revid')
82
82
        # branching copies the tag across
83
 
        self.run_bzr('branch', 'branch1', 'branch2')
 
83
        self.run_bzr('branch branch1 branch2')
84
84
        b2 = Branch.open('branch2')
85
85
        self.assertEquals(b2.tags.lookup_tag('tag1'), 'first-revid')
86
86
        # make a new tag and pull it
87
87
        b1.tags.set_tag('tag2', 'twa')
88
 
        self.run_bzr('pull', '-d', 'branch2', 'branch1')
 
88
        self.run_bzr('pull -d branch2 branch1')
89
89
        self.assertEquals(b2.tags.lookup_tag('tag2'), 'twa')
90
90
        # make a new tag and push it
91
91
        b1.tags.set_tag('tag3', 'san')
92
 
        self.run_bzr('push', '-d', 'branch1', 'branch2')
 
92
        self.run_bzr('push -d branch1 branch2')
93
93
        self.assertEquals(b2.tags.lookup_tag('tag3'), 'san')
94
94
        # make a new tag and merge it
95
95
        t.commit(allow_pointless=True, message='second commit',
97
97
        t2 = WorkingTree.open('branch2')
98
98
        t2.commit(allow_pointless=True, message='commit in second')
99
99
        b1.tags.set_tag('tag4', 'second-revid')
100
 
        self.run_bzr('merge', '-d', 'branch2', 'branch1')
 
100
        self.run_bzr('merge -d branch2 branch1')
101
101
        self.assertEquals(b2.tags.lookup_tag('tag4'), 'second-revid')
102
102
        # pushing to a new location copies the tag across
103
 
        self.run_bzr('push', '-d', 'branch1', 'branch3')
 
103
        self.run_bzr('push -d branch1 branch3')
104
104
        b3 = Branch.open('branch3')
105
105
        self.assertEquals(b3.tags.lookup_tag('tag1'), 'first-revid')
106
106
 
109
109
        b1 = t.branch
110
110
        tagname = u'\u30d0zaar'
111
111
        b1.tags.set_tag(tagname, 'revid-1')
112
 
        out, err = self.run_bzr('tags', '-d', 'branch1', encoding='utf-8')
 
112
        out, err = self.run_bzr('tags -d branch1', encoding='utf-8')
113
113
        self.assertEquals(err, '')
114
114
        self.assertContainsRe(out,
115
115
            u'^\u30d0zaar  *revid-1\n'.encode('utf-8'))
124
124
        b1.tags.set_tag(tagname, 'revid1')
125
125
        b2.tags.set_tag(tagname, 'revid2')
126
126
        # push should give a warning about the tags
127
 
        out, err = self.run_bzr('push', '-d', 'one', 'two', encoding='utf-8')
 
127
        out, err = self.run_bzr('push -d one two', encoding='utf-8')
128
128
        self.assertContainsRe(out,
129
129
                'Conflicting tags:\n.*' + tagname.encode('utf-8'))
130
130
        # pull should give a warning about the tags
131
 
        out, err = self.run_bzr('pull', '-d', 'one', 'two', encoding='utf-8')
 
131
        out, err = self.run_bzr('pull -d one two', encoding='utf-8')
132
132
        self.assertContainsRe(out,
133
133
                'Conflicting tags:\n.*' + tagname.encode('utf-8'))
134
134
        # merge should give a warning about the tags -- not implemented yet
135
 
        ## out, err = self.run_bzr('merge', '-d', 'one', 'two', encoding='utf-8')
 
135
        ## out, err = self.run_bzr('merge -d one two', encoding='utf-8')
136
136
        ## self.assertContainsRe(out,
137
137
        ##         'Conflicting tags:\n.*' + tagname.encode('utf-8'))