Diff
Modified: trunk/Tools/ChangeLog (290321 => 290322)
--- trunk/Tools/ChangeLog 2022-02-22 19:04:39 UTC (rev 290321)
+++ trunk/Tools/ChangeLog 2022-02-22 19:25:49 UTC (rev 290322)
@@ -1,3 +1,21 @@
+2022-02-22 Jonathan Bedard <[email protected]>
+
+ [git-webkit] Extract revision from `git svn dcommit`
+ https://bugs.webkit.org/show_bug.cgi?id=236849
+ <rdar://problem/89155179>
+
+ Reviewed by Ryan Haddad.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
+ (Git): Thoroughly mock `dcommit`
+ * Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py:
+ (Land.main): Extract committed SVN revision from `git svn dcommit` command to accurately
+ match landed commits to the pull request that generated them.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/land_unittest.py:
+ (repository): Add revision to local commit.
+
2022-02-22 Dean Jackson <[email protected]>
Filter some build output from JSC
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (290321 => 290322)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-02-22 19:04:39 UTC (rev 290321)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-02-22 19:25:49 UTC (rev 290322)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='4.3.1',
+ version='4.3.2',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (290321 => 290322)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-02-22 19:04:39 UTC (rev 290321)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-02-22 19:25:49 UTC (rev 290322)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(4, 3, 1)
+version = Version(4, 3, 2)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (290321 => 290322)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2022-02-22 19:04:39 UTC (rev 290321)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2022-02-22 19:25:49 UTC (rev 290322)
@@ -160,7 +160,7 @@
), mocks.Subprocess.Route(
self.executable, 'svn', 'dcommit',
cwd=self.path,
- completion=mocks.ProcessCompletion(returncode=0)
+ generator=lambda *args, **kwargs: self.dcommit(),
),
]
@@ -907,6 +907,15 @@
self.remotes['{}/{}'.format(remote, branch)] = self.commits[branch][-1]
return mocks.ProcessCompletion(returncode=0)
+ def dcommit(self, remote='origin', branch=None):
+ branch = branch or self.default_branch
+ self.remotes['{}/{}'.format(remote, branch)] = self.commits[branch][-1]
+ return mocks.ProcessCompletion(
+ returncode=0,
+ stdout='Committed r{}\n\tM\tFiles/Changed.txt\n'.format(self.commits[branch][-1].revision),
+ )
+
+
def reset(self, index):
self.head = self.commits[self.head.branch][-(index + 1)]
return mocks.ProcessCompletion(returncode=0)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py (290321 => 290322)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py 2022-02-22 19:04:39 UTC (rev 290321)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py 2022-02-22 19:25:49 UTC (rev 290322)
@@ -41,6 +41,7 @@
OOPS_RE = re.compile(r'\(O+P+S!*\)')
REVIEWED_BY_RE = re.compile('Reviewed by (?P<approver>.+)')
+ GIT_SVN_COMMITTED_RE = re.compile(r'Committed r(?P<revision>\d+)')
REMOTE = 'origin'
MIRROR_TIMEOUT = 60
@@ -191,16 +192,31 @@
if run([repository.executable(), 'svn', 'fetch'], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to update subversion refs\n".format(target))
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1
- if run([repository.executable(), 'svn', 'dcommit'], cwd=repository.root_path).returncode:
+
+ dcommit = run([repository.executable(), 'svn', 'dcommit'], cwd=repository.root_path, capture_output=True, encoding='utf-8')
+ if dcommit.returncode:
+ sys.stderr.write(dcommit.stdout)
+ sys.stderr.write(dcommit.stderr)
sys.stderr.write("Failed to commit '{}' to Subversion remote\n".format(target))
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1
+ revisions = []
+ for line in dcommit.stdout.splitlines():
+ match = cls.GIT_SVN_COMMITTED_RE.match(line)
+ if not match:
+ continue
+ revisions.append(int(match.group('revision')))
+ if not revisions:
+ sys.stderr.write(dcommit.stdout)
+ sys.stderr.write(dcommit.stderr)
+ sys.stderr.write("Failed to find revision in '{}' when committing to Subversion remote\n".format(target))
+ 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
started = time.time()
- original = repository.find('HEAD', include_log=False, include_identifier=False)
- latest = original
- while original.hash == latest.hash:
+ latest = repository.find('HEAD', include_log=True, include_identifier=False)
+ while latest.revision < revisions[-1]:
if time.time() - started > cls.MIRROR_TIMEOUT:
sys.stderr.write("Timed out waiting for the git-svn mirror, '{}' landed but not closed\n".format(pull_request or source_branch))
return 1
@@ -207,10 +223,17 @@
log.info(' Verifying mirror processesed change')
time.sleep(5)
run([repository.executable(), 'pull'], cwd=repository.root_path)
- latest = repository.find('HEAD', include_log=False, include_identifier=False)
+ latest = repository.find('HEAD', include_log=True, include_identifier=False)
+ if repository.cache and target in repository.cache._last_populated:
+ del repository.cache._last_populated[target]
+
+ commits = []
+ for revision in revisions:
+ commits.append(repository.commit(revision=revision, include_log=True))
+ commit = commits[-1]
+
if pull_request:
run([repository.executable(), 'branch', '-f', source_branch, target], cwd=repository.root_path)
- commits = list(repository.commits(begin=dict(argument='{}~{}'.format(source_branch, len(commits))), end=dict(branch=source_branch)))
run([repository.executable(), 'push', '-f', remote_target, source_branch], cwd=repository.root_path)
rmt.pull_requests.update(
pull_request=pull_request,
@@ -237,8 +260,8 @@
sys.stderr.write("Failed to push '{}' to '{}'\n".format(target, cls.REMOTE))
return 1 if cls.revert_branch(repository, cls.REMOTE, target) else -1
repository.checkout(target)
+ commit = repository.commit(branch=target, include_log=False)
- commit = repository.commit(branch=target, include_log=True)
if identifier_template and commit.identifier:
land_message = 'Landed {} ({})!'.format(identifier_template.format(commit).split(': ')[-1], commit.hash[:Commit.HASH_LABEL_SIZE])
else:
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/land_unittest.py (290321 => 290322)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/land_unittest.py 2022-02-22 19:04:39 UTC (rev 290321)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/land_unittest.py 2022-02-22 19:25:49 UTC (rev 290322)
@@ -37,6 +37,7 @@
result.commits[branch] = [Commit(
hash='a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd',
identifier='3.1@{}'.format(branch),
+ revision=10,
timestamp=int(time.time()) - 60,
author=Contributor('Tim Committer', ['[email protected]']),
message='To Be Committed\n{}\nReviewed by {}.\n{}'.format(