/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-05 22:30:23 UTC
  • Revision ID: tim@ed.am-20140405223023-3co87mbvnxwk1l65
added revert command

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