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

  • Committer: Tim Marston
  • Date: 2014-03-08 00:47:23 UTC
  • Revision ID: tim@ed.am-20140308004723-hkl3s2hobsblf72o
added diff command; moved all command to commands subdir; made stage-revert
handle ongoing deployment automatically (now that initial revno is known); made
verbose level incremental; detect obstructing conflicts in ConflictWalker;
handle files deleted from repo during copy-out (update)

Show diffs side-by-side

added added

removed removed

1
 
# copy_in_walker.py
 
1
# copy_in.py
2
2
#
3
3
# Copyright (C) 2013 to 2014 Tim Marston <tim@edm.am>
4
4
#
35
35
        """
36
36
 
37
37
        def __init__( self ):
38
 
                self.src_dir = the.full_fsdir
 
38
                self.src_dir = the.full_home_dir
39
39
                self.dst_dir = the.repo.full_dir
40
40
                self.walk_list = self.generate_walk_list( the.repo.full_dir )
41
41
 
50
50
                        # if entity doesn't exist in home dir, delete directory in repo (and
51
51
                        # don't recurse, obviously!)
52
52
                        if src_type == '_':
53
 
                                if the.verbose: print "  _>d " + rel_file
 
53
                                if the.verbose > 1: print "  _>d " + rel_file
54
54
                                shutil.rmtree( dst_file )
55
55
                                return False
56
56
 
58
58
                        # diurectory in repo, as necessary, and recurse
59
59
                        elif src_type == 'd':
60
60
                                # TODO: should check permissions and only do as necessary
61
 
                                if the.verbose: print "  d>d " + rel_file
 
61
                                if the.verbose > 1: print "  d>d " + rel_file
62
62
                                shutil.copystat( src_file, dst_file )
63
63
                                return True
64
64
 
82
82
 
83
83
                        # if entity doesn't exist in home dir, delete file in repo
84
84
                        if src_type == '_':
85
 
                                if the.verbose: print "  _>f " + rel_file
 
85
                                if the.verbose > 1: print "  _>f " + rel_file
86
86
                                os.unlink( dst_file )
87
87
 
88
88
                        # if entity in home dir is a symlink, replace file in repo
89
89
                        elif src_type == 'l':
90
 
                                if the.verbose: print "  l>f " + rel_file
 
90
                                if the.verbose > 1: print "  l>f " + rel_file
91
91
                                os.unlink( dst_file )
92
92
                                os.symlink( os.readlink( src_file ), dst_file )
93
93
 
95
95
                        # differs
96
96
                        elif src_type == 'f':
97
97
                                if not filecmp.cmp( src_file, dst_file ):
98
 
                                        if the.verbose: print "  f>f " + rel_file
 
98
                                        if the.verbose > 1: print "  f>f " + rel_file
99
99
                                        os.unlink( dst_file )
100
100
                                        shutil.copy( src_file, dst_file )
101
101
                                        shutil.copystat( src_file, dst_file )
102
102
                                else:
103
 
                                        if the.verbose: print "  f=f " + rel_file
 
103
                                        if the.verbose > 1: print "  f=f " + rel_file
104
104
 
105
105
                        # TODO: serious differences in between ~/ and repo (e.g., files in
106
106
                        # one that are directories in the other) should be ignored (e.g.,
121
121
 
122
122
                        # if entity doesn't exist in home dir, delete symlink in repo
123
123
                        if src_type == '_':
124
 
                                if the.verbose: print "  _>l " + rel_file
 
124
                                if the.verbose > 1: print "  _>l " + rel_file
125
125
                                os.unlink( dst_file )
126
126
 
127
127
                        # if entity in home dir is a symlink, replace symlink in repo only
128
128
                        # if it differs
129
129
                        elif src_type == 'l':
130
130
                                if os.readlink( src_file ) != os.readlink( dst_file ):
131
 
                                        if the.verbose: print "  l>l " + rel_file
 
131
                                        if the.verbose > 1: print "  l>l " + rel_file
132
132
                                        os.unlink( dst_file )
133
133
                                        os.symlink( os.readlink( src_file ), dst_file )
134
134
                                else:
135
 
                                        if the.verbose: print "  l=l " + rel_file
 
135
                                        if the.verbose > 1: print "  l=l " + rel_file
136
136
 
137
137
                        # if entity in home dir is a file, replace symlink in repo
138
138
                        elif src_type == 'f':
139
 
                                if the.verbose: print "  f>l " + rel_file
 
139
                                if the.verbose > 1: print "  f>l " + rel_file
140
140
                                os.unlink( dst_file )
141
141
                                shutil.copy( src_file, dst_file )
142
142
                                shutil.copystat( src_file, dst_file )