~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2005-10-04 04:32:32 UTC
  • mfrom: (1185.12.6)
  • mto: (1185.12.13)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: aaron.bentley@utoronto.ca-20051004043231-40302a149769263b
merged my own changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
227
227
        self.tree = tree
228
228
        self.tempdir = tempdir
229
229
        os.mkdir(os.path.join(self.tempdir, "texts"))
 
230
        os.mkdir(os.path.join(self.tempdir, "symlinks"))
230
231
        self.cached = {}
231
232
 
232
233
    def __iter__(self):
241
242
    def get_file_sha1(self, id):
242
243
        return self.tree.get_file_sha1(id)
243
244
 
 
245
    def is_executable(self, id):
 
246
        return self.tree.is_executable(id)
 
247
 
244
248
    def id2path(self, file_id):
245
249
        return self.tree.id2path(file_id)
246
250
 
263
267
        if self.root is not None:
264
268
            return self.tree.abspath(self.tree.id2path(id))
265
269
        else:
266
 
            if self.tree.inventory[id].kind in ("directory", "root_directory"):
 
270
            kind = self.tree.inventory[id].kind
 
271
            if kind in ("directory", "root_directory"):
267
272
                return self.tempdir
268
273
            if not self.cached.has_key(id):
269
 
                path = os.path.join(self.tempdir, "texts", id)
270
 
                outfile = file(path, "wb")
271
 
                outfile.write(self.tree.get_file(id).read())
272
 
                assert(os.path.exists(path))
 
274
                if kind == "file":
 
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):
 
280
                        os.chmod(path, 0755)
 
281
                else:
 
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)
273
286
                self.cached[id] = path
274
287
            return self.cached[id]
275
288