##// END OF EJS Templates
tests: stabilize test-fix.t for Windows
Matt Harbison -
r37809:72ccb071 stable
parent child Browse files
Show More
@@ -1,1025 +1,1028 b''
1 A script that implements uppercasing of specific lines in a file. This
1 A script that implements uppercasing of specific lines in a file. This
2 approximates the behavior of code formatters well enough for our tests.
2 approximates the behavior of code formatters well enough for our tests.
3
3
4 $ UPPERCASEPY="$TESTTMP/uppercase.py"
4 $ UPPERCASEPY="$TESTTMP/uppercase.py"
5 $ cat > $UPPERCASEPY <<EOF
5 $ cat > $UPPERCASEPY <<EOF
6 > import sys
6 > import sys
7 > from mercurial.utils.procutil import setbinary
7 > from mercurial.utils.procutil import setbinary
8 > setbinary(sys.stdin)
8 > setbinary(sys.stdin)
9 > setbinary(sys.stdout)
9 > setbinary(sys.stdout)
10 > lines = set()
10 > lines = set()
11 > for arg in sys.argv[1:]:
11 > for arg in sys.argv[1:]:
12 > if arg == 'all':
12 > if arg == 'all':
13 > sys.stdout.write(sys.stdin.read().upper())
13 > sys.stdout.write(sys.stdin.read().upper())
14 > sys.exit(0)
14 > sys.exit(0)
15 > else:
15 > else:
16 > first, last = arg.split('-')
16 > first, last = arg.split('-')
17 > lines.update(range(int(first), int(last) + 1))
17 > lines.update(range(int(first), int(last) + 1))
18 > for i, line in enumerate(sys.stdin.readlines()):
18 > for i, line in enumerate(sys.stdin.readlines()):
19 > if i + 1 in lines:
19 > if i + 1 in lines:
20 > sys.stdout.write(line.upper())
20 > sys.stdout.write(line.upper())
21 > else:
21 > else:
22 > sys.stdout.write(line)
22 > sys.stdout.write(line)
23 > EOF
23 > EOF
24 $ TESTLINES="foo\nbar\nbaz\nqux\n"
24 $ TESTLINES="foo\nbar\nbaz\nqux\n"
25 $ printf $TESTLINES | $PYTHON $UPPERCASEPY
25 $ printf $TESTLINES | $PYTHON $UPPERCASEPY
26 foo
26 foo
27 bar
27 bar
28 baz
28 baz
29 qux
29 qux
30 $ printf $TESTLINES | $PYTHON $UPPERCASEPY all
30 $ printf $TESTLINES | $PYTHON $UPPERCASEPY all
31 FOO
31 FOO
32 BAR
32 BAR
33 BAZ
33 BAZ
34 QUX
34 QUX
35 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 1-1
35 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 1-1
36 FOO
36 FOO
37 bar
37 bar
38 baz
38 baz
39 qux
39 qux
40 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 1-2
40 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 1-2
41 FOO
41 FOO
42 BAR
42 BAR
43 baz
43 baz
44 qux
44 qux
45 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 2-3
45 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 2-3
46 foo
46 foo
47 BAR
47 BAR
48 BAZ
48 BAZ
49 qux
49 qux
50 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 2-2 4-4
50 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 2-2 4-4
51 foo
51 foo
52 BAR
52 BAR
53 baz
53 baz
54 QUX
54 QUX
55
55
56 Set up the config with two simple fixers: one that fixes specific line ranges,
56 Set up the config with two simple fixers: one that fixes specific line ranges,
57 and one that always fixes the whole file. They both "fix" files by converting
57 and one that always fixes the whole file. They both "fix" files by converting
58 letters to uppercase. They use different file extensions, so each test case can
58 letters to uppercase. They use different file extensions, so each test case can
59 choose which behavior to use by naming files.
59 choose which behavior to use by naming files.
60
60
61 $ cat >> $HGRCPATH <<EOF
61 $ cat >> $HGRCPATH <<EOF
62 > [extensions]
62 > [extensions]
63 > fix =
63 > fix =
64 > [experimental]
64 > [experimental]
65 > evolution.createmarkers=True
65 > evolution.createmarkers=True
66 > evolution.allowunstable=True
66 > evolution.allowunstable=True
67 > [fix]
67 > [fix]
68 > uppercase-whole-file:command=$PYTHON $UPPERCASEPY all
68 > uppercase-whole-file:command=$PYTHON $UPPERCASEPY all
69 > uppercase-whole-file:fileset=set:**.whole
69 > uppercase-whole-file:fileset=set:**.whole
70 > uppercase-changed-lines:command=$PYTHON $UPPERCASEPY
70 > uppercase-changed-lines:command=$PYTHON $UPPERCASEPY
71 > uppercase-changed-lines:linerange={first}-{last}
71 > uppercase-changed-lines:linerange={first}-{last}
72 > uppercase-changed-lines:fileset=set:**.changed
72 > uppercase-changed-lines:fileset=set:**.changed
73 > EOF
73 > EOF
74
74
75 Help text for fix.
75 Help text for fix.
76
76
77 $ hg help fix
77 $ hg help fix
78 hg fix [OPTION]... [FILE]...
78 hg fix [OPTION]... [FILE]...
79
79
80 rewrite file content in changesets or working directory
80 rewrite file content in changesets or working directory
81
81
82 Runs any configured tools to fix the content of files. Only affects files
82 Runs any configured tools to fix the content of files. Only affects files
83 with changes, unless file arguments are provided. Only affects changed
83 with changes, unless file arguments are provided. Only affects changed
84 lines of files, unless the --whole flag is used. Some tools may always
84 lines of files, unless the --whole flag is used. Some tools may always
85 affect the whole file regardless of --whole.
85 affect the whole file regardless of --whole.
86
86
87 If revisions are specified with --rev, those revisions will be checked,
87 If revisions are specified with --rev, those revisions will be checked,
88 and they may be replaced with new revisions that have fixed file content.
88 and they may be replaced with new revisions that have fixed file content.
89 It is desirable to specify all descendants of each specified revision, so
89 It is desirable to specify all descendants of each specified revision, so
90 that the fixes propagate to the descendants. If all descendants are fixed
90 that the fixes propagate to the descendants. If all descendants are fixed
91 at the same time, no merging, rebasing, or evolution will be required.
91 at the same time, no merging, rebasing, or evolution will be required.
92
92
93 If --working-dir is used, files with uncommitted changes in the working
93 If --working-dir is used, files with uncommitted changes in the working
94 copy will be fixed. If the checked-out revision is also fixed, the working
94 copy will be fixed. If the checked-out revision is also fixed, the working
95 directory will update to the replacement revision.
95 directory will update to the replacement revision.
96
96
97 When determining what lines of each file to fix at each revision, the
97 When determining what lines of each file to fix at each revision, the
98 whole set of revisions being fixed is considered, so that fixes to earlier
98 whole set of revisions being fixed is considered, so that fixes to earlier
99 revisions are not forgotten in later ones. The --base flag can be used to
99 revisions are not forgotten in later ones. The --base flag can be used to
100 override this default behavior, though it is not usually desirable to do
100 override this default behavior, though it is not usually desirable to do
101 so.
101 so.
102
102
103 (use 'hg help -e fix' to show help for the fix extension)
103 (use 'hg help -e fix' to show help for the fix extension)
104
104
105 options ([+] can be repeated):
105 options ([+] can be repeated):
106
106
107 --all fix all non-public non-obsolete revisions
107 --all fix all non-public non-obsolete revisions
108 --base REV [+] revisions to diff against (overrides automatic selection,
108 --base REV [+] revisions to diff against (overrides automatic selection,
109 and applies to every revision being fixed)
109 and applies to every revision being fixed)
110 -r --rev REV [+] revisions to fix
110 -r --rev REV [+] revisions to fix
111 -w --working-dir fix the working directory
111 -w --working-dir fix the working directory
112 --whole always fix every line of a file
112 --whole always fix every line of a file
113
113
114 (some details hidden, use --verbose to show complete help)
114 (some details hidden, use --verbose to show complete help)
115
115
116 $ hg help -e fix
116 $ hg help -e fix
117 fix extension - rewrite file content in changesets or working copy
117 fix extension - rewrite file content in changesets or working copy
118 (EXPERIMENTAL)
118 (EXPERIMENTAL)
119
119
120 Provides a command that runs configured tools on the contents of modified
120 Provides a command that runs configured tools on the contents of modified
121 files, writing back any fixes to the working copy or replacing changesets.
121 files, writing back any fixes to the working copy or replacing changesets.
122
122
123 Here is an example configuration that causes 'hg fix' to apply automatic
123 Here is an example configuration that causes 'hg fix' to apply automatic
124 formatting fixes to modified lines in C++ code:
124 formatting fixes to modified lines in C++ code:
125
125
126 [fix]
126 [fix]
127 clang-format:command=clang-format --assume-filename={rootpath}
127 clang-format:command=clang-format --assume-filename={rootpath}
128 clang-format:linerange=--lines={first}:{last}
128 clang-format:linerange=--lines={first}:{last}
129 clang-format:fileset=set:**.cpp or **.hpp
129 clang-format:fileset=set:**.cpp or **.hpp
130
130
131 The :command suboption forms the first part of the shell command that will be
131 The :command suboption forms the first part of the shell command that will be
132 used to fix a file. The content of the file is passed on standard input, and
132 used to fix a file. The content of the file is passed on standard input, and
133 the fixed file content is expected on standard output. If there is any output
133 the fixed file content is expected on standard output. If there is any output
134 on standard error, the file will not be affected. Some values may be
134 on standard error, the file will not be affected. Some values may be
135 substituted into the command:
135 substituted into the command:
136
136
137 {rootpath} The path of the file being fixed, relative to the repo root
137 {rootpath} The path of the file being fixed, relative to the repo root
138 {basename} The name of the file being fixed, without the directory path
138 {basename} The name of the file being fixed, without the directory path
139
139
140 If the :linerange suboption is set, the tool will only be run if there are
140 If the :linerange suboption is set, the tool will only be run if there are
141 changed lines in a file. The value of this suboption is appended to the shell
141 changed lines in a file. The value of this suboption is appended to the shell
142 command once for every range of changed lines in the file. Some values may be
142 command once for every range of changed lines in the file. Some values may be
143 substituted into the command:
143 substituted into the command:
144
144
145 {first} The 1-based line number of the first line in the modified range
145 {first} The 1-based line number of the first line in the modified range
146 {last} The 1-based line number of the last line in the modified range
146 {last} The 1-based line number of the last line in the modified range
147
147
148 The :fileset suboption determines which files will be passed through each
148 The :fileset suboption determines which files will be passed through each
149 configured tool. See 'hg help fileset' for possible values. If there are file
149 configured tool. See 'hg help fileset' for possible values. If there are file
150 arguments to 'hg fix', the intersection of these filesets is used.
150 arguments to 'hg fix', the intersection of these filesets is used.
151
151
152 There is also a configurable limit for the maximum size of file that will be
152 There is also a configurable limit for the maximum size of file that will be
153 processed by 'hg fix':
153 processed by 'hg fix':
154
154
155 [fix]
155 [fix]
156 maxfilesize=2MB
156 maxfilesize=2MB
157
157
158 list of commands:
158 list of commands:
159
159
160 fix rewrite file content in changesets or working directory
160 fix rewrite file content in changesets or working directory
161
161
162 (use 'hg help -v -e fix' to show built-in aliases and global options)
162 (use 'hg help -v -e fix' to show built-in aliases and global options)
163
163
164 There is no default behavior in the absence of --rev and --working-dir.
164 There is no default behavior in the absence of --rev and --working-dir.
165
165
166 $ hg init badusage
166 $ hg init badusage
167 $ cd badusage
167 $ cd badusage
168
168
169 $ hg fix
169 $ hg fix
170 abort: no changesets specified
170 abort: no changesets specified
171 (use --rev or --working-dir)
171 (use --rev or --working-dir)
172 [255]
172 [255]
173 $ hg fix --whole
173 $ hg fix --whole
174 abort: no changesets specified
174 abort: no changesets specified
175 (use --rev or --working-dir)
175 (use --rev or --working-dir)
176 [255]
176 [255]
177 $ hg fix --base 0
177 $ hg fix --base 0
178 abort: no changesets specified
178 abort: no changesets specified
179 (use --rev or --working-dir)
179 (use --rev or --working-dir)
180 [255]
180 [255]
181
181
182 Fixing a public revision isn't allowed. It should abort early enough that
182 Fixing a public revision isn't allowed. It should abort early enough that
183 nothing happens, even to the working directory.
183 nothing happens, even to the working directory.
184
184
185 $ printf "hello\n" > hello.whole
185 $ printf "hello\n" > hello.whole
186 $ hg commit -Aqm "hello"
186 $ hg commit -Aqm "hello"
187 $ hg phase -r 0 --public
187 $ hg phase -r 0 --public
188 $ hg fix -r 0
188 $ hg fix -r 0
189 abort: can't fix immutable changeset 0:6470986d2e7b
189 abort: can't fix immutable changeset 0:6470986d2e7b
190 [255]
190 [255]
191 $ hg fix -r 0 --working-dir
191 $ hg fix -r 0 --working-dir
192 abort: can't fix immutable changeset 0:6470986d2e7b
192 abort: can't fix immutable changeset 0:6470986d2e7b
193 [255]
193 [255]
194 $ hg cat -r tip hello.whole
194 $ hg cat -r tip hello.whole
195 hello
195 hello
196 $ cat hello.whole
196 $ cat hello.whole
197 hello
197 hello
198
198
199 $ cd ..
199 $ cd ..
200
200
201 Fixing a clean working directory should do nothing. Even the --whole flag
201 Fixing a clean working directory should do nothing. Even the --whole flag
202 shouldn't cause any clean files to be fixed. Specifying a clean file explicitly
202 shouldn't cause any clean files to be fixed. Specifying a clean file explicitly
203 should only fix it if the fixer always fixes the whole file. The combination of
203 should only fix it if the fixer always fixes the whole file. The combination of
204 an explicit filename and --whole should format the entire file regardless.
204 an explicit filename and --whole should format the entire file regardless.
205
205
206 $ hg init fixcleanwdir
206 $ hg init fixcleanwdir
207 $ cd fixcleanwdir
207 $ cd fixcleanwdir
208
208
209 $ printf "hello\n" > hello.changed
209 $ printf "hello\n" > hello.changed
210 $ printf "world\n" > hello.whole
210 $ printf "world\n" > hello.whole
211 $ hg commit -Aqm "foo"
211 $ hg commit -Aqm "foo"
212 $ hg fix --working-dir
212 $ hg fix --working-dir
213 $ hg diff
213 $ hg diff
214 $ hg fix --working-dir --whole
214 $ hg fix --working-dir --whole
215 $ hg diff
215 $ hg diff
216 $ hg fix --working-dir *
216 $ hg fix --working-dir *
217 $ cat *
217 $ cat *
218 hello
218 hello
219 WORLD
219 WORLD
220 $ hg revert --all --no-backup
220 $ hg revert --all --no-backup
221 reverting hello.whole
221 reverting hello.whole
222 $ hg fix --working-dir * --whole
222 $ hg fix --working-dir * --whole
223 $ cat *
223 $ cat *
224 HELLO
224 HELLO
225 WORLD
225 WORLD
226
226
227 The same ideas apply to fixing a revision, so we create a revision that doesn't
227 The same ideas apply to fixing a revision, so we create a revision that doesn't
228 modify either of the files in question and try fixing it. This also tests that
228 modify either of the files in question and try fixing it. This also tests that
229 we ignore a file that doesn't match any configured fixer.
229 we ignore a file that doesn't match any configured fixer.
230
230
231 $ hg revert --all --no-backup
231 $ hg revert --all --no-backup
232 reverting hello.changed
232 reverting hello.changed
233 reverting hello.whole
233 reverting hello.whole
234 $ printf "unimportant\n" > some.file
234 $ printf "unimportant\n" > some.file
235 $ hg commit -Aqm "some other file"
235 $ hg commit -Aqm "some other file"
236
236
237 $ hg fix -r .
237 $ hg fix -r .
238 $ hg cat -r tip *
238 $ hg cat -r tip *
239 hello
239 hello
240 world
240 world
241 unimportant
241 unimportant
242 $ hg fix -r . --whole
242 $ hg fix -r . --whole
243 $ hg cat -r tip *
243 $ hg cat -r tip *
244 hello
244 hello
245 world
245 world
246 unimportant
246 unimportant
247 $ hg fix -r . *
247 $ hg fix -r . *
248 $ hg cat -r tip *
248 $ hg cat -r tip *
249 hello
249 hello
250 WORLD
250 WORLD
251 unimportant
251 unimportant
252 $ hg fix -r . * --whole --config experimental.evolution.allowdivergence=true
252 $ hg fix -r . * --whole --config experimental.evolution.allowdivergence=true
253 2 new content-divergent changesets
253 2 new content-divergent changesets
254 $ hg cat -r tip *
254 $ hg cat -r tip *
255 HELLO
255 HELLO
256 WORLD
256 WORLD
257 unimportant
257 unimportant
258
258
259 $ cd ..
259 $ cd ..
260
260
261 Fixing the working directory should still work if there are no revisions.
261 Fixing the working directory should still work if there are no revisions.
262
262
263 $ hg init norevisions
263 $ hg init norevisions
264 $ cd norevisions
264 $ cd norevisions
265
265
266 $ printf "something\n" > something.whole
266 $ printf "something\n" > something.whole
267 $ hg add
267 $ hg add
268 adding something.whole
268 adding something.whole
269 $ hg fix --working-dir
269 $ hg fix --working-dir
270 $ cat something.whole
270 $ cat something.whole
271 SOMETHING
271 SOMETHING
272
272
273 $ cd ..
273 $ cd ..
274
274
275 Test the effect of fixing the working directory for each possible status, with
275 Test the effect of fixing the working directory for each possible status, with
276 and without providing explicit file arguments.
276 and without providing explicit file arguments.
277
277
278 $ hg init implicitlyfixstatus
278 $ hg init implicitlyfixstatus
279 $ cd implicitlyfixstatus
279 $ cd implicitlyfixstatus
280
280
281 $ printf "modified\n" > modified.whole
281 $ printf "modified\n" > modified.whole
282 $ printf "removed\n" > removed.whole
282 $ printf "removed\n" > removed.whole
283 $ printf "deleted\n" > deleted.whole
283 $ printf "deleted\n" > deleted.whole
284 $ printf "clean\n" > clean.whole
284 $ printf "clean\n" > clean.whole
285 $ printf "ignored.whole" > .hgignore
285 $ printf "ignored.whole" > .hgignore
286 $ hg commit -Aqm "stuff"
286 $ hg commit -Aqm "stuff"
287
287
288 $ printf "modified!!!\n" > modified.whole
288 $ printf "modified!!!\n" > modified.whole
289 $ printf "unknown\n" > unknown.whole
289 $ printf "unknown\n" > unknown.whole
290 $ printf "ignored\n" > ignored.whole
290 $ printf "ignored\n" > ignored.whole
291 $ printf "added\n" > added.whole
291 $ printf "added\n" > added.whole
292 $ hg add added.whole
292 $ hg add added.whole
293 $ hg remove removed.whole
293 $ hg remove removed.whole
294 $ rm deleted.whole
294 $ rm deleted.whole
295
295
296 $ hg status --all
296 $ hg status --all
297 M modified.whole
297 M modified.whole
298 A added.whole
298 A added.whole
299 R removed.whole
299 R removed.whole
300 ! deleted.whole
300 ! deleted.whole
301 ? unknown.whole
301 ? unknown.whole
302 I ignored.whole
302 I ignored.whole
303 C .hgignore
303 C .hgignore
304 C clean.whole
304 C clean.whole
305
305
306 $ hg fix --working-dir
306 $ hg fix --working-dir
307
307
308 $ hg status --all
308 $ hg status --all
309 M modified.whole
309 M modified.whole
310 A added.whole
310 A added.whole
311 R removed.whole
311 R removed.whole
312 ! deleted.whole
312 ! deleted.whole
313 ? unknown.whole
313 ? unknown.whole
314 I ignored.whole
314 I ignored.whole
315 C .hgignore
315 C .hgignore
316 C clean.whole
316 C clean.whole
317
317
318 $ cat *.whole
318 $ cat *.whole
319 ADDED
319 ADDED
320 clean
320 clean
321 ignored
321 ignored
322 MODIFIED!!!
322 MODIFIED!!!
323 unknown
323 unknown
324
324
325 $ printf "modified!!!\n" > modified.whole
325 $ printf "modified!!!\n" > modified.whole
326 $ printf "added\n" > added.whole
326 $ printf "added\n" > added.whole
327 $ hg fix --working-dir *.whole
327 $ hg fix --working-dir *.whole
328
328
329 $ hg status --all
329 $ hg status --all
330 M clean.whole
330 M clean.whole
331 M modified.whole
331 M modified.whole
332 A added.whole
332 A added.whole
333 R removed.whole
333 R removed.whole
334 ! deleted.whole
334 ! deleted.whole
335 ? unknown.whole
335 ? unknown.whole
336 I ignored.whole
336 I ignored.whole
337 C .hgignore
337 C .hgignore
338
338
339 It would be better if this also fixed the unknown file.
339 It would be better if this also fixed the unknown file.
340 $ cat *.whole
340 $ cat *.whole
341 ADDED
341 ADDED
342 CLEAN
342 CLEAN
343 ignored
343 ignored
344 MODIFIED!!!
344 MODIFIED!!!
345 unknown
345 unknown
346
346
347 $ cd ..
347 $ cd ..
348
348
349 Test that incremental fixing works on files with additions, deletions, and
349 Test that incremental fixing works on files with additions, deletions, and
350 changes in multiple line ranges. Note that deletions do not generally cause
350 changes in multiple line ranges. Note that deletions do not generally cause
351 neighboring lines to be fixed, so we don't return a line range for purely
351 neighboring lines to be fixed, so we don't return a line range for purely
352 deleted sections. In the future we should support a :deletion config that
352 deleted sections. In the future we should support a :deletion config that
353 allows fixers to know where deletions are located.
353 allows fixers to know where deletions are located.
354
354
355 $ hg init incrementalfixedlines
355 $ hg init incrementalfixedlines
356 $ cd incrementalfixedlines
356 $ cd incrementalfixedlines
357
357
358 $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.txt
358 $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.txt
359 $ hg commit -Aqm "foo"
359 $ hg commit -Aqm "foo"
360 $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.txt
360 $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.txt
361
361
362 $ hg --config "fix.fail:command=echo" \
362 $ hg --config "fix.fail:command=echo" \
363 > --config "fix.fail:linerange={first}:{last}" \
363 > --config "fix.fail:linerange={first}:{last}" \
364 > --config "fix.fail:fileset=foo.txt" \
364 > --config "fix.fail:fileset=foo.txt" \
365 > fix --working-dir
365 > fix --working-dir
366 $ cat foo.txt
366 $ cat foo.txt
367 1:1 4:6 8:8
367 1:1 4:6 8:8
368
368
369 $ cd ..
369 $ cd ..
370
370
371 Test that --whole fixes all lines regardless of the diffs present.
371 Test that --whole fixes all lines regardless of the diffs present.
372
372
373 $ hg init wholeignoresdiffs
373 $ hg init wholeignoresdiffs
374 $ cd wholeignoresdiffs
374 $ cd wholeignoresdiffs
375
375
376 $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.changed
376 $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.changed
377 $ hg commit -Aqm "foo"
377 $ hg commit -Aqm "foo"
378 $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.changed
378 $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.changed
379 $ hg fix --working-dir --whole
379 $ hg fix --working-dir --whole
380 $ cat foo.changed
380 $ cat foo.changed
381 ZZ
381 ZZ
382 A
382 A
383 C
383 C
384 DD
384 DD
385 EE
385 EE
386 FF
386 FF
387 F
387 F
388 GG
388 GG
389
389
390 $ cd ..
390 $ cd ..
391
391
392 We should do nothing with symlinks, and their targets should be unaffected. Any
392 We should do nothing with symlinks, and their targets should be unaffected. Any
393 other behavior would be more complicated to implement and harder to document.
393 other behavior would be more complicated to implement and harder to document.
394
394
395 #if symlink
395 #if symlink
396 $ hg init dontmesswithsymlinks
396 $ hg init dontmesswithsymlinks
397 $ cd dontmesswithsymlinks
397 $ cd dontmesswithsymlinks
398
398
399 $ printf "hello\n" > hello.whole
399 $ printf "hello\n" > hello.whole
400 $ ln -s hello.whole hellolink
400 $ ln -s hello.whole hellolink
401 $ hg add
401 $ hg add
402 adding hello.whole
402 adding hello.whole
403 adding hellolink
403 adding hellolink
404 $ hg fix --working-dir hellolink
404 $ hg fix --working-dir hellolink
405 $ hg status
405 $ hg status
406 A hello.whole
406 A hello.whole
407 A hellolink
407 A hellolink
408
408
409 $ cd ..
409 $ cd ..
410 #endif
410 #endif
411
411
412 We should allow fixers to run on binary files, even though this doesn't sound
412 We should allow fixers to run on binary files, even though this doesn't sound
413 like a common use case. There's not much benefit to disallowing it, and users
413 like a common use case. There's not much benefit to disallowing it, and users
414 can add "and not binary()" to their filesets if needed. The Mercurial
414 can add "and not binary()" to their filesets if needed. The Mercurial
415 philosophy is generally to not handle binary files specially anyway.
415 philosophy is generally to not handle binary files specially anyway.
416
416
417 $ hg init cantouchbinaryfiles
417 $ hg init cantouchbinaryfiles
418 $ cd cantouchbinaryfiles
418 $ cd cantouchbinaryfiles
419
419
420 $ printf "hello\0\n" > hello.whole
420 $ printf "hello\0\n" > hello.whole
421 $ hg add
421 $ hg add
422 adding hello.whole
422 adding hello.whole
423 $ hg fix --working-dir 'set:binary()'
423 $ hg fix --working-dir 'set:binary()'
424 $ cat hello.whole
424 $ cat hello.whole
425 HELLO\x00 (esc)
425 HELLO\x00 (esc)
426
426
427 $ cd ..
427 $ cd ..
428
428
429 We have a config for the maximum size of file we will attempt to fix. This can
429 We have a config for the maximum size of file we will attempt to fix. This can
430 be helpful to avoid running unsuspecting fixer tools on huge inputs, which
430 be helpful to avoid running unsuspecting fixer tools on huge inputs, which
431 could happen by accident without a well considered configuration. A more
431 could happen by accident without a well considered configuration. A more
432 precise configuration could use the size() fileset function if one global limit
432 precise configuration could use the size() fileset function if one global limit
433 is undesired.
433 is undesired.
434
434
435 $ hg init maxfilesize
435 $ hg init maxfilesize
436 $ cd maxfilesize
436 $ cd maxfilesize
437
437
438 $ printf "this file is huge\n" > hello.whole
438 $ printf "this file is huge\n" > hello.whole
439 $ hg add
439 $ hg add
440 adding hello.whole
440 adding hello.whole
441 $ hg --config fix.maxfilesize=10 fix --working-dir
441 $ hg --config fix.maxfilesize=10 fix --working-dir
442 ignoring file larger than 10 bytes: hello.whole
442 ignoring file larger than 10 bytes: hello.whole
443 $ cat hello.whole
443 $ cat hello.whole
444 this file is huge
444 this file is huge
445
445
446 $ cd ..
446 $ cd ..
447
447
448 If we specify a file to fix, other files should be left alone, even if they
448 If we specify a file to fix, other files should be left alone, even if they
449 have changes.
449 have changes.
450
450
451 $ hg init fixonlywhatitellyouto
451 $ hg init fixonlywhatitellyouto
452 $ cd fixonlywhatitellyouto
452 $ cd fixonlywhatitellyouto
453
453
454 $ printf "fix me!\n" > fixme.whole
454 $ printf "fix me!\n" > fixme.whole
455 $ printf "not me.\n" > notme.whole
455 $ printf "not me.\n" > notme.whole
456 $ hg add
456 $ hg add
457 adding fixme.whole
457 adding fixme.whole
458 adding notme.whole
458 adding notme.whole
459 $ hg fix --working-dir fixme.whole
459 $ hg fix --working-dir fixme.whole
460 $ cat *.whole
460 $ cat *.whole
461 FIX ME!
461 FIX ME!
462 not me.
462 not me.
463
463
464 $ cd ..
464 $ cd ..
465
465
466 Specifying a directory name should fix all its files and subdirectories.
466 Specifying a directory name should fix all its files and subdirectories.
467
467
468 $ hg init fixdirectory
468 $ hg init fixdirectory
469 $ cd fixdirectory
469 $ cd fixdirectory
470
470
471 $ mkdir -p dir1/dir2
471 $ mkdir -p dir1/dir2
472 $ printf "foo\n" > foo.whole
472 $ printf "foo\n" > foo.whole
473 $ printf "bar\n" > dir1/bar.whole
473 $ printf "bar\n" > dir1/bar.whole
474 $ printf "baz\n" > dir1/dir2/baz.whole
474 $ printf "baz\n" > dir1/dir2/baz.whole
475 $ hg add
475 $ hg add
476 adding dir1/bar.whole
476 adding dir1/bar.whole
477 adding dir1/dir2/baz.whole
477 adding dir1/dir2/baz.whole
478 adding foo.whole
478 adding foo.whole
479 $ hg fix --working-dir dir1
479 $ hg fix --working-dir dir1
480 $ cat foo.whole dir1/bar.whole dir1/dir2/baz.whole
480 $ cat foo.whole dir1/bar.whole dir1/dir2/baz.whole
481 foo
481 foo
482 BAR
482 BAR
483 BAZ
483 BAZ
484
484
485 $ cd ..
485 $ cd ..
486
486
487 Fixing a file in the working directory that needs no fixes should not actually
487 Fixing a file in the working directory that needs no fixes should not actually
488 write back to the file, so for example the mtime shouldn't change.
488 write back to the file, so for example the mtime shouldn't change.
489
489
490 $ hg init donttouchunfixedfiles
490 $ hg init donttouchunfixedfiles
491 $ cd donttouchunfixedfiles
491 $ cd donttouchunfixedfiles
492
492
493 $ printf "NO FIX NEEDED\n" > foo.whole
493 $ printf "NO FIX NEEDED\n" > foo.whole
494 $ hg add
494 $ hg add
495 adding foo.whole
495 adding foo.whole
496 $ cp foo.whole foo.whole.orig
496 $ cp foo.whole foo.whole.orig
497 $ sleep 2 # mtime has a resolution of one or two seconds.
497 $ sleep 2 # mtime has a resolution of one or two seconds.
498 $ hg fix --working-dir
498 $ hg fix --working-dir
499 $ f foo.whole --newer foo.whole.orig
499 $ f foo.whole --newer foo.whole.orig
500 foo.whole: older than foo.whole.orig
500 foo.whole: older than foo.whole.orig
501
501
502 $ cd ..
502 $ cd ..
503
503
504 When a fixer prints to stderr, we assume that it has failed. We should show the
504 When a fixer prints to stderr, we assume that it has failed. We should show the
505 error messages to the user, and we should not let the failing fixer affect the
505 error messages to the user, and we should not let the failing fixer affect the
506 file it was fixing (many code formatters might emit error messages on stderr
506 file it was fixing (many code formatters might emit error messages on stderr
507 and nothing on stdout, which would cause us the clear the file). We show the
507 and nothing on stdout, which would cause us the clear the file). We show the
508 user which fixer failed and which revision, but we assume that the fixer will
508 user which fixer failed and which revision, but we assume that the fixer will
509 print the filename if it is relevant.
509 print the filename if it is relevant.
510
510
511 $ hg init showstderr
511 $ hg init showstderr
512 $ cd showstderr
512 $ cd showstderr
513
513
514 $ printf "hello\n" > hello.txt
514 $ printf "hello\n" > hello.txt
515 $ hg add
515 $ hg add
516 adding hello.txt
516 adding hello.txt
517 $ hg --config "fix.fail:command=printf 'HELLO\n' ; \
517 $ cat >> $TESTTMP/cmd.sh <<'EOF'
518 > printf '{rootpath}: some\nerror' >&2" \
518 > printf 'HELLO\n'
519 > printf "$@: some\nerror" >&2
520 > EOF
521 $ hg --config "fix.fail:command=sh $TESTTMP/cmd.sh {rootpath}" \
519 > --config "fix.fail:fileset=hello.txt" \
522 > --config "fix.fail:fileset=hello.txt" \
520 > fix --working-dir
523 > fix --working-dir
521 [wdir] fail: hello.txt: some
524 [wdir] fail: hello.txt: some
522 [wdir] fail: error
525 [wdir] fail: error
523 $ cat hello.txt
526 $ cat hello.txt
524 hello
527 hello
525
528
526 $ cd ..
529 $ cd ..
527
530
528 Fixing the working directory and its parent revision at the same time should
531 Fixing the working directory and its parent revision at the same time should
529 check out the replacement revision for the parent. This prevents any new
532 check out the replacement revision for the parent. This prevents any new
530 uncommitted changes from appearing. We test this for a clean working directory
533 uncommitted changes from appearing. We test this for a clean working directory
531 and a dirty one. In both cases, all lines/files changed since the grandparent
534 and a dirty one. In both cases, all lines/files changed since the grandparent
532 will be fixed. The grandparent is the "baserev" for both the parent and the
535 will be fixed. The grandparent is the "baserev" for both the parent and the
533 working copy.
536 working copy.
534
537
535 $ hg init fixdotandcleanwdir
538 $ hg init fixdotandcleanwdir
536 $ cd fixdotandcleanwdir
539 $ cd fixdotandcleanwdir
537
540
538 $ printf "hello\n" > hello.whole
541 $ printf "hello\n" > hello.whole
539 $ printf "world\n" > world.whole
542 $ printf "world\n" > world.whole
540 $ hg commit -Aqm "the parent commit"
543 $ hg commit -Aqm "the parent commit"
541
544
542 $ hg parents --template '{rev} {desc}\n'
545 $ hg parents --template '{rev} {desc}\n'
543 0 the parent commit
546 0 the parent commit
544 $ hg fix --working-dir -r .
547 $ hg fix --working-dir -r .
545 $ hg parents --template '{rev} {desc}\n'
548 $ hg parents --template '{rev} {desc}\n'
546 1 the parent commit
549 1 the parent commit
547 $ hg cat -r . *.whole
550 $ hg cat -r . *.whole
548 HELLO
551 HELLO
549 WORLD
552 WORLD
550 $ cat *.whole
553 $ cat *.whole
551 HELLO
554 HELLO
552 WORLD
555 WORLD
553 $ hg status
556 $ hg status
554
557
555 $ cd ..
558 $ cd ..
556
559
557 Same test with a dirty working copy.
560 Same test with a dirty working copy.
558
561
559 $ hg init fixdotanddirtywdir
562 $ hg init fixdotanddirtywdir
560 $ cd fixdotanddirtywdir
563 $ cd fixdotanddirtywdir
561
564
562 $ printf "hello\n" > hello.whole
565 $ printf "hello\n" > hello.whole
563 $ printf "world\n" > world.whole
566 $ printf "world\n" > world.whole
564 $ hg commit -Aqm "the parent commit"
567 $ hg commit -Aqm "the parent commit"
565
568
566 $ printf "hello,\n" > hello.whole
569 $ printf "hello,\n" > hello.whole
567 $ printf "world!\n" > world.whole
570 $ printf "world!\n" > world.whole
568
571
569 $ hg parents --template '{rev} {desc}\n'
572 $ hg parents --template '{rev} {desc}\n'
570 0 the parent commit
573 0 the parent commit
571 $ hg fix --working-dir -r .
574 $ hg fix --working-dir -r .
572 $ hg parents --template '{rev} {desc}\n'
575 $ hg parents --template '{rev} {desc}\n'
573 1 the parent commit
576 1 the parent commit
574 $ hg cat -r . *.whole
577 $ hg cat -r . *.whole
575 HELLO
578 HELLO
576 WORLD
579 WORLD
577 $ cat *.whole
580 $ cat *.whole
578 HELLO,
581 HELLO,
579 WORLD!
582 WORLD!
580 $ hg status
583 $ hg status
581 M hello.whole
584 M hello.whole
582 M world.whole
585 M world.whole
583
586
584 $ cd ..
587 $ cd ..
585
588
586 When we have a chain of commits that change mutually exclusive lines of code,
589 When we have a chain of commits that change mutually exclusive lines of code,
587 we should be able to do incremental fixing that causes each commit in the chain
590 we should be able to do incremental fixing that causes each commit in the chain
588 to include fixes made to the previous commits. This prevents children from
591 to include fixes made to the previous commits. This prevents children from
589 backing out the fixes made in their parents. A dirty working directory is
592 backing out the fixes made in their parents. A dirty working directory is
590 conceptually similar to another commit in the chain.
593 conceptually similar to another commit in the chain.
591
594
592 $ hg init incrementallyfixchain
595 $ hg init incrementallyfixchain
593 $ cd incrementallyfixchain
596 $ cd incrementallyfixchain
594
597
595 $ cat > file.changed <<EOF
598 $ cat > file.changed <<EOF
596 > first
599 > first
597 > second
600 > second
598 > third
601 > third
599 > fourth
602 > fourth
600 > fifth
603 > fifth
601 > EOF
604 > EOF
602 $ hg commit -Aqm "the common ancestor (the baserev)"
605 $ hg commit -Aqm "the common ancestor (the baserev)"
603 $ cat > file.changed <<EOF
606 $ cat > file.changed <<EOF
604 > first (changed)
607 > first (changed)
605 > second
608 > second
606 > third
609 > third
607 > fourth
610 > fourth
608 > fifth
611 > fifth
609 > EOF
612 > EOF
610 $ hg commit -Aqm "the first commit to fix"
613 $ hg commit -Aqm "the first commit to fix"
611 $ cat > file.changed <<EOF
614 $ cat > file.changed <<EOF
612 > first (changed)
615 > first (changed)
613 > second
616 > second
614 > third (changed)
617 > third (changed)
615 > fourth
618 > fourth
616 > fifth
619 > fifth
617 > EOF
620 > EOF
618 $ hg commit -Aqm "the second commit to fix"
621 $ hg commit -Aqm "the second commit to fix"
619 $ cat > file.changed <<EOF
622 $ cat > file.changed <<EOF
620 > first (changed)
623 > first (changed)
621 > second
624 > second
622 > third (changed)
625 > third (changed)
623 > fourth
626 > fourth
624 > fifth (changed)
627 > fifth (changed)
625 > EOF
628 > EOF
626
629
627 $ hg fix -r . -r '.^' --working-dir
630 $ hg fix -r . -r '.^' --working-dir
628
631
629 $ hg parents --template '{rev}\n'
632 $ hg parents --template '{rev}\n'
630 4
633 4
631 $ hg cat -r '.^^' file.changed
634 $ hg cat -r '.^^' file.changed
632 first
635 first
633 second
636 second
634 third
637 third
635 fourth
638 fourth
636 fifth
639 fifth
637 $ hg cat -r '.^' file.changed
640 $ hg cat -r '.^' file.changed
638 FIRST (CHANGED)
641 FIRST (CHANGED)
639 second
642 second
640 third
643 third
641 fourth
644 fourth
642 fifth
645 fifth
643 $ hg cat -r . file.changed
646 $ hg cat -r . file.changed
644 FIRST (CHANGED)
647 FIRST (CHANGED)
645 second
648 second
646 THIRD (CHANGED)
649 THIRD (CHANGED)
647 fourth
650 fourth
648 fifth
651 fifth
649 $ cat file.changed
652 $ cat file.changed
650 FIRST (CHANGED)
653 FIRST (CHANGED)
651 second
654 second
652 THIRD (CHANGED)
655 THIRD (CHANGED)
653 fourth
656 fourth
654 FIFTH (CHANGED)
657 FIFTH (CHANGED)
655
658
656 $ cd ..
659 $ cd ..
657
660
658 If we incrementally fix a merge commit, we should fix any lines that changed
661 If we incrementally fix a merge commit, we should fix any lines that changed
659 versus either parent. You could imagine only fixing the intersection or some
662 versus either parent. You could imagine only fixing the intersection or some
660 other subset, but this is necessary if either parent is being fixed. It
663 other subset, but this is necessary if either parent is being fixed. It
661 prevents us from forgetting fixes made in either parent.
664 prevents us from forgetting fixes made in either parent.
662
665
663 $ hg init incrementallyfixmergecommit
666 $ hg init incrementallyfixmergecommit
664 $ cd incrementallyfixmergecommit
667 $ cd incrementallyfixmergecommit
665
668
666 $ printf "a\nb\nc\n" > file.changed
669 $ printf "a\nb\nc\n" > file.changed
667 $ hg commit -Aqm "ancestor"
670 $ hg commit -Aqm "ancestor"
668
671
669 $ printf "aa\nb\nc\n" > file.changed
672 $ printf "aa\nb\nc\n" > file.changed
670 $ hg commit -m "change a"
673 $ hg commit -m "change a"
671
674
672 $ hg checkout '.^'
675 $ hg checkout '.^'
673 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
676 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
674 $ printf "a\nb\ncc\n" > file.changed
677 $ printf "a\nb\ncc\n" > file.changed
675 $ hg commit -m "change c"
678 $ hg commit -m "change c"
676 created new head
679 created new head
677
680
678 $ hg merge
681 $ hg merge
679 merging file.changed
682 merging file.changed
680 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
683 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
681 (branch merge, don't forget to commit)
684 (branch merge, don't forget to commit)
682 $ hg commit -m "merge"
685 $ hg commit -m "merge"
683 $ hg cat -r . file.changed
686 $ hg cat -r . file.changed
684 aa
687 aa
685 b
688 b
686 cc
689 cc
687
690
688 $ hg fix -r . --working-dir
691 $ hg fix -r . --working-dir
689 $ hg cat -r . file.changed
692 $ hg cat -r . file.changed
690 AA
693 AA
691 b
694 b
692 CC
695 CC
693
696
694 $ cd ..
697 $ cd ..
695
698
696 Abort fixing revisions if there is an unfinished operation. We don't want to
699 Abort fixing revisions if there is an unfinished operation. We don't want to
697 make things worse by editing files or stripping/obsoleting things. Also abort
700 make things worse by editing files or stripping/obsoleting things. Also abort
698 fixing the working directory if there are unresolved merge conflicts.
701 fixing the working directory if there are unresolved merge conflicts.
699
702
700 $ hg init abortunresolved
703 $ hg init abortunresolved
701 $ cd abortunresolved
704 $ cd abortunresolved
702
705
703 $ echo "foo1" > foo.whole
706 $ echo "foo1" > foo.whole
704 $ hg commit -Aqm "foo 1"
707 $ hg commit -Aqm "foo 1"
705
708
706 $ hg update null
709 $ hg update null
707 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
710 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
708 $ echo "foo2" > foo.whole
711 $ echo "foo2" > foo.whole
709 $ hg commit -Aqm "foo 2"
712 $ hg commit -Aqm "foo 2"
710
713
711 $ hg --config extensions.rebase= rebase -r 1 -d 0
714 $ hg --config extensions.rebase= rebase -r 1 -d 0
712 rebasing 1:c3b6dc0e177a "foo 2" (tip)
715 rebasing 1:c3b6dc0e177a "foo 2" (tip)
713 merging foo.whole
716 merging foo.whole
714 warning: conflicts while merging foo.whole! (edit, then use 'hg resolve --mark')
717 warning: conflicts while merging foo.whole! (edit, then use 'hg resolve --mark')
715 unresolved conflicts (see hg resolve, then hg rebase --continue)
718 unresolved conflicts (see hg resolve, then hg rebase --continue)
716 [1]
719 [1]
717
720
718 $ hg --config extensions.rebase= fix --working-dir
721 $ hg --config extensions.rebase= fix --working-dir
719 abort: unresolved conflicts
722 abort: unresolved conflicts
720 (use 'hg resolve')
723 (use 'hg resolve')
721 [255]
724 [255]
722
725
723 $ hg --config extensions.rebase= fix -r .
726 $ hg --config extensions.rebase= fix -r .
724 abort: rebase in progress
727 abort: rebase in progress
725 (use 'hg rebase --continue' or 'hg rebase --abort')
728 (use 'hg rebase --continue' or 'hg rebase --abort')
726 [255]
729 [255]
727
730
728 When fixing a file that was renamed, we should diff against the source of the
731 When fixing a file that was renamed, we should diff against the source of the
729 rename for incremental fixing and we should correctly reproduce the rename in
732 rename for incremental fixing and we should correctly reproduce the rename in
730 the replacement revision.
733 the replacement revision.
731
734
732 $ hg init fixrenamecommit
735 $ hg init fixrenamecommit
733 $ cd fixrenamecommit
736 $ cd fixrenamecommit
734
737
735 $ printf "a\nb\nc\n" > source.changed
738 $ printf "a\nb\nc\n" > source.changed
736 $ hg commit -Aqm "source revision"
739 $ hg commit -Aqm "source revision"
737 $ hg move source.changed dest.changed
740 $ hg move source.changed dest.changed
738 $ printf "a\nb\ncc\n" > dest.changed
741 $ printf "a\nb\ncc\n" > dest.changed
739 $ hg commit -m "dest revision"
742 $ hg commit -m "dest revision"
740
743
741 $ hg fix -r .
744 $ hg fix -r .
742 $ hg log -r tip --copies --template "{file_copies}\n"
745 $ hg log -r tip --copies --template "{file_copies}\n"
743 dest.changed (source.changed)
746 dest.changed (source.changed)
744 $ hg cat -r tip dest.changed
747 $ hg cat -r tip dest.changed
745 a
748 a
746 b
749 b
747 CC
750 CC
748
751
749 $ cd ..
752 $ cd ..
750
753
751 When fixing revisions that remove files we must ensure that the replacement
754 When fixing revisions that remove files we must ensure that the replacement
752 actually removes the file, whereas it could accidentally leave it unchanged or
755 actually removes the file, whereas it could accidentally leave it unchanged or
753 write an empty string to it.
756 write an empty string to it.
754
757
755 $ hg init fixremovedfile
758 $ hg init fixremovedfile
756 $ cd fixremovedfile
759 $ cd fixremovedfile
757
760
758 $ printf "foo\n" > foo.whole
761 $ printf "foo\n" > foo.whole
759 $ printf "bar\n" > bar.whole
762 $ printf "bar\n" > bar.whole
760 $ hg commit -Aqm "add files"
763 $ hg commit -Aqm "add files"
761 $ hg remove bar.whole
764 $ hg remove bar.whole
762 $ hg commit -m "remove file"
765 $ hg commit -m "remove file"
763 $ hg status --change .
766 $ hg status --change .
764 R bar.whole
767 R bar.whole
765 $ hg fix -r . foo.whole
768 $ hg fix -r . foo.whole
766 $ hg status --change tip
769 $ hg status --change tip
767 M foo.whole
770 M foo.whole
768 R bar.whole
771 R bar.whole
769
772
770 $ cd ..
773 $ cd ..
771
774
772 If fixing a revision finds no fixes to make, no replacement revision should be
775 If fixing a revision finds no fixes to make, no replacement revision should be
773 created.
776 created.
774
777
775 $ hg init nofixesneeded
778 $ hg init nofixesneeded
776 $ cd nofixesneeded
779 $ cd nofixesneeded
777
780
778 $ printf "FOO\n" > foo.whole
781 $ printf "FOO\n" > foo.whole
779 $ hg commit -Aqm "add file"
782 $ hg commit -Aqm "add file"
780 $ hg log --template '{rev}\n'
783 $ hg log --template '{rev}\n'
781 0
784 0
782 $ hg fix -r .
785 $ hg fix -r .
783 $ hg log --template '{rev}\n'
786 $ hg log --template '{rev}\n'
784 0
787 0
785
788
786 $ cd ..
789 $ cd ..
787
790
788 If fixing a commit reverts all the changes in the commit, we replace it with a
791 If fixing a commit reverts all the changes in the commit, we replace it with a
789 commit that changes no files.
792 commit that changes no files.
790
793
791 $ hg init nochangesleft
794 $ hg init nochangesleft
792 $ cd nochangesleft
795 $ cd nochangesleft
793
796
794 $ printf "FOO\n" > foo.whole
797 $ printf "FOO\n" > foo.whole
795 $ hg commit -Aqm "add file"
798 $ hg commit -Aqm "add file"
796 $ printf "foo\n" > foo.whole
799 $ printf "foo\n" > foo.whole
797 $ hg commit -m "edit file"
800 $ hg commit -m "edit file"
798 $ hg status --change .
801 $ hg status --change .
799 M foo.whole
802 M foo.whole
800 $ hg fix -r .
803 $ hg fix -r .
801 $ hg status --change tip
804 $ hg status --change tip
802
805
803 $ cd ..
806 $ cd ..
804
807
805 If we fix a parent and child revision together, the child revision must be
808 If we fix a parent and child revision together, the child revision must be
806 replaced if the parent is replaced, even if the diffs of the child needed no
809 replaced if the parent is replaced, even if the diffs of the child needed no
807 fixes. However, we're free to not replace revisions that need no fixes and have
810 fixes. However, we're free to not replace revisions that need no fixes and have
808 no ancestors that are replaced.
811 no ancestors that are replaced.
809
812
810 $ hg init mustreplacechild
813 $ hg init mustreplacechild
811 $ cd mustreplacechild
814 $ cd mustreplacechild
812
815
813 $ printf "FOO\n" > foo.whole
816 $ printf "FOO\n" > foo.whole
814 $ hg commit -Aqm "add foo"
817 $ hg commit -Aqm "add foo"
815 $ printf "foo\n" > foo.whole
818 $ printf "foo\n" > foo.whole
816 $ hg commit -m "edit foo"
819 $ hg commit -m "edit foo"
817 $ printf "BAR\n" > bar.whole
820 $ printf "BAR\n" > bar.whole
818 $ hg commit -Aqm "add bar"
821 $ hg commit -Aqm "add bar"
819
822
820 $ hg log --graph --template '{node|shortest} {files}'
823 $ hg log --graph --template '{node|shortest} {files}'
821 @ bc05 bar.whole
824 @ bc05 bar.whole
822 |
825 |
823 o 4fd2 foo.whole
826 o 4fd2 foo.whole
824 |
827 |
825 o f9ac foo.whole
828 o f9ac foo.whole
826
829
827 $ hg fix -r 0:2
830 $ hg fix -r 0:2
828 $ hg log --graph --template '{node|shortest} {files}'
831 $ hg log --graph --template '{node|shortest} {files}'
829 o 3801 bar.whole
832 o 3801 bar.whole
830 |
833 |
831 o 38cc
834 o 38cc
832 |
835 |
833 | @ bc05 bar.whole
836 | @ bc05 bar.whole
834 | |
837 | |
835 | x 4fd2 foo.whole
838 | x 4fd2 foo.whole
836 |/
839 |/
837 o f9ac foo.whole
840 o f9ac foo.whole
838
841
839
842
840 $ cd ..
843 $ cd ..
841
844
842 It's also possible that the child needs absolutely no changes, but we still
845 It's also possible that the child needs absolutely no changes, but we still
843 need to replace it to update its parent. If we skipped replacing the child
846 need to replace it to update its parent. If we skipped replacing the child
844 because it had no file content changes, it would become an orphan for no good
847 because it had no file content changes, it would become an orphan for no good
845 reason.
848 reason.
846
849
847 $ hg init mustreplacechildevenifnop
850 $ hg init mustreplacechildevenifnop
848 $ cd mustreplacechildevenifnop
851 $ cd mustreplacechildevenifnop
849
852
850 $ printf "Foo\n" > foo.whole
853 $ printf "Foo\n" > foo.whole
851 $ hg commit -Aqm "add a bad foo"
854 $ hg commit -Aqm "add a bad foo"
852 $ printf "FOO\n" > foo.whole
855 $ printf "FOO\n" > foo.whole
853 $ hg commit -m "add a good foo"
856 $ hg commit -m "add a good foo"
854 $ hg fix -r . -r '.^'
857 $ hg fix -r . -r '.^'
855 $ hg log --graph --template '{rev} {desc}'
858 $ hg log --graph --template '{rev} {desc}'
856 o 3 add a good foo
859 o 3 add a good foo
857 |
860 |
858 o 2 add a bad foo
861 o 2 add a bad foo
859
862
860 @ 1 add a good foo
863 @ 1 add a good foo
861 |
864 |
862 x 0 add a bad foo
865 x 0 add a bad foo
863
866
864
867
865 $ cd ..
868 $ cd ..
866
869
867 Similar to the case above, the child revision may become empty as a result of
870 Similar to the case above, the child revision may become empty as a result of
868 fixing its parent. We should still create an empty replacement child.
871 fixing its parent. We should still create an empty replacement child.
869 TODO: determine how this should interact with ui.allowemptycommit given that
872 TODO: determine how this should interact with ui.allowemptycommit given that
870 the empty replacement could have children.
873 the empty replacement could have children.
871
874
872 $ hg init mustreplacechildevenifempty
875 $ hg init mustreplacechildevenifempty
873 $ cd mustreplacechildevenifempty
876 $ cd mustreplacechildevenifempty
874
877
875 $ printf "foo\n" > foo.whole
878 $ printf "foo\n" > foo.whole
876 $ hg commit -Aqm "add foo"
879 $ hg commit -Aqm "add foo"
877 $ printf "Foo\n" > foo.whole
880 $ printf "Foo\n" > foo.whole
878 $ hg commit -m "edit foo"
881 $ hg commit -m "edit foo"
879 $ hg fix -r . -r '.^'
882 $ hg fix -r . -r '.^'
880 $ hg log --graph --template '{rev} {desc}\n' --stat
883 $ hg log --graph --template '{rev} {desc}\n' --stat
881 o 3 edit foo
884 o 3 edit foo
882 |
885 |
883 o 2 add foo
886 o 2 add foo
884 foo.whole | 1 +
887 foo.whole | 1 +
885 1 files changed, 1 insertions(+), 0 deletions(-)
888 1 files changed, 1 insertions(+), 0 deletions(-)
886
889
887 @ 1 edit foo
890 @ 1 edit foo
888 | foo.whole | 2 +-
891 | foo.whole | 2 +-
889 | 1 files changed, 1 insertions(+), 1 deletions(-)
892 | 1 files changed, 1 insertions(+), 1 deletions(-)
890 |
893 |
891 x 0 add foo
894 x 0 add foo
892 foo.whole | 1 +
895 foo.whole | 1 +
893 1 files changed, 1 insertions(+), 0 deletions(-)
896 1 files changed, 1 insertions(+), 0 deletions(-)
894
897
895
898
896 $ cd ..
899 $ cd ..
897
900
898 Fixing a secret commit should replace it with another secret commit.
901 Fixing a secret commit should replace it with another secret commit.
899
902
900 $ hg init fixsecretcommit
903 $ hg init fixsecretcommit
901 $ cd fixsecretcommit
904 $ cd fixsecretcommit
902
905
903 $ printf "foo\n" > foo.whole
906 $ printf "foo\n" > foo.whole
904 $ hg commit -Aqm "add foo" --secret
907 $ hg commit -Aqm "add foo" --secret
905 $ hg fix -r .
908 $ hg fix -r .
906 $ hg log --template '{rev} {phase}\n'
909 $ hg log --template '{rev} {phase}\n'
907 1 secret
910 1 secret
908 0 secret
911 0 secret
909
912
910 $ cd ..
913 $ cd ..
911
914
912 We should also preserve phase when fixing a draft commit while the user has
915 We should also preserve phase when fixing a draft commit while the user has
913 their default set to secret.
916 their default set to secret.
914
917
915 $ hg init respectphasesnewcommit
918 $ hg init respectphasesnewcommit
916 $ cd respectphasesnewcommit
919 $ cd respectphasesnewcommit
917
920
918 $ printf "foo\n" > foo.whole
921 $ printf "foo\n" > foo.whole
919 $ hg commit -Aqm "add foo"
922 $ hg commit -Aqm "add foo"
920 $ hg --config phases.newcommit=secret fix -r .
923 $ hg --config phases.newcommit=secret fix -r .
921 $ hg log --template '{rev} {phase}\n'
924 $ hg log --template '{rev} {phase}\n'
922 1 draft
925 1 draft
923 0 draft
926 0 draft
924
927
925 $ cd ..
928 $ cd ..
926
929
927 Debug output should show what fixer commands are being subprocessed, which is
930 Debug output should show what fixer commands are being subprocessed, which is
928 useful for anyone trying to set up a new config.
931 useful for anyone trying to set up a new config.
929
932
930 $ hg init debugoutput
933 $ hg init debugoutput
931 $ cd debugoutput
934 $ cd debugoutput
932
935
933 $ printf "foo\nbar\nbaz\n" > foo.changed
936 $ printf "foo\nbar\nbaz\n" > foo.changed
934 $ hg commit -Aqm "foo"
937 $ hg commit -Aqm "foo"
935 $ printf "Foo\nbar\nBaz\n" > foo.changed
938 $ printf "Foo\nbar\nBaz\n" > foo.changed
936 $ hg --debug fix --working-dir
939 $ hg --debug fix --working-dir
937 subprocess: * $TESTTMP/uppercase.py 1-1 3-3 (glob)
940 subprocess: * $TESTTMP/uppercase.py 1-1 3-3 (glob)
938
941
939 $ cd ..
942 $ cd ..
940
943
941 Fixing an obsolete revision can cause divergence, so we abort unless the user
944 Fixing an obsolete revision can cause divergence, so we abort unless the user
942 configures to allow it. This is not yet smart enough to know whether there is a
945 configures to allow it. This is not yet smart enough to know whether there is a
943 successor, but even then it is not likely intentional or idiomatic to fix an
946 successor, but even then it is not likely intentional or idiomatic to fix an
944 obsolete revision.
947 obsolete revision.
945
948
946 $ hg init abortobsoleterev
949 $ hg init abortobsoleterev
947 $ cd abortobsoleterev
950 $ cd abortobsoleterev
948
951
949 $ printf "foo\n" > foo.changed
952 $ printf "foo\n" > foo.changed
950 $ hg commit -Aqm "foo"
953 $ hg commit -Aqm "foo"
951 $ hg debugobsolete `hg parents --template '{node}'`
954 $ hg debugobsolete `hg parents --template '{node}'`
952 obsoleted 1 changesets
955 obsoleted 1 changesets
953 $ hg --hidden fix -r 0
956 $ hg --hidden fix -r 0
954 abort: fixing obsolete revision could cause divergence
957 abort: fixing obsolete revision could cause divergence
955 [255]
958 [255]
956
959
957 $ hg --hidden fix -r 0 --config experimental.evolution.allowdivergence=true
960 $ hg --hidden fix -r 0 --config experimental.evolution.allowdivergence=true
958 $ hg cat -r tip foo.changed
961 $ hg cat -r tip foo.changed
959 FOO
962 FOO
960
963
961 $ cd ..
964 $ cd ..
962
965
963 Test all of the available substitution values for fixer commands.
966 Test all of the available substitution values for fixer commands.
964
967
965 $ hg init substitution
968 $ hg init substitution
966 $ cd substitution
969 $ cd substitution
967
970
968 $ mkdir foo
971 $ mkdir foo
969 $ printf "hello\ngoodbye\n" > foo/bar
972 $ printf "hello\ngoodbye\n" > foo/bar
970 $ hg add
973 $ hg add
971 adding foo/bar
974 adding foo/bar
972 $ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \
975 $ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \
973 > --config "fix.fail:linerange='{first}' '{last}'" \
976 > --config "fix.fail:linerange='{first}' '{last}'" \
974 > --config "fix.fail:fileset=foo/bar" \
977 > --config "fix.fail:fileset=foo/bar" \
975 > fix --working-dir
978 > fix --working-dir
976 $ cat foo/bar
979 $ cat foo/bar
977 foo/bar
980 foo/bar
978 bar
981 bar
979 1
982 1
980 2
983 2
981
984
982 $ cd ..
985 $ cd ..
983
986
984 The --base flag should allow picking the revisions to diff against for changed
987 The --base flag should allow picking the revisions to diff against for changed
985 files and incremental line formatting.
988 files and incremental line formatting.
986
989
987 $ hg init baseflag
990 $ hg init baseflag
988 $ cd baseflag
991 $ cd baseflag
989
992
990 $ printf "one\ntwo\n" > foo.changed
993 $ printf "one\ntwo\n" > foo.changed
991 $ printf "bar\n" > bar.changed
994 $ printf "bar\n" > bar.changed
992 $ hg commit -Aqm "first"
995 $ hg commit -Aqm "first"
993 $ printf "one\nTwo\n" > foo.changed
996 $ printf "one\nTwo\n" > foo.changed
994 $ hg commit -m "second"
997 $ hg commit -m "second"
995 $ hg fix -w --base .
998 $ hg fix -w --base .
996 $ hg status
999 $ hg status
997 $ hg fix -w --base null
1000 $ hg fix -w --base null
998 $ cat foo.changed
1001 $ cat foo.changed
999 ONE
1002 ONE
1000 TWO
1003 TWO
1001 $ cat bar.changed
1004 $ cat bar.changed
1002 BAR
1005 BAR
1003
1006
1004 $ cd ..
1007 $ cd ..
1005
1008
1006 If the user asks to fix the parent of another commit, they are asking to create
1009 If the user asks to fix the parent of another commit, they are asking to create
1007 an orphan. We must respect experimental.evolution.allowunstable.
1010 an orphan. We must respect experimental.evolution.allowunstable.
1008
1011
1009 $ hg init allowunstable
1012 $ hg init allowunstable
1010 $ cd allowunstable
1013 $ cd allowunstable
1011
1014
1012 $ printf "one\n" > foo.whole
1015 $ printf "one\n" > foo.whole
1013 $ hg commit -Aqm "first"
1016 $ hg commit -Aqm "first"
1014 $ printf "two\n" > foo.whole
1017 $ printf "two\n" > foo.whole
1015 $ hg commit -m "second"
1018 $ hg commit -m "second"
1016 $ hg --config experimental.evolution.allowunstable=False fix -r '.^'
1019 $ hg --config experimental.evolution.allowunstable=False fix -r '.^'
1017 abort: can only fix a changeset together with all its descendants
1020 abort: can only fix a changeset together with all its descendants
1018 [255]
1021 [255]
1019 $ hg fix -r '.^'
1022 $ hg fix -r '.^'
1020 1 new orphan changesets
1023 1 new orphan changesets
1021 $ hg cat -r 2 foo.whole
1024 $ hg cat -r 2 foo.whole
1022 ONE
1025 ONE
1023
1026
1024 $ cd ..
1027 $ cd ..
1025
1028
General Comments 0
You need to be logged in to leave comments. Login now