Merge lp:~bac/tarmac/make_treedir into lp:tarmac

Proposed by Brad Crittenden
Status: Merged
Approved by: Paul Hummer
Approved revision: 401
Merged at revision: 400
Proposed branch: lp:~bac/tarmac/make_treedir
Merge into: lp:tarmac
Diff against target: 233 lines (+64/-24)
8 files modified
HACKING (+11/-0)
docs/introduction.txt (+23/-18)
docs/writingplugins.txt (+1/-1)
tarmac/bin/commands.py (+2/-2)
tarmac/branch.py (+5/-0)
tarmac/config.py (+2/-2)
tarmac/tests/test_branch.py (+19/-0)
tarmac/tests/test_commands.py (+1/-1)
To merge this branch: bzr merge lp:~bac/tarmac/make_treedir
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Review via email: mp+112840@code.launchpad.net

Commit message

If the dirname() portion of tree_dir does not exist, then create it in create_tree.

Description of the change

If the dirname() portion of tree_dir does not exist, then create it in create_tree.

Also made some changes to the documentation that I think helps clarify things. One change that may be controversial is to *not* use 'tarmac' as the example when explaining the configuration as it is too subtle for new users to see the difference between the [Tarmac] stanzas and the subsequent [lp:tarmac] parts. Perhaps just an introductory statement would've sufficed but it seemed reasonable to avoid the confusion all together.

Some line changes are due to deleting trailing whitespace, which my editor does automatically. Sorry for polluting the diff with those. Similarly, I removed some apostrophes (single-quotes) contained within docstrings as they appear as unbalanced quotes.

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the review Paul. I assume you'll merge it into trunk shortly?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'HACKING'
--- HACKING 2010-11-04 16:34:30 +0000
+++ HACKING 2012-06-29 20:15:23 +0000
@@ -24,6 +24,17 @@
2424
2525
26=============26=============
27Running Tests
28=============
29
30Tests are run using 'trial' from Twisted and rely on bzrlib.tests. So
31you must install the `python-twisted-core` and `python-bzrlib.tests`
32packages in order to run the tests. Once done, from the top of the
33repository you can run:
34
35% trial tarmac
36
37=============
27Writing Tests38Writing Tests
28=============39=============
2940
3041
=== modified file 'docs/introduction.txt'
--- docs/introduction.txt 2011-06-22 09:50:42 +0000
+++ docs/introduction.txt 2012-06-29 20:15:23 +0000
@@ -25,13 +25,13 @@
25=============25=============
2626
27Tarmac gets it's configuration data from ``~/.config/tarmac/tarmac.conf`` --27Tarmac gets it's configuration data from ``~/.config/tarmac/tarmac.conf`` --
28The configuration is split up by projects. As an example, Tarmac will28The configuration is split up by projects. As an example, a fictional
29demonstrate its own config throughout this project. To start with, the Tarmac29`phoo` project will be used. The config file starts with items that
30project should be added to the config (with the file being created if it30apply to the Tarmac command. Add to the following to the config file,
31doesn't exist already).::31creating it if it doesn't exist already).::
3232
33 [Tarmac]33 [Tarmac]
34 # Configuration for the Tarmac project34 # Configuration for the Tarmac command.
3535
36This doesn't mean much by itself. Optionally, we can also specify where to36This doesn't mean much by itself. Optionally, we can also specify where to
37write the log (by default, it logs to ~/tarmac.log). A basic log file setting37write the log (by default, it logs to ~/tarmac.log). A basic log file setting
@@ -40,19 +40,22 @@
40 [Tarmac]40 [Tarmac]
41 log_file = /var/log/tarmac.log41 log_file = /var/log/tarmac.log
4242
43Now let's provide some branches for Tarmac to manage. How about Tarmac's43If placing the file in ``/var/log`` be sure the user running
44``tarmac`` has write permission to that file.
45
46Now let's provide some branches for Tarmac to manage. How about phoo's
44development focus first? Specifying this is REALLY easy. Now my config file47development focus first? Specifying this is REALLY easy. Now my config file
45will look like this::48will look like this::
4649
47 [Tarmac]50 [Tarmac]
48 log_file = /var/log/tarmac.log51 log_file = /var/log/tarmac.log
4952
50 [lp:tarmac]53 [lp:phoo]
5154
52That's it! I specify the branch by it's lp: name, and Tarmac knows that when55That's it! I specify the branch by it's lp: name, and Tarmac knows that when
53it's instructed to land branches, it should check up on lp:tarmac for approved56it's instructed to land branches, it should check up on lp:phoo for approved
54merge proposals. However, this means that Tarmac has to make a new tree of57merge proposals. However, this means that Tarmac has to make a new tree of
55lp:tarmac every time it makes a landing run. This is rather inefficient. We58lp:phoo every time it makes a landing run. This is rather inefficient. We
56can actually have Tarmac cache a tree, and just update it on every run. This59can actually have Tarmac cache a tree, and just update it on every run. This
57path to the cache tree can be specified by changing the config file to look60path to the cache tree can be specified by changing the config file to look
58like this::61like this::
@@ -60,8 +63,8 @@
60 [Tarmac]63 [Tarmac]
61 log_file = /var/log/tarmac.log64 log_file = /var/log/tarmac.log
6265
63 [lp:tarmac]66 [lp:phoo]
64 tree_dir = /var/cache/tarmac67 tree_dir = /var/cache/tarmac/phoo/trunk
6568
66If this directory or tree doesn't exist, Tarmac will go ahead and create it.69If this directory or tree doesn't exist, Tarmac will go ahead and create it.
6770
@@ -71,14 +74,15 @@
7174
72Once Tarmac is all configured, simply run ``tarmac merge``. Voila! If there75Once Tarmac is all configured, simply run ``tarmac merge``. Voila! If there
73are issues at all, you can run ``tarmac merge --debug`` to get more debug76are issues at all, you can run ``tarmac merge --debug`` to get more debug
74imformation.77information.
7578
76==============79==============
77Tarmac on Cron80Tarmac on Cron
78==============81==============
7982
80Tarmac runs best on a cron, because it's doing stuff you shouldn't even need to83Tarmac runs best on a cron job, because it's doing stuff you shouldn't
81worry about. To make Tarmac run on a cron, add this to your crontab::84even need to worry about. To make Tarmac run on a cron, add this to
85your crontab::
8286
830 * * * * tarmac merge870 * * * * tarmac merge
8488
@@ -190,10 +194,11 @@
190CIA.vc Notifier194CIA.vc Notifier
191===============195===============
192196
193The CIA.vc Notifier can be configured to notify the CIA.vc service of197The CIA.vc Notifier (see ``http://cia.vc``) can be configured to
194successful merges. Tarmac has already been configured to work with the CIA.vc198notify the CIA.vc service of successful merges. Tarmac has already
195service and is set up to notify those in the #tarmac IRC channel on Freenode.199been configured to work with the CIA.vc service and is set up to
196This configuration looks like this::200notify those in the #tarmac IRC channel on Freenode. This
201configuration looks like this::
197202
198 [lp:tarmac]203 [lp:tarmac]
199 cia_project = tarmac204 cia_project = tarmac
200205
=== modified file 'docs/writingplugins.txt'
--- docs/writingplugins.txt 2010-09-17 21:57:28 +0000
+++ docs/writingplugins.txt 2012-06-29 20:15:23 +0000
@@ -53,7 +53,7 @@
53arguments to the plugin are explained below.53arguments to the plugin are explained below.
5454
55**command**55**command**
56 The tarmac command. For instance, a ``tarmac land`` call.56 The tarmac command. For instance, a ``tarmac merge`` call.
5757
58**target**58**target**
59 An instance of ``tarmac.branch.Branch`` containing details about the target59 An instance of ``tarmac.branch.Branch`` containing details about the target
6060
=== modified file 'tarmac/bin/commands.py'
--- tarmac/bin/commands.py 2012-06-28 13:50:56 +0000
+++ tarmac/bin/commands.py 2012-06-29 20:15:23 +0000
@@ -40,7 +40,7 @@
40 self.config.set('Tarmac', name, False)40 self.config.set('Tarmac', name, False)
4141
42 def _usage(self):42 def _usage(self):
43 """Custom _usage for referencing "tarmac" instead of "bzr."""43 """Custom _usage for referencing 'tarmac' instead of 'bzr'."""
44 s = 'tarmac ' + self.name() + ' '44 s = 'tarmac ' + self.name() + ' '
45 for aname in self.takes_args:45 for aname in self.takes_args:
46 aname = aname.upper()46 aname = aname.upper()
@@ -306,7 +306,7 @@
306 "'Approved'".format(entry.queue_status))306 "'Approved'".format(entry.queue_status))
307 continue307 continue
308308
309 if (not self.config.imply_commit_message and 309 if (not self.config.imply_commit_message and
310 not entry.commit_message):310 not entry.commit_message):
311 self.logger.debug(311 self.logger.debug(
312 " Skipping proposal: proposal has no commit message")312 " Skipping proposal: proposal has no commit message")
313313
=== modified file 'tarmac/branch.py'
--- tarmac/branch.py 2010-10-22 17:59:26 +0000
+++ tarmac/branch.py 2012-06-29 20:15:23 +0000
@@ -72,6 +72,11 @@
72 self.tree = WorkingTree.open(self.config.tree_dir)72 self.tree = WorkingTree.open(self.config.tree_dir)
73 else:73 else:
74 self.logger.debug('Tree does not exist. Creating dir')74 self.logger.debug('Tree does not exist. Creating dir')
75 # Create the path up to but not including tree_dir if it does
76 # not exist.
77 parent_dir = os.path.dirname(self.config.tree_dir)
78 if not os.path.exists(parent_dir):
79 os.makedirs(parent_dir)
75 self.tree = self.bzr_branch.create_checkout(80 self.tree = self.bzr_branch.create_checkout(
76 self.config.tree_dir, lightweight=True)81 self.config.tree_dir, lightweight=True)
77 except AttributeError:82 except AttributeError:
7883
=== modified file 'tarmac/config.py'
--- tarmac/config.py 2011-01-05 17:25:58 +0000
+++ tarmac/config.py 2012-06-29 20:15:23 +0000
@@ -104,7 +104,7 @@
104 section.startswith('lp:')]104 section.startswith('lp:')]
105105
106 def _check_config_dirs(self):106 def _check_config_dirs(self):
107 '''Create the configuration directory if it doesn't exist.'''107 '''Create the configuration directory if it does not exist.'''
108 if not os.path.exists(self.CONFIG_HOME):108 if not os.path.exists(self.CONFIG_HOME):
109 os.makedirs(self.CONFIG_HOME)109 os.makedirs(self.CONFIG_HOME)
110 if not os.path.exists(self.CACHE_HOME):110 if not os.path.exists(self.CACHE_HOME):
@@ -117,7 +117,7 @@
117class BranchConfig:117class BranchConfig:
118 '''A Branch specific config.118 '''A Branch specific config.
119119
120 Instead of providing the whole config for branches, it's better to provide120 Instead of providing the whole config for branches, it is better to provide
121 it with only its specific config vars.121 it with only its specific config vars.
122 '''122 '''
123123
124124
=== modified file 'tarmac/tests/test_branch.py'
--- tarmac/tests/test_branch.py 2010-10-22 13:51:39 +0000
+++ tarmac/tests/test_branch.py 2012-06-29 20:15:23 +0000
@@ -41,6 +41,25 @@
41 self.assertFalse(hasattr(a_branch, 'tree'))41 self.assertFalse(hasattr(a_branch, 'tree'))
42 self.remove_branch_config(tree_dir)42 self.remove_branch_config(tree_dir)
4343
44 def test_create_missing_parent_dir(self):
45 '''Test the creation of a TarmacBranch instance in a path that does
46 not fully exist, with a tree'''
47 branch_name = 'test_branch'
48 parent_dir = os.path.join(self.TEST_ROOT, 'missing')
49 tree_dir = os.path.join(parent_dir, branch_name)
50 self.add_branch_config(tree_dir)
51 # Create the mock somewhere other than where the tarmac branch will be
52 # located. Keep it right under TEST_ROOT so the
53 # TarmacDirectoryFactory mocking will work.
54 mock = MockLPBranch(os.path.join(self.TEST_ROOT, branch_name))
55 self.assertFalse(os.path.exists(parent_dir))
56 a_branch = branch.Branch.create(mock, self.config, create_tree=True)
57 self.assertTrue(os.path.exists(parent_dir))
58 self.assertTrue(isinstance(a_branch, branch.Branch))
59 self.assertTrue(a_branch.lp_branch.bzr_identity is not None)
60 self.assertTrue(hasattr(a_branch, 'tree'))
61 self.remove_branch_config(tree_dir)
62
44 def test_create_with_tree(self):63 def test_create_with_tree(self):
45 '''Test the creation of a TarmacBranch with a created tree.'''64 '''Test the creation of a TarmacBranch with a created tree.'''
46 self.assertTrue(isinstance(self.branch1, branch.Branch))65 self.assertTrue(isinstance(self.branch1, branch.Branch))
4766
=== modified file 'tarmac/tests/test_commands.py'
--- tarmac/tests/test_commands.py 2010-10-12 19:58:22 +0000
+++ tarmac/tests/test_commands.py 2012-06-29 20:15:23 +0000
@@ -60,7 +60,7 @@
60 # sys.stdout = old_stdout60 # sys.stdout = old_stdout
6161
62 def test_run_already_authenticated(self):62 def test_run_already_authenticated(self):
63 '''If the user has already been authenticated, don't try again.'''63 '''If the user has already been authenticated, do not try again.'''
64 registry = CommandRegistry(config=self.config)64 registry = CommandRegistry(config=self.config)
65 registry.register_command('authenticate', commands.cmd_authenticate)65 registry.register_command('authenticate', commands.cmd_authenticate)
66 command = registry._get_command(commands.cmd_authenticate,66 command = registry._get_command(commands.cmd_authenticate,

Subscribers

People subscribed via source and target branches