Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/local/bin/python | |
| 2 import sys | |
| 3 import re | |
| 4 import optparse | |
| 5 | |
| 6 import subcommand | |
| 7 | |
| 8 from git_common import run, stream | |
| 9 | |
| 10 FREEZE = 'FREEZE' | |
| 11 SECTIONS = { | |
| 12 'indexed': 'soft', | |
| 13 'unindexed': 'mixed' | |
| 14 } | |
| 15 MATCHER = re.compile(r'%s.(%s)' % (FREEZE, '|'.join(SECTIONS))) | |
| 16 | |
| 17 | |
| 18 def CMDfreeze(_parser, _args): | |
| 19 """freeze a branches changes.""" | |
|
agable
2014/02/28 19:35:35
possessive
| |
| 20 took_action = False | |
| 21 status = [(line[:2], line[2:]) for line in run('status', '-z').split('\0')] | |
| 22 if status[-1] == ('', ''): | |
| 23 status.pop() | |
| 24 if any(mode[0] != ' ' for mode, _ in status): | |
| 25 run('commit', '-m', FREEZE + '.' + 'indexed') | |
|
agable
2014/02/28 19:35:35
+ '.indexed'?
| |
| 26 took_action = True | |
| 27 if any(mode[0] in ' ?' for mode, _ in status): | |
| 28 run('add', '-A') | |
| 29 run('commit', '-m', FREEZE + '.' + 'unindexed') | |
| 30 took_action = True | |
| 31 | |
| 32 if not took_action: | |
| 33 print 'Nothing to freeze.' | |
| 34 | |
| 35 | |
| 36 def CMDthaw(_parser, _args): | |
| 37 """returns a frozen branch to the state before it was frozen.""" | |
| 38 took_action = False | |
| 39 for sha in (s.strip() for s in stream('rev-list', 'HEAD').xreadlines()): | |
| 40 msg = run('show', '--format=%f%b', '-s', 'HEAD') | |
| 41 match = MATCHER.match(msg) | |
| 42 if not match: | |
| 43 if not took_action: | |
| 44 print 'Nothing to thaw.' | |
| 45 break | |
| 46 | |
| 47 run('reset', '--' + SECTIONS[match.group(1)], sha) | |
| 48 took_action = True | |
| 49 | |
| 50 | |
| 51 def main(): | |
| 52 dispatcher = subcommand.CommandDispatcher(__name__) | |
| 53 return dispatcher.execute(optparse.OptionParser(), sys.argv[1:]) | |
| 54 | |
| 55 if __name__ == '__main__': | |
| 56 sys.exit(main()) | |
| OLD | NEW |