Merge lp:~jelmer/brz/git-remote-uncommit into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/git-remote-uncommit
Merge into: lp:brz
Diff against target: 65 lines (+44/-0)
2 files modified
breezy/git/remote.py (+13/-0)
breezy/git/tests/test_remote.py (+31/-0)
To merge this branch: bzr merge lp:~jelmer/brz/git-remote-uncommit
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+355576@code.launchpad.net

Commit message

Support uncommit on remote git branches.

Description of the change

Support uncommit on remote git branches.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks, makes sense with the explaining.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/remote.py'
2--- breezy/git/remote.py 2018-10-14 12:46:54 +0000
3+++ breezy/git/remote.py 2018-11-12 21:12:26 +0000
4@@ -927,6 +927,19 @@
5 raise TypeError(tag_name)
6 yield (ref_name, tag_name, peeled, unpeeled)
7
8+ def set_last_revision_info(self, revno, revid):
9+ self.generate_revision_history(revid)
10+
11+ def generate_revision_history(self, revision_id, last_rev=None,
12+ other_branch=None):
13+ sha = self.lookup_bzr_revision_id(revision_id)[0]
14+ def get_changed_refs(old_refs):
15+ return {self.ref: sha}
16+ def generate_pack_data(have, want, ofs_delta=False):
17+ return pack_objects_to_data([])
18+ self.repository.send_pack(get_changed_refs, generate_pack_data)
19+ self._sha = sha
20+
21
22 def remote_refs_dict_to_container(refs_dict, symrefs_dict={}):
23 base = {}
24
25=== modified file 'breezy/git/tests/test_remote.py'
26--- breezy/git/tests/test_remote.py 2018-10-06 21:01:10 +0000
27+++ breezy/git/tests/test_remote.py 2018-11-12 21:12:26 +0000
28@@ -141,6 +141,37 @@
29 self.assertTrue(self.format.supports_tags())
30
31
32+class TestRemoteGitBranch(TestCaseWithTransport):
33+
34+ def setUp(self):
35+ TestCaseWithTransport.setUp(self)
36+ self.remote_real = GitRepo.init('remote', mkdir=True)
37+ self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
38+ self.permit_url(self.remote_url)
39+
40+ def test_set_last_revision_info(self):
41+ c1 = self.remote_real.do_commit(
42+ message=b'message 1',
43+ committer=b'committer <committer@example.com>',
44+ author=b'author <author@example.com>',
45+ ref=b'refs/heads/newbranch')
46+ c2 = self.remote_real.do_commit(
47+ message=b'message 2',
48+ committer=b'committer <committer@example.com>',
49+ author=b'author <author@example.com>',
50+ ref=b'refs/heads/newbranch')
51+
52+ remote = ControlDir.open(self.remote_url)
53+ newbranch = remote.open_branch('newbranch')
54+ self.assertEqual(newbranch.lookup_foreign_revision_id(c2),
55+ newbranch.last_revision())
56+ newbranch.set_last_revision_info(
57+ 1, newbranch.lookup_foreign_revision_id(c1))
58+ self.assertEqual(c1, self.remote_real.refs[b'refs/heads/newbranch'])
59+ self.assertEqual(newbranch.last_revision(),
60+ newbranch.lookup_foreign_revision_id(c1))
61+
62+
63 class FetchFromRemoteTestBase(object):
64
65 _test_needs_features = [ExecutableFeature('git')]

Subscribers

People subscribed via source and target branches