Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 | 156 |
| 157 @Strip | 157 @Strip |
| 158 def GitCurrentBranch(self, **kwargs): | 158 def GitCurrentBranch(self, **kwargs): |
| 159 for line in self.Git("status -s -b -uno", **kwargs).strip().splitlines(): | 159 for line in self.Git("status -s -b -uno", **kwargs).strip().splitlines(): |
| 160 match = re.match(r"^## (.+)", line) | 160 match = re.match(r"^## (.+)", line) |
| 161 if match: return match.group(1) | 161 if match: return match.group(1) |
| 162 raise Exception("Couldn't find curent branch.") # pragma: no cover | 162 raise Exception("Couldn't find curent branch.") # pragma: no cover |
| 163 | 163 |
| 164 @Strip | 164 @Strip |
| 165 def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="", | 165 def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="", |
| 166 branch="", reverse=False, **kwargs): | 166 branch="", path=None, reverse=False, **kwargs): |
| 167 assert not (git_hash and parent_hash) | 167 assert not (git_hash and parent_hash) |
| 168 args = ["log"] | 168 args = ["log"] |
| 169 if n > 0: | 169 if n > 0: |
| 170 args.append("-%d" % n) | 170 args.append("-%d" % n) |
| 171 if format: | 171 if format: |
| 172 args.append("--format=%s" % format) | 172 args.append("--format=%s" % format) |
| 173 if grep: | 173 if grep: |
| 174 args.append("--grep=\"%s\"" % grep.replace("\"", "\\\"")) | 174 args.append("--grep=\"%s\"" % grep.replace("\"", "\\\"")) |
| 175 if reverse: | 175 if reverse: |
| 176 args.append("--reverse") | 176 args.append("--reverse") |
| 177 if git_hash: | 177 if git_hash: |
| 178 args.append(git_hash) | 178 args.append(git_hash) |
| 179 if parent_hash: | 179 if parent_hash: |
| 180 args.append("%s^" % parent_hash) | 180 args.append("%s^" % parent_hash) |
| 181 args.append(branch) | 181 args.append(branch) |
| 182 if path: | |
| 183 args.extend(["--", path]) | |
|
tandrii(chromium)
2015/04/07 15:13:51
nice!
| |
| 182 return self.Git(MakeArgs(args), **kwargs) | 184 return self.Git(MakeArgs(args), **kwargs) |
| 183 | 185 |
| 186 def GitShowFile(self, refspec, path, **kwargs): | |
| 187 assert refspec | |
| 188 assert path | |
| 189 return self.Git(MakeArgs(["show", "%s:%s" % (refspec, path)]), **kwargs) | |
| 190 | |
| 184 def GitGetPatch(self, git_hash, **kwargs): | 191 def GitGetPatch(self, git_hash, **kwargs): |
| 185 assert git_hash | 192 assert git_hash |
| 186 return self.Git(MakeArgs(["log", "-1", "-p", git_hash]), **kwargs) | 193 return self.Git(MakeArgs(["log", "-1", "-p", git_hash]), **kwargs) |
| 187 | 194 |
| 188 # TODO(machenbach): Unused? Remove. | 195 # TODO(machenbach): Unused? Remove. |
| 189 def GitAdd(self, name, **kwargs): | 196 def GitAdd(self, name, **kwargs): |
| 190 assert name | 197 assert name |
| 191 self.Git(MakeArgs(["add", Quoted(name)]), **kwargs) | 198 self.Git(MakeArgs(["add", Quoted(name)]), **kwargs) |
| 192 | 199 |
| 193 def GitApplyPatch(self, patch_file, reverse=False, **kwargs): | 200 def GitApplyPatch(self, patch_file, reverse=False, **kwargs): |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 def GitCLLand(self, **kwargs): | 241 def GitCLLand(self, **kwargs): |
| 235 self.Git( | 242 self.Git( |
| 236 "cl land -f --bypass-hooks", retry_on=lambda x: x is None, **kwargs) | 243 "cl land -f --bypass-hooks", retry_on=lambda x: x is None, **kwargs) |
| 237 | 244 |
| 238 def GitDiff(self, loc1, loc2, **kwargs): | 245 def GitDiff(self, loc1, loc2, **kwargs): |
| 239 return self.Git(MakeArgs(["diff", loc1, loc2]), **kwargs) | 246 return self.Git(MakeArgs(["diff", loc1, loc2]), **kwargs) |
| 240 | 247 |
| 241 def GitPull(self, **kwargs): | 248 def GitPull(self, **kwargs): |
| 242 self.Git("pull", **kwargs) | 249 self.Git("pull", **kwargs) |
| 243 | 250 |
| 244 def GitFetchOrigin(self, **kwargs): | 251 def GitFetchOrigin(self, *refspecs, **kwargs): |
| 245 self.Git("fetch origin", **kwargs) | 252 self.Git(MakeArgs(["fetch", "origin"] + list(refspecs)), **kwargs) |
| 246 | 253 |
| 247 @Strip | 254 @Strip |
| 248 # Copied from bot_update.py and modified for svn-like numbers only. | 255 # Copied from bot_update.py and modified for svn-like numbers only. |
| 249 def GetCommitPositionNumber(self, git_hash, **kwargs): | 256 def GetCommitPositionNumber(self, git_hash, **kwargs): |
| 250 """Dumps the 'git' log for a specific revision and parses out the commit | 257 """Dumps the 'git' log for a specific revision and parses out the commit |
| 251 position number. | 258 position number. |
| 252 | 259 |
| 253 If a commit position metadata key is found, its number will be returned. | 260 If a commit position metadata key is found, its number will be returned. |
| 254 | 261 |
| 255 Otherwise, we will search for a 'git-svn' metadata entry. If one is found, | 262 Otherwise, we will search for a 'git-svn' metadata entry. If one is found, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 266 return match.group(2) | 273 return match.group(2) |
| 267 | 274 |
| 268 # Extract the svn revision from 'git-svn' metadata | 275 # Extract the svn revision from 'git-svn' metadata |
| 269 value = footer_map.get(GIT_SVN_ID_FOOTER_KEY) | 276 value = footer_map.get(GIT_SVN_ID_FOOTER_KEY) |
| 270 if value: | 277 if value: |
| 271 match = GIT_SVN_ID_RE.match(value) | 278 match = GIT_SVN_ID_RE.match(value) |
| 272 if match: | 279 if match: |
| 273 return match.group(1) | 280 return match.group(1) |
| 274 raise GitFailedException("Couldn't determine commit position for %s" % | 281 raise GitFailedException("Couldn't determine commit position for %s" % |
| 275 git_hash) | 282 git_hash) |
| OLD | NEW |