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

  • Committer: Tim Marston
  • Date: 2016-05-22 16:45:54 UTC
  • Revision ID: tim@ed.am-20160522164554-n5qhuibvnv0z4tk1
added general reporting to CopyBase and configured it via copy-in and copy-out
walkers (it is required in copy in, during add command); added -R (recursive)
flass to add command; allow vcs backends to augment statically ignored files
list; added detection of out of date working copy to bzr backend;
generate_walk_list() now takes a mandatory directory as the first argument;
don't copy entire subtree during copy of missing directory (as this makes
assumptions about what's in the walk-list)

Show diffs side-by-side

added added

removed removed

32
32
        process() for more information.
33
33
        """
34
34
 
 
35
 
35
36
        def walk( self ):
36
37
                """Iterates over self.walk_list, calling process() for each entry in turn.  For
37
38
                directory entries, where process() returns False, subsequent entries in
38
39
                walk_list that fall under the directory are skipped.
39
40
                """
40
41
 
41
 
                if the.verbose >= 3: print "walking [%s]" % self.__class__.__name__
 
42
                if the.verbose >= 3:
 
43
                        print "walking [%s]" % self.__class__.__name__
42
44
 
43
45
                skip = ''
44
46
                for rel_file in self.walk_list:
100
102
 
101
103
 
102
104
        @staticmethod
103
 
        def generate_walk_list( rel_file = '', full_dir = None ):
 
105
        def generate_walk_list( full_dir, rel_file = '', recurse = True ):
104
106
                """Returns a list of files and directories in full_dir, specified as relative
105
107
                files (relative to full_dir), breadth first.
 
108
 
106
109
                """
107
110
 
108
 
                # default place to walk
109
 
                if full_dir is None: full_dir = the.repo.full_dir
110
 
 
111
111
                # ignore some files
112
 
                if rel_file in [ '.bzr', '.bzrignore', '.stdhome', '.stdhomerc' ]:
 
112
                static_ignores = [ '.stdhome', '.stdhomerc' ] + \
 
113
                                                 the.repo.vcs.ignored_files
 
114
                if rel_file in static_ignores:
113
115
                        return list()
114
116
 
115
117
                full_file = os.path.join( full_dir, rel_file )
121
123
                # directories are returned and recursed in to
122
124
                elif os.path.isdir( full_file ):
123
125
                        ret = [ rel_file ] if rel_file != '' else []
124
 
                        for file in os.listdir( full_file ):
125
 
                                ret.extend( Walker.generate_walk_list(
126
 
                                        os.path.join( rel_file, file ), full_dir ) )
 
126
                        if recurse:
 
127
                                for file in os.listdir( full_file ):
 
128
                                        ret.extend( Walker.generate_walk_list(
 
129
                                                full_dir, os.path.join( rel_file, file ) ) )
127
130
                        return sorted( ret )
128
131
 
129
132
                # other kinds are invalid