/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/walker/copy_base.py

  • Committer: Tim Marston
  • Date: 2016-05-22 16:45:54 UTC
  • Revision ID: tim@ed.am-20160522164554-n5qhuibvnv0z4tk1
added general reporting to CopyBase and configured it via copy-in and copy-out
walkers (it is required in copy in, during add command); added -R (recursive)
flass to add command; allow vcs backends to augment statically ignored files
list; added detection of out of date working copy to bzr backend;
generate_walk_list() now takes a mandatory directory as the first argument;
don't copy entire subtree during copy of missing directory (as this makes
assumptions about what's in the walk-list)

Show diffs side-by-side

added added

removed removed

29
29
        """The copy-base walker traverses a walklist ruthlessly mirroring src to dst.
30
30
        It is designed to be the base class of both the copy-in and copy-out walker,
31
31
        both of which are specialisations of this purpose.  See them for more
32
 
        information.  The print_op method, derived in those classes, takes, in
33
 
        addition to the relative filename, a source file type, an operation, and a
34
 
        sestination file type.  Valid file types are f (file), l (symlink), d
35
 
        (directory) and _ (non-existant).  Valid operations are * (modify), = (skip:
36
 
        same), @ (skip: symlink substitute) and # (skip: ignored).
 
32
        information.  The report method, which can be overridden in derived classes,
 
33
        takes, in addition to the relative filename, a source file type, an
 
34
        operation, and a sestination file type.  Valid file types are f (file), l
 
35
        (symlink), d (directory) and _ (non-existant).  Valid operations are *
 
36
        (modify), = (skip: same), @ (skip: symlink substitute) and # (skip:
 
37
        ignored).
 
38
 
37
39
        """
38
40
 
39
41
 
41
43
                self.check_src_symlinks = False
42
44
                self.check_dst_symlinks = False
43
45
                self.check_dst_ignores = False
 
46
                self.report = False
 
47
 
 
48
 
 
49
        def print_op( self, rel_file, src, op, dst ):
 
50
 
 
51
                # report changes
 
52
                if self.report and the.verbose < 2 and op == '*':
 
53
                        if dst == '_':
 
54
                                print " N  %s" % ( rel_file )
 
55
                        elif src == '_':
 
56
                                print " D  %s" % ( rel_file )
 
57
                        elif src == dst:
 
58
                                print " M  %s" % ( rel_file )
 
59
                        else:
 
60
                                print " K  %s" % ( rel_file )
44
61
 
45
62
 
46
63
        def process( self, rel_file, src, dst ):
53
70
                # src entity is directory
54
71
                if src.type == 'd':
55
72
 
56
 
                        # if dst entity doesn't exist, create directory (no need to recurse,
57
 
                        # since we're copying the whole directory)
 
73
                        # if dst entity doesn't exist, create it (and recurse)
58
74
                        if dst.type == '_':
59
75
                                self.print_op( rel_file, 'd', '*', '_' )
60
 
                                shutil.copytree( src.file, dst.file, True )
 
76
                                os.mkdir( dst.file )
 
77
                                shutil.copystat( src.file, dst.file )
 
78
                                return True
61
79
 
62
80
                        # if dst entity is a directory, copy permissions, as required (and
63
81
                        # recurse)