72
73
def create_tree(self):
73
74
'''Create the dir and working tree.'''
76
'Using tree in %(tree_dir)s' % {
77
'tree_dir': self.config.tree_dir})
78
if os.path.exists(self.config.tree_dir):
79
self.tree = WorkingTree.open(self.config.tree_dir)
76
'Using tree in %(tree_dir)s' % {
77
'tree_dir': self.config.tree_dir})
78
if os.path.exists(self.config.tree_dir):
79
self.tree = WorkingTree.open(self.config.tree_dir)
81
if self.tree.branch.user_url != self.bzr_branch.user_url:
82
self.logger.debug('Tree URLs do not match: %s - %s' % (
83
self.bzr_branch.user_url, self.tree.branch.user_url))
84
raise InvalidWorkingTree(
85
'The `tree_dir` option for the target branch is not a '
86
'lightweight checkout. Please ask a project '
87
'administrator to resolve the issue, and try again.')
89
self.logger.debug('Tree does not exist. Creating dir')
90
# Create the path up to but not including tree_dir if it does
92
parent_dir = os.path.dirname(self.config.tree_dir)
93
if not os.path.exists(parent_dir):
94
os.makedirs(parent_dir)
95
self.tree = self.bzr_branch.create_checkout(
96
self.config.tree_dir, lightweight=True)
97
except AttributeError:
98
# Store this so we can rmtree later
99
self.temp_tree_dir = tempfile.mkdtemp()
101
'Using temp dir at %(tree_dir)s' % {
102
'tree_dir': self.temp_tree_dir})
103
self.tree = self.bzr_branch.create_checkout(self.temp_tree_dir)
81
if self.tree.branch.user_url != self.bzr_branch.user_url:
82
self.logger.debug('Tree URLs do not match: %s - %s' % (
83
self.bzr_branch.user_url, self.tree.branch.user_url))
84
raise InvalidWorkingTree(
85
'The `tree_dir` option for the target branch is not a '
86
'lightweight checkout. Please ask a project '
87
'administrator to resolve the issue, and try again.')
89
self.logger.debug('Tree does not exist. Creating dir')
90
# Create the path up to but not including tree_dir if it does
92
parent_dir = os.path.dirname(self.config.tree_dir)
93
if not os.path.exists(parent_dir):
94
os.makedirs(parent_dir)
95
self.tree = self.bzr_branch.create_checkout(
96
self.config.tree_dir, lightweight=True)
156
146
'%s in %s' % (conflict.typestring, conflict.path))
157
147
return '\n'.join(conflicts)
159
def commit(self, commit_message, revprops=None, **kwargs):
149
def commit(self, commit_message, revprops=None, dry_run=False, **kwargs):
160
150
'''Commit changes.'''
180
170
committer = 'Tarmac'
183
173
self.tree.commit(commit_message, committer=committer,
184
174
revprops=revprops, authors=authors)
185
except AssertionError as error:
186
raise TarmacMergeError(str(error))
189
177
def landing_candidates(self):
199
self.bzr_branch.lock_read()
200
self.target.bzr_branch.lock_read()
186
with ExitStack() as es:
187
es.enter_context(self.bzr_branch.lock_read())
188
es.enter_context(self.target.bzr_branch.lock_read())
202
190
graph = self.bzr_branch.repository.get_graph(
203
191
self.target.bzr_branch.repository)
232
217
"""Return the list of bugs fixed by the branch."""
236
self.bzr_branch.lock_read()
220
with self.bzr_branch.lock_read():
237
221
oldrevid = self.bzr_branch.get_rev_id(self.lp_branch.revision_count)
238
222
for rev_info in self.bzr_branch.iter_merge_sorted_revisions(
239
223
stop_revision_id=oldrevid):