Skip to content

Commit

Permalink
Cherry-pick 274747@main (273218f). rdar://121400016
Browse files Browse the repository at this point in the history
    [git-webkit] Prefer hash over identifier in relationships
    https://bugs.webkit.org/show_bug.cgi?id=267889
    rdar://121400016

    Reviewed by Dewei Zhu.

    Users can create identifiers from branches which aren't linear, so it's possible
    that a branch identifier refers more than one commit in the history of the repository.
    Since hashes are more stable, if a relationship uses both, prefer the hash.

    * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/trace.py:
    (Relationship.parse): Prefer hash commit reference when parsing relationships, even if the hash
    reference is the secondary reference.
    * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/trace_unittest.py:
    (TestRelationship.test_cherry_pick):
    (TestRelationship.test_revert):
    (TestRelationship.test_follow_up):
    (TestRelationship.test_double_revert):

    Canonical link: https://commits.webkit.org/274747@main

Canonical link: https://commits.webkit.org/272448.573@safari-7618-branch
  • Loading branch information
JonWBedard committed Feb 19, 2024
1 parent 9286403 commit 49d0bdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def parse(cls, commit):
secondary = match.group('secondary')
if secondary:
secondary = UNPACK_SECONDARY_RE.match(secondary).groups()[0]
if secondary and Commit.HASH_RE.match(secondary):
primary, secondary = secondary, primary
return type, [ref.rstrip() for ref in [primary, secondary] if ref]
return None, []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_cherry_pick(self):
))
)
self.assertEqual(
('original', ['123@main', '0123456789ab']), Relationship.parse(Commit(
('original', ['0123456789ab', '123@main']), Relationship.parse(Commit(
hash='deadbeef1234', revision=1234, identifier='1234@main',
message='Cherry-pick 123@main (0123456789ab). <rdar://54321>',
))
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_cherry_pick(self):

def test_revert(self):
self.assertEqual(
('reverts', ['1230@main', '0123456789ab']), Relationship.parse(Commit(
('reverts', ['0123456789ab', '1230@main']), Relationship.parse(Commit(
hash='deadbeef1234', revision=1234, identifier='1234@main',
message='Reverts 1230@main (0123456789ab)',
))
Expand All @@ -94,7 +94,7 @@ def test_revert(self):

def test_follow_up(self):
self.assertEqual(
('follow-up to', ['1230@main', '0123456789ab']), Relationship.parse(Commit(
('follow-up to', ['0123456789ab', '1230@main']), Relationship.parse(Commit(
hash='deadbeef1234', revision=1234, identifier='1234@main',
message='Fix following 1230@main (0123456789ab)',
))
Expand All @@ -120,7 +120,7 @@ def test_follow_up(self):

def test_double_revert(self):
self.assertEqual(
('original', ['1230@main', '0123456789ab']), Relationship.parse(Commit(
('original', ['0123456789ab', '1230@main']), Relationship.parse(Commit(
hash='deadbeef1234', revision=1234, identifier='1234@main',
message='Reverts "Revert 1230@main (0123456789ab)"',
))
Expand Down

0 comments on commit 49d0bdf

Please sign in to comment.