##// END OF EJS Templates
ancestor.missingancestors: turn into a state-keeping class...
ancestor.missingancestors: turn into a state-keeping class This allows multiple efficient missing ancestor queries against the same set of bases. In upcoming patches we'll also define ways to grow the set of bases. The fact that the test output hasn't changed establishes this patch's correctness.

File last commit:

r23195:29977b31 default
r23334:59e6e5dd default
Show More
generate-working-copy-states.py
50 lines | 1.7 KiB | text/x-python | PythonLexer
/ tests / generate-working-copy-states.py
# generate proper file state to test working copy behavior
import sys
import os
# build the combination of possible states
combination = []
for base in [None, 'content1']:
for parent in set([None, 'content2']) | set([base]):
for wcc in set([None, 'content3']) | set([base, parent]):
for tracked in (False, True):
def statestring(content):
return content is None and 'missing' or content
trackedstring = tracked and 'tracked' or 'untracked'
filename = "%s_%s_%s-%s" % (statestring(base),
statestring(parent),
statestring(wcc),
trackedstring)
combination.append((filename, base, parent, wcc))
# make sure we have stable output
combination.sort()
# retrieve the state we must generate
target = sys.argv[1]
# compute file content
content = []
for filename, base, parent, wcc in combination:
if target == 'filelist':
print filename
elif target == 'base':
content.append((filename, base))
elif target == 'parent':
content.append((filename, parent))
elif target == 'wc':
# Make sure there is content so the file gets written and can be
# tracked. It will be deleted outside of this script.
content.append((filename, wcc or 'TOBEDELETED'))
else:
print >> sys.stderr, "unknown target:", target
sys.exit(1)
# write actual content
for filename, data in content:
if data is not None:
f = open(filename, 'w')
f.write(data + '\n')
f.close()
elif os.path.exists(filename):
os.remove(filename)