git_freezer.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python3
  2. # Copyright 2014 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. import sys
  6. import optparse
  7. import subcommand
  8. from git_common import freeze, thaw
  9. import gclient_utils
  10. def CMDfreeze(parser, args):
  11. """Freeze a branch's changes, excluding unstaged gitlinks changes."""
  12. parser.parse_args(args)
  13. return freeze()
  14. def CMDthaw(parser, args):
  15. """Returns a frozen branch to the state before it was frozen."""
  16. parser.parse_args(args)
  17. return thaw()
  18. def main(args):
  19. if gclient_utils.IsEnvCog():
  20. print(f'{args[0]} command is not supported in non-git environment.',
  21. file=sys.stderr)
  22. return 1
  23. dispatcher = subcommand.CommandDispatcher(__name__)
  24. ret = dispatcher.execute(optparse.OptionParser(), args)
  25. if ret:
  26. print(ret)
  27. return 0
  28. if __name__ == '__main__':
  29. try:
  30. sys.exit(main(sys.argv[1:]))
  31. except KeyboardInterrupt:
  32. sys.stderr.write('interrupted\n')
  33. sys.exit(1)