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
=== modified file '.bzrignore'
--- .bzrignore 2013-12-05 22:28:15 +0000
+++ .bzrignore 2015-06-09 15:08:40 +0000
@@ -5,3 +5,4 @@
5TODO5TODO
6debug*6debug*
7tarmac.egg-info7tarmac.egg-info
8*.pyc
89
=== modified file 'tarmac/bin/commands.py'
--- tarmac/bin/commands.py 2014-02-24 23:38:37 +0000
+++ tarmac/bin/commands.py 2015-06-09 15:08:40 +0000
@@ -27,7 +27,7 @@
27 STAGING_SERVICE_ROOT)27 STAGING_SERVICE_ROOT)
2828
29from tarmac.bin import options29from tarmac.bin import options
30from tarmac.branch import Branch30from tarmac.branch import BzrBranch
31from tarmac.hooks import tarmac_hooks31from tarmac.hooks import tarmac_hooks
32from tarmac.log import set_up_debug_logging, set_up_logging32from tarmac.log import set_up_debug_logging, set_up_logging
33from tarmac.exceptions import (33from tarmac.exceptions import (
@@ -226,8 +226,8 @@
226 return226 return
227227
228 try:228 try:
229 target = Branch.create(lp_branch, self.config, create_tree=True,229 target = BzrBranch.create(lp_branch, self.config, create_tree=True,
230 launchpad=self.launchpad)230 launchpad=self.launchpad)
231 except TarmacMergeError as failure:231 except TarmacMergeError as failure:
232 self._handle_merge_error(proposals[0], failure)232 self._handle_merge_error(proposals[0], failure)
233 return233 return
@@ -267,7 +267,7 @@
267 u'No approved revision specified.')267 u'No approved revision specified.')
268268
269269
270 source = Branch.create(270 source = BzrBranch.create(
271 proposal.source_branch, self.config, target=target)271 proposal.source_branch, self.config, target=target)
272272
273 approved = source.bzr_branch.revision_id_to_revno(273 approved = source.bzr_branch.revision_id_to_revno(
@@ -449,7 +449,7 @@
449 self.logger.debug('%(branch_url)s specified as branch_url' % {449 self.logger.debug('%(branch_url)s specified as branch_url' % {
450 'branch_url': branch_url})450 'branch_url': branch_url})
451 if not branch_url.startswith('lp:'):451 if not branch_url.startswith('lp:'):
452 raise TarmacCommandError('Branch urls must start with lp:')452 raise TarmacCommandError('Bzr branch urls must start with lp:')
453 self._do_merges(branch_url, source_mp=proposal)453 self._do_merges(branch_url, source_mp=proposal)
454454
455 else:455 else:
456456
=== modified file 'tarmac/branch.py'
--- tarmac/branch.py 2013-11-07 17:28:53 +0000
+++ tarmac/branch.py 2015-06-09 15:08:40 +0000
@@ -32,7 +32,7 @@
32)32)
3333
3434
35class Branch(object):35class BzrBranch(object):
3636
37 def __init__(self, lp_branch, config=False, target=None, launchpad=None):37 def __init__(self, lp_branch, config=False, target=None, launchpad=None):
38 self.lp_branch = lp_branch38 self.lp_branch = lp_branch
@@ -112,7 +112,7 @@
112 self.tree.update()112 self.tree.update()
113113
114 def merge(self, branch, revid=None):114 def merge(self, branch, revid=None):
115 '''Merge from another tarmac.branch.Branch instance.'''115 '''Merge from another tarmac.branch.BzrBranch instance.'''
116 assert self.tree116 assert self.tree
117 conflict_list = self.tree.merge_from_branch(117 conflict_list = self.tree.merge_from_branch(
118 branch.bzr_branch, to_revision=revid)118 branch.bzr_branch, to_revision=revid)
119119
=== modified file 'tarmac/tests/__init__.py'
--- tarmac/tests/__init__.py 2013-12-05 22:28:15 +0000
+++ tarmac/tests/__init__.py 2015-06-09 15:08:40 +0000
@@ -203,13 +203,13 @@
203 self.add_branch_config(branch2_dir)203 self.add_branch_config(branch2_dir)
204204
205 mock1 = MockLPBranch(branch1_dir)205 mock1 = MockLPBranch(branch1_dir)
206 branch1 = branch.Branch.create(mock1, self.config, create_tree=True)206 branch1 = branch.BzrBranch.create(mock1, self.config, create_tree=True)
207 branch1.commit("Reading, 'riting, 'rithmetic")207 branch1.commit("Reading, 'riting, 'rithmetic")
208 branch1.lp_branch.revision_count += 1208 branch1.lp_branch.revision_count += 1
209209
210 mock2 = MockLPBranch(branch2_dir, source_branch=branch1.lp_branch)210 mock2 = MockLPBranch(branch2_dir, source_branch=branch1.lp_branch)
211 branch2 = branch.Branch.create(mock2, self.config, create_tree=True,211 branch2 = branch.BzrBranch.create(mock2, self.config, create_tree=True,
212 target=branch1)212 target=branch1)
213 branch2.commit('ABC...')213 branch2.commit('ABC...')
214214
215 added_file = os.path.join(branch2.lp_branch.tree_dir, 'README')215 added_file = os.path.join(branch2.lp_branch.tree_dir, 'README')
216216
=== modified file 'tarmac/tests/test_branch.py'
--- tarmac/tests/test_branch.py 2013-11-07 17:28:53 +0000
+++ tarmac/tests/test_branch.py 2015-06-09 15:08:40 +0000
@@ -33,15 +33,15 @@
3333
3434
35class TestBranch(BranchTestCase):35class TestBranch(BranchTestCase):
36 '''Test for Tarmac.branch.Branch.'''36 '''Test for Tarmac.branch.BzrBranch.'''
3737
38 def test_create(self):38 def test_create(self):
39 '''Test the creation of a TarmacBranch instance.'''39 '''Test the creation of a TarmacBranch instance.'''
40 tree_dir = os.path.join(self.TEST_ROOT, 'test_create')40 tree_dir = os.path.join(self.TEST_ROOT, 'test_create')
41 self.add_branch_config(tree_dir)41 self.add_branch_config(tree_dir)
4242
43 a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config)43 a_branch = branch.BzrBranch.create(MockLPBranch(tree_dir), self.config)
44 self.assertTrue(isinstance(a_branch, branch.Branch))44 self.assertTrue(isinstance(a_branch, branch.BzrBranch))
45 self.assertTrue(a_branch.lp_branch.bzr_identity is not None)45 self.assertTrue(a_branch.lp_branch.bzr_identity is not None)
46 self.assertFalse(hasattr(a_branch, 'tree'))46 self.assertFalse(hasattr(a_branch, 'tree'))
47 self.remove_branch_config(tree_dir)47 self.remove_branch_config(tree_dir)
@@ -58,16 +58,16 @@
58 # TarmacDirectoryFactory mocking will work.58 # TarmacDirectoryFactory mocking will work.
59 mock = MockLPBranch(os.path.join(self.TEST_ROOT, branch_name))59 mock = MockLPBranch(os.path.join(self.TEST_ROOT, branch_name))
60 self.assertFalse(os.path.exists(parent_dir))60 self.assertFalse(os.path.exists(parent_dir))
61 a_branch = branch.Branch.create(mock, self.config, create_tree=True)61 a_branch = branch.BzrBranch.create(mock, self.config, create_tree=True)
62 self.assertTrue(os.path.exists(parent_dir))62 self.assertTrue(os.path.exists(parent_dir))
63 self.assertTrue(isinstance(a_branch, branch.Branch))63 self.assertTrue(isinstance(a_branch, branch.BzrBranch))
64 self.assertTrue(a_branch.lp_branch.bzr_identity is not None)64 self.assertTrue(a_branch.lp_branch.bzr_identity is not None)
65 self.assertTrue(hasattr(a_branch, 'tree'))65 self.assertTrue(hasattr(a_branch, 'tree'))
66 self.remove_branch_config(tree_dir)66 self.remove_branch_config(tree_dir)
6767
68 def test_create_with_tree(self):68 def test_create_with_tree(self):
69 '''Test the creation of a TarmacBranch with a created tree.'''69 '''Test the creation of a TarmacBranch with a created tree.'''
70 self.assertTrue(isinstance(self.branch1, branch.Branch))70 self.assertTrue(isinstance(self.branch1, branch.BzrBranch))
71 self.assertTrue(self.branch1.lp_branch.bzr_identity is not None)71 self.assertTrue(self.branch1.lp_branch.bzr_identity is not None)
72 self.assertTrue(hasattr(self.branch1, 'tree'))72 self.assertTrue(hasattr(self.branch1, 'tree'))
7373
@@ -75,7 +75,7 @@
75 '''A merge on a branch with no tree will raise an exception.'''75 '''A merge on a branch with no tree will raise an exception.'''
76 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')76 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
77 self.add_branch_config(branch3_dir)77 self.add_branch_config(branch3_dir)
78 branch3 = branch.Branch.create(MockLPBranch(78 branch3 = branch.BzrBranch.create(MockLPBranch(
79 branch3_dir, source_branch=self.branch1.lp_branch),79 branch3_dir, source_branch=self.branch1.lp_branch),
80 self.config)80 self.config)
8181
@@ -89,7 +89,7 @@
89 changes are present.'''89 changes are present.'''
90 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')90 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
91 self.add_branch_config(branch3_dir)91 self.add_branch_config(branch3_dir)
92 branch3 = branch.Branch.create(MockLPBranch(92 branch3 = branch.BzrBranch.create(MockLPBranch(
93 branch3_dir, source_branch=self.branch1.lp_branch),93 branch3_dir, source_branch=self.branch1.lp_branch),
94 self.config)94 self.config)
9595
@@ -214,13 +214,13 @@
214 self.branch2.commit,214 self.branch2.commit,
215 'Authors Merge test', authors=['\n'.join(authors)])215 'Authors Merge test', authors=['\n'.join(authors)])
216216
217 @patch('tarmac.branch.bzr_branch.Branch.user_url')217 @patch('tarmac.branch.bzr_branch.BzrBranch.user_url')
218 def test_create_tree_invalid_workingtree(self, mocked):218 def test_create_tree_invalid_workingtree(self, mocked):
219 """Test that InvalidWorkingTree is raised when it should be."""219 """Test that InvalidWorkingTree is raised when it should be."""
220 tree_dir = os.path.join(self.TEST_ROOT, 'test_invalid_workingtree')220 tree_dir = os.path.join(self.TEST_ROOT, 'test_invalid_workingtree')
221 self.add_branch_config(tree_dir)221 self.add_branch_config(tree_dir)
222 self.addCleanup(self.remove_branch_config, tree_dir)222 self.addCleanup(self.remove_branch_config, tree_dir)
223 a_branch = branch.Branch(MockLPBranch(tree_dir), self.config)223 a_branch = branch.BzrBranch(MockLPBranch(tree_dir), self.config)
224 a_branch.bzr_branch.user_url = 'lp:invalid'224 a_branch.bzr_branch.user_url = 'lp:invalid'
225 self.assertRaises(InvalidWorkingTree,225 self.assertRaises(InvalidWorkingTree,
226 a_branch.create_tree)226 a_branch.create_tree)
@@ -233,7 +233,7 @@
233 self.addCleanup(shutil.rmtree, tree_dir)233 self.addCleanup(shutil.rmtree, tree_dir)
234234
235 committer = 'LP User'235 committer = 'LP User'
236 a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config,236 a_branch = branch.BzrBranch.create(MockLPBranch(tree_dir), self.config,
237 create_tree=True, launchpad=Thing(237 create_tree=True, launchpad=Thing(
238 me=Thing(display_name=committer)))238 me=Thing(display_name=committer)))
239 a_branch.commit('Test LP User.')239 a_branch.commit('Test LP User.')
240240
=== modified file 'tarmac/tests/test_commands.py'
--- tarmac/tests/test_commands.py 2014-02-24 23:41:32 +0000
+++ tarmac/tests/test_commands.py 2015-06-09 15:08:40 +0000
@@ -22,7 +22,7 @@
22from mock import patch, MagicMock22from mock import patch, MagicMock
23from tarmac.bin import commands23from tarmac.bin import commands
24from tarmac.bin.registry import CommandRegistry24from tarmac.bin.registry import CommandRegistry
25from tarmac.branch import Branch25from tarmac.branch import BzrBranch
26from tarmac.config import TarmacConfig26from tarmac.config import TarmacConfig
27from tarmac.exceptions import (27from tarmac.exceptions import (
28 InvalidWorkingTree,28 InvalidWorkingTree,
@@ -190,8 +190,8 @@
190 # Create a 3rd branch we'll use to test with190 # Create a 3rd branch we'll use to test with
191 branch3_dir = os.path.join(self.TEST_ROOT, name)191 branch3_dir = os.path.join(self.TEST_ROOT, name)
192 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)192 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
193 branch3 = Branch.create(mock3, self.config, create_tree=True,193 branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
194 target=self.branch1)194 target=self.branch1)
195 branch3.commit('Prerequisite commit.')195 branch3.commit('Prerequisite commit.')
196 branch3.lp_branch.revision_count += 1196 branch3.lp_branch.revision_count += 1
197197
@@ -270,8 +270,8 @@
270 # Create a 3rd prerequisite branch we'll use to test with270 # Create a 3rd prerequisite branch we'll use to test with
271 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')271 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
272 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)272 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
273 branch3 = Branch.create(mock3, self.config, create_tree=True,273 branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
274 target=self.branch1)274 target=self.branch1)
275 branch3.commit('Prerequisite commit.')275 branch3.commit('Prerequisite commit.')
276 branch3.lp_branch.revision_count += 1276 branch3.lp_branch.revision_count += 1
277277
@@ -316,8 +316,8 @@
316 # Create a 3rd prerequisite branch we'll use to test with316 # Create a 3rd prerequisite branch we'll use to test with
317 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')317 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
318 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)318 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
319 branch3 = Branch.create(mock3, self.config, create_tree=True,319 branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
320 target=self.branch1)320 target=self.branch1)
321 branch3.commit('Prerequisite commit.')321 branch3.commit('Prerequisite commit.')
322 branch3.lp_branch.revision_count += 1322 branch3.lp_branch.revision_count += 1
323323
@@ -365,8 +365,8 @@
365 # Create a 3rd prerequisite branch we'll use to test with365 # Create a 3rd prerequisite branch we'll use to test with
366 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')366 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
367 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)367 mock3 = MockLPBranch(branch3_dir, source_branch=self.branch1.lp_branch)
368 branch3 = Branch.create(mock3, self.config, create_tree=True,368 branch3 = BzrBranch.create(mock3, self.config, create_tree=True,
369 target=self.branch1)369 target=self.branch1)
370 branch3.commit('Prerequisite commit.')370 branch3.commit('Prerequisite commit.')
371 branch3.lp_branch.revision_count += 1371 branch3.lp_branch.revision_count += 1
372372

Subscribers

People subscribed via source and target branches