author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Mon, 25 Mar 2019 08:41:02 -0700 | |
changeset 42016 | b900b392c1cc |
parent 42008 | 7f6b375a8903 |
child 42194 | 0da689a60163 |
permissions | -rw-r--r-- |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
1 |
A script that implements uppercasing of specific lines in a file. This |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
2 |
approximates the behavior of code formatters well enough for our tests. |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
3 |
|
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
4 |
$ UPPERCASEPY="$TESTTMP/uppercase.py" |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
5 |
$ cat > $UPPERCASEPY <<EOF |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
6 |
> import sys |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
7 |
> from mercurial.utils.procutil import setbinary |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
8 |
> setbinary(sys.stdin) |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
9 |
> setbinary(sys.stdout) |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
10 |
> lines = set() |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
11 |
> for arg in sys.argv[1:]: |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
12 |
> if arg == 'all': |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
13 |
> sys.stdout.write(sys.stdin.read().upper()) |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
14 |
> sys.exit(0) |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
15 |
> else: |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
16 |
> first, last = arg.split('-') |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
17 |
> lines.update(range(int(first), int(last) + 1)) |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
18 |
> for i, line in enumerate(sys.stdin.readlines()): |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
19 |
> if i + 1 in lines: |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
20 |
> sys.stdout.write(line.upper()) |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
21 |
> else: |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
22 |
> sys.stdout.write(line) |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
23 |
> EOF |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
24 |
$ TESTLINES="foo\nbar\nbaz\nqux\n" |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
25 |
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
26 |
foo |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
27 |
bar |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
28 |
baz |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
29 |
qux |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
30 |
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY all |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
31 |
FOO |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
32 |
BAR |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
33 |
BAZ |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
34 |
QUX |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
35 |
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 1-1 |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
36 |
FOO |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
37 |
bar |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
38 |
baz |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
39 |
qux |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
40 |
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 1-2 |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
41 |
FOO |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
42 |
BAR |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
43 |
baz |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
44 |
qux |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
45 |
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 2-3 |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
46 |
foo |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
47 |
BAR |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
48 |
BAZ |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
49 |
qux |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
50 |
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 2-2 4-4 |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
51 |
foo |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
52 |
BAR |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
53 |
baz |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
54 |
QUX |
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
55 |
|
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
56 |
Set up the config with two simple fixers: one that fixes specific line ranges, |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
57 |
and one that always fixes the whole file. They both "fix" files by converting |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
58 |
letters to uppercase. They use different file extensions, so each test case can |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
59 |
choose which behavior to use by naming files. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
60 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
61 |
$ cat >> $HGRCPATH <<EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
62 |
> [extensions] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
63 |
> fix = |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
64 |
> [experimental] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
65 |
> evolution.createmarkers=True |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
66 |
> evolution.allowunstable=True |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
67 |
> [fix] |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
68 |
> uppercase-whole-file:command="$PYTHON" $UPPERCASEPY all |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
69 |
> uppercase-whole-file:pattern=set:**.whole |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39111
diff
changeset
|
70 |
> uppercase-changed-lines:command="$PYTHON" $UPPERCASEPY |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
71 |
> uppercase-changed-lines:linerange={first}-{last} |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
72 |
> uppercase-changed-lines:pattern=set:**.changed |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
73 |
> EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
74 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
75 |
Help text for fix. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
76 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
77 |
$ hg help fix |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
78 |
hg fix [OPTION]... [FILE]... |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
79 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
80 |
rewrite file content in changesets or working directory |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
81 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
82 |
Runs any configured tools to fix the content of files. Only affects files |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
83 |
with changes, unless file arguments are provided. Only affects changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
84 |
lines of files, unless the --whole flag is used. Some tools may always |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
85 |
affect the whole file regardless of --whole. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
86 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
87 |
If revisions are specified with --rev, those revisions will be checked, |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
88 |
and they may be replaced with new revisions that have fixed file content. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
89 |
It is desirable to specify all descendants of each specified revision, so |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
90 |
that the fixes propagate to the descendants. If all descendants are fixed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
91 |
at the same time, no merging, rebasing, or evolution will be required. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
92 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
93 |
If --working-dir is used, files with uncommitted changes in the working |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
94 |
copy will be fixed. If the checked-out revision is also fixed, the working |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
95 |
directory will update to the replacement revision. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
96 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
97 |
When determining what lines of each file to fix at each revision, the |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
98 |
whole set of revisions being fixed is considered, so that fixes to earlier |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
99 |
revisions are not forgotten in later ones. The --base flag can be used to |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
100 |
override this default behavior, though it is not usually desirable to do |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
101 |
so. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
102 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
103 |
(use 'hg help -e fix' to show help for the fix extension) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
104 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
105 |
options ([+] can be repeated): |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
106 |
|
41010
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41009
diff
changeset
|
107 |
--all fix all non-public non-obsolete revisions |
41009
fcc0a7ac9ebd
help: show "[no-]" only for default-on Flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
40955
diff
changeset
|
108 |
--base REV [+] revisions to diff against (overrides automatic selection, |
fcc0a7ac9ebd
help: show "[no-]" only for default-on Flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
40955
diff
changeset
|
109 |
and applies to every revision being fixed) |
fcc0a7ac9ebd
help: show "[no-]" only for default-on Flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
40955
diff
changeset
|
110 |
-r --rev REV [+] revisions to fix |
41010
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41009
diff
changeset
|
111 |
-w --working-dir fix the working directory |
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41009
diff
changeset
|
112 |
--whole always fix every line of a file |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
113 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
114 |
(some details hidden, use --verbose to show complete help) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
115 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
116 |
$ hg help -e fix |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
117 |
fix extension - rewrite file content in changesets or working copy |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
118 |
(EXPERIMENTAL) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
119 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
120 |
Provides a command that runs configured tools on the contents of modified |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
121 |
files, writing back any fixes to the working copy or replacing changesets. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
122 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
123 |
Here is an example configuration that causes 'hg fix' to apply automatic |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
124 |
formatting fixes to modified lines in C++ code: |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
125 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
126 |
[fix] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
127 |
clang-format:command=clang-format --assume-filename={rootpath} |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
128 |
clang-format:linerange=--lines={first}:{last} |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
129 |
clang-format:pattern=set:**.cpp or **.hpp |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
130 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
131 |
The :command suboption forms the first part of the shell command that will be |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
132 |
used to fix a file. The content of the file is passed on standard input, and |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
133 |
the fixed file content is expected on standard output. Any output on standard |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
134 |
error will be displayed as a warning. If the exit status is not zero, the file |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
135 |
will not be affected. A placeholder warning is displayed if there is a non- |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
136 |
zero exit status but no standard error output. Some values may be substituted |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
137 |
into the command: |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
138 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
139 |
{rootpath} The path of the file being fixed, relative to the repo root |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
140 |
{basename} The name of the file being fixed, without the directory path |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
141 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
142 |
If the :linerange suboption is set, the tool will only be run if there are |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
143 |
changed lines in a file. The value of this suboption is appended to the shell |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
144 |
command once for every range of changed lines in the file. Some values may be |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
145 |
substituted into the command: |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
146 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
147 |
{first} The 1-based line number of the first line in the modified range |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
148 |
{last} The 1-based line number of the last line in the modified range |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
149 |
|
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
150 |
The :pattern suboption determines which files will be passed through each |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
151 |
configured tool. See 'hg help patterns' for possible values. If there are file |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
152 |
arguments to 'hg fix', the intersection of these patterns is used. |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
153 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
154 |
There is also a configurable limit for the maximum size of file that will be |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
155 |
processed by 'hg fix': |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
156 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
157 |
[fix] |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
158 |
maxfilesize = 2MB |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
159 |
|
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
160 |
Normally, execution of configured tools will continue after a failure |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
161 |
(indicated by a non-zero exit status). It can also be configured to abort |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
162 |
after the first such failure, so that no files will be affected if any tool |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
163 |
fails. This abort will also cause 'hg fix' to exit with a non-zero status: |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
164 |
|
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
165 |
[fix] |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
166 |
failure = abort |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
167 |
|
40566
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
168 |
When multiple tools are configured to affect a file, they execute in an order |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
169 |
defined by the :priority suboption. The priority suboption has a default value |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
170 |
of zero for each tool. Tools are executed in order of descending priority. The |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
171 |
execution order of tools with equal priority is unspecified. For example, you |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
172 |
could use the 'sort' and 'head' utilities to keep only the 10 smallest numbers |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
173 |
in a text file by ensuring that 'sort' runs before 'head': |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
174 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
175 |
[fix] |
41126
d8f5c615e811
tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents:
41010
diff
changeset
|
176 |
sort:command = sort -n |
d8f5c615e811
tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents:
41010
diff
changeset
|
177 |
head:command = head -n 10 |
40566
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
178 |
sort:pattern = numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
179 |
head:pattern = numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
180 |
sort:priority = 2 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
181 |
head:priority = 1 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
182 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
183 |
To account for changes made by each tool, the line numbers used for |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
184 |
incremental formatting are recomputed before executing the next tool. So, each |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
185 |
tool may see different values for the arguments added by the :linerange |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
186 |
suboption. |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
187 |
|
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
188 |
list of commands: |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
189 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
190 |
fix rewrite file content in changesets or working directory |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
191 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
192 |
(use 'hg help -v -e fix' to show built-in aliases and global options) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
193 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
194 |
There is no default behavior in the absence of --rev and --working-dir. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
195 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
196 |
$ hg init badusage |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
197 |
$ cd badusage |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
198 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
199 |
$ hg fix |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
200 |
abort: no changesets specified |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
201 |
(use --rev or --working-dir) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
202 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
203 |
$ hg fix --whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
204 |
abort: no changesets specified |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
205 |
(use --rev or --working-dir) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
206 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
207 |
$ hg fix --base 0 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
208 |
abort: no changesets specified |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
209 |
(use --rev or --working-dir) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
210 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
211 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
212 |
Fixing a public revision isn't allowed. It should abort early enough that |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
213 |
nothing happens, even to the working directory. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
214 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
215 |
$ printf "hello\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
216 |
$ hg commit -Aqm "hello" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
217 |
$ hg phase -r 0 --public |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
218 |
$ hg fix -r 0 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
219 |
abort: can't fix immutable changeset 0:6470986d2e7b |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
220 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
221 |
$ hg fix -r 0 --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
222 |
abort: can't fix immutable changeset 0:6470986d2e7b |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
223 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
224 |
$ hg cat -r tip hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
225 |
hello |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
226 |
$ cat hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
227 |
hello |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
228 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
229 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
230 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
231 |
Fixing a clean working directory should do nothing. Even the --whole flag |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
232 |
shouldn't cause any clean files to be fixed. Specifying a clean file explicitly |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
233 |
should only fix it if the fixer always fixes the whole file. The combination of |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
234 |
an explicit filename and --whole should format the entire file regardless. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
235 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
236 |
$ hg init fixcleanwdir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
237 |
$ cd fixcleanwdir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
238 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
239 |
$ printf "hello\n" > hello.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
240 |
$ printf "world\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
241 |
$ hg commit -Aqm "foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
242 |
$ hg fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
243 |
$ hg diff |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
244 |
$ hg fix --working-dir --whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
245 |
$ hg diff |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
246 |
$ hg fix --working-dir * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
247 |
$ cat * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
248 |
hello |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
249 |
WORLD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
250 |
$ hg revert --all --no-backup |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
251 |
reverting hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
252 |
$ hg fix --working-dir * --whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
253 |
$ cat * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
254 |
HELLO |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
255 |
WORLD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
256 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
257 |
The same ideas apply to fixing a revision, so we create a revision that doesn't |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
258 |
modify either of the files in question and try fixing it. This also tests that |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
259 |
we ignore a file that doesn't match any configured fixer. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
260 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
261 |
$ hg revert --all --no-backup |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
262 |
reverting hello.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
263 |
reverting hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
264 |
$ printf "unimportant\n" > some.file |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
265 |
$ hg commit -Aqm "some other file" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
266 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
267 |
$ hg fix -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
268 |
$ hg cat -r tip * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
269 |
hello |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
270 |
world |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
271 |
unimportant |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
272 |
$ hg fix -r . --whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
273 |
$ hg cat -r tip * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
274 |
hello |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
275 |
world |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
276 |
unimportant |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
277 |
$ hg fix -r . * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
278 |
$ hg cat -r tip * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
279 |
hello |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
280 |
WORLD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
281 |
unimportant |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
282 |
$ hg fix -r . * --whole --config experimental.evolution.allowdivergence=true |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
283 |
2 new content-divergent changesets |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
284 |
$ hg cat -r tip * |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
285 |
HELLO |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
286 |
WORLD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
287 |
unimportant |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
288 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
289 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
290 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
291 |
Fixing the working directory should still work if there are no revisions. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
292 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
293 |
$ hg init norevisions |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
294 |
$ cd norevisions |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
295 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
296 |
$ printf "something\n" > something.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
297 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
298 |
adding something.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
299 |
$ hg fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
300 |
$ cat something.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
301 |
SOMETHING |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
302 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
303 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
304 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
305 |
Test the effect of fixing the working directory for each possible status, with |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
306 |
and without providing explicit file arguments. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
307 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
308 |
$ hg init implicitlyfixstatus |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
309 |
$ cd implicitlyfixstatus |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
310 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
311 |
$ printf "modified\n" > modified.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
312 |
$ printf "removed\n" > removed.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
313 |
$ printf "deleted\n" > deleted.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
314 |
$ printf "clean\n" > clean.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
315 |
$ printf "ignored.whole" > .hgignore |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
316 |
$ hg commit -Aqm "stuff" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
317 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
318 |
$ printf "modified!!!\n" > modified.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
319 |
$ printf "unknown\n" > unknown.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
320 |
$ printf "ignored\n" > ignored.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
321 |
$ printf "added\n" > added.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
322 |
$ hg add added.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
323 |
$ hg remove removed.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
324 |
$ rm deleted.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
325 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
326 |
$ hg status --all |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
327 |
M modified.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
328 |
A added.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
329 |
R removed.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
330 |
! deleted.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
331 |
? unknown.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
332 |
I ignored.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
333 |
C .hgignore |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
334 |
C clean.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
335 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
336 |
$ hg fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
337 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
338 |
$ hg status --all |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
339 |
M modified.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
340 |
A added.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
341 |
R removed.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
342 |
! deleted.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
343 |
? unknown.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
344 |
I ignored.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
345 |
C .hgignore |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
346 |
C clean.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
347 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
348 |
$ cat *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
349 |
ADDED |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
350 |
clean |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
351 |
ignored |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
352 |
MODIFIED!!! |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
353 |
unknown |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
354 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
355 |
$ printf "modified!!!\n" > modified.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
356 |
$ printf "added\n" > added.whole |
42008
7f6b375a8903
fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents:
41126
diff
changeset
|
357 |
|
7f6b375a8903
fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents:
41126
diff
changeset
|
358 |
Listing the files explicitly causes untracked files to also be fixed, but |
7f6b375a8903
fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents:
41126
diff
changeset
|
359 |
ignored files are still unaffected. |
7f6b375a8903
fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents:
41126
diff
changeset
|
360 |
|
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
361 |
$ hg fix --working-dir *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
362 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
363 |
$ hg status --all |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
364 |
M clean.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
365 |
M modified.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
366 |
A added.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
367 |
R removed.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
368 |
! deleted.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
369 |
? unknown.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
370 |
I ignored.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
371 |
C .hgignore |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
372 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
373 |
$ cat *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
374 |
ADDED |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
375 |
CLEAN |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
376 |
ignored |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
377 |
MODIFIED!!! |
42008
7f6b375a8903
fix: allow fixing untracked files when given as arguments
Danny Hooper <hooper@google.com>
parents:
41126
diff
changeset
|
378 |
UNKNOWN |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
379 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
380 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
381 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
382 |
Test that incremental fixing works on files with additions, deletions, and |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
383 |
changes in multiple line ranges. Note that deletions do not generally cause |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
384 |
neighboring lines to be fixed, so we don't return a line range for purely |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
385 |
deleted sections. In the future we should support a :deletion config that |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
386 |
allows fixers to know where deletions are located. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
387 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
388 |
$ hg init incrementalfixedlines |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
389 |
$ cd incrementalfixedlines |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
390 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
391 |
$ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.txt |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
392 |
$ hg commit -Aqm "foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
393 |
$ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.txt |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
394 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
395 |
$ hg --config "fix.fail:command=echo" \ |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
396 |
> --config "fix.fail:linerange={first}:{last}" \ |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
397 |
> --config "fix.fail:pattern=foo.txt" \ |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
398 |
> fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
399 |
$ cat foo.txt |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
400 |
1:1 4:6 8:8 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
401 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
402 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
403 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
404 |
Test that --whole fixes all lines regardless of the diffs present. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
405 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
406 |
$ hg init wholeignoresdiffs |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
407 |
$ cd wholeignoresdiffs |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
408 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
409 |
$ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
410 |
$ hg commit -Aqm "foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
411 |
$ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
412 |
$ hg fix --working-dir --whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
413 |
$ cat foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
414 |
ZZ |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
415 |
A |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
416 |
C |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
417 |
DD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
418 |
EE |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
419 |
FF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
420 |
F |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
421 |
GG |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
422 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
423 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
424 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
425 |
We should do nothing with symlinks, and their targets should be unaffected. Any |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
426 |
other behavior would be more complicated to implement and harder to document. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
427 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
428 |
#if symlink |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
429 |
$ hg init dontmesswithsymlinks |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
430 |
$ cd dontmesswithsymlinks |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
431 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
432 |
$ printf "hello\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
433 |
$ ln -s hello.whole hellolink |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
434 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
435 |
adding hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
436 |
adding hellolink |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
437 |
$ hg fix --working-dir hellolink |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
438 |
$ hg status |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
439 |
A hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
440 |
A hellolink |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
441 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
442 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
443 |
#endif |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
444 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
445 |
We should allow fixers to run on binary files, even though this doesn't sound |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
446 |
like a common use case. There's not much benefit to disallowing it, and users |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
447 |
can add "and not binary()" to their filesets if needed. The Mercurial |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
448 |
philosophy is generally to not handle binary files specially anyway. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
449 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
450 |
$ hg init cantouchbinaryfiles |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
451 |
$ cd cantouchbinaryfiles |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
452 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
453 |
$ printf "hello\0\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
454 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
455 |
adding hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
456 |
$ hg fix --working-dir 'set:binary()' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
457 |
$ cat hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
458 |
HELLO\x00 (esc) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
459 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
460 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
461 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
462 |
We have a config for the maximum size of file we will attempt to fix. This can |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
463 |
be helpful to avoid running unsuspecting fixer tools on huge inputs, which |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
464 |
could happen by accident without a well considered configuration. A more |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
465 |
precise configuration could use the size() fileset function if one global limit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
466 |
is undesired. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
467 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
468 |
$ hg init maxfilesize |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
469 |
$ cd maxfilesize |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
470 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
471 |
$ printf "this file is huge\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
472 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
473 |
adding hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
474 |
$ hg --config fix.maxfilesize=10 fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
475 |
ignoring file larger than 10 bytes: hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
476 |
$ cat hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
477 |
this file is huge |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
478 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
479 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
480 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
481 |
If we specify a file to fix, other files should be left alone, even if they |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
482 |
have changes. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
483 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
484 |
$ hg init fixonlywhatitellyouto |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
485 |
$ cd fixonlywhatitellyouto |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
486 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
487 |
$ printf "fix me!\n" > fixme.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
488 |
$ printf "not me.\n" > notme.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
489 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
490 |
adding fixme.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
491 |
adding notme.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
492 |
$ hg fix --working-dir fixme.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
493 |
$ cat *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
494 |
FIX ME! |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
495 |
not me. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
496 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
497 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
498 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
499 |
Specifying a directory name should fix all its files and subdirectories. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
500 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
501 |
$ hg init fixdirectory |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
502 |
$ cd fixdirectory |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
503 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
504 |
$ mkdir -p dir1/dir2 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
505 |
$ printf "foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
506 |
$ printf "bar\n" > dir1/bar.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
507 |
$ printf "baz\n" > dir1/dir2/baz.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
508 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
509 |
adding dir1/bar.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
510 |
adding dir1/dir2/baz.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
511 |
adding foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
512 |
$ hg fix --working-dir dir1 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
513 |
$ cat foo.whole dir1/bar.whole dir1/dir2/baz.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
514 |
foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
515 |
BAR |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
516 |
BAZ |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
517 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
518 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
519 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
520 |
Fixing a file in the working directory that needs no fixes should not actually |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
521 |
write back to the file, so for example the mtime shouldn't change. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
522 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
523 |
$ hg init donttouchunfixedfiles |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
524 |
$ cd donttouchunfixedfiles |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
525 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
526 |
$ printf "NO FIX NEEDED\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
527 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
528 |
adding foo.whole |
37798
8fa3396a832d
test-fix: fix use of 'f --newer' to check that foo.whole is not updated
Yuya Nishihara <yuya@tcha.org>
parents:
37791
diff
changeset
|
529 |
$ cp -p foo.whole foo.whole.orig |
37809
80695628adcb
test-fix: normalize precision of mtime copied by 'cp -p'
Yuya Nishihara <yuya@tcha.org>
parents:
37798
diff
changeset
|
530 |
$ cp -p foo.whole.orig foo.whole |
37593
314f39e5fa86
tests: use `f --newer` instead of `stat -c` in test-fix.t
Augie Fackler <augie@google.com>
parents:
37560
diff
changeset
|
531 |
$ sleep 2 # mtime has a resolution of one or two seconds. |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
532 |
$ hg fix --working-dir |
37798
8fa3396a832d
test-fix: fix use of 'f --newer' to check that foo.whole is not updated
Yuya Nishihara <yuya@tcha.org>
parents:
37791
diff
changeset
|
533 |
$ f foo.whole.orig --newer foo.whole |
8fa3396a832d
test-fix: fix use of 'f --newer' to check that foo.whole is not updated
Yuya Nishihara <yuya@tcha.org>
parents:
37791
diff
changeset
|
534 |
foo.whole.orig: newer than foo.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
535 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
536 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
537 |
|
38967
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
538 |
When a fixer prints to stderr, we don't assume that it has failed. We show the |
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
539 |
error messages to the user, and we still let the fixer affect the file it was |
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
540 |
fixing if its exit code is zero. Some code formatters might emit error messages |
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
541 |
on stderr and nothing on stdout, which would cause us the clear the file, |
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
542 |
except that they also exit with a non-zero code. We show the user which fixer |
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
543 |
emitted the stderr, and which revision, but we assume that the fixer will print |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
544 |
the filename if it is relevant (since the issue may be non-specific). There is |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
545 |
also a config to abort (without affecting any files whatsoever) if we see any |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
546 |
tool with a non-zero exit status. |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
547 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
548 |
$ hg init showstderr |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
549 |
$ cd showstderr |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
550 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
551 |
$ printf "hello\n" > hello.txt |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
552 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
553 |
adding hello.txt |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
554 |
$ cat > $TESTTMP/work.sh <<'EOF' |
37791
72ccb0716302
tests: stabilize test-fix.t for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
37595
diff
changeset
|
555 |
> printf 'HELLO\n' |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
556 |
> printf "$@: some\nerror that didn't stop the tool" >&2 |
38967
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
557 |
> exit 0 # success despite the stderr output |
37791
72ccb0716302
tests: stabilize test-fix.t for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
37595
diff
changeset
|
558 |
> EOF |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
559 |
$ hg --config "fix.work:command=sh $TESTTMP/work.sh {rootpath}" \ |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
560 |
> --config "fix.work:pattern=hello.txt" \ |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
561 |
> fix --working-dir |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
562 |
[wdir] work: hello.txt: some |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
563 |
[wdir] work: error that didn't stop the tool |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
564 |
$ cat hello.txt |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
565 |
HELLO |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
566 |
|
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
567 |
$ printf "goodbye\n" > hello.txt |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
568 |
$ printf "foo\n" > foo.whole |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
569 |
$ hg add |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
570 |
adding foo.whole |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
571 |
$ cat > $TESTTMP/fail.sh <<'EOF' |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
572 |
> printf 'GOODBYE\n' |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
573 |
> printf "$@: some\nerror that did stop the tool\n" >&2 |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
574 |
> exit 42 # success despite the stdout output |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
575 |
> EOF |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
576 |
$ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \ |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
577 |
> --config "fix.fail:pattern=hello.txt" \ |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
578 |
> --config "fix.failure=abort" \ |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
579 |
> fix --working-dir |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
580 |
[wdir] fail: hello.txt: some |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
581 |
[wdir] fail: error that did stop the tool |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
582 |
abort: no fixes will be applied |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
583 |
(use --config fix.failure=continue to apply any successful fixes anyway) |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
584 |
[255] |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
585 |
$ cat hello.txt |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
586 |
goodbye |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
587 |
$ cat foo.whole |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
588 |
foo |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
589 |
|
38967
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
590 |
$ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \ |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
591 |
> --config "fix.fail:pattern=hello.txt" \ |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
592 |
> fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
593 |
[wdir] fail: hello.txt: some |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
594 |
[wdir] fail: error that did stop the tool |
38967
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
595 |
$ cat hello.txt |
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
596 |
goodbye |
40532
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
597 |
$ cat foo.whole |
93bab80993f4
fix: add a config to abort when a fixer tool fails
Danny Hooper <hooper@google.com>
parents:
39707
diff
changeset
|
598 |
FOO |
38967
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
599 |
|
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
600 |
$ hg --config "fix.fail:command=exit 42" \ |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
601 |
> --config "fix.fail:pattern=hello.txt" \ |
38967
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
602 |
> fix --working-dir |
a009589cd32a
fix: determine fixer tool failure by exit code instead of stderr
Danny Hooper <hooper@google.com>
parents:
38590
diff
changeset
|
603 |
[wdir] fail: exited with status 42 |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
604 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
605 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
606 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
607 |
Fixing the working directory and its parent revision at the same time should |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
608 |
check out the replacement revision for the parent. This prevents any new |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
609 |
uncommitted changes from appearing. We test this for a clean working directory |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
610 |
and a dirty one. In both cases, all lines/files changed since the grandparent |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
611 |
will be fixed. The grandparent is the "baserev" for both the parent and the |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
612 |
working copy. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
613 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
614 |
$ hg init fixdotandcleanwdir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
615 |
$ cd fixdotandcleanwdir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
616 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
617 |
$ printf "hello\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
618 |
$ printf "world\n" > world.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
619 |
$ hg commit -Aqm "the parent commit" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
620 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
621 |
$ hg parents --template '{rev} {desc}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
622 |
0 the parent commit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
623 |
$ hg fix --working-dir -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
624 |
$ hg parents --template '{rev} {desc}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
625 |
1 the parent commit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
626 |
$ hg cat -r . *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
627 |
HELLO |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
628 |
WORLD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
629 |
$ cat *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
630 |
HELLO |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
631 |
WORLD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
632 |
$ hg status |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
633 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
634 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
635 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
636 |
Same test with a dirty working copy. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
637 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
638 |
$ hg init fixdotanddirtywdir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
639 |
$ cd fixdotanddirtywdir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
640 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
641 |
$ printf "hello\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
642 |
$ printf "world\n" > world.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
643 |
$ hg commit -Aqm "the parent commit" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
644 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
645 |
$ printf "hello,\n" > hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
646 |
$ printf "world!\n" > world.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
647 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
648 |
$ hg parents --template '{rev} {desc}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
649 |
0 the parent commit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
650 |
$ hg fix --working-dir -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
651 |
$ hg parents --template '{rev} {desc}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
652 |
1 the parent commit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
653 |
$ hg cat -r . *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
654 |
HELLO |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
655 |
WORLD |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
656 |
$ cat *.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
657 |
HELLO, |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
658 |
WORLD! |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
659 |
$ hg status |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
660 |
M hello.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
661 |
M world.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
662 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
663 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
664 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
665 |
When we have a chain of commits that change mutually exclusive lines of code, |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
666 |
we should be able to do incremental fixing that causes each commit in the chain |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
667 |
to include fixes made to the previous commits. This prevents children from |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
668 |
backing out the fixes made in their parents. A dirty working directory is |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
669 |
conceptually similar to another commit in the chain. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
670 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
671 |
$ hg init incrementallyfixchain |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
672 |
$ cd incrementallyfixchain |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
673 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
674 |
$ cat > file.changed <<EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
675 |
> first |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
676 |
> second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
677 |
> third |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
678 |
> fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
679 |
> fifth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
680 |
> EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
681 |
$ hg commit -Aqm "the common ancestor (the baserev)" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
682 |
$ cat > file.changed <<EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
683 |
> first (changed) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
684 |
> second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
685 |
> third |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
686 |
> fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
687 |
> fifth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
688 |
> EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
689 |
$ hg commit -Aqm "the first commit to fix" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
690 |
$ cat > file.changed <<EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
691 |
> first (changed) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
692 |
> second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
693 |
> third (changed) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
694 |
> fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
695 |
> fifth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
696 |
> EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
697 |
$ hg commit -Aqm "the second commit to fix" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
698 |
$ cat > file.changed <<EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
699 |
> first (changed) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
700 |
> second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
701 |
> third (changed) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
702 |
> fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
703 |
> fifth (changed) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
704 |
> EOF |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
705 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
706 |
$ hg fix -r . -r '.^' --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
707 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
708 |
$ hg parents --template '{rev}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
709 |
4 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
710 |
$ hg cat -r '.^^' file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
711 |
first |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
712 |
second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
713 |
third |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
714 |
fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
715 |
fifth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
716 |
$ hg cat -r '.^' file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
717 |
FIRST (CHANGED) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
718 |
second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
719 |
third |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
720 |
fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
721 |
fifth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
722 |
$ hg cat -r . file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
723 |
FIRST (CHANGED) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
724 |
second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
725 |
THIRD (CHANGED) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
726 |
fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
727 |
fifth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
728 |
$ cat file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
729 |
FIRST (CHANGED) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
730 |
second |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
731 |
THIRD (CHANGED) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
732 |
fourth |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
733 |
FIFTH (CHANGED) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
734 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
735 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
736 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
737 |
If we incrementally fix a merge commit, we should fix any lines that changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
738 |
versus either parent. You could imagine only fixing the intersection or some |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
739 |
other subset, but this is necessary if either parent is being fixed. It |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
740 |
prevents us from forgetting fixes made in either parent. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
741 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
742 |
$ hg init incrementallyfixmergecommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
743 |
$ cd incrementallyfixmergecommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
744 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
745 |
$ printf "a\nb\nc\n" > file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
746 |
$ hg commit -Aqm "ancestor" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
747 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
748 |
$ printf "aa\nb\nc\n" > file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
749 |
$ hg commit -m "change a" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
750 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
751 |
$ hg checkout '.^' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
752 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
753 |
$ printf "a\nb\ncc\n" > file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
754 |
$ hg commit -m "change c" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
755 |
created new head |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
756 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
757 |
$ hg merge |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
758 |
merging file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
759 |
0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
760 |
(branch merge, don't forget to commit) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
761 |
$ hg commit -m "merge" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
762 |
$ hg cat -r . file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
763 |
aa |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
764 |
b |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
765 |
cc |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
766 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
767 |
$ hg fix -r . --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
768 |
$ hg cat -r . file.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
769 |
AA |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
770 |
b |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
771 |
CC |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
772 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
773 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
774 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
775 |
Abort fixing revisions if there is an unfinished operation. We don't want to |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
776 |
make things worse by editing files or stripping/obsoleting things. Also abort |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
777 |
fixing the working directory if there are unresolved merge conflicts. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
778 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
779 |
$ hg init abortunresolved |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
780 |
$ cd abortunresolved |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
781 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
782 |
$ echo "foo1" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
783 |
$ hg commit -Aqm "foo 1" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
784 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
785 |
$ hg update null |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
786 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
787 |
$ echo "foo2" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
788 |
$ hg commit -Aqm "foo 2" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
789 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
790 |
$ hg --config extensions.rebase= rebase -r 1 -d 0 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
791 |
rebasing 1:c3b6dc0e177a "foo 2" (tip) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
792 |
merging foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
793 |
warning: conflicts while merging foo.whole! (edit, then use 'hg resolve --mark') |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
794 |
unresolved conflicts (see hg resolve, then hg rebase --continue) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
795 |
[1] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
796 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
797 |
$ hg --config extensions.rebase= fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
798 |
abort: unresolved conflicts |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
799 |
(use 'hg resolve') |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
800 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
801 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
802 |
$ hg --config extensions.rebase= fix -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
803 |
abort: rebase in progress |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
804 |
(use 'hg rebase --continue' or 'hg rebase --abort') |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
805 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
806 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
807 |
When fixing a file that was renamed, we should diff against the source of the |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
808 |
rename for incremental fixing and we should correctly reproduce the rename in |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
809 |
the replacement revision. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
810 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
811 |
$ hg init fixrenamecommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
812 |
$ cd fixrenamecommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
813 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
814 |
$ printf "a\nb\nc\n" > source.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
815 |
$ hg commit -Aqm "source revision" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
816 |
$ hg move source.changed dest.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
817 |
$ printf "a\nb\ncc\n" > dest.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
818 |
$ hg commit -m "dest revision" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
819 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
820 |
$ hg fix -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
821 |
$ hg log -r tip --copies --template "{file_copies}\n" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
822 |
dest.changed (source.changed) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
823 |
$ hg cat -r tip dest.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
824 |
a |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
825 |
b |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
826 |
CC |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
827 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
828 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
829 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
830 |
When fixing revisions that remove files we must ensure that the replacement |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
831 |
actually removes the file, whereas it could accidentally leave it unchanged or |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
832 |
write an empty string to it. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
833 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
834 |
$ hg init fixremovedfile |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
835 |
$ cd fixremovedfile |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
836 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
837 |
$ printf "foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
838 |
$ printf "bar\n" > bar.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
839 |
$ hg commit -Aqm "add files" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
840 |
$ hg remove bar.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
841 |
$ hg commit -m "remove file" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
842 |
$ hg status --change . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
843 |
R bar.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
844 |
$ hg fix -r . foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
845 |
$ hg status --change tip |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
846 |
M foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
847 |
R bar.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
848 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
849 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
850 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
851 |
If fixing a revision finds no fixes to make, no replacement revision should be |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
852 |
created. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
853 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
854 |
$ hg init nofixesneeded |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
855 |
$ cd nofixesneeded |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
856 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
857 |
$ printf "FOO\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
858 |
$ hg commit -Aqm "add file" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
859 |
$ hg log --template '{rev}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
860 |
0 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
861 |
$ hg fix -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
862 |
$ hg log --template '{rev}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
863 |
0 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
864 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
865 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
866 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
867 |
If fixing a commit reverts all the changes in the commit, we replace it with a |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
868 |
commit that changes no files. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
869 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
870 |
$ hg init nochangesleft |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
871 |
$ cd nochangesleft |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
872 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
873 |
$ printf "FOO\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
874 |
$ hg commit -Aqm "add file" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
875 |
$ printf "foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
876 |
$ hg commit -m "edit file" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
877 |
$ hg status --change . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
878 |
M foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
879 |
$ hg fix -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
880 |
$ hg status --change tip |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
881 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
882 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
883 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
884 |
If we fix a parent and child revision together, the child revision must be |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
885 |
replaced if the parent is replaced, even if the diffs of the child needed no |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
886 |
fixes. However, we're free to not replace revisions that need no fixes and have |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
887 |
no ancestors that are replaced. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
888 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
889 |
$ hg init mustreplacechild |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
890 |
$ cd mustreplacechild |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
891 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
892 |
$ printf "FOO\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
893 |
$ hg commit -Aqm "add foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
894 |
$ printf "foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
895 |
$ hg commit -m "edit foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
896 |
$ printf "BAR\n" > bar.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
897 |
$ hg commit -Aqm "add bar" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
898 |
|
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
899 |
$ hg log --graph --template '{rev} {files}' |
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
900 |
@ 2 bar.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
901 |
| |
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
902 |
o 1 foo.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
903 |
| |
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
904 |
o 0 foo.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
905 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
906 |
$ hg fix -r 0:2 |
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
907 |
$ hg log --graph --template '{rev} {files}' |
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
908 |
o 4 bar.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
909 |
| |
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
910 |
o 3 |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
911 |
| |
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
912 |
| @ 2 bar.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
913 |
| | |
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
914 |
| x 1 foo.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
915 |
|/ |
40569
19e1c26213f1
cleanup: use revision numbers instead of hashes in test output
Danny Hooper <hooper@google.com>
parents:
40566
diff
changeset
|
916 |
o 0 foo.whole |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
917 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
918 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
919 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
920 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
921 |
It's also possible that the child needs absolutely no changes, but we still |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
922 |
need to replace it to update its parent. If we skipped replacing the child |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
923 |
because it had no file content changes, it would become an orphan for no good |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
924 |
reason. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
925 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
926 |
$ hg init mustreplacechildevenifnop |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
927 |
$ cd mustreplacechildevenifnop |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
928 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
929 |
$ printf "Foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
930 |
$ hg commit -Aqm "add a bad foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
931 |
$ printf "FOO\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
932 |
$ hg commit -m "add a good foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
933 |
$ hg fix -r . -r '.^' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
934 |
$ hg log --graph --template '{rev} {desc}' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
935 |
o 3 add a good foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
936 |
| |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
937 |
o 2 add a bad foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
938 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
939 |
@ 1 add a good foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
940 |
| |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
941 |
x 0 add a bad foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
942 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
943 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
944 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
945 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
946 |
Similar to the case above, the child revision may become empty as a result of |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
947 |
fixing its parent. We should still create an empty replacement child. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
948 |
TODO: determine how this should interact with ui.allowemptycommit given that |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
949 |
the empty replacement could have children. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
950 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
951 |
$ hg init mustreplacechildevenifempty |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
952 |
$ cd mustreplacechildevenifempty |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
953 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
954 |
$ printf "foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
955 |
$ hg commit -Aqm "add foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
956 |
$ printf "Foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
957 |
$ hg commit -m "edit foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
958 |
$ hg fix -r . -r '.^' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
959 |
$ hg log --graph --template '{rev} {desc}\n' --stat |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
960 |
o 3 edit foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
961 |
| |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
962 |
o 2 add foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
963 |
foo.whole | 1 + |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
964 |
1 files changed, 1 insertions(+), 0 deletions(-) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
965 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
966 |
@ 1 edit foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
967 |
| foo.whole | 2 +- |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
968 |
| 1 files changed, 1 insertions(+), 1 deletions(-) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
969 |
| |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
970 |
x 0 add foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
971 |
foo.whole | 1 + |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
972 |
1 files changed, 1 insertions(+), 0 deletions(-) |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
973 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
974 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
975 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
976 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
977 |
Fixing a secret commit should replace it with another secret commit. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
978 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
979 |
$ hg init fixsecretcommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
980 |
$ cd fixsecretcommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
981 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
982 |
$ printf "foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
983 |
$ hg commit -Aqm "add foo" --secret |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
984 |
$ hg fix -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
985 |
$ hg log --template '{rev} {phase}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
986 |
1 secret |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
987 |
0 secret |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
988 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
989 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
990 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
991 |
We should also preserve phase when fixing a draft commit while the user has |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
992 |
their default set to secret. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
993 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
994 |
$ hg init respectphasesnewcommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
995 |
$ cd respectphasesnewcommit |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
996 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
997 |
$ printf "foo\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
998 |
$ hg commit -Aqm "add foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
999 |
$ hg --config phases.newcommit=secret fix -r . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1000 |
$ hg log --template '{rev} {phase}\n' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1001 |
1 draft |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1002 |
0 draft |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1003 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1004 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1005 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1006 |
Debug output should show what fixer commands are being subprocessed, which is |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1007 |
useful for anyone trying to set up a new config. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1008 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1009 |
$ hg init debugoutput |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1010 |
$ cd debugoutput |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1011 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1012 |
$ printf "foo\nbar\nbaz\n" > foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1013 |
$ hg commit -Aqm "foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1014 |
$ printf "Foo\nbar\nBaz\n" > foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1015 |
$ hg --debug fix --working-dir |
37560
41ba336d9f1e
fix: use a portable python script instead of sed in test
Danny Hooper <hooper@google.com>
parents:
37183
diff
changeset
|
1016 |
subprocess: * $TESTTMP/uppercase.py 1-1 3-3 (glob) |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1017 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1018 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1019 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1020 |
Fixing an obsolete revision can cause divergence, so we abort unless the user |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1021 |
configures to allow it. This is not yet smart enough to know whether there is a |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1022 |
successor, but even then it is not likely intentional or idiomatic to fix an |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1023 |
obsolete revision. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1024 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1025 |
$ hg init abortobsoleterev |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1026 |
$ cd abortobsoleterev |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1027 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1028 |
$ printf "foo\n" > foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1029 |
$ hg commit -Aqm "foo" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1030 |
$ hg debugobsolete `hg parents --template '{node}'` |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1031 |
obsoleted 1 changesets |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1032 |
$ hg --hidden fix -r 0 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1033 |
abort: fixing obsolete revision could cause divergence |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1034 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1035 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1036 |
$ hg --hidden fix -r 0 --config experimental.evolution.allowdivergence=true |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1037 |
$ hg cat -r tip foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1038 |
FOO |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1039 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1040 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1041 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1042 |
Test all of the available substitution values for fixer commands. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1043 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1044 |
$ hg init substitution |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1045 |
$ cd substitution |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1046 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1047 |
$ mkdir foo |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1048 |
$ printf "hello\ngoodbye\n" > foo/bar |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1049 |
$ hg add |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1050 |
adding foo/bar |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1051 |
$ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \ |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1052 |
> --config "fix.fail:linerange='{first}' '{last}'" \ |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1053 |
> --config "fix.fail:pattern=foo/bar" \ |
37183
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1054 |
> fix --working-dir |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1055 |
$ cat foo/bar |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1056 |
foo/bar |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1057 |
bar |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1058 |
1 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1059 |
2 |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1060 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1061 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1062 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1063 |
The --base flag should allow picking the revisions to diff against for changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1064 |
files and incremental line formatting. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1065 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1066 |
$ hg init baseflag |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1067 |
$ cd baseflag |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1068 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1069 |
$ printf "one\ntwo\n" > foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1070 |
$ printf "bar\n" > bar.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1071 |
$ hg commit -Aqm "first" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1072 |
$ printf "one\nTwo\n" > foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1073 |
$ hg commit -m "second" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1074 |
$ hg fix -w --base . |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1075 |
$ hg status |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1076 |
$ hg fix -w --base null |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1077 |
$ cat foo.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1078 |
ONE |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1079 |
TWO |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1080 |
$ cat bar.changed |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1081 |
BAR |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1082 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1083 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1084 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1085 |
If the user asks to fix the parent of another commit, they are asking to create |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1086 |
an orphan. We must respect experimental.evolution.allowunstable. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1087 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1088 |
$ hg init allowunstable |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1089 |
$ cd allowunstable |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1090 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1091 |
$ printf "one\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1092 |
$ hg commit -Aqm "first" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1093 |
$ printf "two\n" > foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1094 |
$ hg commit -m "second" |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1095 |
$ hg --config experimental.evolution.allowunstable=False fix -r '.^' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1096 |
abort: can only fix a changeset together with all its descendants |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1097 |
[255] |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1098 |
$ hg fix -r '.^' |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1099 |
1 new orphan changesets |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1100 |
$ hg cat -r 2 foo.whole |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1101 |
ONE |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1102 |
|
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1103 |
$ cd .. |
ded5ea279a93
fix: new extension for automatically modifying file contents
Danny Hooper <hooper@google.com>
parents:
diff
changeset
|
1104 |
|
38590
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1105 |
The --base flag affects the set of files being fixed. So while the --whole flag |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1106 |
makes the base irrelevant for changed line ranges, it still changes the |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1107 |
meaning and effect of the command. In this example, no files or lines are fixed |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1108 |
until we specify the base, but then we do fix unchanged lines. |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1109 |
|
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1110 |
$ hg init basewhole |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1111 |
$ cd basewhole |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1112 |
$ printf "foo1\n" > foo.changed |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1113 |
$ hg commit -Aqm "first" |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1114 |
$ printf "foo2\n" >> foo.changed |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1115 |
$ printf "bar\n" > bar.changed |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1116 |
$ hg commit -Aqm "second" |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1117 |
|
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1118 |
$ hg fix --working-dir --whole |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1119 |
$ cat *.changed |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1120 |
bar |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1121 |
foo1 |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1122 |
foo2 |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1123 |
|
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1124 |
$ hg fix --working-dir --base 0 --whole |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1125 |
$ cat *.changed |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1126 |
BAR |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1127 |
FOO1 |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1128 |
FOO2 |
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1129 |
|
f068495a1c28
fix: add test case that shows why --whole with --base is useful
Danny Hooper <hooper@google.com>
parents:
37809
diff
changeset
|
1130 |
$ cd .. |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1131 |
|
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1132 |
The :fileset subconfig was a misnomer, so we renamed it to :pattern. We will |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1133 |
still accept :fileset by itself as if it were :pattern, but this will issue a |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1134 |
warning. |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1135 |
|
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1136 |
$ hg init filesetispattern |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1137 |
$ cd filesetispattern |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1138 |
|
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1139 |
$ printf "foo\n" > foo.whole |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1140 |
$ printf "first\nsecond\n" > bar.txt |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1141 |
$ hg add -q |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1142 |
$ hg fix -w --config fix.sometool:fileset=bar.txt \ |
40564
0df4d93fdc27
tests: replace `tac` reimplementation by `sort -r`
Martin von Zweigbergk <martinvonz@google.com>
parents:
40563
diff
changeset
|
1143 |
> --config fix.sometool:command="sort -r" |
40533
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1144 |
the fix.tool:fileset config name is deprecated; please rename it to fix.tool:pattern |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1145 |
|
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1146 |
$ cat foo.whole |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1147 |
FOO |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1148 |
$ cat bar.txt |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1149 |
second |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1150 |
first |
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1151 |
|
2ecf5c24d0cd
fix: rename :fileset subconfig to :pattern
Danny Hooper <hooper@google.com>
parents:
40532
diff
changeset
|
1152 |
$ cd .. |
40566
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1153 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1154 |
The execution order of tools can be controlled. This example doesn't work if |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1155 |
you sort after truncating, but the config defines the correct order while the |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1156 |
definitions are out of order (which might imply the incorrect order given the |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1157 |
implementation of fix). The goal is to use multiple tools to select the lowest |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1158 |
5 numbers in the file. |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1159 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1160 |
$ hg init priorityexample |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1161 |
$ cd priorityexample |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1162 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1163 |
$ cat >> .hg/hgrc <<EOF |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1164 |
> [fix] |
41126
d8f5c615e811
tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents:
41010
diff
changeset
|
1165 |
> head:command = head -n 5 |
40566
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1166 |
> head:pattern = numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1167 |
> head:priority = 1 |
41126
d8f5c615e811
tests: use more portable flags in test-fix.t
Danny Hooper <hooper@google.com>
parents:
41010
diff
changeset
|
1168 |
> sort:command = sort -n |
40566
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1169 |
> sort:pattern = numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1170 |
> sort:priority = 2 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1171 |
> EOF |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1172 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1173 |
$ printf "8\n2\n3\n6\n7\n4\n9\n5\n1\n0\n" > numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1174 |
$ hg add -q |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1175 |
$ hg fix -w |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1176 |
$ cat numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1177 |
0 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1178 |
1 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1179 |
2 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1180 |
3 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1181 |
4 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1182 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1183 |
And of course we should be able to break this by reversing the execution order. |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1184 |
Test negative priorities while we're at it. |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1185 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1186 |
$ cat >> .hg/hgrc <<EOF |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1187 |
> [fix] |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1188 |
> head:priority = -1 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1189 |
> sort:priority = -2 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1190 |
> EOF |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1191 |
$ printf "8\n2\n3\n6\n7\n4\n9\n5\n1\n0\n" > numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1192 |
$ hg fix -w |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1193 |
$ cat numbers.txt |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1194 |
2 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1195 |
3 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1196 |
6 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1197 |
7 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1198 |
8 |
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1199 |
|
b9557567cc3f
fix: add suboption for configuring execution order of tools
Danny Hooper <hooper@google.com>
parents:
40564
diff
changeset
|
1200 |
$ cd .. |
40570
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1201 |
|
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1202 |
It's possible for repeated applications of a fixer tool to create cycles in the |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1203 |
generated content of a file. For example, two users with different versions of |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1204 |
a code formatter might fight over the formatting when they run hg fix. In the |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1205 |
absence of other changes, this means we could produce commits with the same |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1206 |
hash in subsequent runs of hg fix. This is a problem unless we support |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1207 |
obsolescence cycles well. We avoid this by adding an extra field to the |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1208 |
successor which forces it to have a new hash. That's why this test creates |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1209 |
three revisions instead of two. |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1210 |
|
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1211 |
$ hg init cyclictool |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1212 |
$ cd cyclictool |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1213 |
|
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1214 |
$ cat >> .hg/hgrc <<EOF |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1215 |
> [fix] |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1216 |
> swapletters:command = tr ab ba |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1217 |
> swapletters:pattern = foo |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1218 |
> EOF |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1219 |
|
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1220 |
$ echo ab > foo |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1221 |
$ hg commit -Aqm foo |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1222 |
|
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1223 |
$ hg fix -r 0 |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1224 |
$ hg fix -r 1 |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1225 |
|
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1226 |
$ hg cat -r 0 foo --hidden |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1227 |
ab |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1228 |
$ hg cat -r 1 foo --hidden |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1229 |
ba |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1230 |
$ hg cat -r 2 foo |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1231 |
ab |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1232 |
|
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1233 |
$ cd .. |
ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
Danny Hooper <hooper@google.com>
parents:
40569
diff
changeset
|
1234 |