Merge lp:~zyga/tarmac/git-support into lp:tarmac

Proposed by Zygmunt Krynicki
Status: Needs review
Proposed branch: lp:~zyga/tarmac/git-support
Merge into: lp:tarmac
Diff against target: 235 lines (+31/-30)
6 files modified
.bzrignore (+1/-0)
tarmac/bin/commands.py (+5/-5)
tarmac/branch.py (+2/-2)
tarmac/tests/__init__.py (+3/-3)
tarmac/tests/test_branch.py (+11/-11)
tarmac/tests/test_commands.py (+9/-9)
To merge this branch: bzr merge lp:~zyga/tarmac/git-support
Reviewer Review Type Date Requested Status
dobey Needs Information
Review via email: mp+261528@code.launchpad.net

Description of the change

aa97679 Rename Branch to BzrBranch
fb93a53 Ignore .pyc files

This branch is meant to get started with adding git support to tarmac. I'd like to see how conductive upstream is with this move and start making the necessary changes.

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

This specific change looks OK to me, but it implies there is an idea about how to get to the end goal. I'd like to know what the ideas of how to get to the end goal of this are, before landing this change, though.

There's a lot of ugliness in the current tests that I think could/should be cleaned up first, for example. Abstracting the bzr integration away and switching to use mocking in the tests, instead of creating actual branches and performing actions in them, will make things more reliable, and easy to repeat across VCS implementations.

review: Needs Information
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Thanks for the feedback!

I'll continue working on this and I'll be pushing more branches as I
make progress. I'll focus on separating the bzr bits so that git can
co-exist. As for testing, do you intend to have a single set of tests
that work for git and bzr together?

Thanks
ZK

On Tue, Jul 7, 2015 at 7:14 PM, Rodney Dawes <email address hidden> wrote:
> Review: Needs Information
>
> This specific change looks OK to me, but it implies there is an idea about how to get to the end goal. I'd like to know what the ideas of how to get to the end goal of this are, before landing this change, though.
>
> There's a lot of ugliness in the current tests that I think could/should be cleaned up first, for example. Abstracting the bzr integration away and switching to use mocking in the tests, instead of creating actual branches and performing actions in them, will make things more reliable, and easy to repeat across VCS implementations.
> --
> https://code.launchpad.net/~zyga/tarmac/git-support/+merge/261528
> You are the owner of lp:~zyga/tarmac/git-support.

Revision history for this message
dobey (dobey) wrote :

I think for the tests, each layer will need to be tested separately. The
abstraction would have tests, the underlying bzrlib back-end with its
own tests, and the git back-end with its tests.

On Tue, 2015-07-07 at 17:27 +0000, Zygmunt Krynicki wrote:
> Thanks for the feedback!
>
> I'll continue working on this and I'll be pushing more branches as I
> make progress. I'll focus on separating the bzr bits so that git can
> co-exist. As for testing, do you intend to have a single set of tests
> that work for git and bzr together?
>
> Thanks
> ZK
>
> On Tue, Jul 7, 2015 at 7:14 PM, Rodney Dawes <email address hidden> wrote:
> > Review: Needs Information
> >
> > This specific change looks OK to me, but it implies there is an idea about how to get to the end goal. I'd like to know what the ideas of how to get to the end goal of this are, before landing this change, though.
> >
> > There's a lot of ugliness in the current tests that I think could/should be cleaned up first, for example. Abstracting the bzr integration away and switching to use mocking in the tests, instead of creating actual branches and performing actions in them, will make things more reliable, and easy to repeat across VCS implementations.
> > --
> > https://code.launchpad.net/~zyga/tarmac/git-support/+merge/261528
> > You are the owner of lp:~zyga/tarmac/git-support.
>

Unmerged revisions

434. By Zygmunt Krynicki

Ignore .pyc files

Signed-off-by: Zygmunt Krynicki <email address hidden>

433. By Zygmunt Krynicki

Rename Branch to BzrBranch

This patch is meant to test the waters. My goal is to add git support to
tarmac. This change is a harmless change of tarmac.branch.Branch to
tarmac.branch.BzrBranch, this is in anticipation of subsequent add to
GitBranch and subsequent changes as they show up.

Signed-off-by: Zygmunt Krynicki <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2013-12-05 22:28:15 +0000
3+++ .bzrignore 2015-06-09 15:08:40 +0000
4@@ -5,3 +5,4 @@
5 TODO
6 debug*
7 tarmac.egg-info
8+*.pyc
9
10=== modified file 'tarmac/bin/commands.py'
11--- tarmac/bin/commands.py 2014-02-24 23:38:37 +0000
12+++ tarmac/bin/commands.py 2015-06-09 15:08:40 +0000
13@@ -27,7 +27,7 @@
14 STAGING_SERVICE_ROOT)
15
16 from tarmac.bin import options
17-from tarmac.branch import Branch
18+from tarmac.branch import BzrBranch
19 from tarmac.hooks import tarmac_hooks
20 from tarmac.log import set_up_debug_logging, set_up_logging
21 from tarmac.exceptions import (
22@@ -226,8 +226,8 @@
23 return
24
25 try:
26- target = Branch.create(lp_branch, self.config, create_tree=True,
27- launchpad=self.launchpad)
28+ target = BzrBranch.create(lp_branch, self.config, create_tree=True,
29+ launchpad=self.launchpad)
30 except TarmacMergeError as failure:
31 self._handle_merge_error(proposals[0], failure)
32 return
33@@ -267,7 +267,7 @@
34 u'No approved revision specified.')
35
36
37- source = Branch.create(
38+ source = BzrBranch.create(
39 proposal.source_branch, self.config, target=target)
40
41 approved = source.bzr_branch.revision_id_to_revno(
42@@ -449,7 +449,7 @@
43 self.logger.debug('%(branch_url)s specified as branch_url' % {
44 'branch_url': branch_url})
45 if not branch_url.startswith('lp:'):
46- raise TarmacCommandError('Branch urls must start with lp:')
47+ raise TarmacCommandError('Bzr branch urls must start with lp:')
48 self._do_merges(branch_url, source_mp=proposal)
49
50 else:
51
52=== modified file 'tarmac/branch.py'
53--- tarmac/branch.py 2013-11-07 17:28:53 +0000
54+++ tarmac/branch.py 2015-06-09 15:08:40 +0000
55@@ -32,7 +32,7 @@
56 )
57
58
59-class Branch(object):
60+class BzrBranch(object):
61
62 def __init__(self, lp_branch, config=False, target=None, launchpad=None):
63 self.lp_branch = lp_branch
64@@ -112,7 +112,7 @@
65 self.tree.update()
66
67 def merge(self, branch, revid=None):
68- '''Merge from another tarmac.branch.Branch instance.'''
69+ '''Merge from another tarmac.branch.BzrBranch instance.'''
70 assert self.tree
71 conflict_list = self.tree.merge_from_branch(
72 branch.bzr_branch, to_revision=revid)
73
74=== modified file 'tarmac/tests/__init__.py'
75--- tarmac/tests/__init__.py 2013-12-05 22:28:15 +0000
76+++ tarmac/tests/__init__.py 2015-06-09 15:08:40 +0000
77@@ -203,13 +203,13 @@
78 self.add_branch_config(branch2_dir)
79
80 mock1 = MockLPBranch(branch1_dir)
81- branch1 = branch.Branch.create(mock1, self.config, create_tree=True)
82+ branch1 = branch.BzrBranch.create(mock1, self.config, create_tree=True)
83 branch1.commit("Reading, 'riting, 'rithmetic")
84 branch1.lp_branch.revision_count += 1
85
86 mock2 = MockLPBranch(branch2_dir, source_branch=branch1.lp_branch)
87- branch2 = branch.Branch.create(mock2, self.config, create_tree=True,
88- target=branch1)
89+ branch2 = branch.BzrBranch.create(mock2, self.config, create_tree=True,
90+ target=branch1)
91 branch2.commit('ABC...')
92
93 added_file = os.path.join(branch2.lp_branch.tree_dir, 'README')
94
95=== modified file 'tarmac/tests/test_branch.py'
96--- tarmac/tests/test_branch.py 2013-11-07 17:28:53 +0000
97+++ tarmac/tests/test_branch.py 2015-06-09 15:08:40 +0000
98@@ -33,15 +33,15 @@
99
100
101 class TestBranch(BranchTestCase):
102- '''Test for Tarmac.branch.Branch.'''
103+ '''Test for Tarmac.branch.BzrBranch.'''
104
105 def test_create(self):
106 '''Test the creation of a TarmacBranch instance.'''
107 tree_dir = os.path.join(self.TEST_ROOT, 'test_create')
108 self.add_branch_config(tree_dir)
109
110- a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config)
111- self.assertTrue(isinstance(a_branch, branch.Branch))
112+ a_branch = branch.BzrBranch.create(MockLPBranch(tree_dir), self.config)
113+ self.assertTrue(isinstance(a_branch, branch.BzrBranch))
114 self.assertTrue(a_branch.lp_branch.bzr_identity is not None)
115 self.assertFalse(hasattr(a_branch, 'tree'))
116 self.remove_branch_config(tree_dir)
117@@ -58,16 +58,16 @@
118 # TarmacDirectoryFactory mocking will work.
119 mock = MockLPBranch(os.path.join(self.TEST_ROOT, branch_name))
120 self.assertFalse(os.path.exists(parent_dir))
121- a_branch = branch.Branch.create(mock, self.config, create_tree=True)
122+ a_branch = branch.BzrBranch.create(mock, self.config, create_tree=True)
123 self.assertTrue(os.path.exists(parent_dir))
124- self.assertTrue(isinstance(a_branch, branch.Branch))
125+ self.assertTrue(isinstance(a_branch, branch.BzrBranch))
126 self.assertTrue(a_branch.lp_branch.bzr_identity is not None)
127 self.assertTrue(hasattr(a_branch, 'tree'))
128 self.remove_branch_config(tree_dir)
129
130 def test_create_with_tree(self):
131 '''Test the creation of a TarmacBranch with a created tree.'''
132- self.assertTrue(isinstance(self.branch1, branch.Branch))
133+ self.assertTrue(isinstance(self.branch1, branch.BzrBranch))
134 self.assertTrue(self.branch1.lp_branch.bzr_identity is not None)
135 self.assertTrue(hasattr(self.branch1, 'tree'))
136
137@@ -75,7 +75,7 @@
138 '''A merge on a branch with no tree will raise an exception.'''
139 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
140 self.add_branch_config(branch3_dir)
141- branch3 = branch.Branch.create(MockLPBranch(
142+ branch3 = branch.BzrBranch.create(MockLPBranch(
143 branch3_dir, source_branch=self.branch1.lp_branch),
144 self.config)
145
146@@ -89,7 +89,7 @@
147 changes are present.'''
148 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
149 self.add_branch_config(branch3_dir)
150- branch3 = branch.Branch.create(MockLPBranch(
151+ branch3 = branch.BzrBranch.create(MockLPBranch(
152 branch3_dir, source_branch=self.branch1.lp_branch),
153 self.config)
154
155@@ -214,13 +214,13 @@
156 self.branch2.commit,
157 'Authors Merge test', authors=['\n'.join(authors)])
158
159- @patch('tarmac.branch.bzr_branch.Branch.user_url')
160+ @patch('tarmac.branch.bzr_branch.BzrBranch.user_url')
161 def test_create_tree_invalid_workingtree(self, mocked):
162 """Test that InvalidWorkingTree is raised when it should be."""
163 tree_dir = os.path.join(self.TEST_ROOT, 'test_invalid_workingtree')
164 self.add_branch_config(tree_dir)
165 self.addCleanup(self.remove_branch_config, tree_dir)
166- a_branch = branch.Branch(MockLPBranch(tree_dir), self.config)
167+ a_branch = branch.BzrBranch(MockLPBranch(tree_dir), self.config)
168 a_branch.bzr_branch.user_url = 'lp:invalid'
169 self.assertRaises(InvalidWorkingTree,
170 a_branch.create_tree)
171@@ -233,7 +233,7 @@
172 self.addCleanup(shutil.rmtree, tree_dir)
173
174 committer = 'LP User'
175- a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config,
176+ a_branch = branch.BzrBranch.create(MockLPBranch(tree_dir), self.config,
177 create_tree=True, launchpad=Thing(
178 me=Thing(display_name=committer)))
179 a_branch.commit('Test LP User.')
180
181=== modified file 'tarmac/tests/test_commands.py'
182--- tarmac/tests/test_commands.py 2014-02-24 23:41:32 +0000
183+++ tarmac/tests/test_commands.py 2015-06-09 15:08:40 +0000
184@@ -22,7 +22,7 @@
185 from mock import patch, MagicMock
186 from tarmac.bin import commands
187 from tarmac.bin.registry import CommandRegistry
188-from tarmac.branch import Branch
189+from tarmac.branch import BzrBranch
190 from tarmac.config import TarmacConfig
191 from tarmac.exceptions import (
192 InvalidWorkingTree,
193@@ -190,8 +190,8 @@
194 # Create a 3rd branch we'll use to test with
195 branch3_dir = os.path.join(self.TEST_ROOT, name)
196 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
197- branch3 = Branch.create(mock3, self.config, create_tree=True,
198- target=self.branch1)
199+ branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
200+ target=self.branch1)
201 branch3.commit('Prerequisite commit.')
202 branch3.lp_branch.revision_count += 1
203
204@@ -270,8 +270,8 @@
205 # Create a 3rd prerequisite branch we'll use to test with
206 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
207 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
208- branch3 = Branch.create(mock3, self.config, create_tree=True,
209- target=self.branch1)
210+ branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
211+ target=self.branch1)
212 branch3.commit('Prerequisite commit.')
213 branch3.lp_branch.revision_count += 1
214
215@@ -316,8 +316,8 @@
216 # Create a 3rd prerequisite branch we'll use to test with
217 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
218 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
219- branch3 = Branch.create(mock3, self.config, create_tree=True,
220- target=self.branch1)
221+ branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
222+ target=self.branch1)
223 branch3.commit('Prerequisite commit.')
224 branch3.lp_branch.revision_count += 1
225
226@@ -365,8 +365,8 @@
227 # Create a 3rd prerequisite branch we'll use to test with
228 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
229 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
230- branch3 = Branch.create(mock3, self.config, create_tree=True,
231- target=self.branch1)
232+ branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
233+ target=self.branch1)
234 branch3.commit('Prerequisite commit.')
235 branch3.lp_branch.revision_count += 1
236

Subscribers

People subscribed via source and target branches