1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# conflict_walker.py
#
# Copyright (C) 2013 to 2014 Tim Marston <tim@edm.am>
#
# This file is part of stdhome (hereafter referred to as "this program").
# See http://ed.am/dev/stdhome for more information.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from walker import Walker
import stdhome.the as the
class ConflictWalker( Walker ):
"""The conflict walker traverses the repo looking for "deployment conflicts"
(i.e., changes in the type of file). This is run prior to running the
copy-out walker and, as such, is given a list of files that were copied-in
and which is can, therefore, safely ignore. It can also be given a list of
files affected by the update (it will walk all repo files otherwise).
Walker source: repo
Walker destination: home dir
Walker traversing: repo
"""
def __init__( self, ignore_files, affected_files = None ):
self.src_dir = the.repo.full_dir
self.dst_dir = the.full_fsdir
self.walk_list = affected_files if affected_files is not None else \
self.generate_walk_list( the.repo.full_dir )
self.ignore_files = ignore_files
self.changed = list()
def process( self, rel_file, src_file, src_type, dst_file, dst_type ):
# if entity is missing in home dir, it's ok to copy out (and there's no
# need to recurse)
if dst_type == '_': return False
# if entity was copied-in, it's ok to copy out
if rel_file in self.ignore_files:
# we recurse only if this is a directory in the home dir, because if
# it isn't copying-out will replace whatever's in the home dir with
# the whole directory from the repo
return dst_type == 'd'
# entity has changed type?
elif src_type != dst_type:
self.changed.append( "%s (now %s)" % (
rel_file, self.name_of_type( src_type ) ) )
# if an entity has changed to/from a directory, we don't care about
# anything that directory does/did contain
return False
# nothing to see here
return True
|