19
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
import filecmp, os, shutil
23
23
from copy_base import CopyBaseWalker
24
24
import stdhome.the as the
25
from stdhome.file_matcher import FileMatcher
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.
35
34
Walker source: repo
36
35
Walker destination: home dir
37
36
Walker traversing: repo (or a provided file list, which may include stuff
38
37
that no longer exists in the repo
42
def __init__( self, walk_files = None ):
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 \
43
self.walk_list = updated_files if updated_files is not None else \
46
44
self.generate_walk_list( the.repo.full_dir )
48
self.accept_list = FileMatcher( the.config_file, 'symlink' )
51
def print_op( self, rel_file, operation ):
52
operation = re.sub( r'(.)(.)(.)', r'\3\2\1', operation )
53
operation = re.sub( r'\>', r'<', operation )
54
print " %s %s" % ( operation, rel_file )
47
def print_cp( self, rel_file, src_type, dst_type, operation = '<' ):
48
if( the.verbose <= 1 ): return
49
print " %s%s%s %s" % ( dst_type, operation, src_type, rel_file )