~duplicity-team/duplicity/0.7-series

« back to all changes in this revision

Viewing changes to duplicity/selection.py

  • Committer: Kenneth Loafman
  • Date: 2015-07-29 10:10:46 UTC
  • mfrom: (1109.1.8 duplicity_globmatch)
  • Revision ID: kenneth@loafman.com-20150729101046-5fcd3ydc1i3pkqli
* Merged in lp:~aaron-whitehouse/duplicity/bug_884371
  - Fixed Bug #884371 - Stopped an exclude glob trumping an earlier scan glob, but also
    ensured that an exclude glob is not trumped by a later include. This fix is important,
    as without it files that are specified to be included are not being backed up as expected.
  - Fixed Bug #932482 - a trailing slash at the end of globs no longer prevents them working
    as expected.

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
        if not self.selection_functions:
208
208
            return 1
209
209
        scan_pending = False
210
 
        for sf in self.selection_functions[:-1]:
 
210
        for sf in self.selection_functions:
211
211
            result = sf(path)
212
212
            if result is 2:
 
213
                # Selection function says that the path should be scanned for matching files, but keep going
 
214
                # through the selection functions looking for a real match (0 or 1).
213
215
                scan_pending = True
214
 
            if result in [0, 1]:
 
216
            elif result == 1:
 
217
                # Selection function says file should be included.
215
218
                return result
 
219
            elif result == 0:
 
220
                # Selection function says file should be excluded.
 
221
                if scan_pending is False:
 
222
                    return result
 
223
                else:
 
224
                    # scan_pending is True, meaning that a higher-priority selection function has said that this
 
225
                    # folder should be scanned. We therefore return the scan value. We return here, rather than
 
226
                    # below, because we don't want the exclude to be trumped by a lower-priority include.
 
227
                    return 2
216
228
        if scan_pending:
 
229
            # A selection function returned 2 and no other selection functions returned 0 or 1.
217
230
            return 2
218
 
        sf = self.selection_functions[-1]
219
 
        result = sf(path)
220
231
        if result is not None:
221
232
            return result
222
233
        else:
327
338
 
328
339
        include = include_default
329
340
        if line[:2] == "+ ":
330
 
            # Check for "+ "/"- " syntax
 
341
            # Check for "+ " or "- " syntax
331
342
            include = 1
332
343
            line = line[2:]
333
344
        elif line[:2] == "- ":
508
519
 
509
520
        """
510
521
        # Internal. Used by glob_get_sf and unit tests.
 
522
        if glob_str != "/" and glob_str[-1] == "/":
 
523
            # Remove trailing / from directory name (unless that is the entire string)
 
524
            glob_str = glob_str[:-1]
 
525
 
511
526
        if glob_str.lower().startswith("ignorecase:"):
512
527
            re_comp = lambda r: re.compile(r, re.I | re.S)
513
528
            glob_str = glob_str[len("ignorecase:"):]