~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Robert Collins
  • Date: 2005-10-03 01:15:02 UTC
  • mfrom: (1092.2.28)
  • Revision ID: robertc@robertcollins.net-20051003011502-f579a509a136b774
mergeĀ fromĀ baz2bzr

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):
263
264
        if self.root is not None:
264
265
            return self.tree.abspath(self.tree.id2path(id))
265
266
        else:
266
 
            if self.tree.inventory[id].kind in ("directory", "root_directory"):
 
267
            kind = self.tree.inventory[id].kind
 
268
            if kind in ("directory", "root_directory"):
267
269
                return self.tempdir
268
270
            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))
 
271
                if kind == "file":
 
272
                    path = os.path.join(self.tempdir, "texts", id)
 
273
                    outfile = file(path, "wb")
 
274
                    outfile.write(self.tree.get_file(id).read())
 
275
                    assert(bzrlib.osutils.lexists(path))
 
276
                else:
 
277
                    assert kind == "symlink"
 
278
                    path = os.path.join(self.tempdir, "symlinks", id)
 
279
                    target = self.tree.get_symlink_target(id)
 
280
                    os.symlink(target, path)
273
281
                self.cached[id] = path
274
282
            return self.cached[id]
275
283