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

  • Committer: Tim Marston
  • Date: 2016-04-10 20:29:46 UTC
  • Revision ID: tim@ed.am-20160410202946-9eoh5i3et9443aq6
fixed greps in tools/dev to detect home-dir lines in stdhomerc

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
        @staticmethod
32
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
36
 
                the home directory.
 
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.  Any directories
 
38
                are recursed in to so that their content is also returned.
37
39
                """
38
40
 
39
41
                ret = list()
41
43
 
42
44
                # iterate through file list
43
45
                for file in files:
44
 
                        abs_file = os.path.realpath( file )
 
46
                        parts = os.path.split( file )
 
47
                        abs_file = os.path.join(
 
48
                                os.path.realpath( parts[ 0 ] ), parts[ 1 ] )
45
49
 
46
50
                        # check the file is in the home directory
47
51
                        if abs_file[ : len( home_dir_prefix ) ] != home_dir_prefix:
48
52
                                raise the.program.FatalError(
49
 
                                        'not in home directory: %s' % abs_file )
 
53
                                        'not under home directory: %s' % abs_file )
50
54
 
51
55
                        # relative file
52
56
                        rel_file = abs_file[ len( home_dir_prefix ) : ]
58
62
                                        'not managed by stdhome: %s' % rel_file )
59
63
 
60
64
                        # append the file or directory tree
61
 
                        ret.extend( Walker.generate_walk_list(
62
 
                                the.repo.full_dir, rel_file ) )
 
65
                        ret.extend( Walker.generate_walk_list( rel_file ) )
63
66
 
64
 
                return ret
 
67
                return sorted( set ( ret ) )