# HG changeset patch # User Jason R. Coombs # Date 1684968774 -7200 # Node ID e36883d8810802c979615d0f5f9f4831508f5f33 # Parent e44d343b9ed23080ede3f1888f41fb09345398f9 evolve: add a test to capture the expected behavior of retaining extras diff -r e44d343b9ed2 -r e36883d88108 tests/test-check-sdist.t --- a/tests/test-check-sdist.t Thu Jun 08 11:07:34 2023 -0400 +++ b/tests/test-check-sdist.t Thu May 25 00:52:54 2023 +0200 @@ -35,7 +35,7 @@ $ tar -tzf hg-evolve-*.tar.gz | sed 's|^hg-evolve-[^/]*/||' | sort > files $ wc -l files - 361 files + 363 files $ fgrep debian files tests/test-check-debian.t $ fgrep __init__.py files diff -r e44d343b9ed2 -r e36883d88108 tests/test-evolve-extras.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-evolve-extras.t Thu May 25 00:52:54 2023 +0200 @@ -0,0 +1,42 @@ +Testing retained_extras_on_rebase usage in evolve and modifying it in an extension + + $ . $TESTDIR/testlib/common.sh + + $ hg init repo + $ cd repo + $ cat > .hg/hgrc << EOF + > [extensions] + > evolve = + > EOF + + $ echo apple > a + $ hg ci -qAm 'apple' + $ echo banana > b + $ hg ci -qAm 'banana' --config extensions.commitextras= \ + > --extra useful=b-for-banana \ + > --extra useless=banana-peel + +amending apple + + $ hg prev + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + [0] apple + $ echo apricot > a + $ hg amend -m 'apricot' + 1 new orphan changesets + +the commit still has all extras that we added previously + + $ hg log -r 'desc("banana")' -T '{join(extras, " ")}\n' + *useful=b-for-banana*useless=banana-peel* (glob) + +let's run evolve with our extension + + $ hg --config extensions.retained_extras=${TESTDIR}/testlib/retain-extras-ext.py evolve + move:[1] banana + atop:[2] apricot + +evolving banana retained "useful" and discarded "useless" + + $ hg log -r 'desc("banana")' -T '{join(extras, " ")}\n' + *useful=b-for-banana* (glob) diff -r e44d343b9ed2 -r e36883d88108 tests/testlib/retain-extras-ext.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/testlib/retain-extras-ext.py Thu May 25 00:52:54 2023 +0200 @@ -0,0 +1,16 @@ +""" +Wrap 'retained_extras_on_rebase' (from either mercurial or evolve) to retain +the "useful" extra. +""" + +from mercurial import rewriteutil + +try: + rewriteutil.retained_extras_on_rebase +except AttributeError: + # install the compatibility layer on older version + from hgext3rd.evolve import compat + compat.retained_extras_on_rebase # silence linter + +def extsetup(ui): + rewriteutil.retained_extras_on_rebase.add(b'useful')