avirshup: Here's my stab at a fix for #219. Please let me know if this seems reasonable and/or if there are any changes that should be made.
diff --git a/setuptools_scm/hg.py b/setuptools_scm/hg.py
index 9322fb3..0ba1774 100644
--- a/setuptools_scm/hg.py
+++ b/setuptools_scm/hg.py
@@ -8,8 +8,14 @@ FILES_COMMAND = 'hg locate -I .'
 def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
     dirty = node.endswith('+')
     node = 'h' + node.strip('+')
-    revset = ("(branch(.) and tag({tag!r})::. and file('re:^(?!\.hgtags).*$')"
-              " - tag({tag!r}))").format(tag=tag)
+
+    # Detect changes since the specified tag
+    revset = ("(branch(.)"  # look for revisions in this branch only
+              " and tag({tag!r})::."  # after the last tag
+              # ignore commits that only modify .hgtags and nothing else:
+              " and (merge() or file('re:^(?!\.hgtags).*$'))"
+              " and not tag({tag!r}))"  # ignore the tagged commit itself
+              ).format(tag=tag)
     if tag != '0.0':
         commits = do(['hg', 'log', '-r', revset, '--template', '{node|short}'],
                      root)

Regression: hg repos with setuptools_scm>=1.15 are missing dev version bumps
`setuptools_scm` 1.15.* is reporting incorrect version numbers for my hg repositories.

Specifically, a merge commit that follows a tag commit does not seem to trigger the version bump like I would expect. In the screenshot below, for instance, I would expect the tip to be version `1.1.dev[N]+[sha]`. However, versions 1.15.* report the tip's version as `1.0`.

To reproduce:
```bash
mkdir hgmergetest && cd hgmergetest && hg init

# create initial commit and tag it
touch a && hg add a && hg commit -m "initial commit" 
hg tag 1.0

# create a branch
hg branch branch1
touch b && hg add b && hg commit -m "create branch1"

# merge the branch into default
hg update default && hg merge branch1 && hg commit -m "merge branch1 into default"
```

Expected behavior (setuptools_scm 1.13 and 1.14):
```bash
> pip install "setuptools_scm<1.15"
> python -m setuptools_scm
Guessed Version 1.1.dev3+n8dce1535e70a
```

Behavior with `1.15.*`:
```bash
> pip install setuptools_scm==1.15.7
> python -m setuptools_scm
Guessed Version 1.0
```

![image](https://user-images.githubusercontent.com/9388007/37140764-b80a0c36-2267-11e8-87f8-bd52d199140c.png)
diff --git a/testing/test_mercurial.py b/testing/test_mercurial.py
index 1fe6841..1d91444 100644
--- a/testing/test_mercurial.py
+++ b/testing/test_mercurial.py
@@ -108,3 +108,47 @@ def test_version_in_merge(wd):
 def test_parse_no_worktree(tmpdir):
     ret = parse(str(tmpdir))
     assert ret is None
+
+
+@pytest.fixture
+def version_1_0(wd):
+    wd('hg branch default')
+    wd.commit_testfile()
+    wd('hg tag 1.0 -u test -d "0 0"')
+    return wd
+
+
+@pytest.fixture
+def pre_merge_commit_after_tag(wd, version_1_0):
+    wd('hg branch testbranch')
+    wd.write('branchfile', 'branchtext')
+    wd(wd.add_command)
+    wd.commit()
+    wd('hg update default')
+    wd('hg merge testbranch')
+    return wd
+
+
+@pytest.mark.usefixtures("pre_merge_commit_after_tag")
+def test_version_bump_before_merge_commit(wd):
+    assert wd.version.startswith('1.1.dev1+')
+
+
+@pytest.mark.issue(219)
+@pytest.mark.usefixtures("pre_merge_commit_after_tag")
+def test_version_bump_from_merge_commit(wd):
+    wd.commit()
+    assert wd.version.startswith('1.1.dev3+')  # issue 219
+
+
+@pytest.mark.usefixtures("version_1_0")
+def test_version_bump_from_commit_including_hgtag_mods(wd):
+    """ Test the case where a commit includes changes to .hgtags and other files
+    """
+    with wd.cwd.join('.hgtags').open('a') as tagfile:
+        tagfile.write('0  0\n')
+    wd.write('branchfile', 'branchtext')
+    wd(wd.add_command)
+    assert wd.version.startswith('1.1.dev1+')  # bump from dirty version
+    wd.commit()  # commits both the testfile _and_ .hgtags
+    assert wd.version.startswith('1.1.dev2+')

pip install -e .[dev]
parse_log_pytest
pytest
pytest
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
-e git+https://github.com/pypa/setuptools_scm.git@632b02b8ad1f10c79d36c03502069d74c9686c73#egg=setuptools_scm
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work

name: setuptools_scm
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
prefix: /opt/conda/envs/setuptools_scm

testing/test_mercurial.py::test_version_bump_from_merge_commit
testing/test_mercurial.py::test_archival_to_version[1.2.2.dev0-data4]
testing/test_mercurial.py::test_archival_to_version[0.0-data0] testing/test_mercurial.py::test_archival_to_version[1.0-data1] testing/test_mercurial.py::test_archival_to_version[1.1.dev3+h000000000000-data2] testing/test_mercurial.py::test_archival_to_version[1.2.2-data3] testing/test_mercurial.py::test_find_files_stop_at_root_hg testing/test_mercurial.py::test_version_from_hg_id testing/test_mercurial.py::test_version_from_archival testing/test_mercurial.py::test_version_in_merge testing/test_mercurial.py::test_parse_no_worktree testing/test_mercurial.py::test_version_bump_before_merge_commit testing/test_mercurial.py::test_version_bump_from_commit_including_hgtag_mods
setuptools_scm/hg.py
setuptools_scm/hg.py