36
36
from bzrlib.revision import common_ancestor, MultipleRevisionSources
37
37
from bzrlib.errors import NoSuchRevision
39
# TODO: build_working_dir can be built on something simpler than merge()
41
# FIXME: merge() parameters seem oriented towards the command line
40
43
# comments from abentley on irc: merge happens in two stages, each
41
44
# of which generates a changeset object
238
242
def get_file_sha1(self, id):
239
243
return self.tree.get_file_sha1(id)
245
def is_executable(self, id):
246
return self.tree.is_executable(id)
241
248
def id2path(self, file_id):
242
249
return self.tree.id2path(file_id)
260
267
if self.root is not None:
261
268
return self.tree.abspath(self.tree.id2path(id))
263
if self.tree.inventory[id].kind in ("directory", "root_directory"):
270
kind = self.tree.inventory[id].kind
271
if kind in ("directory", "root_directory"):
264
272
return self.tempdir
265
273
if not self.cached.has_key(id):
266
path = os.path.join(self.tempdir, "texts", id)
267
outfile = file(path, "wb")
268
outfile.write(self.tree.get_file(id).read())
269
assert(os.path.exists(path))
275
path = os.path.join(self.tempdir, "texts", id)
276
outfile = file(path, "wb")
277
outfile.write(self.tree.get_file(id).read())
278
assert(bzrlib.osutils.lexists(path))
279
if self.tree.is_executable(id):
282
assert kind == "symlink"
283
path = os.path.join(self.tempdir, "symlinks", id)
284
target = self.tree.get_symlink_target(id)
285
os.symlink(target, path)
270
286
self.cached[id] = path
271
287
return self.cached[id]
290
def build_working_dir(to_dir):
291
"""Build a working directory in an empty directory.
293
to_dir is a directory containing branch metadata but no working files,
294
typically constructed by cloning an existing branch.
296
This is split out as a special idiomatic case of merge. It could
297
eventually be done by just building the tree directly calling into
298
lower-level code (e.g. constructing a changeset).
300
merge((to_dir, -1), (to_dir, 0), this_dir=to_dir,
301
check_clean=False, ignore_zero=True)
275
304
def merge(other_revision, base_revision,
276
305
check_clean=True, ignore_zero=False,
288
317
If true, this_dir must have no uncommitted changes before the
319
ignore_zero - If true, suppress the "zero conflicts" message when
320
there are no conflicts; should be set when doing something we expect
321
to complete perfectly.
291
323
All available ancestors of other_revision and base_revision are
292
324
automatically pulled into the branch.