/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: 2014-04-18 14:42:00 UTC
  • Revision ID: tim@ed.am-20140418144200-ksbr3l58p2v3jhy2
fixed bugs in command.expand_files, where results could be not unique, nor
sorted, and make sure the last component of the files is not resolved if it is a
symlink

Show diffs side-by-side

added added

removed removed

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:
61
65
                        ret.extend( Walker.generate_walk_list(
62
66
                                the.repo.full_dir, rel_file ) )
63
67
 
64
 
                return ret
 
68
                return sorted( set ( ret ) )