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

Side by Side Diff: build/util/lastchange.py

Issue 3570006: Try harder to determine lastchange in case of git-svn repository with some local changes. (Closed)
Patch Set: tweak Created 10 years, 2 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
« 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 lastchange.py -- Chromium revision fetching utility. 7 lastchange.py -- Chromium revision fetching utility.
8 """ 8 """
9 9
10 import optparse 10 import optparse
11 import os 11 import os
12 import re 12 import re
(...skipping 23 matching lines...) Expand all
36 revision = m.group(1) 36 revision = m.group(1)
37 return revision 37 return revision
38 38
39 39
40 def git_fetch_id(): 40 def git_fetch_id():
41 """ 41 """
42 Fetch the GIT identifier for the local tree. 42 Fetch the GIT identifier for the local tree.
43 43
44 Errors are swallowed. 44 Errors are swallowed.
45 """ 45 """
46 git_re = re.compile('^\s*git-svn-id:\s+(\S+)@(\d+)', re.M)
46 try: 47 try:
47 p = subprocess.Popen(['git', 'log', '-1'], 48 proc = subprocess.Popen(['git', 'log', '-999'],
48 stdout=subprocess.PIPE, 49 stdout=subprocess.PIPE,
49 stderr=subprocess.PIPE, 50 stderr=subprocess.PIPE,
50 shell=(sys.platform=='win32')) 51 shell=(sys.platform=='win32'))
52 for line in proc.stdout:
53 match = git_re.search(line)
54 if match:
55 id = match.group(2)
56 if id:
57 proc.stdout.close() # Cut pipe.
58 return id
51 except OSError: 59 except OSError:
52 # 'git' is apparently either not installed or not executable. 60 # 'git' is apparently either not installed or not executable.
53 return None 61 pass
54 id = None 62 return None
55 if p:
56 git_re = re.compile('^\s*git-svn-id:\s+(\S+)@(\d+)', re.M)
57 m = git_re.search(p.stdout.read())
58 if m:
59 id = m.group(2)
60 return id
61 63
62 64
63 def fetch_change(default_lastchange): 65 def fetch_change(default_lastchange):
64 """ 66 """
65 Returns the last change, from some appropriate revision control system. 67 Returns the last change, from some appropriate revision control system.
66 """ 68 """
67 change = svn_fetch_revision() 69 change = svn_fetch_revision()
68 if not change and sys.platform in ('linux2',): 70 if not change and sys.platform in ('linux2',):
69 change = git_fetch_id() 71 change = git_fetch_id()
70 if not change: 72 if not change:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if out_file: 121 if out_file:
120 write_if_changed(out_file, contents) 122 write_if_changed(out_file, contents)
121 else: 123 else:
122 sys.stdout.write(contents) 124 sys.stdout.write(contents)
123 125
124 return 0 126 return 0
125 127
126 128
127 if __name__ == '__main__': 129 if __name__ == '__main__':
128 sys.exit(main()) 130 sys.exit(main())
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