465 > |
465 > |
466 > # build the combination of possible states |
466 > # build the combination of possible states |
467 > combination = [] |
467 > combination = [] |
468 > for ctxkey, ctxvalue in ctxcontent.iteritems(): |
468 > for ctxkey, ctxvalue in ctxcontent.iteritems(): |
469 > for wckey in wccontent: |
469 > for wckey in wccontent: |
470 > if (ctxvalue[0] == ctxvalue[1] and 'revert' in wckey): |
470 > base, parent = ctxvalue |
|
471 > if (base == parent and 'revert' in wckey): |
471 > continue |
472 > continue |
472 > if not ctxvalue[0] and 'revert' in wckey: |
473 > if not base and 'revert' in wckey: |
473 > continue |
474 > continue |
474 > if not ctxvalue[1] and 'deleted' in wckey: |
475 > if not parent and 'deleted' in wckey: |
475 > continue |
476 > continue |
476 > filename = "%s_%s" % (ctxkey, wckey) |
477 > filename = "%s_%s" % (ctxkey, wckey) |
477 > combination.append((filename, ctxkey, wckey)) |
478 > combination.append((filename, base, parent, |
|
479 > wccontent[wckey](ctxvalue))) |
478 > |
480 > |
479 > # make sure we have stable output |
481 > # make sure we have stable output |
480 > combination.sort() |
482 > combination.sort() |
481 > |
483 > |
482 > # retrieve the state we must generate |
484 > # retrieve the state we must generate |
483 > target = sys.argv[1] |
485 > target = sys.argv[1] |
484 > |
486 > |
485 > # compute file content |
487 > # compute file content |
486 > content = [] |
488 > content = [] |
487 > for filename, ctxkey, wckey in combination: |
489 > for filename, base, parent, wcc in combination: |
488 > cc = ctxcontent[ctxkey] |
|
489 > if target == 'filelist': |
490 > if target == 'filelist': |
490 > print filename |
491 > print filename |
491 > elif target == 'base': |
492 > elif target == 'base': |
492 > content.append((filename, cc[0])) |
493 > content.append((filename, base)) |
493 > elif target == 'parent': |
494 > elif target == 'parent': |
494 > content.append((filename, cc[1])) |
495 > content.append((filename, parent)) |
495 > elif target == 'wc': |
496 > elif target == 'wc': |
496 > content.append((filename, wccontent[wckey](cc))) |
497 > content.append((filename, wcc)) |
497 > else: |
498 > else: |
498 > print >> sys.stderr, "unknown target:", target |
499 > print >> sys.stderr, "unknown target:", target |
499 > sys.exit(1) |
500 > sys.exit(1) |
500 > |
501 > |
501 > # write actual content |
502 > # write actual content |