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, remote): | 298 def Tag(self, tag, remote): |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, remote): | 349 def Tag(self, tag, remote): |
346 self.step.GitSVNFetch() | 350 self.step.GitSVNFetch() |
347 self.step.Git("rebase %s" % remote) | 351 self.step.Git("rebase %s" % remote) |
348 self.step.GitSVNTag(tag) | 352 self.step.GitSVNTag(tag) |
349 | 353 |
350 | 354 |
351 class GitReadOnlyMixin(VCInterface): | 355 class GitTagsOnlyMixin(VCInterface): |
352 def Pull(self): | 356 def Pull(self): |
353 self.step.GitPull() | 357 self.step.GitPull() |
354 | 358 |
355 def Fetch(self): | 359 def Fetch(self): |
356 self.step.Git("fetch") | 360 self.step.Git("fetch") |
357 | 361 |
358 def GetTags(self): | 362 def GetTags(self): |
359 return self.step.Git("tag").strip().splitlines() | 363 return self.step.Git("tag").strip().splitlines() |
360 | 364 |
361 def GetBranches(self): | 365 def GetBranches(self): |
362 # Get relevant remote branches, e.g. "origin/branch-heads/3.25". | 366 # Get relevant remote branches, e.g. "origin/branch-heads/3.25". |
363 branches = filter( | 367 branches = filter( |
364 lambda s: re.match(r"^origin/branch\-heads/\d+\.\d+$", s), | 368 lambda s: re.match(r"^origin/branch\-heads/\d+\.\d+$", s), |
365 self.step.GitRemotes()) | 369 self.step.GitRemotes()) |
366 # Remove 'origin/branch-heads/' prefix. | 370 # Remove 'origin/branch-heads/' prefix. |
367 return map(lambda s: s[20:], branches) | 371 return map(lambda s: s[20:], branches) |
368 | 372 |
369 def RemoteMasterBranch(self): | 373 def RemoteMasterBranch(self): |
370 return "origin/master" | 374 return "origin/master" |
371 | 375 |
372 def RemoteCandidateBranch(self): | 376 def RemoteCandidateBranch(self): |
373 return "origin/candidates" | 377 return "origin/candidates" |
374 | 378 |
375 def RemoteBranch(self, name): | 379 def RemoteBranch(self, name): |
376 if name in ["candidates", "master"]: | 380 if name in ["candidates", "master"]: |
377 return "origin/%s" % name | 381 return "origin/%s" % name |
378 return "origin/branch-heads/%s" % name | 382 return "origin/branch-heads/%s" % name |
379 | 383 |
384 def Tag(self, tag, remote): | |
385 # Title of the current commit (the local title and the title for committing | |
386 # is the same in all merge and push scripts). | |
387 title = self.step.GitLog(n=1, format="%s") | |
380 | 388 |
381 class GitReadSvnWriteInterface(GitReadOnlyMixin, GitSvnInterface): | 389 # Wait for the commit to appear. Assumes unique commit message titles (this |
390 # is the case for all automated merge and push commits - also no title is | |
391 # the prefix of another title). | |
392 commit = None | |
393 for wait_interval in [3, 5, 10, 30]: | |
tandrii(chromium)
2014/10/02 17:36:06
not sure 48 seconds is enough, you probably know b
Michael Achenbach
2014/10/07 10:10:50
Bumped it a little.
| |
394 self.step.Git("fetch") | |
395 commit = self.step.GitLog(n=1, format="%H", grep=title, branch=remote) | |
396 if commit: | |
tandrii(chromium)
2014/10/02 17:36:06
Naturally, i'm not sure about assumption above the
Michael Achenbach
2014/10/07 10:10:50
I don't need the assumption if I add the commit me
| |
397 break | |
398 print("The commit has not replicated to git. Waiting for %s seconds." % | |
399 wait_interval) | |
400 self.step._side_effect_handler.Sleep(wait_interval) | |
401 | |
402 if not commit: | |
tandrii(chromium)
2014/10/02 17:36:06
or just
else:
Michael Achenbach
2014/10/07 10:10:50
Odd construct - but I love shorter code :)
| |
403 self.step.Die("Couldn't determine commit for setting the tag. Maybe the " | |
404 "git updater is lagging behind?") | |
405 | |
406 self.step.Git("tag %s %s" % (tag, commit)) | |
407 self.step.Git("push origin %s" % tag) | |
408 | |
409 | |
410 class GitReadSvnWriteInterface(GitTagsOnlyMixin, GitSvnInterface): | |
382 pass | 411 pass |
383 | 412 |
384 | 413 |
385 VC_INTERFACES = { | 414 VC_INTERFACES = { |
386 "git_svn": GitSvnInterface, | 415 "git_svn": GitSvnInterface, |
387 "git_read_svn_write": GitReadSvnWriteInterface, | 416 "git_read_svn_write": GitReadSvnWriteInterface, |
388 } | 417 } |
389 | 418 |
390 | 419 |
391 class Step(GitRecipesMixin): | 420 class Step(GitRecipesMixin): |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 for (number, step_class) in enumerate(step_classes): | 867 for (number, step_class) in enumerate(step_classes): |
839 steps.append(MakeStep(step_class, number, self._state, self._config, | 868 steps.append(MakeStep(step_class, number, self._state, self._config, |
840 options, self._side_effect_handler)) | 869 options, self._side_effect_handler)) |
841 for step in steps[options.step:]: | 870 for step in steps[options.step:]: |
842 if step.Run(): | 871 if step.Run(): |
843 return 0 | 872 return 0 |
844 return 0 | 873 return 0 |
845 | 874 |
846 def Run(self, args=None): | 875 def Run(self, args=None): |
847 return self.RunSteps(self._Steps(), args) | 876 return self.RunSteps(self._Steps(), args) |
OLD | NEW |