Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: git_freezer.py

Issue 184253003: Add git-reup and friends (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@freeze_thaw
Patch Set: fix pylint Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_common.py ('k') | git_map.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_freezer.py
diff --git a/git_freezer.py b/git_freezer.py
index 6e28b3e342b066f582fd46c48153f90a8038ebf9..f1e4c95725d5317be7deb2ad965bda812c2f3111 100755
--- a/git_freezer.py
+++ b/git_freezer.py
@@ -1,73 +1,33 @@
#!/usr/local/bin/python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
import sys
-import re
import optparse
import subcommand
-import subprocess2
-
-from git_common import run, stream
-
-FREEZE = 'FREEZE'
-SECTIONS = {
- 'indexed': 'soft',
- 'unindexed': 'mixed'
-}
-MATCHER = re.compile(r'%s.(%s)' % (FREEZE, '|'.join(SECTIONS)))
-
-
-def freeze():
- took_action = False
-
- try:
- run('commit', '-m', FREEZE + '.indexed')
- took_action = True
- except subprocess2.CalledProcessError:
- pass
-
- try:
- run('add', '-A')
- run('commit', '-m', FREEZE + '.unindexed')
- took_action = True
- except subprocess2.CalledProcessError:
- pass
-
- if not took_action:
- return 'Nothing to freeze.'
-
-
-def thaw():
- took_action = False
- for sha in (s.strip() for s in stream('rev-list', 'HEAD').xreadlines()):
- msg = run('show', '--format=%f%b', '-s', 'HEAD')
- match = MATCHER.match(msg)
- if not match:
- if not took_action:
- return 'Nothing to thaw.'
- break
-
- run('reset', '--' + SECTIONS[match.group(1)], sha)
- took_action = True
+from git_common import freeze, thaw
-def CMDfreeze(parser, args): # pragma: no cover
+def CMDfreeze(parser, args):
"""Freeze a branch's changes."""
parser.parse_args(args)
return freeze()
-def CMDthaw(parser, args): # pragma: no cover
+def CMDthaw(parser, args):
"""Returns a frozen branch to the state before it was frozen."""
parser.parse_args(args)
return thaw()
-def main(): # pragma: no cover
+def main():
dispatcher = subcommand.CommandDispatcher(__name__)
ret = dispatcher.execute(optparse.OptionParser(), sys.argv[1:])
if ret:
print ret
-if __name__ == '__main__': # pragma: no cover
- main()
+if __name__ == '__main__':
+ main()
« no previous file with comments | « git_common.py ('k') | git_map.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698