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

Side by Side Diff: git_cl/git_cl.py

Issue 6079003: Improve parsing of committed hash to be more resilient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/git_cl
Patch Set: Address review comments Created 9 years, 11 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 subprocess 10 import subprocess
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 retcode, output = RunGitWithCode(['svn', 'dcommit', '--no-rebase']) 993 retcode, output = RunGitWithCode(['svn', 'dcommit', '--no-rebase'])
994 finally: 994 finally:
995 # And then swap back to the original branch and clean up. 995 # And then swap back to the original branch and clean up.
996 RunGit(['checkout', '-q', cl.GetBranch()]) 996 RunGit(['checkout', '-q', cl.GetBranch()])
997 RunGit(['branch', '-D', MERGE_BRANCH]) 997 RunGit(['branch', '-D', MERGE_BRANCH])
998 998
999 if cl.GetIssue(): 999 if cl.GetIssue():
1000 if cmd == 'dcommit' and 'Committed r' in output: 1000 if cmd == 'dcommit' and 'Committed r' in output:
1001 revision = re.match('.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1) 1001 revision = re.match('.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1)
1002 elif cmd == 'push' and retcode == 0: 1002 elif cmd == 'push' and retcode == 0:
1003 revision = output.splitlines()[1].split('\t')[2].split('..')[1] 1003 match = (re.match(r'.*?([a-f0-9]{7})\.\.([a-f0-9]{7})$', l)
1004 for l in output.splitlines(False))
1005 match = filter(None, match)
1006 if len(match) != 1:
1007 DieWithError("Couldn't parse ouput to extract the committed hash:\n%s" %
1008 output)
1009 revision = match[0].group(2)
1004 else: 1010 else:
1005 return 1 1011 return 1
1006 viewvc_url = settings.GetViewVCUrl() 1012 viewvc_url = settings.GetViewVCUrl()
1007 if viewvc_url and revision: 1013 if viewvc_url and revision:
1008 cl.description += ('\n\nCommitted: ' + viewvc_url + revision) 1014 cl.description += ('\n\nCommitted: ' + viewvc_url + revision)
1009 print ('Closing issue ' 1015 print ('Closing issue '
1010 '(you may be prompted for your codereview password)...') 1016 '(you may be prompted for your codereview password)...')
1011 cl.CloseIssue() 1017 cl.CloseIssue()
1012 cl.SetIssue(0) 1018 cl.SetIssue(0)
1013 1019
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 1261 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
1256 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1262 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1257 1263
1258 # Not a known command. Default to help. 1264 # Not a known command. Default to help.
1259 GenUsage(parser, 'help') 1265 GenUsage(parser, 'help')
1260 return CMDhelp(parser, argv) 1266 return CMDhelp(parser, argv)
1261 1267
1262 1268
1263 if __name__ == '__main__': 1269 if __name__ == '__main__':
1264 sys.exit(main(sys.argv[1:])) 1270 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