| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 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, message): |
| 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 26 matching lines...) Expand all Loading... |
| 335 | 339 |
| 336 def RemoteBranch(self, name): | 340 def RemoteBranch(self, name): |
| 337 return "svn/%s" % name | 341 return "svn/%s" % name |
| 338 | 342 |
| 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, 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, message): |
| 385 # Wait for the commit to appear. Assumes unique commit message titles (this |
| 386 # is the case for all automated merge and push commits - also no title is |
| 387 # the prefix of another title). |
| 388 commit = None |
| 389 for wait_interval in [3, 7, 15, 35]: |
| 390 self.step.Git("fetch") |
| 391 commit = self.step.GitLog(n=1, format="%H", grep=message, branch=remote) |
| 392 if commit: |
| 393 break |
| 394 print("The commit has not replicated to git. Waiting for %s seconds." % |
| 395 wait_interval) |
| 396 self.step._side_effect_handler.Sleep(wait_interval) |
| 397 else: |
| 398 self.step.Die("Couldn't determine commit for setting the tag. Maybe the " |
| 399 "git updater is lagging behind?") |
| 380 | 400 |
| 381 class GitReadSvnWriteInterface(GitReadOnlyMixin, GitSvnInterface): | 401 self.step.Git("tag %s %s" % (tag, commit)) |
| 402 self.step.Git("push origin %s" % tag) |
| 403 |
| 404 |
| 405 class GitReadSvnWriteInterface(GitTagsOnlyMixin, GitSvnInterface): |
| 382 pass | 406 pass |
| 383 | 407 |
| 384 | 408 |
| 385 VC_INTERFACES = { | 409 VC_INTERFACES = { |
| 386 "git_svn": GitSvnInterface, | 410 "git_svn": GitSvnInterface, |
| 387 "git_read_svn_write": GitReadSvnWriteInterface, | 411 "git_read_svn_write": GitReadSvnWriteInterface, |
| 388 } | 412 } |
| 389 | 413 |
| 390 | 414 |
| 391 class Step(GitRecipesMixin): | 415 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): | 862 for (number, step_class) in enumerate(step_classes): |
| 839 steps.append(MakeStep(step_class, number, self._state, self._config, | 863 steps.append(MakeStep(step_class, number, self._state, self._config, |
| 840 options, self._side_effect_handler)) | 864 options, self._side_effect_handler)) |
| 841 for step in steps[options.step:]: | 865 for step in steps[options.step:]: |
| 842 if step.Run(): | 866 if step.Run(): |
| 843 return 0 | 867 return 0 |
| 844 return 0 | 868 return 0 |
| 845 | 869 |
| 846 def Run(self, args=None): | 870 def Run(self, args=None): |
| 847 return self.RunSteps(self._Steps(), args) | 871 return self.RunSteps(self._Steps(), args) |
| OLD | NEW |