Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGf068495a1c28: fix: add test case that shows why --whole with --base is useful
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/fix.py (4 lines) | |||
M | tests/test-fix.t (26 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Danny Hooper | Jul 6 2018, 3:47 PM |
if kind == '!' and firstline != lastline: | if kind == '!' and firstline != lastline: | ||||
ranges.append((firstline + 1, lastline)) | ranges.append((firstline + 1, lastline)) | ||||
return ranges | return ranges | ||||
def getbasectxs(repo, opts, revstofix): | def getbasectxs(repo, opts, revstofix): | ||||
"""Returns a map of the base contexts for each revision | """Returns a map of the base contexts for each revision | ||||
The base contexts determine which lines are considered modified when we | The base contexts determine which lines are considered modified when we | ||||
attempt to fix just the modified lines in a file. | attempt to fix just the modified lines in a file. It also determines which | ||||
files we attempt to fix, so it is important to compute this even when | |||||
--whole is used. | |||||
""" | """ | ||||
# The --base flag overrides the usual logic, and we give every revision | # The --base flag overrides the usual logic, and we give every revision | ||||
# exactly the set of baserevs that the user specified. | # exactly the set of baserevs that the user specified. | ||||
if opts.get('base'): | if opts.get('base'): | ||||
baserevs = set(scmutil.revrange(repo, opts.get('base'))) | baserevs = set(scmutil.revrange(repo, opts.get('base'))) | ||||
if not baserevs: | if not baserevs: | ||||
baserevs = {nullrev} | baserevs = {nullrev} | ||||
basectxs = {repo[rev] for rev in baserevs} | basectxs = {repo[rev] for rev in baserevs} |
[255] | [255] | ||||
$ hg fix -r '.^' | $ hg fix -r '.^' | ||||
1 new orphan changesets | 1 new orphan changesets | ||||
$ hg cat -r 2 foo.whole | $ hg cat -r 2 foo.whole | ||||
ONE | ONE | ||||
$ cd .. | $ cd .. | ||||
The --base flag affects the set of files being fixed. So while the --whole flag | |||||
makes the base irrelevant for changed line ranges, it still changes the | |||||
meaning and effect of the command. In this example, no files or lines are fixed | |||||
until we specify the base, but then we do fix unchanged lines. | |||||
$ hg init basewhole | |||||
$ cd basewhole | |||||
$ printf "foo1\n" > foo.changed | |||||
$ hg commit -Aqm "first" | |||||
$ printf "foo2\n" >> foo.changed | |||||
$ printf "bar\n" > bar.changed | |||||
$ hg commit -Aqm "second" | |||||
$ hg fix --working-dir --whole | |||||
$ cat *.changed | |||||
bar | |||||
foo1 | |||||
foo2 | |||||
$ hg fix --working-dir --base 0 --whole | |||||
$ cat *.changed | |||||
BAR | |||||
FOO1 | |||||
FOO2 | |||||
$ cd .. |