Title: [289643] trunk/Tools
Revision
289643
Author
[email protected]
Date
2022-02-11 11:54:29 -0800 (Fri, 11 Feb 2022)

Log Message

[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

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (289642 => 289643)


--- trunk/Tools/ChangeLog	2022-02-11 19:47:46 UTC (rev 289642)
+++ trunk/Tools/ChangeLog	2022-02-11 19:54:29 UTC (rev 289643)
@@ -1,5 +1,20 @@
 2022-02-11  Jonathan Bedard  <[email protected]>
 
+        [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  <[email protected]>
+
         [EWS] Enable WPE and WinCairo queues for PRs
         https://bugs.webkit.org/show_bug.cgi?id=236517
         <rdar://problem/88823117>

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (289642 => 289643)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-02-11 19:47:46 UTC (rev 289642)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-02-11 19:54:29 UTC (rev 289643)
@@ -29,7 +29,7 @@
 
 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=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (289642 => 289643)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-02-11 19:47:46 UTC (rev 289642)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-02-11 19:54:29 UTC (rev 289643)
@@ -46,7 +46,7 @@
         "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)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py (289642 => 289643)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py	2022-02-11 19:47:46 UTC (rev 289642)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py	2022-02-11 19:54:29 UTC (rev 289643)
@@ -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
@@ -44,6 +44,15 @@
     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(
             '--no-force-review', '--force-review', '--no-review',
@@ -154,7 +163,7 @@
 
         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)
@@ -162,9 +171,10 @@
                 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 @@
         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 @@
 
             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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to