~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

Added symlink support

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
        """
99
99
        unique_add(self._new_contents, trans_id, ('directory',))
100
100
 
 
101
    def create_symlink(self, target, trans_id):
 
102
        """Schedule creation of a new symbolic link.
 
103
 
 
104
        target is a bytestring.
 
105
        See also new_symlink.
 
106
        """
 
107
        unique_add(self._new_contents, trans_id, ('symlink', target))
 
108
 
101
109
    def version_file(self, file_id, trans_id):
102
110
        """Schedule a file to become versioned."""
103
111
        unique_add(self._new_id, trans_id, file_id)
277
285
                f.close()
278
286
            elif kind == 'directory':
279
287
                os.mkdir(self._tree.abspath(path))
 
288
            elif kind == 'symlink':
 
289
                target = self._new_contents[trans_id][1]
 
290
                os.symlink(target, path)
280
291
 
281
292
            if trans_id in self._new_id:
282
293
                if kind is None:
318
329
        self.create_directory(trans_id)
319
330
        return trans_id 
320
331
 
 
332
    def new_symlink(self, name, parent_id, target, file_id=None):
 
333
        """\
 
334
        Convenience method to create symbolic link.
 
335
        
 
336
        name is the name of the symlink to create.
 
337
        parent_id is the transaction id of the parent directory of the symlink.
 
338
        target is a bytestring of the target of the symlink.
 
339
        file_id is the inventory ID of the file, if it is to be versioned.
 
340
        """
 
341
        trans_id = self.new_entry(name, parent_id, file_id)
 
342
        self.create_symlink(target, trans_id)
 
343
        return trans_id
 
344
 
321
345
 
322
346
class FinalPaths(object):
323
347
    """\