/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/tests/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    )
31
31
 
32
32
import os
33
 
import urllib
34
33
 
35
34
from ... import (
36
35
    errors,
113
112
        reva = self.simple_commit_a()
114
113
        self.build_tree(['b'])
115
114
        r = GitRepo(".")
 
115
        self.addCleanup(r.close)
116
116
        r.stage("b")
117
117
        revb = r.do_commit(b"b", committer=b"Somebody <foo@example.com>")
118
118
 
119
119
        thebranch = Branch.open('.')
120
 
        self.assertEqual((2, default_mapping.revision_id_foreign_to_bzr(revb)), thebranch.last_revision_info())
 
120
        self.assertEqual((2, default_mapping.revision_id_foreign_to_bzr(
 
121
            revb)), thebranch.last_revision_info())
121
122
 
122
123
    def test_tag_annotated(self):
123
124
        reva = self.simple_commit_a()
129
130
        o.tag_timezone = 0
130
131
        o.tag_time = 42
131
132
        r = GitRepo(".")
 
133
        self.addCleanup(r.close)
132
134
        r.object_store.add_object(o)
133
135
        r[b'refs/tags/foo'] = o.id
134
136
        thebranch = Branch.open('.')
135
137
        self.assertEqual({"foo": default_mapping.revision_id_foreign_to_bzr(reva)},
136
 
                          thebranch.tags.get_tag_dict())
 
138
                         thebranch.tags.get_tag_dict())
137
139
 
138
140
    def test_tag(self):
139
141
        reva = self.simple_commit_a()
140
142
        r = GitRepo(".")
 
143
        self.addCleanup(r.close)
141
144
        r.refs[b"refs/tags/foo"] = reva
142
145
        thebranch = Branch.open('.')
143
146
        self.assertEqual({"foo": default_mapping.revision_id_foreign_to_bzr(reva)},
144
 
                          thebranch.tags.get_tag_dict())
145
 
 
 
147
                         thebranch.tags.get_tag_dict())
146
148
 
147
149
 
148
150
class TestWithGitBranch(tests.TestCaseWithTransport):
158
160
 
159
161
    def test_get_stacked_on_url(self):
160
162
        self.assertRaises(UnstackableBranchFormat,
161
 
            self.git_branch.get_stacked_on_url)
 
163
                          self.git_branch.get_stacked_on_url)
162
164
 
163
165
    def test_get_physical_lock_status(self):
164
166
        self.assertFalse(self.git_branch.get_physical_lock_status())
171
173
        self.format = branch.LocalGitBranchFormat()
172
174
 
173
175
    def test_get_format_description(self):
174
 
        self.assertEqual("Local Git Branch", self.format.get_format_description())
 
176
        self.assertEqual("Local Git Branch",
 
177
                         self.format.get_format_description())
175
178
 
176
179
    def test_get_network_name(self):
177
180
        self.assertEqual(b"git", self.format.network_name())
221
224
    def test_sprouted_tags(self):
222
225
        path, gitsha = self.make_onerev_branch()
223
226
        r = GitRepo(path)
 
227
        self.addCleanup(r.close)
224
228
        r.refs[b"refs/tags/lala"] = r.head()
225
229
        oldrepo = Repository.open(path)
226
230
        revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha)
228
232
        self.assertEqual({"lala": revid}, newbranch.tags.get_tag_dict())
229
233
        self.assertEqual([revid], newbranch.repository.all_revision_ids())
230
234
 
 
235
    def test_sprouted_ghost_tags(self):
 
236
        path, gitsha = self.make_onerev_branch()
 
237
        r = GitRepo(path)
 
238
        self.addCleanup(r.close)
 
239
        r.refs[b"refs/tags/lala"] = b"aa" * 20
 
240
        oldrepo = Repository.open(path)
 
241
        revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha)
 
242
        warnings, newbranch = self.callCatchWarnings(
 
243
            self.clone_git_branch, path, "f")
 
244
        self.assertEqual({}, newbranch.tags.get_tag_dict())
 
245
        # Dulwich raises a UserWarning for tags with invalid target
 
246
        self.assertIn(('ref refs/tags/lala points at non-present sha ' + ("aa" * 20), ), [w.args for w in warnings])
 
247
 
231
248
    def test_interbranch_pull(self):
232
249
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
233
250
        oldrepo = Repository.open(path)
260
277
    def test_interbranch_pull_with_tags(self):
261
278
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
262
279
        gitrepo = GitRepo(path)
 
280
        self.addCleanup(gitrepo.close)
263
281
        gitrepo.refs[b"refs/tags/sometag"] = gitsha2
264
282
        oldrepo = Repository.open(path)
265
283
        revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1)
272
290
        self.assertEqual(revid1, newbranch.last_revision())
273
291
        self.assertTrue(newbranch.repository.has_revision(revid2))
274
292
 
 
293
    def test_bzr_branch_bound_to_git(self):
 
294
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
 
295
        wt = Branch.open(path).create_checkout('co')
 
296
        self.build_tree_contents([('co/foobar', b'blah')])
 
297
        self.assertRaises(
 
298
            errors.NoRoundtrippingSupport, wt.commit,
 
299
            'commit from bound branch.')
 
300
        revid = wt.commit('commit from bound branch.', lossy=True)
 
301
        self.assertEqual(revid, wt.branch.last_revision())
 
302
        self.assertEqual(
 
303
            revid,
 
304
            wt.branch.get_master_branch().last_revision())
 
305
 
275
306
 
276
307
class ForeignTestsBranchFactory(object):
277
308