Merge lp:~w.baranowski/duplicity/selection_debug into lp:~duplicity-team/duplicity/0.7-series

Proposed by Wojciech Baranowski
Status: Merged
Merged at revision: 1124
Proposed branch: lp:~w.baranowski/duplicity/selection_debug
Merge into: lp:~duplicity-team/duplicity/0.7-series
Diff against target: 61 lines (+23/-18)
1 file modified
duplicity/selection.py (+23/-18)
To merge this branch: bzr merge lp:~w.baranowski/duplicity/selection_debug
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+268791@code.launchpad.net

Description of the change

This little patch logs debug messages concerning path selection process, and so allows users to debug their include/exclude configuration.

As a new user I had a problem understanding how the include/exclude options work, especially how they interact with each-other. With this modification I managed to instantly fix my filelists.

To post a comment you must log in.
Revision history for this message
Aaron Whitehouse (aaron-whitehouse) wrote :

Good work, thanks Wojciech. In addition to the debug messages, which are a good idea, I like how you have rearranged this section.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/selection.py'
2--- duplicity/selection.py 2015-07-31 08:22:31 +0000
3+++ duplicity/selection.py 2015-08-21 17:56:26 +0000
4@@ -204,34 +204,39 @@
5 def Select(self, path):
6 """Run through the selection functions and return dominant val 0/1/2"""
7 # Only used by diryield and tests. Internal.
8+ log.Debug("Selection: examining path %s" % util.ufn(path.name))
9 if not self.selection_functions:
10+ log.Debug("Selection: + no selection functions found. Including")
11 return 1
12 scan_pending = False
13 for sf in self.selection_functions:
14 result = sf(path)
15+ log.Debug("Selection: result: %4s from function: %s" %
16+ (str(result), sf.name))
17 if result is 2:
18 # Selection function says that the path should be scanned for matching files, but keep going
19 # through the selection functions looking for a real match (0 or 1).
20 scan_pending = True
21- elif result == 1:
22- # Selection function says file should be included.
23- return result
24- elif result == 0:
25- # Selection function says file should be excluded.
26- if scan_pending is False:
27- return result
28- else:
29- # scan_pending is True, meaning that a higher-priority selection function has said that this
30- # folder should be scanned. We therefore return the scan value. We return here, rather than
31- # below, because we don't want the exclude to be trumped by a lower-priority include.
32- return 2
33- if scan_pending:
34- # A selection function returned 2 and no other selection functions returned 0 or 1.
35- return 2
36- if result is not None:
37- return result
38+ elif result == 0 or result == 1:
39+ # A real match found, no need to try other functions.
40+ break
41+
42+ if scan_pending and result != 1:
43+ # A selection function returned 2 and either no real match was
44+ # found or the highest-priority match was 0
45+ result = 2
46+ if result is None:
47+ result = 1
48+
49+ if result == 0:
50+ log.Debug("Selection: - excluding file")
51+ elif result == 1:
52+ log.Debug("Selection: + including file")
53 else:
54- return 1
55+ assert result == 2
56+ log.Debug("Selection: ? scanning directory for matches")
57+
58+ return result
59
60 def ParseArgs(self, argtuples, filelists):
61 """Create selection functions based on list of tuples

Subscribers

People subscribed via source and target branches