summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Virshup <avirshup@gmail.com>2018-03-12 15:26:20 -0700
committerAaron Virshup <avirshup@gmail.com>2018-03-12 15:26:20 -0700
commit4263f574fe6c2ac374be0a14ae36553ae0af5d5c (patch)
tree447e82f4bd38d66474a416c7732f76fd746e6c7c
parent5b59b07d2ed9d5f92fd7c2c28542d073abff01dc (diff)
downloadsetuptools-scm-4263f574fe6c2ac374be0a14ae36553ae0af5d5c.tar.gz
Fix #219
-rw-r--r--setuptools_scm/hg.py10
-rw-r--r--testing/test_mercurial.py9
2 files changed, 16 insertions, 3 deletions
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)
diff --git a/testing/test_mercurial.py b/testing/test_mercurial.py
index 6df3cc0..1d91444 100644
--- a/testing/test_mercurial.py
+++ b/testing/test_mercurial.py
@@ -134,6 +134,13 @@ 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
@@ -144,4 +151,4 @@ def test_version_bump_from_commit_including_hgtag_mods(wd):
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+') \ No newline at end of file
+ assert wd.version.startswith('1.1.dev2+')