27 # $ python $TESTDIR/generate-working-copy-states.py state 2 wc |
27 # $ python $TESTDIR/generate-working-copy-states.py state 2 wc |
28 # $ hg addremove --similarity 0 |
28 # $ hg addremove --similarity 0 |
29 # $ hg forget *_*_*-untracked |
29 # $ hg forget *_*_*-untracked |
30 # $ rm *_*_missing-* |
30 # $ rm *_*_missing-* |
31 |
31 |
32 from __future__ import absolute_import |
32 from __future__ import absolute_import, print_function |
33 |
33 |
34 import os |
34 import os |
35 import sys |
35 import sys |
36 |
36 |
37 # Generates pairs of (filename, contents), where 'contents' is a list |
37 # Generates pairs of (filename, contents), where 'contents' is a list |
64 |
64 |
65 # compute file content |
65 # compute file content |
66 content = [] |
66 content = [] |
67 for filename, states in combinations: |
67 for filename, states in combinations: |
68 if target == 'filelist': |
68 if target == 'filelist': |
69 print filename |
69 print(filename) |
70 elif target == 'state': |
70 elif target == 'state': |
71 if depth == 'wc': |
71 if depth == 'wc': |
72 # Make sure there is content so the file gets written and can be |
72 # Make sure there is content so the file gets written and can be |
73 # tracked. It will be deleted outside of this script. |
73 # tracked. It will be deleted outside of this script. |
74 content.append((filename, states[maxchangesets] or 'TOBEDELETED')) |
74 content.append((filename, states[maxchangesets] or 'TOBEDELETED')) |
75 else: |
75 else: |
76 content.append((filename, states[int(depth) - 1])) |
76 content.append((filename, states[int(depth) - 1])) |
77 else: |
77 else: |
78 print >> sys.stderr, "unknown target:", target |
78 print("unknown target:", target, file=sys.stderr) |
79 sys.exit(1) |
79 sys.exit(1) |
80 |
80 |
81 # write actual content |
81 # write actual content |
82 for filename, data in content: |
82 for filename, data in content: |
83 if data is not None: |
83 if data is not None: |