32
def expand_files( files, recurse = True ):
33
"""Returns a unique, sorted list of relative files, calculated from the list
34
provided, which is made up from individual files and directories
35
relative to the CWD (and which must be contained within the home
36
directory, although the files need not actually exist in the home
37
directory). All files must exist in the repository. Directories are
38
recursed in to as required.
32
def expand_files( files ):
33
"""Returns a unique, sorted list of relative files, calculated from the list of
34
files provided, which is made up from individual files and directories
35
to scan that are all relative to the CWD and must be contained within
43
40
home_dir_prefix = os.path.realpath( the.full_home_dir ) + os.sep
45
42
# iterate through file list
47
parts = os.path.split( file )
48
abs_file = os.path.join(
49
os.path.realpath( parts[ 0 ] ), parts[ 1 ] )
44
abs_file = os.path.realpath( file )
51
46
# check the file is in the home directory
52
47
if abs_file[ : len( home_dir_prefix ) ] != home_dir_prefix:
53
48
raise the.program.FatalError(
54
'not under home directory: %s' % abs_file )
49
'not in home directory: %s' % abs_file )
57
52
rel_file = abs_file[ len( home_dir_prefix ) : ]
63
58
'not managed by stdhome: %s' % rel_file )
65
60
# append the file or directory tree
66
ret.update( Walker.generate_walk_list(
67
the.repo.full_dir, rel_file, recurse ) )
61
ret.extend( Walker.generate_walk_list(
62
the.repo.full_dir, rel_file ) )
69
return sorted( set ( ret ) )