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

Side by Side Diff: git_cl/git_cl.py

Issue 6690012: Better revert (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # git-cl -- a git-command for integrating reviews on Rietveld 2 # git-cl -- a git-command for integrating reviews on Rietveld
3 # Copyright (C) 2008 Evan Martin <martine@danga.com> 3 # Copyright (C) 2008 Evan Martin <martine@danga.com>
4 4
5 import errno 5 import errno
6 import logging 6 import logging
7 import optparse 7 import optparse
8 import os 8 import os
9 import re 9 import re
10 import StringIO 10 import StringIO
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 def UserEditedLog(starting_text): 704 def UserEditedLog(starting_text):
705 """Given some starting text, let the user edit it and return the result.""" 705 """Given some starting text, let the user edit it and return the result."""
706 editor = os.getenv('EDITOR', 'vi') 706 editor = os.getenv('EDITOR', 'vi')
707 707
708 (file_handle, filename) = tempfile.mkstemp() 708 (file_handle, filename) = tempfile.mkstemp()
709 fileobj = os.fdopen(file_handle, 'w') 709 fileobj = os.fdopen(file_handle, 'w')
710 fileobj.write(starting_text) 710 fileobj.write(starting_text)
711 fileobj.close() 711 fileobj.close()
712 712
713 # Open up the default editor in the system to get the CL description. 713 # Open up the default editor in the system to get the CL description.
714 result = None 714 ret = subprocess.call(editor + ' ' + filename, shell=True)
715 try: 715 if ret != 0:
716 subprocess.check_call(['env', editor, filename], shell=True)
717 fileobj = open(filename)
718 result = fileobj.read()
719 fileobj.close()
720 finally:
721 os.remove(filename) 716 os.remove(filename)
717 return
718 fileobj = open(filename)
719 text = fileobj.read()
720 fileobj.close()
722 721
723 if not result: 722 os.remove(filename)
724 return
725 723
726 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) 724 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE)
727 return stripcomment_re.sub('', result).strip() 725 return stripcomment_re.sub('', text).strip()
728 726
729 727
730 def ConvertToInteger(inputval): 728 def ConvertToInteger(inputval):
731 """Convert a string to integer, but returns either an int or None.""" 729 """Convert a string to integer, but returns either an int or None."""
732 try: 730 try:
733 return int(inputval) 731 return int(inputval)
734 except (TypeError, ValueError): 732 except (TypeError, ValueError):
735 return None 733 return None
736 734
737 735
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 1408 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
1411 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1409 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1412 1410
1413 # Not a known command. Default to help. 1411 # Not a known command. Default to help.
1414 GenUsage(parser, 'help') 1412 GenUsage(parser, 'help')
1415 return CMDhelp(parser, argv) 1413 return CMDhelp(parser, argv)
1416 1414
1417 1415
1418 if __name__ == '__main__': 1416 if __name__ == '__main__':
1419 sys.exit(main(sys.argv[1:])) 1417 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698