Mercurial > evolve
changeset 6870:120f0ad4646c
branching: merge with stable
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 16 Oct 2024 18:24:09 +0400 |
parents | d892efaa3615 (current diff) 28be6e0aa95d (diff) |
children | f1eefaa0ad28 |
files | .gitlab-ci.yml hgext3rd/evolve/evolvecmd.py tests/test-check-sdist.t |
diffstat | 6 files changed, 115 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/.gitlab-ci.yml Sun Sep 22 12:06:03 2024 +0200 +++ b/.gitlab-ci.yml Wed Oct 16 18:24:09 2024 +0400 @@ -24,7 +24,7 @@ TEST_HGMODULEPOLICY: "allow" .runtests_template: &runtests - image: registry.heptapod.net/mercurial/ci-images/py3-hgext3rd:v2.0 + image: registry.heptapod.net/mercurial/ci-images/py3-hgext3rd:v2.1 before_script: - (cd tests; ls -1 test-check-*.t > /tmp/check-tests.txt) script: @@ -62,7 +62,7 @@ allow_failure: true doc: - image: registry.heptapod.net/mercurial/ci-images/py3-evolve-doc:v2.0 + image: registry.heptapod.net/mercurial/ci-images/py3-evolve-doc:v2.1 script: - make doc variables:
--- a/README.rst Sun Sep 22 12:06:03 2024 +0200 +++ b/README.rst Wed Oct 16 18:24:09 2024 +0400 @@ -26,7 +26,7 @@ * improves performance of obsolescence marker exchange and discovery during push and pull. -.. _`changeset evolution`: https://www.mercurial-scm.org/wiki/ChangesetEvolution +.. _`changeset evolution`: https://wiki.mercurial-scm.org/ChangesetEvolution Documentation ------------- @@ -48,44 +48,101 @@ $ pip install --user hg-evolve -Then enable it in your hgrc:: +Note: some distributions have adopted PEP 668 and made using ``pip install +--user`` more difficult than it should be. One of the cleanest ways around this +issue is to install both Mercurial and this extension in a separate virtual +environment. If you don't want to manage the virtual environment manually, you +can use Pipx. + +Using Pipx +---------- + +Its documentation explains that "pipx is made specifically for application +installation", and the idea is that for every application it can create and +maintain a separate virtual environment and make all executables available on a +single path (e.g. ~/.local/bin/ on Linux, check ``pipx ensurepath``). + +To create a virtual environment for hg and install evolve:: + + $ pipx install mercurial + $ pipx inject mercurial hg-evolve + # or pipx runpip mercurial install hg-evolve + +Note: it's recommended to use ``inject`` command to install evolve, but +sometimes ``runpip`` could be used. On some setups ``inject`` might require +specifying the full path to the extension in the configuration file, while +``runpip`` might not. + +Using Your Package Manager +-------------------------- + +Sometimes your distribution's package manager might have the newest (or recent +enough) version of the extension. For example, both `Debian`_ and `Ubuntu`_ +currently have a package called ``mercurial-evolve``. Similarly, other +distributions might have it packaged, possibly under a slightly different name. +Try searching your package manager's database or see `this Repology page`_. + +.. _`Debian`: https://packages.debian.org/search?keywords=mercurial-evolve&searchon=names&exact=1&suite=all§ion=all +.. _`Ubuntu`: https://packages.ubuntu.com/search?keywords=mercurial-evolve&searchon=names&exact=1&suite=all§ion=all +.. _`this Repology page`: https://repology.org/project/mercurial-evolve/related + +From Source +----------- + +To obtain a local version from source:: + + $ hg clone https://repo.mercurial-scm.org/evolve + +There's no need to compile anything or run ``make``. + +This method keeps the extension in its own repo, and you can use it by +specifying the full path to the ``hgext3rd/evolve/``. + +Alternatively, you can install it:: + + $ cd evolve + # optionally `hg update <target revision>` + $ pip install --user . + +This should avoid the need to specify the full path to the extension. + +Enabling the Extension +---------------------- + +After installing the extension, you need to enable it before you can use it. + +To do that, edit your hgrc:: $ hg config --edit # add these two lines: [extensions] evolve = -From Source ------------ - -To install a local version from source:: - - $ hg clone https://www.mercurial-scm.org/repo/evolve/ - $ cd evolve - # optionally `hg update <target revision>` - $ pip install --user . - -Then enable it in your hgrc:: - - $ hg config --edit # add these two lines: - [extensions] - evolve = - -It's also possible to use evolve without installing it, in which case you will -need to provide the full path to ``hgext3rd/evolve/``, for example:: +If you didn't install the extension or Mercurial can't find it on one of the +default paths, you need to specify the full path to ``hgext3rd/evolve/``:: [extensions] evolve = ~/evolve/hgext3rd/evolve +Similarly, if you want to enable topic extension, do this:: + + $ hg config --edit + [extensions] + topic = + # or + topic = ~/evolve/hgext3rd/topic + Pitfalls -------- If you get ``"failed to import extension evolve: No module named 'evolve'"`` error, there are a couple of things to check: -* make sure you gave pip the correct package name (it's hg-evolve), +* make sure you gave pip/pipx the correct package name (it's ``hg-evolve``), * make sure evolve is installed for the same version of Python that you use for - running Mercurial (``hg debuginstall | grep Python``). + running Mercurial (``hg debuginstall | grep Python``), + +* try specifying the full path to the ``hgext3rd/evolve/`` directory. Extension Purpose ================= @@ -110,7 +167,7 @@ Mercurial announced official `support for Python 3`_ starting with its 5.2 release. Since 9.3.0, evolve has official support for Python 3.6+. -.. _`support for Python 3`: https://www.mercurial-scm.org/wiki/Python3 +.. _`support for Python 3`: https://wiki.mercurial-scm.org/Python3 Python 2 Support ================ @@ -146,7 +203,7 @@ For guidelines on the patch description, see the `official Mercurial guideline`_. -.. _`official Mercurial guideline`: https://mercurial-scm.org/wiki/ContributingChanges#Patch_descriptions +.. _`official Mercurial guideline`: https://wiki.mercurial-scm.org/ContributingChanges#Patch_descriptions Please don't forget to update and run the tests when you fix a bug or add a feature. To run the tests, you need a working copy of Mercurial, say in
--- a/hgext3rd/evolve/evolvecmd.py Sun Sep 22 12:06:03 2024 +0200 +++ b/hgext3rd/evolve/evolvecmd.py Wed Oct 16 18:24:09 2024 +0400 @@ -1887,10 +1887,10 @@ cleanup = True startnode = evolvestate[b'startnode'] for old, new in evolvestate[b'replacements'].items(): - if new: + if new and new in repo: evolvedctx.append(repo[new]) for temp in evolvestate[b'temprevs']: - if temp: + if temp and temp in repo: evolvedctx.append(repo[temp]) evolvedrevs = [c.rev() for c in evolvedctx]
--- a/tests/test-check-commit.t Sun Sep 22 12:06:03 2024 +0200 +++ b/tests/test-check-commit.t Wed Oct 16 18:24:09 2024 +0400 @@ -1,24 +1,32 @@ #require test-repo + $ . "$RUNTESTDIR/helpers-testrepo.sh" + Enable obsolescence to avoid the warning issue when obsmarkers are found $ cat << EOF >> $HGRCPATH > [experimental] > evolution = all - > [diff] - > git = yes > EOF Go back in the hg repo $ cd $TESTDIR/.. - $ for node in `hg log --rev 'not public() and ::. and not desc("# no-check-commit")' --template '{node|short}\n'`; do - > hg export $node | ${RUNTESTDIR}/../contrib/check-commit > ${TESTTMP}/check-commit.out - > if [ $? -ne 0 ]; then - > echo "Revision $node does not comply with rules" - > echo '------------------------------------------------------' - > cat ${TESTTMP}/check-commit.out - > echo - > fi - > done + $ REVSET='not public() and ::. and not desc("# no-check-commit")' + + $ mkdir "$TESTTMP/p" + $ REVS=`testrepohg log -r "$REVSET" -T.` + $ if [ -n "$REVS" ] ; then + > testrepohg export --git -o "$TESTTMP/p/%n-%h" -r "$REVSET" + > for f in `ls "$TESTTMP/p"`; do + > "$RUNTESTDIR/../contrib/check-commit" < "$TESTTMP/p/$f" > "$TESTTMP/check-commit.out" + > if [ $? -ne 0 ]; then + > node="${f##*-}" + > echo "Revision $node does not comply with rules" + > echo '------------------------------------------------------' + > cat ${TESTTMP}/check-commit.out + > echo + > fi + > done + > fi
--- a/tests/test-check-sdist.t Sun Sep 22 12:06:03 2024 +0200 +++ b/tests/test-check-sdist.t Wed Oct 16 18:24:09 2024 +0400 @@ -11,7 +11,8 @@ #if test-repo - $ hg archive "$TESTTMP"/hg-evolve + $ . "$RUNTESTDIR/helpers-testrepo.sh" + $ testrepohg archive "$TESTTMP"/hg-evolve $ cd "$TESTTMP"/hg-evolve #endif
--- a/tests/test-doctest.py Sun Sep 22 12:06:03 2024 +0200 +++ b/tests/test-doctest.py Wed Oct 16 18:24:09 2024 +0400 @@ -67,11 +67,15 @@ if not os.path.isdir(os.path.join(cwd, ".hg")): sys.exit(0) -files = subprocess.check_output( - "hg files --print0 \"%s\"" % fileset, - shell=True, - cwd=cwd, -).split(b'\0') +files_cmd = 'hg files --print0 "%s"' % fileset + +# we prefer system hg for reading the repository, unless we're on python2 +# because then we assume that system hg is too old (this is not always true, +# but it's an easy check and works well enough for us) +if ispy3 and 'HGTEST_RESTOREENV': + files_cmd = '. $HGTEST_RESTOREENV; ' + files_cmd + +files = subprocess.check_output(files_cmd, shell=True, cwd=cwd).split(b'\0') if sys.version_info[0] >= 3: cwd = os.fsencode(cwd)