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
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.
40
43
home_dir_prefix = os.path.realpath( the.full_home_dir ) + os.sep
42
45
# iterate through file list
44
abs_file = os.path.realpath( file )
47
parts = os.path.split( file )
48
abs_file = os.path.join(
49
os.path.realpath( parts[ 0 ] ), parts[ 1 ] )
46
51
# check the file is in the home directory
47
52
if abs_file[ : len( home_dir_prefix ) ] != home_dir_prefix:
48
53
raise the.program.FatalError(
49
'not in home directory: %s' % abs_file )
54
'not under home directory: %s' % abs_file )
52
57
rel_file = abs_file[ len( home_dir_prefix ) : ]
58
63
'not managed by stdhome: %s' % rel_file )
60
65
# append the file or directory tree
61
ret.extend( Walker.generate_walk_list(
62
the.repo.full_dir, rel_file ) )
66
ret.update( Walker.generate_walk_list(
67
the.repo.full_dir, rel_file, recurse ) )
69
return sorted( set ( ret ) )