Skip to content

Commit 4263f57

Browse files
committed
Fix #219
1 parent 5b59b07 commit 4263f57

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

setuptools_scm/hg.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
99
dirty = node.endswith('+')
1010
node = 'h' + node.strip('+')
11-
revset = ("(branch(.) and tag({tag!r})::. and file('re:^(?!\.hgtags).*$')"
12-
" - tag({tag!r}))").format(tag=tag)
11+
12+
# Detect changes since the specified tag
13+
revset = ("(branch(.)" # look for revisions in this branch only
14+
" and tag({tag!r})::." # after the last tag
15+
# ignore commits that only modify .hgtags and nothing else:
16+
" and (merge() or file('re:^(?!\.hgtags).*$'))"
17+
" and not tag({tag!r}))" # ignore the tagged commit itself
18+
).format(tag=tag)
1319
if tag != '0.0':
1420
commits = do(['hg', 'log', '-r', revset, '--template', '{node|short}'],
1521
root)

testing/test_mercurial.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ def test_version_bump_before_merge_commit(wd):
134134
assert wd.version.startswith('1.1.dev1+')
135135

136136

137+
@pytest.mark.issue(219)
138+
@pytest.mark.usefixtures("pre_merge_commit_after_tag")
139+
def test_version_bump_from_merge_commit(wd):
140+
wd.commit()
141+
assert wd.version.startswith('1.1.dev3+') # issue 219
142+
143+
137144
@pytest.mark.usefixtures("version_1_0")
138145
def test_version_bump_from_commit_including_hgtag_mods(wd):
139146
""" 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):
144151
wd(wd.add_command)
145152
assert wd.version.startswith('1.1.dev1+') # bump from dirty version
146153
wd.commit() # commits both the testfile _and_ .hgtags
147-
assert wd.version.startswith('1.1.dev2+')
154+
assert wd.version.startswith('1.1.dev2+')

0 commit comments

Comments
 (0)