OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 def Land(self): | 289 def Land(self): |
290 raise NotImplementedError() | 290 raise NotImplementedError() |
291 | 291 |
292 def CLLand(self): | 292 def CLLand(self): |
293 raise NotImplementedError() | 293 raise NotImplementedError() |
294 | 294 |
295 # TODO(machenbach): There is some svn knowledge in this interface. In svn, | 295 # TODO(machenbach): There is some svn knowledge in this interface. In svn, |
296 # tag and commit are different remote commands, while in git we would commit | 296 # tag and commit are different remote commands, while in git we would commit |
297 # and tag locally and then push/land in one unique step. | 297 # and tag locally and then push/land in one unique step. |
298 def Tag(self, tag): | 298 def Tag(self, tag): |
299 """Sets a tag for the current commit. | |
300 | |
301 Assumptions: The commit already landed and the commit message is unique. | |
302 """ | |
299 raise NotImplementedError() | 303 raise NotImplementedError() |
300 | 304 |
301 | 305 |
302 class GitSvnInterface(VCInterface): | 306 class GitSvnInterface(VCInterface): |
303 def Pull(self): | 307 def Pull(self): |
304 self.step.GitSVNRebase() | 308 self.step.GitSVNRebase() |
305 | 309 |
306 def Fetch(self): | 310 def Fetch(self): |
307 self.step.GitSVNFetch() | 311 self.step.GitSVNFetch() |
308 | 312 |
(...skipping 30 matching lines...) Expand all Loading... | |
339 def Land(self): | 343 def Land(self): |
340 self.step.GitSVNDCommit() | 344 self.step.GitSVNDCommit() |
341 | 345 |
342 def CLLand(self): | 346 def CLLand(self): |
343 self.step.GitDCommit() | 347 self.step.GitDCommit() |
344 | 348 |
345 def Tag(self, tag): | 349 def Tag(self, tag): |
346 self.step.GitSVNTag(tag) | 350 self.step.GitSVNTag(tag) |
347 | 351 |
348 | 352 |
349 class GitReadOnlyMixin(VCInterface): | 353 class GitTagsOnlyMixin(VCInterface): |
350 def Pull(self): | 354 def Pull(self): |
351 self.step.GitPull() | 355 self.step.GitPull() |
352 | 356 |
353 def Fetch(self): | 357 def Fetch(self): |
354 self.step.Git("fetch") | 358 self.step.Git("fetch") |
355 | 359 |
356 def GetTags(self): | 360 def GetTags(self): |
357 return self.step.Git("tag").strip().splitlines() | 361 return self.step.Git("tag").strip().splitlines() |
358 | 362 |
359 def GetBranches(self): | 363 def GetBranches(self): |
360 # Get relevant remote branches, e.g. "origin/branch-heads/3.25". | 364 # Get relevant remote branches, e.g. "origin/branch-heads/3.25". |
361 branches = filter( | 365 branches = filter( |
362 lambda s: re.match(r"^origin/branch\-heads/\d+\.\d+$", s), | 366 lambda s: re.match(r"^origin/branch\-heads/\d+\.\d+$", s), |
363 self.step.GitRemotes()) | 367 self.step.GitRemotes()) |
364 # Remove 'origin/branch-heads/' prefix. | 368 # Remove 'origin/branch-heads/' prefix. |
365 return map(lambda s: s[20:], branches) | 369 return map(lambda s: s[20:], branches) |
366 | 370 |
367 def RemoteMasterBranch(self): | 371 def RemoteMasterBranch(self): |
368 return "origin/master" | 372 return "origin/master" |
369 | 373 |
370 def RemoteCandidateBranch(self): | 374 def RemoteCandidateBranch(self): |
371 return "origin/candidates" | 375 return "origin/candidates" |
372 | 376 |
373 def RemoteBranch(self, name): | 377 def RemoteBranch(self, name): |
374 if name in ["candidates", "master"]: | 378 if name in ["candidates", "master"]: |
375 return "origin/%s" % name | 379 return "origin/%s" % name |
376 return "origin/branch-heads/%s" % name | 380 return "origin/branch-heads/%s" % name |
377 | 381 |
382 def Tag(self, tag): | |
383 # Title of the current commit (the local title and the title for committing | |
384 # is the same in all merge and push scripts). | |
385 title = self.step.GitLog(n=1, format="%s") | |
378 | 386 |
379 class GitReadSvnWriteInterface(GitReadOnlyMixin, GitSvnInterface): | 387 # Find remote branch where current commit will appear. Assumes everything |
388 # to be merge-free (unique parents). | |
389 branch = None | |
390 hsh = "HEAD" | |
391 while not branch: | |
392 branch = self.step.GitRemoteContains(hsh) | |
393 hsh += "^" | |
agable
2014/09/29 09:49:11
Cute. Might be better to actually query Git for th
Michael Achenbach
2014/09/29 10:46:25
Done. Changed the semantics slightly as HEAD alway
| |
394 | |
395 # Wait for the commit to appear. Assumes unique commit message titles (this | |
396 # is the case for all automated merge and push commits - also no title is | |
397 # the prefix of another title). | |
398 commit = None | |
399 for wait_interval in [3, 5, 10, 30]: | |
400 self.step.Git("fetch") | |
401 commit = self.step.GitLog(n=1, format="%H", grep=title, branch=branch) | |
agable
2014/09/29 09:49:11
This n=1 is dangerous -- what if two commits get r
Michael Achenbach
2014/09/29 10:46:25
But shouldn't the grep on the unique title take ca
| |
402 if commit: | |
403 break | |
404 print("The commit is not replicated on git. Waiting for %s seconds." % | |
agable
2014/09/29 09:49:11
nit: "...has not replicated to..."
Michael Achenbach
2014/09/29 10:46:25
Done.
| |
405 wait_interval) | |
406 self.step._side_effect_handler.Sleep(wait_interval) | |
407 | |
408 if not commit: | |
409 self.step.Die("Couldn't determine commit for setting the tag. Maybe the " | |
410 "git updater is lacking behind?") | |
agable
2014/09/29 09:49:11
nit: "lagging"
agable
2014/09/29 09:49:11
nit: indentation
Michael Achenbach
2014/09/29 10:46:24
Done.
Michael Achenbach
2014/09/29 10:46:24
Done.
| |
411 | |
412 self.step.Git("tag %s %s" % (tag, commit)) | |
agable
2014/09/29 09:49:11
The fact that this takes args as a single string i
Michael Achenbach
2014/09/29 10:46:24
I'm sad too. But I'll address this in a separate r
| |
413 self.step.Git("push origin %s" % tag) | |
414 | |
415 | |
416 class GitReadSvnWriteInterface(GitTagsOnlyMixin, GitSvnInterface): | |
380 pass | 417 pass |
381 | 418 |
382 | 419 |
383 VC_INTERFACES = { | 420 VC_INTERFACES = { |
384 "git_svn": GitSvnInterface, | 421 "git_svn": GitSvnInterface, |
385 "git_read_svn_write": GitReadSvnWriteInterface, | 422 "git_read_svn_write": GitReadSvnWriteInterface, |
386 } | 423 } |
387 | 424 |
388 | 425 |
389 class Step(GitRecipesMixin): | 426 class Step(GitRecipesMixin): |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 for (number, step_class) in enumerate(step_classes): | 873 for (number, step_class) in enumerate(step_classes): |
837 steps.append(MakeStep(step_class, number, self._state, self._config, | 874 steps.append(MakeStep(step_class, number, self._state, self._config, |
838 options, self._side_effect_handler)) | 875 options, self._side_effect_handler)) |
839 for step in steps[options.step:]: | 876 for step in steps[options.step:]: |
840 if step.Run(): | 877 if step.Run(): |
841 return 0 | 878 return 0 |
842 return 0 | 879 return 0 |
843 | 880 |
844 def Run(self, args=None): | 881 def Run(self, args=None): |
845 return self.RunSteps(self._Steps(), args) | 882 return self.RunSteps(self._Steps(), args) |
OLD | NEW |