##// END OF EJS Templates
amend: add tests for amending only some files from commit to be amended...
Saurabh Singh -
r34061:6fb5a06b default
parent child Browse files
Show More
@@ -1,1176 +1,1269
1 $ cat << EOF >> $HGRCPATH
1 $ cat << EOF >> $HGRCPATH
2 > [format]
2 > [format]
3 > usegeneraldelta=yes
3 > usegeneraldelta=yes
4 > EOF
4 > EOF
5
5
6 $ hg init
6 $ hg init
7
7
8 Setup:
8 Setup:
9
9
10 $ echo a >> a
10 $ echo a >> a
11 $ hg ci -Am 'base'
11 $ hg ci -Am 'base'
12 adding a
12 adding a
13
13
14 Refuse to amend public csets:
14 Refuse to amend public csets:
15
15
16 $ hg phase -r . -p
16 $ hg phase -r . -p
17 $ hg ci --amend
17 $ hg ci --amend
18 abort: cannot amend public changesets
18 abort: cannot amend public changesets
19 [255]
19 [255]
20 $ hg phase -r . -f -d
20 $ hg phase -r . -f -d
21
21
22 $ echo a >> a
22 $ echo a >> a
23 $ hg ci -Am 'base1'
23 $ hg ci -Am 'base1'
24
24
25 Nothing to amend:
25 Nothing to amend:
26
26
27 $ hg ci --amend -m 'base1'
27 $ hg ci --amend -m 'base1'
28 nothing changed
28 nothing changed
29 [1]
29 [1]
30
30
31 $ cat >> $HGRCPATH <<EOF
31 $ cat >> $HGRCPATH <<EOF
32 > [hooks]
32 > [hooks]
33 > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE"
33 > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE"
34 > EOF
34 > EOF
35
35
36 Amending changeset with changes in working dir:
36 Amending changeset with changes in working dir:
37 (and check that --message does not trigger an editor)
37 (and check that --message does not trigger an editor)
38
38
39 $ echo a >> a
39 $ echo a >> a
40 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
40 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
41 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149
41 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149
42 43f1ba15f28a tip
42 43f1ba15f28a tip
43 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-f1bf3ab8-amend.hg (glob)
43 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-f1bf3ab8-amend.hg (glob)
44 $ echo 'pretxncommit.foo = ' >> $HGRCPATH
44 $ echo 'pretxncommit.foo = ' >> $HGRCPATH
45 $ hg diff -c .
45 $ hg diff -c .
46 diff -r ad120869acf0 -r 43f1ba15f28a a
46 diff -r ad120869acf0 -r 43f1ba15f28a a
47 --- a/a Thu Jan 01 00:00:00 1970 +0000
47 --- a/a Thu Jan 01 00:00:00 1970 +0000
48 +++ b/a Thu Jan 01 00:00:00 1970 +0000
48 +++ b/a Thu Jan 01 00:00:00 1970 +0000
49 @@ -1,1 +1,3 @@
49 @@ -1,1 +1,3 @@
50 a
50 a
51 +a
51 +a
52 +a
52 +a
53 $ hg log
53 $ hg log
54 changeset: 1:43f1ba15f28a
54 changeset: 1:43f1ba15f28a
55 tag: tip
55 tag: tip
56 user: test
56 user: test
57 date: Thu Jan 01 00:00:00 1970 +0000
57 date: Thu Jan 01 00:00:00 1970 +0000
58 summary: amend base1
58 summary: amend base1
59
59
60 changeset: 0:ad120869acf0
60 changeset: 0:ad120869acf0
61 user: test
61 user: test
62 date: Thu Jan 01 00:00:00 1970 +0000
62 date: Thu Jan 01 00:00:00 1970 +0000
63 summary: base
63 summary: base
64
64
65
65
66 Check proper abort for empty message
66 Check proper abort for empty message
67
67
68 $ cat > editor.sh << '__EOF__'
68 $ cat > editor.sh << '__EOF__'
69 > #!/bin/sh
69 > #!/bin/sh
70 > echo "" > "$1"
70 > echo "" > "$1"
71 > __EOF__
71 > __EOF__
72 $ echo b > b
72 $ echo b > b
73 $ hg add b
73 $ hg add b
74 $ hg summary
74 $ hg summary
75 parent: 1:43f1ba15f28a tip
75 parent: 1:43f1ba15f28a tip
76 amend base1
76 amend base1
77 branch: default
77 branch: default
78 commit: 1 added, 1 unknown
78 commit: 1 added, 1 unknown
79 update: (current)
79 update: (current)
80 phases: 2 draft
80 phases: 2 draft
81 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
81 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
82 transaction abort!
82 transaction abort!
83 rollback completed
83 rollback completed
84 abort: empty commit message
84 abort: empty commit message
85 [255]
85 [255]
86 $ hg summary
86 $ hg summary
87 parent: 1:43f1ba15f28a tip
87 parent: 1:43f1ba15f28a tip
88 amend base1
88 amend base1
89 branch: default
89 branch: default
90 commit: 1 added, 1 unknown
90 commit: 1 added, 1 unknown
91 update: (current)
91 update: (current)
92 phases: 2 draft
92 phases: 2 draft
93
93
94 Add new file:
94 Add new file:
95 $ hg ci --amend -m 'amend base1 new file'
95 $ hg ci --amend -m 'amend base1 new file'
96 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-7a3b3496-amend.hg (glob)
96 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-7a3b3496-amend.hg (glob)
97
97
98 Remove file that was added in amended commit:
98 Remove file that was added in amended commit:
99 (and test logfile option)
99 (and test logfile option)
100 (and test that logfile option do not trigger an editor)
100 (and test that logfile option do not trigger an editor)
101
101
102 $ hg rm b
102 $ hg rm b
103 $ echo 'amend base1 remove new file' > ../logfile
103 $ echo 'amend base1 remove new file' > ../logfile
104 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
104 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
105 saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-0b55739a-amend.hg (glob)
105 saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-0b55739a-amend.hg (glob)
106
106
107 $ hg cat b
107 $ hg cat b
108 b: no such file in rev 74609c7f506e
108 b: no such file in rev 74609c7f506e
109 [1]
109 [1]
110
110
111 No changes, just a different message:
111 No changes, just a different message:
112
112
113 $ hg ci -v --amend -m 'no changes, new message'
113 $ hg ci -v --amend -m 'no changes, new message'
114 amending changeset 74609c7f506e
114 amending changeset 74609c7f506e
115 copying changeset 74609c7f506e to ad120869acf0
115 copying changeset 74609c7f506e to ad120869acf0
116 committing files:
116 committing files:
117 a
117 a
118 committing manifest
118 committing manifest
119 committing changelog
119 committing changelog
120 1 changesets found
120 1 changesets found
121 uncompressed size of bundle content:
121 uncompressed size of bundle content:
122 254 (changelog)
122 254 (changelog)
123 163 (manifests)
123 163 (manifests)
124 129 a
124 129 a
125 saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-1bfde511-amend.hg (glob)
125 saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-1bfde511-amend.hg (glob)
126 1 changesets found
126 1 changesets found
127 uncompressed size of bundle content:
127 uncompressed size of bundle content:
128 250 (changelog)
128 250 (changelog)
129 163 (manifests)
129 163 (manifests)
130 129 a
130 129 a
131 adding branch
131 adding branch
132 adding changesets
132 adding changesets
133 adding manifests
133 adding manifests
134 adding file changes
134 adding file changes
135 added 1 changesets with 1 changes to 1 files
135 added 1 changesets with 1 changes to 1 files
136 committed changeset 1:1cd866679df8
136 committed changeset 1:1cd866679df8
137 $ hg diff -c .
137 $ hg diff -c .
138 diff -r ad120869acf0 -r 1cd866679df8 a
138 diff -r ad120869acf0 -r 1cd866679df8 a
139 --- a/a Thu Jan 01 00:00:00 1970 +0000
139 --- a/a Thu Jan 01 00:00:00 1970 +0000
140 +++ b/a Thu Jan 01 00:00:00 1970 +0000
140 +++ b/a Thu Jan 01 00:00:00 1970 +0000
141 @@ -1,1 +1,3 @@
141 @@ -1,1 +1,3 @@
142 a
142 a
143 +a
143 +a
144 +a
144 +a
145 $ hg log
145 $ hg log
146 changeset: 1:1cd866679df8
146 changeset: 1:1cd866679df8
147 tag: tip
147 tag: tip
148 user: test
148 user: test
149 date: Thu Jan 01 00:00:00 1970 +0000
149 date: Thu Jan 01 00:00:00 1970 +0000
150 summary: no changes, new message
150 summary: no changes, new message
151
151
152 changeset: 0:ad120869acf0
152 changeset: 0:ad120869acf0
153 user: test
153 user: test
154 date: Thu Jan 01 00:00:00 1970 +0000
154 date: Thu Jan 01 00:00:00 1970 +0000
155 summary: base
155 summary: base
156
156
157
157
158 Disable default date on commit so when -d isn't given, the old date is preserved:
158 Disable default date on commit so when -d isn't given, the old date is preserved:
159
159
160 $ echo '[defaults]' >> $HGRCPATH
160 $ echo '[defaults]' >> $HGRCPATH
161 $ echo 'commit=' >> $HGRCPATH
161 $ echo 'commit=' >> $HGRCPATH
162
162
163 Test -u/-d:
163 Test -u/-d:
164
164
165 $ cat > .hg/checkeditform.sh <<EOF
165 $ cat > .hg/checkeditform.sh <<EOF
166 > env | grep HGEDITFORM
166 > env | grep HGEDITFORM
167 > true
167 > true
168 > EOF
168 > EOF
169 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
169 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
170 HGEDITFORM=commit.amend.normal
170 HGEDITFORM=commit.amend.normal
171 saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-5f5bcb85-amend.hg (glob)
171 saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-5f5bcb85-amend.hg (glob)
172 $ echo a >> a
172 $ echo a >> a
173 $ hg ci --amend -u foo -d '1 0'
173 $ hg ci --amend -u foo -d '1 0'
174 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-83b10a27-amend.hg (glob)
174 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-83b10a27-amend.hg (glob)
175 $ hg log -r .
175 $ hg log -r .
176 changeset: 1:5f357c7560ab
176 changeset: 1:5f357c7560ab
177 tag: tip
177 tag: tip
178 user: foo
178 user: foo
179 date: Thu Jan 01 00:00:01 1970 +0000
179 date: Thu Jan 01 00:00:01 1970 +0000
180 summary: no changes, new message
180 summary: no changes, new message
181
181
182
182
183 Open editor with old commit message if a message isn't given otherwise:
183 Open editor with old commit message if a message isn't given otherwise:
184
184
185 $ cat > editor.sh << '__EOF__'
185 $ cat > editor.sh << '__EOF__'
186 > #!/bin/sh
186 > #!/bin/sh
187 > cat $1
187 > cat $1
188 > echo "another precious commit message" > "$1"
188 > echo "another precious commit message" > "$1"
189 > __EOF__
189 > __EOF__
190
190
191 at first, test saving last-message.txt
191 at first, test saving last-message.txt
192
192
193 $ cat > .hg/hgrc << '__EOF__'
193 $ cat > .hg/hgrc << '__EOF__'
194 > [hooks]
194 > [hooks]
195 > pretxncommit.test-saving-last-message = false
195 > pretxncommit.test-saving-last-message = false
196 > __EOF__
196 > __EOF__
197
197
198 $ rm -f .hg/last-message.txt
198 $ rm -f .hg/last-message.txt
199 $ hg commit --amend -v -m "message given from command line"
199 $ hg commit --amend -v -m "message given from command line"
200 amending changeset 5f357c7560ab
200 amending changeset 5f357c7560ab
201 copying changeset 5f357c7560ab to ad120869acf0
201 copying changeset 5f357c7560ab to ad120869acf0
202 committing files:
202 committing files:
203 a
203 a
204 committing manifest
204 committing manifest
205 committing changelog
205 committing changelog
206 running hook pretxncommit.test-saving-last-message: false
206 running hook pretxncommit.test-saving-last-message: false
207 transaction abort!
207 transaction abort!
208 rollback completed
208 rollback completed
209 abort: pretxncommit.test-saving-last-message hook exited with status 1
209 abort: pretxncommit.test-saving-last-message hook exited with status 1
210 [255]
210 [255]
211 $ cat .hg/last-message.txt
211 $ cat .hg/last-message.txt
212 message given from command line (no-eol)
212 message given from command line (no-eol)
213
213
214 $ rm -f .hg/last-message.txt
214 $ rm -f .hg/last-message.txt
215 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
215 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
216 amending changeset 5f357c7560ab
216 amending changeset 5f357c7560ab
217 copying changeset 5f357c7560ab to ad120869acf0
217 copying changeset 5f357c7560ab to ad120869acf0
218 no changes, new message
218 no changes, new message
219
219
220
220
221 HG: Enter commit message. Lines beginning with 'HG:' are removed.
221 HG: Enter commit message. Lines beginning with 'HG:' are removed.
222 HG: Leave message empty to abort commit.
222 HG: Leave message empty to abort commit.
223 HG: --
223 HG: --
224 HG: user: foo
224 HG: user: foo
225 HG: branch 'default'
225 HG: branch 'default'
226 HG: changed a
226 HG: changed a
227 committing files:
227 committing files:
228 a
228 a
229 committing manifest
229 committing manifest
230 committing changelog
230 committing changelog
231 running hook pretxncommit.test-saving-last-message: false
231 running hook pretxncommit.test-saving-last-message: false
232 transaction abort!
232 transaction abort!
233 rollback completed
233 rollback completed
234 abort: pretxncommit.test-saving-last-message hook exited with status 1
234 abort: pretxncommit.test-saving-last-message hook exited with status 1
235 [255]
235 [255]
236
236
237 $ cat .hg/last-message.txt
237 $ cat .hg/last-message.txt
238 another precious commit message
238 another precious commit message
239
239
240 $ cat > .hg/hgrc << '__EOF__'
240 $ cat > .hg/hgrc << '__EOF__'
241 > [hooks]
241 > [hooks]
242 > pretxncommit.test-saving-last-message =
242 > pretxncommit.test-saving-last-message =
243 > __EOF__
243 > __EOF__
244
244
245 then, test editing custom commit message
245 then, test editing custom commit message
246
246
247 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
247 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
248 amending changeset 5f357c7560ab
248 amending changeset 5f357c7560ab
249 copying changeset 5f357c7560ab to ad120869acf0
249 copying changeset 5f357c7560ab to ad120869acf0
250 no changes, new message
250 no changes, new message
251
251
252
252
253 HG: Enter commit message. Lines beginning with 'HG:' are removed.
253 HG: Enter commit message. Lines beginning with 'HG:' are removed.
254 HG: Leave message empty to abort commit.
254 HG: Leave message empty to abort commit.
255 HG: --
255 HG: --
256 HG: user: foo
256 HG: user: foo
257 HG: branch 'default'
257 HG: branch 'default'
258 HG: changed a
258 HG: changed a
259 committing files:
259 committing files:
260 a
260 a
261 committing manifest
261 committing manifest
262 committing changelog
262 committing changelog
263 1 changesets found
263 1 changesets found
264 uncompressed size of bundle content:
264 uncompressed size of bundle content:
265 249 (changelog)
265 249 (changelog)
266 163 (manifests)
266 163 (manifests)
267 131 a
267 131 a
268 saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-e7c84ade-amend.hg (glob)
268 saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-e7c84ade-amend.hg (glob)
269 1 changesets found
269 1 changesets found
270 uncompressed size of bundle content:
270 uncompressed size of bundle content:
271 257 (changelog)
271 257 (changelog)
272 163 (manifests)
272 163 (manifests)
273 131 a
273 131 a
274 adding branch
274 adding branch
275 adding changesets
275 adding changesets
276 adding manifests
276 adding manifests
277 adding file changes
277 adding file changes
278 added 1 changesets with 1 changes to 1 files
278 added 1 changesets with 1 changes to 1 files
279 committed changeset 1:7ab3bf440b54
279 committed changeset 1:7ab3bf440b54
280
280
281 Same, but with changes in working dir (different code path):
281 Same, but with changes in working dir (different code path):
282
282
283 $ echo a >> a
283 $ echo a >> a
284 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
284 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
285 amending changeset 7ab3bf440b54
285 amending changeset 7ab3bf440b54
286 committing files:
286 committing files:
287 a
287 a
288 committing manifest
288 committing manifest
289 committing changelog
289 committing changelog
290 copying changeset a0ea9b1a4c8c to ad120869acf0
290 copying changeset a0ea9b1a4c8c to ad120869acf0
291 another precious commit message
291 another precious commit message
292
292
293
293
294 HG: Enter commit message. Lines beginning with 'HG:' are removed.
294 HG: Enter commit message. Lines beginning with 'HG:' are removed.
295 HG: Leave message empty to abort commit.
295 HG: Leave message empty to abort commit.
296 HG: --
296 HG: --
297 HG: user: foo
297 HG: user: foo
298 HG: branch 'default'
298 HG: branch 'default'
299 HG: changed a
299 HG: changed a
300 committing files:
300 committing files:
301 a
301 a
302 committing manifest
302 committing manifest
303 committing changelog
303 committing changelog
304 2 changesets found
304 2 changesets found
305 uncompressed size of bundle content:
305 uncompressed size of bundle content:
306 464 (changelog)
306 464 (changelog)
307 322 (manifests)
307 322 (manifests)
308 249 a
308 249 a
309 saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-8e3b5088-amend.hg (glob)
309 saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-8e3b5088-amend.hg (glob)
310 1 changesets found
310 1 changesets found
311 uncompressed size of bundle content:
311 uncompressed size of bundle content:
312 257 (changelog)
312 257 (changelog)
313 163 (manifests)
313 163 (manifests)
314 133 a
314 133 a
315 adding branch
315 adding branch
316 adding changesets
316 adding changesets
317 adding manifests
317 adding manifests
318 adding file changes
318 adding file changes
319 added 1 changesets with 1 changes to 1 files
319 added 1 changesets with 1 changes to 1 files
320 committed changeset 1:ea22a388757c
320 committed changeset 1:ea22a388757c
321
321
322 $ rm editor.sh
322 $ rm editor.sh
323 $ hg log -r .
323 $ hg log -r .
324 changeset: 1:ea22a388757c
324 changeset: 1:ea22a388757c
325 tag: tip
325 tag: tip
326 user: foo
326 user: foo
327 date: Thu Jan 01 00:00:01 1970 +0000
327 date: Thu Jan 01 00:00:01 1970 +0000
328 summary: another precious commit message
328 summary: another precious commit message
329
329
330
330
331 Moving bookmarks, preserve active bookmark:
331 Moving bookmarks, preserve active bookmark:
332
332
333 $ hg book book1
333 $ hg book book1
334 $ hg book book2
334 $ hg book book2
335 $ hg ci --amend -m 'move bookmarks'
335 $ hg ci --amend -m 'move bookmarks'
336 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-e51094db-amend.hg (glob)
336 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-e51094db-amend.hg (glob)
337 $ hg book
337 $ hg book
338 book1 1:6cec5aa930e2
338 book1 1:6cec5aa930e2
339 * book2 1:6cec5aa930e2
339 * book2 1:6cec5aa930e2
340 $ echo a >> a
340 $ echo a >> a
341 $ hg ci --amend -m 'move bookmarks'
341 $ hg ci --amend -m 'move bookmarks'
342 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-e9b06de4-amend.hg (glob)
342 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-e9b06de4-amend.hg (glob)
343 $ hg book
343 $ hg book
344 book1 1:48bb6e53a15f
344 book1 1:48bb6e53a15f
345 * book2 1:48bb6e53a15f
345 * book2 1:48bb6e53a15f
346
346
347 abort does not loose bookmarks
347 abort does not loose bookmarks
348
348
349 $ cat > editor.sh << '__EOF__'
349 $ cat > editor.sh << '__EOF__'
350 > #!/bin/sh
350 > #!/bin/sh
351 > echo "" > "$1"
351 > echo "" > "$1"
352 > __EOF__
352 > __EOF__
353 $ echo a >> a
353 $ echo a >> a
354 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
354 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
355 transaction abort!
355 transaction abort!
356 rollback completed
356 rollback completed
357 abort: empty commit message
357 abort: empty commit message
358 [255]
358 [255]
359 $ hg book
359 $ hg book
360 book1 1:48bb6e53a15f
360 book1 1:48bb6e53a15f
361 * book2 1:48bb6e53a15f
361 * book2 1:48bb6e53a15f
362 $ hg revert -Caq
362 $ hg revert -Caq
363 $ rm editor.sh
363 $ rm editor.sh
364
364
365 $ echo '[defaults]' >> $HGRCPATH
365 $ echo '[defaults]' >> $HGRCPATH
366 $ echo "commit=-d '0 0'" >> $HGRCPATH
366 $ echo "commit=-d '0 0'" >> $HGRCPATH
367
367
368 Moving branches:
368 Moving branches:
369
369
370 $ hg branch foo
370 $ hg branch foo
371 marked working directory as branch foo
371 marked working directory as branch foo
372 (branches are permanent and global, did you want a bookmark?)
372 (branches are permanent and global, did you want a bookmark?)
373 $ echo a >> a
373 $ echo a >> a
374 $ hg ci -m 'branch foo'
374 $ hg ci -m 'branch foo'
375 $ hg branch default -f
375 $ hg branch default -f
376 marked working directory as branch default
376 marked working directory as branch default
377 $ hg ci --amend -m 'back to default'
377 $ hg ci --amend -m 'back to default'
378 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-fd962fef-amend.hg (glob)
378 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-fd962fef-amend.hg (glob)
379 $ hg branches
379 $ hg branches
380 default 2:ce12b0b57d46
380 default 2:ce12b0b57d46
381
381
382 Close branch:
382 Close branch:
383
383
384 $ hg up -q 0
384 $ hg up -q 0
385 $ echo b >> b
385 $ echo b >> b
386 $ hg branch foo
386 $ hg branch foo
387 marked working directory as branch foo
387 marked working directory as branch foo
388 (branches are permanent and global, did you want a bookmark?)
388 (branches are permanent and global, did you want a bookmark?)
389 $ hg ci -Am 'fork'
389 $ hg ci -Am 'fork'
390 adding b
390 adding b
391 $ echo b >> b
391 $ echo b >> b
392 $ hg ci -mb
392 $ hg ci -mb
393 $ hg ci --amend --close-branch -m 'closing branch foo'
393 $ hg ci --amend --close-branch -m 'closing branch foo'
394 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-6701c392-amend.hg (glob)
394 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-6701c392-amend.hg (glob)
395
395
396 Same thing, different code path:
396 Same thing, different code path:
397
397
398 $ echo b >> b
398 $ echo b >> b
399 $ hg ci -m 'reopen branch'
399 $ hg ci -m 'reopen branch'
400 reopening closed branch head 4
400 reopening closed branch head 4
401 $ echo b >> b
401 $ echo b >> b
402 $ hg ci --amend --close-branch
402 $ hg ci --amend --close-branch
403 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-49c0c55d-amend.hg (glob)
403 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-49c0c55d-amend.hg (glob)
404 $ hg branches
404 $ hg branches
405 default 2:ce12b0b57d46
405 default 2:ce12b0b57d46
406
406
407 Refuse to amend during a merge:
407 Refuse to amend during a merge:
408
408
409 $ hg up -q default
409 $ hg up -q default
410 $ hg merge foo
410 $ hg merge foo
411 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
411 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
412 (branch merge, don't forget to commit)
412 (branch merge, don't forget to commit)
413 $ hg ci --amend
413 $ hg ci --amend
414 abort: cannot amend while merging
414 abort: cannot amend while merging
415 [255]
415 [255]
416 $ hg ci -m 'merge'
416 $ hg ci -m 'merge'
417
417
418 Follow copies/renames:
418 Follow copies/renames:
419
419
420 $ hg mv b c
420 $ hg mv b c
421 $ hg ci -m 'b -> c'
421 $ hg ci -m 'b -> c'
422 $ hg mv c d
422 $ hg mv c d
423 $ hg ci --amend -m 'b -> d'
423 $ hg ci --amend -m 'b -> d'
424 saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-adaaa8b1-amend.hg (glob)
424 saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-adaaa8b1-amend.hg (glob)
425 $ hg st --rev '.^' --copies d
425 $ hg st --rev '.^' --copies d
426 A d
426 A d
427 b
427 b
428 $ hg cp d e
428 $ hg cp d e
429 $ hg ci -m 'e = d'
429 $ hg ci -m 'e = d'
430 $ hg cp e f
430 $ hg cp e f
431 $ hg ci --amend -m 'f = d'
431 $ hg ci --amend -m 'f = d'
432 saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-d37aa788-amend.hg (glob)
432 saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-d37aa788-amend.hg (glob)
433 $ hg st --rev '.^' --copies f
433 $ hg st --rev '.^' --copies f
434 A f
434 A f
435 d
435 d
436
436
437 $ mv f f.orig
437 $ mv f f.orig
438 $ hg rm -A f
438 $ hg rm -A f
439 $ hg ci -m removef
439 $ hg ci -m removef
440 $ hg cp a f
440 $ hg cp a f
441 $ mv f.orig f
441 $ mv f.orig f
442 $ hg ci --amend -m replacef
442 $ hg ci --amend -m replacef
443 saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-90259f67-amend.hg (glob)
443 saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-90259f67-amend.hg (glob)
444 $ hg st --change . --copies
444 $ hg st --change . --copies
445 $ hg log -r . --template "{file_copies}\n"
445 $ hg log -r . --template "{file_copies}\n"
446
446
447
447
448 Move added file (issue3410):
448 Move added file (issue3410):
449
449
450 $ echo g >> g
450 $ echo g >> g
451 $ hg ci -Am g
451 $ hg ci -Am g
452 adding g
452 adding g
453 $ hg mv g h
453 $ hg mv g h
454 $ hg ci --amend
454 $ hg ci --amend
455 saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-7059e0f1-amend.hg (glob)
455 saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-7059e0f1-amend.hg (glob)
456 $ hg st --change . --copies h
456 $ hg st --change . --copies h
457 A h
457 A h
458 $ hg log -r . --template "{file_copies}\n"
458 $ hg log -r . --template "{file_copies}\n"
459
459
460
460
461 Can't rollback an amend:
461 Can't rollback an amend:
462
462
463 $ hg rollback
463 $ hg rollback
464 no rollback information available
464 no rollback information available
465 [1]
465 [1]
466
466
467 Preserve extra dict (issue3430):
467 Preserve extra dict (issue3430):
468
468
469 $ hg branch a
469 $ hg branch a
470 marked working directory as branch a
470 marked working directory as branch a
471 (branches are permanent and global, did you want a bookmark?)
471 (branches are permanent and global, did you want a bookmark?)
472 $ echo a >> a
472 $ echo a >> a
473 $ hg ci -ma
473 $ hg ci -ma
474 $ hg ci --amend -m "a'"
474 $ hg ci --amend -m "a'"
475 saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-2be01fd1-amend.hg (glob)
475 saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-2be01fd1-amend.hg (glob)
476 $ hg log -r . --template "{branch}\n"
476 $ hg log -r . --template "{branch}\n"
477 a
477 a
478 $ hg ci --amend -m "a''"
478 $ hg ci --amend -m "a''"
479 saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-ed28c4cd-amend.hg (glob)
479 saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-ed28c4cd-amend.hg (glob)
480 $ hg log -r . --template "{branch}\n"
480 $ hg log -r . --template "{branch}\n"
481 a
481 a
482
482
483 Also preserve other entries in the dict that are in the old commit,
483 Also preserve other entries in the dict that are in the old commit,
484 first graft something so there's an additional entry:
484 first graft something so there's an additional entry:
485
485
486 $ hg up 0 -q
486 $ hg up 0 -q
487 $ echo z > z
487 $ echo z > z
488 $ hg ci -Am 'fork'
488 $ hg ci -Am 'fork'
489 adding z
489 adding z
490 created new head
490 created new head
491 $ hg up 11
491 $ hg up 11
492 5 files updated, 0 files merged, 1 files removed, 0 files unresolved
492 5 files updated, 0 files merged, 1 files removed, 0 files unresolved
493 $ hg graft 12
493 $ hg graft 12
494 grafting 12:2647734878ef "fork" (tip)
494 grafting 12:2647734878ef "fork" (tip)
495 $ hg ci --amend -m 'graft amend'
495 $ hg ci --amend -m 'graft amend'
496 saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-eedb103b-amend.hg (glob)
496 saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-eedb103b-amend.hg (glob)
497 $ hg log -r . --debug | grep extra
497 $ hg log -r . --debug | grep extra
498 extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e
498 extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e
499 extra: branch=a
499 extra: branch=a
500 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
500 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
501
501
502 Preserve phase
502 Preserve phase
503
503
504 $ hg phase '.^::.'
504 $ hg phase '.^::.'
505 11: draft
505 11: draft
506 13: draft
506 13: draft
507 $ hg phase --secret --force .
507 $ hg phase --secret --force .
508 $ hg phase '.^::.'
508 $ hg phase '.^::.'
509 11: draft
509 11: draft
510 13: secret
510 13: secret
511 $ hg commit --amend -m 'amend for phase' -q
511 $ hg commit --amend -m 'amend for phase' -q
512 $ hg phase '.^::.'
512 $ hg phase '.^::.'
513 11: draft
513 11: draft
514 13: secret
514 13: secret
515
515
516 Test amend with obsolete
516 Test amend with obsolete
517 ---------------------------
517 ---------------------------
518
518
519 Enable obsolete
519 Enable obsolete
520
520
521 $ cat >> $HGRCPATH << EOF
521 $ cat >> $HGRCPATH << EOF
522 > [experimental]
522 > [experimental]
523 > stabilization=createmarkers,allowunstable
523 > stabilization=createmarkers,allowunstable
524 > EOF
524 > EOF
525
525
526 Amend with no files changes
526 Amend with no files changes
527
527
528 $ hg id -n
528 $ hg id -n
529 13
529 13
530 $ hg ci --amend -m 'babar'
530 $ hg ci --amend -m 'babar'
531 $ hg id -n
531 $ hg id -n
532 14
532 14
533 $ hg log -Gl 3 --style=compact
533 $ hg log -Gl 3 --style=compact
534 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
534 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
535 | babar
535 | babar
536 |
536 |
537 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
537 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
538 | | fork
538 | | fork
539 | ~
539 | ~
540 o 11 3334b7925910 1970-01-01 00:00 +0000 test
540 o 11 3334b7925910 1970-01-01 00:00 +0000 test
541 | a''
541 | a''
542 ~
542 ~
543 $ hg log -Gl 4 --hidden --style=compact
543 $ hg log -Gl 4 --hidden --style=compact
544 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
544 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
545 | babar
545 | babar
546 |
546 |
547 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
547 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
548 |/ amend for phase
548 |/ amend for phase
549 |
549 |
550 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
550 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
551 | | fork
551 | | fork
552 | ~
552 | ~
553 o 11 3334b7925910 1970-01-01 00:00 +0000 test
553 o 11 3334b7925910 1970-01-01 00:00 +0000 test
554 | a''
554 | a''
555 ~
555 ~
556
556
557 Amend with files changes
557 Amend with files changes
558
558
559 (note: the extra commit over 15 is a temporary junk I would be happy to get
559 (note: the extra commit over 15 is a temporary junk I would be happy to get
560 ride of)
560 ride of)
561
561
562 $ echo 'babar' >> a
562 $ echo 'babar' >> a
563 $ hg commit --amend
563 $ hg commit --amend
564 $ hg log -Gl 6 --hidden --style=compact
564 $ hg log -Gl 6 --hidden --style=compact
565 @ 16[tip]:11 9f9e9bccf56c 1970-01-01 00:00 +0000 test
565 @ 16[tip]:11 9f9e9bccf56c 1970-01-01 00:00 +0000 test
566 | babar
566 | babar
567 |
567 |
568 | x 15 90fef497c56f 1970-01-01 00:00 +0000 test
568 | x 15 90fef497c56f 1970-01-01 00:00 +0000 test
569 | | temporary amend commit for b650e6ee8614
569 | | temporary amend commit for b650e6ee8614
570 | |
570 | |
571 | x 14:11 b650e6ee8614 1970-01-01 00:00 +0000 test
571 | x 14:11 b650e6ee8614 1970-01-01 00:00 +0000 test
572 |/ babar
572 |/ babar
573 |
573 |
574 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
574 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
575 |/ amend for phase
575 |/ amend for phase
576 |
576 |
577 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
577 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
578 | | fork
578 | | fork
579 | ~
579 | ~
580 o 11 3334b7925910 1970-01-01 00:00 +0000 test
580 o 11 3334b7925910 1970-01-01 00:00 +0000 test
581 | a''
581 | a''
582 ~
582 ~
583
583
584
584
585 Test that amend does not make it easy to create obsolescence cycle
585 Test that amend does not make it easy to create obsolescence cycle
586 ---------------------------------------------------------------------
586 ---------------------------------------------------------------------
587
587
588 $ hg id -r 14 --hidden
588 $ hg id -r 14 --hidden
589 b650e6ee8614 (a)
589 b650e6ee8614 (a)
590 $ hg revert -ar 14 --hidden
590 $ hg revert -ar 14 --hidden
591 reverting a
591 reverting a
592 $ hg commit --amend
592 $ hg commit --amend
593 $ hg id
593 $ hg id
594 b99e5df575f7 (a) tip
594 b99e5df575f7 (a) tip
595
595
596 Test that rewriting leaving instability behind is allowed
596 Test that rewriting leaving instability behind is allowed
597 ---------------------------------------------------------------------
597 ---------------------------------------------------------------------
598
598
599 $ hg up '.^'
599 $ hg up '.^'
600 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
600 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
601 $ echo 'b' >> a
601 $ echo 'b' >> a
602 $ hg log --style compact -r 'children(.)'
602 $ hg log --style compact -r 'children(.)'
603 18[tip]:11 b99e5df575f7 1970-01-01 00:00 +0000 test
603 18[tip]:11 b99e5df575f7 1970-01-01 00:00 +0000 test
604 babar
604 babar
605
605
606 $ hg commit --amend
606 $ hg commit --amend
607 $ hg log -r 'orphan()'
607 $ hg log -r 'orphan()'
608 changeset: 18:b99e5df575f7
608 changeset: 18:b99e5df575f7
609 branch: a
609 branch: a
610 parent: 11:3334b7925910
610 parent: 11:3334b7925910
611 user: test
611 user: test
612 date: Thu Jan 01 00:00:00 1970 +0000
612 date: Thu Jan 01 00:00:00 1970 +0000
613 instability: orphan
613 instability: orphan
614 summary: babar
614 summary: babar
615
615
616
616
617 Amend a merge changeset (with renames and conflicts from the second parent):
617 Amend a merge changeset (with renames and conflicts from the second parent):
618
618
619 $ hg up -q default
619 $ hg up -q default
620 $ hg branch -q bar
620 $ hg branch -q bar
621 $ hg cp a aa
621 $ hg cp a aa
622 $ hg mv z zz
622 $ hg mv z zz
623 $ echo cc > cc
623 $ echo cc > cc
624 $ hg add cc
624 $ hg add cc
625 $ hg ci -m aazzcc
625 $ hg ci -m aazzcc
626 $ hg up -q default
626 $ hg up -q default
627 $ echo a >> a
627 $ echo a >> a
628 $ echo dd > cc
628 $ echo dd > cc
629 $ hg add cc
629 $ hg add cc
630 $ hg ci -m aa
630 $ hg ci -m aa
631 $ hg merge -q bar
631 $ hg merge -q bar
632 warning: conflicts while merging cc! (edit, then use 'hg resolve --mark')
632 warning: conflicts while merging cc! (edit, then use 'hg resolve --mark')
633 [1]
633 [1]
634 $ hg resolve -m cc
634 $ hg resolve -m cc
635 (no more unresolved files)
635 (no more unresolved files)
636 $ hg ci -m 'merge bar'
636 $ hg ci -m 'merge bar'
637 $ hg log --config diff.git=1 -pr .
637 $ hg log --config diff.git=1 -pr .
638 changeset: 23:163cfd7219f7
638 changeset: 23:163cfd7219f7
639 tag: tip
639 tag: tip
640 parent: 22:30d96aeaf27b
640 parent: 22:30d96aeaf27b
641 parent: 21:1aa437659d19
641 parent: 21:1aa437659d19
642 user: test
642 user: test
643 date: Thu Jan 01 00:00:00 1970 +0000
643 date: Thu Jan 01 00:00:00 1970 +0000
644 summary: merge bar
644 summary: merge bar
645
645
646 diff --git a/a b/aa
646 diff --git a/a b/aa
647 copy from a
647 copy from a
648 copy to aa
648 copy to aa
649 diff --git a/cc b/cc
649 diff --git a/cc b/cc
650 --- a/cc
650 --- a/cc
651 +++ b/cc
651 +++ b/cc
652 @@ -1,1 +1,5 @@
652 @@ -1,1 +1,5 @@
653 +<<<<<<< working copy: 30d96aeaf27b - test: aa
653 +<<<<<<< working copy: 30d96aeaf27b - test: aa
654 dd
654 dd
655 +=======
655 +=======
656 +cc
656 +cc
657 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
657 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
658 diff --git a/z b/zz
658 diff --git a/z b/zz
659 rename from z
659 rename from z
660 rename to zz
660 rename to zz
661
661
662 $ hg debugrename aa
662 $ hg debugrename aa
663 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
663 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
664 $ hg debugrename zz
664 $ hg debugrename zz
665 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
665 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
666 $ hg debugrename cc
666 $ hg debugrename cc
667 cc not renamed
667 cc not renamed
668 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit
668 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit
669 HGEDITFORM=commit.amend.merge
669 HGEDITFORM=commit.amend.merge
670 $ hg log --config diff.git=1 -pr .
670 $ hg log --config diff.git=1 -pr .
671 changeset: 24:bca52d4ed186
671 changeset: 24:bca52d4ed186
672 tag: tip
672 tag: tip
673 parent: 22:30d96aeaf27b
673 parent: 22:30d96aeaf27b
674 parent: 21:1aa437659d19
674 parent: 21:1aa437659d19
675 user: test
675 user: test
676 date: Thu Jan 01 00:00:00 1970 +0000
676 date: Thu Jan 01 00:00:00 1970 +0000
677 summary: merge bar (amend message)
677 summary: merge bar (amend message)
678
678
679 diff --git a/a b/aa
679 diff --git a/a b/aa
680 copy from a
680 copy from a
681 copy to aa
681 copy to aa
682 diff --git a/cc b/cc
682 diff --git a/cc b/cc
683 --- a/cc
683 --- a/cc
684 +++ b/cc
684 +++ b/cc
685 @@ -1,1 +1,5 @@
685 @@ -1,1 +1,5 @@
686 +<<<<<<< working copy: 30d96aeaf27b - test: aa
686 +<<<<<<< working copy: 30d96aeaf27b - test: aa
687 dd
687 dd
688 +=======
688 +=======
689 +cc
689 +cc
690 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
690 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
691 diff --git a/z b/zz
691 diff --git a/z b/zz
692 rename from z
692 rename from z
693 rename to zz
693 rename to zz
694
694
695 $ hg debugrename aa
695 $ hg debugrename aa
696 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
696 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
697 $ hg debugrename zz
697 $ hg debugrename zz
698 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
698 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
699 $ hg debugrename cc
699 $ hg debugrename cc
700 cc not renamed
700 cc not renamed
701 $ hg mv zz z
701 $ hg mv zz z
702 $ hg ci --amend -m 'merge bar (undo rename)'
702 $ hg ci --amend -m 'merge bar (undo rename)'
703 $ hg log --config diff.git=1 -pr .
703 $ hg log --config diff.git=1 -pr .
704 changeset: 26:12594a98ca3f
704 changeset: 26:12594a98ca3f
705 tag: tip
705 tag: tip
706 parent: 22:30d96aeaf27b
706 parent: 22:30d96aeaf27b
707 parent: 21:1aa437659d19
707 parent: 21:1aa437659d19
708 user: test
708 user: test
709 date: Thu Jan 01 00:00:00 1970 +0000
709 date: Thu Jan 01 00:00:00 1970 +0000
710 summary: merge bar (undo rename)
710 summary: merge bar (undo rename)
711
711
712 diff --git a/a b/aa
712 diff --git a/a b/aa
713 copy from a
713 copy from a
714 copy to aa
714 copy to aa
715 diff --git a/cc b/cc
715 diff --git a/cc b/cc
716 --- a/cc
716 --- a/cc
717 +++ b/cc
717 +++ b/cc
718 @@ -1,1 +1,5 @@
718 @@ -1,1 +1,5 @@
719 +<<<<<<< working copy: 30d96aeaf27b - test: aa
719 +<<<<<<< working copy: 30d96aeaf27b - test: aa
720 dd
720 dd
721 +=======
721 +=======
722 +cc
722 +cc
723 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
723 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
724
724
725 $ hg debugrename z
725 $ hg debugrename z
726 z not renamed
726 z not renamed
727
727
728 Amend a merge changeset (with renames during the merge):
728 Amend a merge changeset (with renames during the merge):
729
729
730 $ hg up -q bar
730 $ hg up -q bar
731 $ echo x > x
731 $ echo x > x
732 $ hg add x
732 $ hg add x
733 $ hg ci -m x
733 $ hg ci -m x
734 $ hg up -q default
734 $ hg up -q default
735 $ hg merge -q bar
735 $ hg merge -q bar
736 $ hg mv aa aaa
736 $ hg mv aa aaa
737 $ echo aa >> aaa
737 $ echo aa >> aaa
738 $ hg ci -m 'merge bar again'
738 $ hg ci -m 'merge bar again'
739 $ hg log --config diff.git=1 -pr .
739 $ hg log --config diff.git=1 -pr .
740 changeset: 28:dffde028b388
740 changeset: 28:dffde028b388
741 tag: tip
741 tag: tip
742 parent: 26:12594a98ca3f
742 parent: 26:12594a98ca3f
743 parent: 27:4c94d5bc65f5
743 parent: 27:4c94d5bc65f5
744 user: test
744 user: test
745 date: Thu Jan 01 00:00:00 1970 +0000
745 date: Thu Jan 01 00:00:00 1970 +0000
746 summary: merge bar again
746 summary: merge bar again
747
747
748 diff --git a/aa b/aa
748 diff --git a/aa b/aa
749 deleted file mode 100644
749 deleted file mode 100644
750 --- a/aa
750 --- a/aa
751 +++ /dev/null
751 +++ /dev/null
752 @@ -1,2 +0,0 @@
752 @@ -1,2 +0,0 @@
753 -a
753 -a
754 -a
754 -a
755 diff --git a/aaa b/aaa
755 diff --git a/aaa b/aaa
756 new file mode 100644
756 new file mode 100644
757 --- /dev/null
757 --- /dev/null
758 +++ b/aaa
758 +++ b/aaa
759 @@ -0,0 +1,3 @@
759 @@ -0,0 +1,3 @@
760 +a
760 +a
761 +a
761 +a
762 +aa
762 +aa
763 diff --git a/x b/x
763 diff --git a/x b/x
764 new file mode 100644
764 new file mode 100644
765 --- /dev/null
765 --- /dev/null
766 +++ b/x
766 +++ b/x
767 @@ -0,0 +1,1 @@
767 @@ -0,0 +1,1 @@
768 +x
768 +x
769
769
770 $ hg debugrename aaa
770 $ hg debugrename aaa
771 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980
771 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980
772 $ hg mv aaa aa
772 $ hg mv aaa aa
773 $ hg ci --amend -m 'merge bar again (undo rename)'
773 $ hg ci --amend -m 'merge bar again (undo rename)'
774 $ hg log --config diff.git=1 -pr .
774 $ hg log --config diff.git=1 -pr .
775 changeset: 30:18e3ba160489
775 changeset: 30:18e3ba160489
776 tag: tip
776 tag: tip
777 parent: 26:12594a98ca3f
777 parent: 26:12594a98ca3f
778 parent: 27:4c94d5bc65f5
778 parent: 27:4c94d5bc65f5
779 user: test
779 user: test
780 date: Thu Jan 01 00:00:00 1970 +0000
780 date: Thu Jan 01 00:00:00 1970 +0000
781 summary: merge bar again (undo rename)
781 summary: merge bar again (undo rename)
782
782
783 diff --git a/aa b/aa
783 diff --git a/aa b/aa
784 --- a/aa
784 --- a/aa
785 +++ b/aa
785 +++ b/aa
786 @@ -1,2 +1,3 @@
786 @@ -1,2 +1,3 @@
787 a
787 a
788 a
788 a
789 +aa
789 +aa
790 diff --git a/x b/x
790 diff --git a/x b/x
791 new file mode 100644
791 new file mode 100644
792 --- /dev/null
792 --- /dev/null
793 +++ b/x
793 +++ b/x
794 @@ -0,0 +1,1 @@
794 @@ -0,0 +1,1 @@
795 +x
795 +x
796
796
797 $ hg debugrename aa
797 $ hg debugrename aa
798 aa not renamed
798 aa not renamed
799 $ hg debugrename -r '.^' aa
799 $ hg debugrename -r '.^' aa
800 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
800 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
801
801
802 Amend a merge changeset (with manifest-level conflicts):
802 Amend a merge changeset (with manifest-level conflicts):
803
803
804 $ hg up -q bar
804 $ hg up -q bar
805 $ hg rm aa
805 $ hg rm aa
806 $ hg ci -m 'rm aa'
806 $ hg ci -m 'rm aa'
807 $ hg up -q default
807 $ hg up -q default
808 $ echo aa >> aa
808 $ echo aa >> aa
809 $ hg ci -m aa
809 $ hg ci -m aa
810 $ hg merge -q bar --config ui.interactive=True << EOF
810 $ hg merge -q bar --config ui.interactive=True << EOF
811 > c
811 > c
812 > EOF
812 > EOF
813 local [working copy] changed aa which other [merge rev] deleted
813 local [working copy] changed aa which other [merge rev] deleted
814 use (c)hanged version, (d)elete, or leave (u)nresolved? c
814 use (c)hanged version, (d)elete, or leave (u)nresolved? c
815 $ hg ci -m 'merge bar (with conflicts)'
815 $ hg ci -m 'merge bar (with conflicts)'
816 $ hg log --config diff.git=1 -pr .
816 $ hg log --config diff.git=1 -pr .
817 changeset: 33:b4c3035e2544
817 changeset: 33:b4c3035e2544
818 tag: tip
818 tag: tip
819 parent: 32:4b216ca5ba97
819 parent: 32:4b216ca5ba97
820 parent: 31:67db8847a540
820 parent: 31:67db8847a540
821 user: test
821 user: test
822 date: Thu Jan 01 00:00:00 1970 +0000
822 date: Thu Jan 01 00:00:00 1970 +0000
823 summary: merge bar (with conflicts)
823 summary: merge bar (with conflicts)
824
824
825
825
826 $ hg rm aa
826 $ hg rm aa
827 $ hg ci --amend -m 'merge bar (with conflicts, amended)'
827 $ hg ci --amend -m 'merge bar (with conflicts, amended)'
828 $ hg log --config diff.git=1 -pr .
828 $ hg log --config diff.git=1 -pr .
829 changeset: 35:1205ed810051
829 changeset: 35:1205ed810051
830 tag: tip
830 tag: tip
831 parent: 32:4b216ca5ba97
831 parent: 32:4b216ca5ba97
832 parent: 31:67db8847a540
832 parent: 31:67db8847a540
833 user: test
833 user: test
834 date: Thu Jan 01 00:00:00 1970 +0000
834 date: Thu Jan 01 00:00:00 1970 +0000
835 summary: merge bar (with conflicts, amended)
835 summary: merge bar (with conflicts, amended)
836
836
837 diff --git a/aa b/aa
837 diff --git a/aa b/aa
838 deleted file mode 100644
838 deleted file mode 100644
839 --- a/aa
839 --- a/aa
840 +++ /dev/null
840 +++ /dev/null
841 @@ -1,4 +0,0 @@
841 @@ -1,4 +0,0 @@
842 -a
842 -a
843 -a
843 -a
844 -aa
844 -aa
845 -aa
845 -aa
846
846
847 Issue 3445: amending with --close-branch a commit that created a new head should fail
847 Issue 3445: amending with --close-branch a commit that created a new head should fail
848 This shouldn't be possible:
848 This shouldn't be possible:
849
849
850 $ hg up -q default
850 $ hg up -q default
851 $ hg branch closewithamend
851 $ hg branch closewithamend
852 marked working directory as branch closewithamend
852 marked working directory as branch closewithamend
853 $ echo foo > foo
853 $ echo foo > foo
854 $ hg add foo
854 $ hg add foo
855 $ hg ci -m..
855 $ hg ci -m..
856 $ hg ci --amend --close-branch -m 'closing'
856 $ hg ci --amend --close-branch -m 'closing'
857 abort: can only close branch heads
857 abort: can only close branch heads
858 [255]
858 [255]
859
859
860 This silliness fails:
860 This silliness fails:
861
861
862 $ hg branch silliness
862 $ hg branch silliness
863 marked working directory as branch silliness
863 marked working directory as branch silliness
864 $ echo b >> b
864 $ echo b >> b
865 $ hg ci --close-branch -m'open and close'
865 $ hg ci --close-branch -m'open and close'
866 abort: can only close branch heads
866 abort: can only close branch heads
867 [255]
867 [255]
868
868
869 Test that amend with --secret creates new secret changeset forcibly
869 Test that amend with --secret creates new secret changeset forcibly
870 ---------------------------------------------------------------------
870 ---------------------------------------------------------------------
871
871
872 $ hg phase '.^::.'
872 $ hg phase '.^::.'
873 35: draft
873 35: draft
874 36: draft
874 36: draft
875 $ hg commit --amend --secret -m 'amend as secret' -q
875 $ hg commit --amend --secret -m 'amend as secret' -q
876 $ hg phase '.^::.'
876 $ hg phase '.^::.'
877 35: draft
877 35: draft
878 38: secret
878 38: secret
879
879
880 Test that amend with --edit invokes editor forcibly
880 Test that amend with --edit invokes editor forcibly
881 ---------------------------------------------------
881 ---------------------------------------------------
882
882
883 $ hg parents --template "{desc}\n"
883 $ hg parents --template "{desc}\n"
884 amend as secret
884 amend as secret
885 $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
885 $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
886 $ hg parents --template "{desc}\n"
886 $ hg parents --template "{desc}\n"
887 editor should be suppressed
887 editor should be suppressed
888
888
889 $ hg status --rev '.^1::.'
889 $ hg status --rev '.^1::.'
890 A foo
890 A foo
891 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
891 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
892 editor should be invoked
892 editor should be invoked
893
893
894
894
895 HG: Enter commit message. Lines beginning with 'HG:' are removed.
895 HG: Enter commit message. Lines beginning with 'HG:' are removed.
896 HG: Leave message empty to abort commit.
896 HG: Leave message empty to abort commit.
897 HG: --
897 HG: --
898 HG: user: test
898 HG: user: test
899 HG: branch 'silliness'
899 HG: branch 'silliness'
900 HG: added foo
900 HG: added foo
901 $ hg parents --template "{desc}\n"
901 $ hg parents --template "{desc}\n"
902 editor should be invoked
902 editor should be invoked
903
903
904 Test that "diff()" in committemplate works correctly for amending
904 Test that "diff()" in committemplate works correctly for amending
905 -----------------------------------------------------------------
905 -----------------------------------------------------------------
906
906
907 $ cat >> .hg/hgrc <<EOF
907 $ cat >> .hg/hgrc <<EOF
908 > [committemplate]
908 > [committemplate]
909 > changeset.commit.amend = {desc}\n
909 > changeset.commit.amend = {desc}\n
910 > HG: M: {file_mods}
910 > HG: M: {file_mods}
911 > HG: A: {file_adds}
911 > HG: A: {file_adds}
912 > HG: R: {file_dels}
912 > HG: R: {file_dels}
913 > {splitlines(diff()) % 'HG: {line}\n'}
913 > {splitlines(diff()) % 'HG: {line}\n'}
914 > EOF
914 > EOF
915
915
916 $ hg parents --template "M: {file_mods}\nA: {file_adds}\nR: {file_dels}\n"
916 $ hg parents --template "M: {file_mods}\nA: {file_adds}\nR: {file_dels}\n"
917 M:
917 M:
918 A: foo
918 A: foo
919 R:
919 R:
920 $ hg status -amr
920 $ hg status -amr
921 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo"
921 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo"
922 expecting diff of foo
922 expecting diff of foo
923
923
924 HG: M:
924 HG: M:
925 HG: A: foo
925 HG: A: foo
926 HG: R:
926 HG: R:
927 HG: diff -r 1205ed810051 foo
927 HG: diff -r 1205ed810051 foo
928 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
928 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
929 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
929 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
930 HG: @@ -0,0 +1,1 @@
930 HG: @@ -0,0 +1,1 @@
931 HG: +foo
931 HG: +foo
932
932
933 $ echo y > y
933 $ echo y > y
934 $ hg add y
934 $ hg add y
935 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo and y"
935 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo and y"
936 expecting diff of foo and y
936 expecting diff of foo and y
937
937
938 HG: M:
938 HG: M:
939 HG: A: foo y
939 HG: A: foo y
940 HG: R:
940 HG: R:
941 HG: diff -r 1205ed810051 foo
941 HG: diff -r 1205ed810051 foo
942 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
942 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
943 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
943 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
944 HG: @@ -0,0 +1,1 @@
944 HG: @@ -0,0 +1,1 @@
945 HG: +foo
945 HG: +foo
946 HG: diff -r 1205ed810051 y
946 HG: diff -r 1205ed810051 y
947 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
947 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
948 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
948 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
949 HG: @@ -0,0 +1,1 @@
949 HG: @@ -0,0 +1,1 @@
950 HG: +y
950 HG: +y
951
951
952 $ hg rm a
952 $ hg rm a
953 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y"
953 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y"
954 expecting diff of a, foo and y
954 expecting diff of a, foo and y
955
955
956 HG: M:
956 HG: M:
957 HG: A: foo y
957 HG: A: foo y
958 HG: R: a
958 HG: R: a
959 HG: diff -r 1205ed810051 a
959 HG: diff -r 1205ed810051 a
960 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
960 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
961 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
961 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
962 HG: @@ -1,2 +0,0 @@
962 HG: @@ -1,2 +0,0 @@
963 HG: -a
963 HG: -a
964 HG: -a
964 HG: -a
965 HG: diff -r 1205ed810051 foo
965 HG: diff -r 1205ed810051 foo
966 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
966 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
967 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
967 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
968 HG: @@ -0,0 +1,1 @@
968 HG: @@ -0,0 +1,1 @@
969 HG: +foo
969 HG: +foo
970 HG: diff -r 1205ed810051 y
970 HG: diff -r 1205ed810051 y
971 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
971 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
972 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
972 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
973 HG: @@ -0,0 +1,1 @@
973 HG: @@ -0,0 +1,1 @@
974 HG: +y
974 HG: +y
975
975
976 $ hg rm x
976 $ hg rm x
977 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y"
977 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y"
978 expecting diff of a, foo, x and y
978 expecting diff of a, foo, x and y
979
979
980 HG: M:
980 HG: M:
981 HG: A: foo y
981 HG: A: foo y
982 HG: R: a x
982 HG: R: a x
983 HG: diff -r 1205ed810051 a
983 HG: diff -r 1205ed810051 a
984 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
984 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
985 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
985 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
986 HG: @@ -1,2 +0,0 @@
986 HG: @@ -1,2 +0,0 @@
987 HG: -a
987 HG: -a
988 HG: -a
988 HG: -a
989 HG: diff -r 1205ed810051 foo
989 HG: diff -r 1205ed810051 foo
990 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
990 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
991 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
991 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
992 HG: @@ -0,0 +1,1 @@
992 HG: @@ -0,0 +1,1 @@
993 HG: +foo
993 HG: +foo
994 HG: diff -r 1205ed810051 x
994 HG: diff -r 1205ed810051 x
995 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
995 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
996 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
996 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
997 HG: @@ -1,1 +0,0 @@
997 HG: @@ -1,1 +0,0 @@
998 HG: -x
998 HG: -x
999 HG: diff -r 1205ed810051 y
999 HG: diff -r 1205ed810051 y
1000 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1000 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1001 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1001 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1002 HG: @@ -0,0 +1,1 @@
1002 HG: @@ -0,0 +1,1 @@
1003 HG: +y
1003 HG: +y
1004
1004
1005 $ echo cccc >> cc
1005 $ echo cccc >> cc
1006 $ hg status -amr
1006 $ hg status -amr
1007 M cc
1007 M cc
1008 $ HGEDITOR=cat hg commit --amend -e -m "cc should be excluded" -X cc
1008 $ HGEDITOR=cat hg commit --amend -e -m "cc should be excluded" -X cc
1009 cc should be excluded
1009 cc should be excluded
1010
1010
1011 HG: M:
1011 HG: M:
1012 HG: A: foo y
1012 HG: A: foo y
1013 HG: R: a x
1013 HG: R: a x
1014 HG: diff -r 1205ed810051 a
1014 HG: diff -r 1205ed810051 a
1015 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
1015 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
1016 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1016 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1017 HG: @@ -1,2 +0,0 @@
1017 HG: @@ -1,2 +0,0 @@
1018 HG: -a
1018 HG: -a
1019 HG: -a
1019 HG: -a
1020 HG: diff -r 1205ed810051 foo
1020 HG: diff -r 1205ed810051 foo
1021 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1021 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1022 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
1022 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
1023 HG: @@ -0,0 +1,1 @@
1023 HG: @@ -0,0 +1,1 @@
1024 HG: +foo
1024 HG: +foo
1025 HG: diff -r 1205ed810051 x
1025 HG: diff -r 1205ed810051 x
1026 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
1026 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
1027 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1027 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1028 HG: @@ -1,1 +0,0 @@
1028 HG: @@ -1,1 +0,0 @@
1029 HG: -x
1029 HG: -x
1030 HG: diff -r 1205ed810051 y
1030 HG: diff -r 1205ed810051 y
1031 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1031 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1032 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1032 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1033 HG: @@ -0,0 +1,1 @@
1033 HG: @@ -0,0 +1,1 @@
1034 HG: +y
1034 HG: +y
1035
1035
1036 Check for issue4405
1036 Check for issue4405
1037 -------------------
1037 -------------------
1038
1038
1039 Setup the repo with a file that gets moved in a second commit.
1039 Setup the repo with a file that gets moved in a second commit.
1040 $ hg init repo
1040 $ hg init repo
1041 $ cd repo
1041 $ cd repo
1042 $ touch a0
1042 $ touch a0
1043 $ hg add a0
1043 $ hg add a0
1044 $ hg commit -m a0
1044 $ hg commit -m a0
1045 $ hg mv a0 a1
1045 $ hg mv a0 a1
1046 $ hg commit -m a1
1046 $ hg commit -m a1
1047 $ hg up -q 0
1047 $ hg up -q 0
1048 $ hg log -G --template '{rev} {desc}'
1048 $ hg log -G --template '{rev} {desc}'
1049 o 1 a1
1049 o 1 a1
1050 |
1050 |
1051 @ 0 a0
1051 @ 0 a0
1052
1052
1053
1053
1054 Now we branch the repro, but re-use the file contents, so we have a divergence
1054 Now we branch the repro, but re-use the file contents, so we have a divergence
1055 in the file revlog topology and the changelog topology.
1055 in the file revlog topology and the changelog topology.
1056 $ hg revert --rev 1 --all
1056 $ hg revert --rev 1 --all
1057 removing a0
1057 removing a0
1058 adding a1
1058 adding a1
1059 $ hg ci -qm 'a1-amend'
1059 $ hg ci -qm 'a1-amend'
1060 $ hg log -G --template '{rev} {desc}'
1060 $ hg log -G --template '{rev} {desc}'
1061 @ 2 a1-amend
1061 @ 2 a1-amend
1062 |
1062 |
1063 | o 1 a1
1063 | o 1 a1
1064 |/
1064 |/
1065 o 0 a0
1065 o 0 a0
1066
1066
1067
1067
1068 The way mercurial does amends is to create a temporary commit (rev 3) and then
1068 The way mercurial does amends is to create a temporary commit (rev 3) and then
1069 fold the new and old commits together into another commit (rev 4). During this
1069 fold the new and old commits together into another commit (rev 4). During this
1070 process, _findlimit is called to check how far back to look for the transitive
1070 process, _findlimit is called to check how far back to look for the transitive
1071 closure of file copy information, but due to the divergence of the filelog
1071 closure of file copy information, but due to the divergence of the filelog
1072 and changelog graph topologies, before _findlimit was fixed, it returned a rev
1072 and changelog graph topologies, before _findlimit was fixed, it returned a rev
1073 which was not far enough back in this case.
1073 which was not far enough back in this case.
1074 $ hg mv a1 a2
1074 $ hg mv a1 a2
1075 $ hg status --copies --rev 0
1075 $ hg status --copies --rev 0
1076 A a2
1076 A a2
1077 a0
1077 a0
1078 R a0
1078 R a0
1079 $ hg ci --amend -q
1079 $ hg ci --amend -q
1080 $ hg log -G --template '{rev} {desc}'
1080 $ hg log -G --template '{rev} {desc}'
1081 @ 4 a1-amend
1081 @ 4 a1-amend
1082 |
1082 |
1083 | o 1 a1
1083 | o 1 a1
1084 |/
1084 |/
1085 o 0 a0
1085 o 0 a0
1086
1086
1087
1087
1088 Before the fix, the copy information was lost.
1088 Before the fix, the copy information was lost.
1089 $ hg status --copies --rev 0
1089 $ hg status --copies --rev 0
1090 A a2
1090 A a2
1091 a0
1091 a0
1092 R a0
1092 R a0
1093 $ cd ..
1093 $ cd ..
1094
1094
1095 Check that amend properly preserve rename from directory rename (issue-4516)
1095 Check that amend properly preserve rename from directory rename (issue-4516)
1096
1096
1097 If a parent of the merge renames a full directory, any files added to the old
1097 If a parent of the merge renames a full directory, any files added to the old
1098 directory in the other parent will be renamed to the new directory. For some
1098 directory in the other parent will be renamed to the new directory. For some
1099 reason, the rename metadata was when amending such merge. This test ensure we
1099 reason, the rename metadata was when amending such merge. This test ensure we
1100 do not regress. We have a dedicated repo because it needs a setup with renamed
1100 do not regress. We have a dedicated repo because it needs a setup with renamed
1101 directory)
1101 directory)
1102
1102
1103 $ hg init issue4516
1103 $ hg init issue4516
1104 $ cd issue4516
1104 $ cd issue4516
1105 $ mkdir olddirname
1105 $ mkdir olddirname
1106 $ echo line1 > olddirname/commonfile.py
1106 $ echo line1 > olddirname/commonfile.py
1107 $ hg add olddirname/commonfile.py
1107 $ hg add olddirname/commonfile.py
1108 $ hg ci -m first
1108 $ hg ci -m first
1109
1109
1110 $ hg branch newdirname
1110 $ hg branch newdirname
1111 marked working directory as branch newdirname
1111 marked working directory as branch newdirname
1112 (branches are permanent and global, did you want a bookmark?)
1112 (branches are permanent and global, did you want a bookmark?)
1113 $ hg mv olddirname newdirname
1113 $ hg mv olddirname newdirname
1114 moving olddirname/commonfile.py to newdirname/commonfile.py (glob)
1114 moving olddirname/commonfile.py to newdirname/commonfile.py (glob)
1115 $ hg ci -m rename
1115 $ hg ci -m rename
1116
1116
1117 $ hg update default
1117 $ hg update default
1118 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1118 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1119 $ echo line1 > olddirname/newfile.py
1119 $ echo line1 > olddirname/newfile.py
1120 $ hg add olddirname/newfile.py
1120 $ hg add olddirname/newfile.py
1121 $ hg ci -m log
1121 $ hg ci -m log
1122
1122
1123 $ hg up newdirname
1123 $ hg up newdirname
1124 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1124 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1125 $ # create newdirname/newfile.py
1125 $ # create newdirname/newfile.py
1126 $ hg merge default
1126 $ hg merge default
1127 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1127 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1128 (branch merge, don't forget to commit)
1128 (branch merge, don't forget to commit)
1129 $ hg ci -m add
1129 $ hg ci -m add
1130 $
1130 $
1131 $ hg debugrename newdirname/newfile.py
1131 $ hg debugrename newdirname/newfile.py
1132 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def (glob)
1132 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def (glob)
1133 $ hg status -C --change .
1133 $ hg status -C --change .
1134 A newdirname/newfile.py
1134 A newdirname/newfile.py
1135 $ hg status -C --rev 1
1135 $ hg status -C --rev 1
1136 A newdirname/newfile.py
1136 A newdirname/newfile.py
1137 $ hg status -C --rev 2
1137 $ hg status -C --rev 2
1138 A newdirname/commonfile.py
1138 A newdirname/commonfile.py
1139 olddirname/commonfile.py
1139 olddirname/commonfile.py
1140 A newdirname/newfile.py
1140 A newdirname/newfile.py
1141 olddirname/newfile.py
1141 olddirname/newfile.py
1142 R olddirname/commonfile.py
1142 R olddirname/commonfile.py
1143 R olddirname/newfile.py
1143 R olddirname/newfile.py
1144 $ hg debugindex newdirname/newfile.py
1144 $ hg debugindex newdirname/newfile.py
1145 rev offset length delta linkrev nodeid p1 p2
1145 rev offset length delta linkrev nodeid p1 p2
1146 0 0 89 -1 3 34a4d536c0c0 000000000000 000000000000
1146 0 0 89 -1 3 34a4d536c0c0 000000000000 000000000000
1147
1147
1148 $ echo a >> newdirname/commonfile.py
1148 $ echo a >> newdirname/commonfile.py
1149 $ hg ci --amend -m bug
1149 $ hg ci --amend -m bug
1150 $ hg debugrename newdirname/newfile.py
1150 $ hg debugrename newdirname/newfile.py
1151 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def (glob)
1151 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def (glob)
1152 $ hg debugindex newdirname/newfile.py
1152 $ hg debugindex newdirname/newfile.py
1153 rev offset length delta linkrev nodeid p1 p2
1153 rev offset length delta linkrev nodeid p1 p2
1154 0 0 89 -1 3 34a4d536c0c0 000000000000 000000000000
1154 0 0 89 -1 3 34a4d536c0c0 000000000000 000000000000
1155
1155
1156 #if execbit
1156 #if execbit
1157
1157
1158 Test if amend preserves executable bit changes
1158 Test if amend preserves executable bit changes
1159 $ chmod +x newdirname/commonfile.py
1159 $ chmod +x newdirname/commonfile.py
1160 $ hg ci -m chmod
1160 $ hg ci -m chmod
1161 $ hg ci --amend -m "chmod amended"
1161 $ hg ci --amend -m "chmod amended"
1162 $ hg ci --amend -m "chmod amended second time"
1162 $ hg ci --amend -m "chmod amended second time"
1163 $ hg log -p --git -r .
1163 $ hg log -p --git -r .
1164 changeset: 8:b1326f52dddf
1164 changeset: 8:b1326f52dddf
1165 branch: newdirname
1165 branch: newdirname
1166 tag: tip
1166 tag: tip
1167 parent: 5:7fd235f7cb2f
1167 parent: 5:7fd235f7cb2f
1168 user: test
1168 user: test
1169 date: Thu Jan 01 00:00:00 1970 +0000
1169 date: Thu Jan 01 00:00:00 1970 +0000
1170 summary: chmod amended second time
1170 summary: chmod amended second time
1171
1171
1172 diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py
1172 diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py
1173 old mode 100644
1173 old mode 100644
1174 new mode 100755
1174 new mode 100755
1175
1175
1176 #endif
1176 #endif
1177
1178 Test amend with file inclusion options
1179 --------------------------------------
1180
1181 These tests ensure that we are always amending some files that were part of the
1182 pre-amend commit. We want to test that the remaining files in the pre-amend
1183 commit were not changed in the amended commit. We do so by performing a diff of
1184 the amended commit against its parent commit.
1185 $ cd ..
1186 $ hg init testfileinclusions
1187 $ cd testfileinclusions
1188 $ echo a > a
1189 $ echo b > b
1190 $ hg commit -Aqm "Adding a and b"
1191
1192 Only add changes to a particular file
1193 $ echo a >> a
1194 $ echo b >> b
1195 $ hg commit --amend -I a
1196 $ hg diff --git -r null -r .
1197 diff --git a/a b/a
1198 new file mode 100644
1199 --- /dev/null
1200 +++ b/a
1201 @@ -0,0 +1,2 @@
1202 +a
1203 +a
1204 diff --git a/b b/b
1205 new file mode 100644
1206 --- /dev/null
1207 +++ b/b
1208 @@ -0,0 +1,1 @@
1209 +b
1210
1211 $ echo a >> a
1212 $ hg commit --amend b
1213 $ hg diff --git -r null -r .
1214 diff --git a/a b/a
1215 new file mode 100644
1216 --- /dev/null
1217 +++ b/a
1218 @@ -0,0 +1,2 @@
1219 +a
1220 +a
1221 diff --git a/b b/b
1222 new file mode 100644
1223 --- /dev/null
1224 +++ b/b
1225 @@ -0,0 +1,2 @@
1226 +b
1227 +b
1228
1229 Exclude changes to a particular file
1230 $ echo b >> b
1231 $ hg commit --amend -X a
1232 $ hg diff --git -r null -r .
1233 diff --git a/a b/a
1234 new file mode 100644
1235 --- /dev/null
1236 +++ b/a
1237 @@ -0,0 +1,2 @@
1238 +a
1239 +a
1240 diff --git a/b b/b
1241 new file mode 100644
1242 --- /dev/null
1243 +++ b/b
1244 @@ -0,0 +1,3 @@
1245 +b
1246 +b
1247 +b
1248
1249 Check the addremove flag
1250 $ echo c > c
1251 $ rm a
1252 $ hg commit --amend -A
1253 removing a
1254 adding c
1255 $ hg diff --git -r null -r .
1256 diff --git a/b b/b
1257 new file mode 100644
1258 --- /dev/null
1259 +++ b/b
1260 @@ -0,0 +1,3 @@
1261 +b
1262 +b
1263 +b
1264 diff --git a/c b/c
1265 new file mode 100644
1266 --- /dev/null
1267 +++ b/c
1268 @@ -0,0 +1,1 @@
1269 +c
General Comments 0
You need to be logged in to leave comments. Login now