/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_out.py

  • Committer: Tim Marston
  • Date: 2014-04-05 22:27:09 UTC
  • Revision ID: tim@ed.am-20140405222709-4mp50aiu184blnf1
fixed file_matcher

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import re
23
23
from copy_base import CopyBaseWalker
24
24
import stdhome.the as the
25
 
from stdhome.file_matcher import FileMatcher
26
25
 
27
26
 
28
27
class CopyOutWalker( CopyBaseWalker ):
29
28
        """The copy-out walker traverses the repo, copying its content to the home
30
 
        directory.  During an update, it is run *after* checking for conflicts that
31
 
        might occur during copy-out, so any conflicts that exist can be assumed to
32
 
        be unimportant and disposable.  In other words, this will happily overwrite
33
 
        stuff in the home directory, without regard to its content.
 
29
        directory.  It is run *after* checking for conflicts that might occur during
 
30
        copy-out, so any conflicts that exist can be assumed to be unimportant and
 
31
        disposable.  In other words, this will happily overwrite stuff in the home
 
32
        directory, without regard to its content.
34
33
 
35
34
        Walker source:       repo
36
35
        Walker destination:  home dir
38
37
                                                        that no longer exists in the repo
39
38
        """
40
39
 
41
 
        def __init__( self, walk_files = None, quiet = False ):
42
 
                CopyBaseWalker.__init__( self )
 
40
        def __init__( self, updated_files = None ):
43
41
                self.src_dir = the.repo.full_dir
44
42
                self.dst_dir = the.full_home_dir
45
 
                self.walk_list = walk_files if walk_files is not None else \
46
 
                                                 self.generate_walk_list()
47
 
                self.check_dst_symlinks = True
48
 
                self.check_dst_ignores = True
49
 
                self.quiet = quiet
50
 
 
51
 
 
52
 
        def print_op( self, rel_file, src, op, dst ):
53
 
 
54
 
                # report changes
55
 
                if not self.quiet and the.verbose < 2 and op == '*':
56
 
                        if dst == '_':
57
 
                                print " N  %s" % ( rel_file )
58
 
                        elif src == '_':
59
 
                                print " D  %s" % ( rel_file )
60
 
                        elif src == dst:
61
 
                                print " M  %s" % ( rel_file )
62
 
                        else:
63
 
                                print " K  %s" % ( rel_file )
64
 
 
65
 
                # verbose reporting
66
 
                if the.verbose >= 2:
67
 
                        if op == '*': op = '<'
68
 
                        print "  %s%s%s %s" % ( src, op, dst, rel_file )
 
43
                self.walk_list = updated_files if updated_files is not None else \
 
44
                                                 self.generate_walk_list( the.repo.full_dir )
 
45
 
 
46
 
 
47
        def print_op( self, rel_file, operation ):
 
48
                operation = re.sub( r'(.)(.)(.)', r'\3\2\1', operation )
 
49
                operation = re.sub( r'\>', r'<', operation )
 
50
                print "  %s %s" % ( operation, rel_file )