Show More
@@ -2,29 +2,34 b'' | |||||
2 | import sys |
|
2 | import sys | |
3 | import os |
|
3 | import os | |
4 |
|
4 | |||
5 | # build the combination of possible states |
|
5 | # Generates pairs of (filename, contents), where 'contents' is a list | |
6 | combination = [] |
|
6 | # describing the file's content at each revision (or in the working copy). | |
7 | for base in [None, 'content1']: |
|
7 | # At each revision, it is either None or the file's actual content. When not | |
8 | for parent in set([None, 'content2']) | set([base]): |
|
8 | # None, it may be either new content or the same content as an earlier | |
9 | for wcc in set([None, 'content3']) | set([base, parent]): |
|
9 | # revisions, so all of (modified,clean,added,removed) can be tested. | |
10 | for tracked in ('untracked', 'tracked'): |
|
10 | def generatestates(maxchangesets, parentcontents): | |
11 | def statestring(content): |
|
11 | depth = len(parentcontents) | |
12 | return content is None and 'missing' or content |
|
12 | if depth == maxchangesets + 1: | |
13 | filename = "%s_%s_%s-%s" % (statestring(base), |
|
13 | for tracked in ('untracked', 'tracked'): | |
14 | statestring(parent), |
|
14 | filename = "_".join([(content is None and 'missing' or content) for | |
15 | statestring(wcc), |
|
15 | content in parentcontents]) + "-" + tracked | |
16 | tracked) |
|
16 | yield (filename, parentcontents) | |
17 | combination.append((filename, base, parent, wcc)) |
|
17 | else: | |
|
18 | for content in (set([None, 'content' + str(depth + 1)]) | | |||
|
19 | set(parentcontents)): | |||
|
20 | for combination in generatestates(maxchangesets, | |||
|
21 | parentcontents + [content]): | |||
|
22 | yield combination | |||
18 |
|
23 | |||
19 | # make sure we have stable output |
|
24 | # sort to make sure we have stable output | |
20 | combination.sort() |
|
25 | combinations = sorted(generatestates(2, [])) | |
21 |
|
26 | |||
22 | # retrieve the state we must generate |
|
27 | # retrieve the state we must generate | |
23 | target = sys.argv[1] |
|
28 | target = sys.argv[1] | |
24 |
|
29 | |||
25 | # compute file content |
|
30 | # compute file content | |
26 | content = [] |
|
31 | content = [] | |
27 | for filename, base, parent, wcc in combination: |
|
32 | for filename, [base, parent, wcc] in combinations: | |
28 | if target == 'filelist': |
|
33 | if target == 'filelist': | |
29 | print filename |
|
34 | print filename | |
30 | elif target == 'base': |
|
35 | elif target == 'base': |
General Comments 0
You need to be logged in to leave comments.
Login now