Mercurial > evolve
changeset 6493:e36883d88108
evolve: add a test to capture the expected behavior of retaining extras
author | Jason R. Coombs <jaraco@jaraco.com> |
---|---|
date | Thu, 25 May 2023 00:52:54 +0200 |
parents | e44d343b9ed2 |
children | 4ff6ed433ab2 |
files | tests/test-check-sdist.t tests/test-evolve-extras.t tests/testlib/retain-extras-ext.py |
diffstat | 3 files changed, 59 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- /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)
--- /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')