~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

Move working tree initialisation out from  Branch.initialize, deprecated Branch.initialize to Branch.create.

Show diffs side-by-side

added added

removed removed

Lines of Context:
334
334
 
335
335
        return self._iterate_over(relpaths, copy_entry, pb, 'copy_to', expand=False)
336
336
 
 
337
    def copy_tree(self, from_relpath, to_relpath):
 
338
        """Copy a subtree from one relpath to another.
 
339
 
 
340
        If a faster implementation is available, specific transports should 
 
341
        implement it.
 
342
        """
 
343
        source = self.clone(from_relpath)
 
344
        self.mkdir(to_relpath)
 
345
        target = self.clone(to_relpath)
 
346
        files = []
 
347
        directories = ['.']
 
348
        while directories:
 
349
            dir = directories.pop()
 
350
            if dir != '.':
 
351
                target.mkdir(dir)
 
352
            for path in source.list_dir(dir):
 
353
                path = dir + '/' + path
 
354
                stat = source.stat(path)
 
355
                if S_ISDIR(stat.st_mode):
 
356
                    directories.append(path)
 
357
                else:
 
358
                    files.append(path)
 
359
        source.copy_to(files, target)
 
360
 
337
361
    def move(self, rel_from, rel_to):
338
362
        """Move the item at rel_from to the location at rel_to.
339
363
        
340
364
        If a transport can directly implement this it is suggested that
341
365
        it do so for efficiency.
342
366
        """
343
 
        self.copy(rel_from, rel_to)
344
 
        self.delete(rel_from)
 
367
        if S_ISDIR(self.stat(rel_from).st_mode):
 
368
            self.copy_tree(rel_from, rel_to)
 
369
            self.delete_tree(rel_from)
 
370
        else:
 
371
            self.copy(rel_from, rel_to)
 
372
            self.delete(rel_from)
345
373
 
346
374
    def move_multi(self, relpaths, pb=None):
347
375
        """Move a bunch of entries.