Skip to content
Permalink
Browse files
[git-webkit] Reset target branch when landing fails
https://bugs.webkit.org/show_bug.cgi?id=236110
<rdar://problem/88463164>

Reviewed by Dewei Zhu.

* Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py:
(Land.revert_branch): Move branch to specified remote's representation of the branch.
(Land.main): If we fail to land a change after moving a branch's local ref to include that
change, we should return that local ref to what the branch's remote reports.


Canonical link: https://commits.webkit.org/247147@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289643 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed Feb 11, 2022
1 parent 09ec6b3 commit a6cf830b5d6e1d04fbd06a202359297c8c778710
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
@@ -1,3 +1,18 @@
2022-02-11 Jonathan Bedard <jbedard@apple.com>

[git-webkit] Reset target branch when landing fails
https://bugs.webkit.org/show_bug.cgi?id=236110
<rdar://problem/88463164>

Reviewed by Dewei Zhu.

* Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py:
(Land.revert_branch): Move branch to specified remote's representation of the branch.
(Land.main): If we fail to land a change after moving a branch's local ref to include that
change, we should return that local ref to what the branch's remote reports.

2022-02-11 Jonathan Bedard <jbedard@apple.com>

[EWS] Enable WPE and WinCairo queues for PRs
@@ -29,7 +29,7 @@ def readme():

setup(
name='webkitscmpy',
version='4.1.0',
version='4.1.1',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
@@ -46,7 +46,7 @@ def _maybe_add_webkitcorepy_path():
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(4, 1, 0)
version = Version(4, 1, 1)

AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
@@ -1,4 +1,4 @@
# Copyright (C) 2021 Apple Inc. All rights reserved.
# Copyright (C) 2021-2022 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -43,6 +43,15 @@ class Land(Command):
REMOTE = 'origin'
MIRROR_TIMEOUT = 60

@classmethod
def revert_branch(cls, repository, remote, branch):
if run(
[repository.executable(), 'branch', '-f', branch, 'remotes/{}/{}'.format(remote, branch)],
cwd=repository.root_path,
).returncode:
return False
return True

@classmethod
def parser(cls, parser, loggers=None):
parser.add_argument(
@@ -154,17 +163,18 @@ def main(cls, args, repository, identifier_template=None, canonical_svn=False, *

if run([repository.executable(), 'branch', '-f', target, source_branch], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to move '{}' ref\n".format(target))
return 1
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1

if identifier_template:
repository.checkout(target)
if Canonicalize.main(Namespace(
identifier=True, remote=cls.REMOTE, number=len(commits),
), repository, identifier_template=identifier_template):
sys.stderr.write("Failed to embed identifiers to '{}'\n".format(target))
return 1
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1
if run([repository.executable(), 'branch', '-f', source_branch, target], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to move '{}' ref to the canonicalized head of '{}'\n".format(source, target))
cls.revert_branch(repository, cls.REMOTE, target)
return -1

# Need to compute the remote source
@@ -173,10 +183,10 @@ def main(cls, args, repository, identifier_template=None, canonical_svn=False, *
if canonical_svn:
if run([repository.executable(), 'svn', 'fetch'], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to update subversion refs\n".format(target))
return 1
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1
if run([repository.executable(), 'svn', 'dcommit'], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to commit '{}' to Subversion remote\n".format(target))
return 1
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1
run([repository.executable(), 'reset', 'HEAD~{}'.format(len(commits)), '--hard'], cwd=repository.root_path)

# Verify the mirror processed our change
@@ -218,7 +228,7 @@ def main(cls, args, repository, identifier_template=None, canonical_svn=False, *

if run([repository.executable(), 'push', cls.REMOTE, target], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to push '{}' to '{}'\n".format(target, cls.REMOTE))
return 1
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1
repository.checkout(target)

commit = repository.commit(branch=target, include_log=False)

0 comments on commit a6cf830

Please sign in to comment.