Skip to content

Commit

Permalink
[git-webkit] Prioritize identity commit relationships over references
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246661
rdar://101269112

Rubber-stamped by Aakash Jain.

* Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/trace.py:
(Trace.relationships): Prefer "Revert" and "Cherry-Pick" relationships over "Reference" ones.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/trace_unittest.py:
(TestTrace.test_reverted_by):

Canonical link: https://commits.webkit.org/255686@main
  • Loading branch information
JonWBedard committed Oct 18, 2022
1 parent 713a700 commit 8c46e24
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Tools/Scripts/libraries/webkitscmpy/setup.py
Expand Up @@ -29,7 +29,7 @@ def readme():

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

version = Version(5, 6, 23)
version = Version(5, 6, 24)

AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Expand Down
17 changes: 9 additions & 8 deletions Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/trace.py
Expand Up @@ -205,14 +205,6 @@ def relationships(cls, commit, repository, commits_story=None):
if not commits_story:
return result

type = Relationship.REFERENCES
for issue in CommitsStory.issues_for(commit):
for candidate in commits_story.by_issue.get(issue.link, []):
if str(candidate) in tracked:
continue
tracked.add(str(candidate))
result.append(Relationship(candidate, type))

references = [str(commit)]
if commit.hash:
references.append(commit.hash[:Commit.HASH_LABEL_SIZE])
Expand All @@ -224,6 +216,15 @@ def relationships(cls, commit, repository, commits_story=None):
continue
tracked.add(str(candidate.commit))
result.append(candidate)

type = Relationship.REFERENCES
for issue in CommitsStory.issues_for(commit):
for candidate in commits_story.by_issue.get(issue.link, []):
if str(candidate) in tracked:
continue
tracked.add(str(candidate))
result.append(Relationship(candidate, type))

return result

@classmethod
Expand Down
Expand Up @@ -197,3 +197,23 @@ def test_invalid_revert(self):
'6@main | deadbeef1234 | Reverts <rdar://1234>\n',
)
self.assertEqual(captured.stderr.getvalue(), 'No relationships found\n')

def test_reverted_by(self):
with OutputCapture() as captured, mocks.local.Git(self.path) as repo, mocks.local.Svn(), Terminal.override_atty(
sys.stdin, isatty=False):
repo.head = Commit(
hash='deadbeef1234', revision=10, identifier='6@main',
message='Reverts 5@main', timestamp=int(time.time()),
author=repo.head.author,
)
repo.commits['main'].append(repo.head)

self.assertEqual(0, program.main(
args=('trace', '5@main', '--limit', '1'),
path=self.path,
))
self.assertEqual(
captured.stdout.getvalue(),
'5@main | d8bce26fa65c | Patch Series\n reverted by 6@main | deadbeef1234 | Reverts 5@main\n',
)
self.assertEqual(captured.stderr.getvalue(), '')

0 comments on commit 8c46e24

Please sign in to comment.