197
197
if not self.ignore_zero:
198
198
note("%d conflicts encountered.\n" % self.conflicts)
200
def get_tree(treespec, temp_root, label, local_branch=None):
200
def get_tree(treespec, local_branch=None):
201
201
location, revno = treespec
202
202
branch = Branch.open_containing(location)
203
203
if revno is None:
206
206
revision = branch.last_revision()
208
208
revision = branch.get_rev_id(revno)
209
return branch, get_revid_tree(branch, revision, temp_root, label,
209
return branch, get_revid_tree(branch, revision, local_branch)
212
def get_revid_tree(branch, revision, temp_root, label, local_branch):
211
def get_revid_tree(branch, revision, local_branch):
213
212
if revision is None:
214
213
base_tree = branch.working_tree()
218
217
base_tree = local_branch.revision_tree(revision)
220
219
base_tree = branch.revision_tree(revision)
221
temp_path = os.path.join(temp_root, label)
223
return MergeAdapterTree(base_tree, temp_path)
226
223
def file_exists(tree, file_id):
227
224
return tree.has_filename(tree.id2path(file_id))
230
class MergeAdapterTree(object):
231
"""MergeAdapterTree adapts a normal tree for merge_inner to use.
233
The interface the merge_inner needs is nearly but not quite
234
the same as that of bzrlib.tree.
237
def __init__(self, tree, tempdir):
238
object.__init__(self)
239
if hasattr(tree, "basedir"):
240
self.basedir = tree.basedir
244
self.inventory = tree.inventory
245
self.tempdir = tempdir
246
os.mkdir(os.path.join(self.tempdir, "texts"))
247
os.mkdir(os.path.join(self.tempdir, "symlinks"))
251
return self.tree.__iter__()
253
def __contains__(self, file_id):
254
return file_id in self.tree
256
def get_file(self, file_id):
257
return self.tree.get_file(file_id)
259
def get_file_sha1(self, id):
260
return self.tree.get_file_sha1(id)
262
def is_executable(self, id):
263
return self.tree.is_executable(id)
265
def id2path(self, file_id):
266
return self.tree.id2path(file_id)
268
def has_id(self, file_id):
269
return self.tree.has_id(file_id)
271
def has_or_had_id(self, file_id):
272
return self.tree.has_or_had_id(file_id)
274
def kind(self, file_id):
275
return self.tree.kind(file_id)
277
def get_symlink_target(self, file_id):
278
return self.tree.get_symlink_target(file_id)
280
def id2abspath(self, file_id):
281
return self.tree.id2abspath(file_id)
284
227
def build_working_dir(to_dir):
285
228
"""Build a working directory in an empty directory.
330
273
this_branch.basis_tree(), False)
331
274
if changes.has_changed():
332
275
raise BzrCommandError("Working tree has uncommitted changes.")
333
other_branch, other_tree = get_tree(other_revision, tempdir, "other",
276
other_branch, other_tree = get_tree(other_revision, this_branch)
335
277
if other_revision[1] == -1:
336
278
other_rev_id = other_branch.last_revision()
337
279
if other_rev_id is None:
352
294
except NoCommonAncestor:
353
295
raise UnrelatedBranches()
354
base_tree = get_revid_tree(this_branch, base_rev_id, tempdir,
296
base_tree = get_revid_tree(this_branch, base_rev_id, None)
356
297
base_is_ancestor = True
358
base_branch, base_tree = get_tree(base_revision, tempdir, "base")
299
base_branch, base_tree = get_tree(base_revision)
359
300
if base_revision[1] == -1:
360
301
base_rev_id = base_branch.last_revision()
361
302
elif base_revision[1] is None: