##// END OF EJS Templates
test-commit-amend: exhibit an --amend weirdness...
Patrick Mezard -
r16552:90ca344a stable
parent child Browse files
Show More
@@ -1,294 +1,306 b''
1 $ "$TESTDIR/hghave" execbit || exit 80
1 $ "$TESTDIR/hghave" execbit || exit 80
2
2
3 $ hg init
3 $ hg init
4
4
5 Setup:
5 Setup:
6
6
7 $ echo a >> a
7 $ echo a >> a
8 $ hg ci -Am 'base'
8 $ hg ci -Am 'base'
9 adding a
9 adding a
10
10
11 Refuse to amend public csets:
11 Refuse to amend public csets:
12
12
13 $ hg phase -r . -p
13 $ hg phase -r . -p
14 $ hg ci --amend
14 $ hg ci --amend
15 abort: cannot amend public changesets
15 abort: cannot amend public changesets
16 [255]
16 [255]
17 $ hg phase -r . -f -d
17 $ hg phase -r . -f -d
18
18
19 $ echo a >> a
19 $ echo a >> a
20 $ hg ci -Am 'base1'
20 $ hg ci -Am 'base1'
21
21
22 Nothing to amend:
22 Nothing to amend:
23
23
24 $ hg ci --amend
24 $ hg ci --amend
25 nothing changed
25 nothing changed
26 [1]
26 [1]
27
27
28 Amending changeset with changes in working dir:
28 Amending changeset with changes in working dir:
29
29
30 $ echo a >> a
30 $ echo a >> a
31 $ hg ci --amend -m 'amend base1'
31 $ hg ci --amend -m 'amend base1'
32 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg
32 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg
33 $ hg diff -c .
33 $ hg diff -c .
34 diff -r ad120869acf0 -r 9cd25b479c51 a
34 diff -r ad120869acf0 -r 9cd25b479c51 a
35 --- a/a Thu Jan 01 00:00:00 1970 +0000
35 --- a/a Thu Jan 01 00:00:00 1970 +0000
36 +++ b/a Thu Jan 01 00:00:00 1970 +0000
36 +++ b/a Thu Jan 01 00:00:00 1970 +0000
37 @@ -1,1 +1,3 @@
37 @@ -1,1 +1,3 @@
38 a
38 a
39 +a
39 +a
40 +a
40 +a
41 $ hg log
41 $ hg log
42 changeset: 1:9cd25b479c51
42 changeset: 1:9cd25b479c51
43 tag: tip
43 tag: tip
44 user: test
44 user: test
45 date: Thu Jan 01 00:00:00 1970 +0000
45 date: Thu Jan 01 00:00:00 1970 +0000
46 summary: amend base1
46 summary: amend base1
47
47
48 changeset: 0:ad120869acf0
48 changeset: 0:ad120869acf0
49 user: test
49 user: test
50 date: Thu Jan 01 00:00:00 1970 +0000
50 date: Thu Jan 01 00:00:00 1970 +0000
51 summary: base
51 summary: base
52
52
53
53
54 Add new file:
54 Add new file:
55
55
56 $ echo b > b
56 $ echo b > b
57 $ hg ci --amend -Am 'amend base1 new file'
57 $ hg ci --amend -Am 'amend base1 new file'
58 adding b
58 adding b
59 saved backup bundle to $TESTTMP/.hg/strip-backup/9cd25b479c51-amend-backup.hg
59 saved backup bundle to $TESTTMP/.hg/strip-backup/9cd25b479c51-amend-backup.hg
60
60
61 Remove file that was added in amended commit:
61 Remove file that was added in amended commit:
62
62
63 $ hg rm b
63 $ hg rm b
64 $ hg ci --amend -m 'amend base1 remove new file'
64 $ hg ci --amend -m 'amend base1 remove new file'
65 saved backup bundle to $TESTTMP/.hg/strip-backup/e2bb3ecffd2f-amend-backup.hg
65 saved backup bundle to $TESTTMP/.hg/strip-backup/e2bb3ecffd2f-amend-backup.hg
66
66
67 $ hg cat b
67 $ hg cat b
68 b: no such file in rev 664a9b2d60cd
68 b: no such file in rev 664a9b2d60cd
69 [1]
69 [1]
70
70
71 No changes, just a different message:
71 No changes, just a different message:
72
72
73 $ hg ci -v --amend -m 'no changes, new message'
73 $ hg ci -v --amend -m 'no changes, new message'
74 amending changeset 664a9b2d60cd
74 amending changeset 664a9b2d60cd
75 copying changeset 664a9b2d60cd to ad120869acf0
75 copying changeset 664a9b2d60cd to ad120869acf0
76 a
76 a
77 stripping amended changeset 664a9b2d60cd
77 stripping amended changeset 664a9b2d60cd
78 1 changesets found
78 1 changesets found
79 saved backup bundle to $TESTTMP/.hg/strip-backup/664a9b2d60cd-amend-backup.hg
79 saved backup bundle to $TESTTMP/.hg/strip-backup/664a9b2d60cd-amend-backup.hg
80 1 changesets found
80 1 changesets found
81 adding branch
81 adding branch
82 adding changesets
82 adding changesets
83 adding manifests
83 adding manifests
84 adding file changes
84 adding file changes
85 added 1 changesets with 1 changes to 1 files
85 added 1 changesets with 1 changes to 1 files
86 committed changeset 1:ea6e356ff2ad
86 committed changeset 1:ea6e356ff2ad
87 $ hg diff -c .
87 $ hg diff -c .
88 diff -r ad120869acf0 -r ea6e356ff2ad a
88 diff -r ad120869acf0 -r ea6e356ff2ad a
89 --- a/a Thu Jan 01 00:00:00 1970 +0000
89 --- a/a Thu Jan 01 00:00:00 1970 +0000
90 +++ b/a Thu Jan 01 00:00:00 1970 +0000
90 +++ b/a Thu Jan 01 00:00:00 1970 +0000
91 @@ -1,1 +1,3 @@
91 @@ -1,1 +1,3 @@
92 a
92 a
93 +a
93 +a
94 +a
94 +a
95 $ hg log
95 $ hg log
96 changeset: 1:ea6e356ff2ad
96 changeset: 1:ea6e356ff2ad
97 tag: tip
97 tag: tip
98 user: test
98 user: test
99 date: Thu Jan 01 00:00:00 1970 +0000
99 date: Thu Jan 01 00:00:00 1970 +0000
100 summary: no changes, new message
100 summary: no changes, new message
101
101
102 changeset: 0:ad120869acf0
102 changeset: 0:ad120869acf0
103 user: test
103 user: test
104 date: Thu Jan 01 00:00:00 1970 +0000
104 date: Thu Jan 01 00:00:00 1970 +0000
105 summary: base
105 summary: base
106
106
107
107
108 Disable default date on commit so when -d isn't given, the old date is preserved:
108 Disable default date on commit so when -d isn't given, the old date is preserved:
109
109
110 $ echo '[defaults]' >> $HGRCPATH
110 $ echo '[defaults]' >> $HGRCPATH
111 $ echo 'commit=' >> $HGRCPATH
111 $ echo 'commit=' >> $HGRCPATH
112
112
113 Test -u/-d:
113 Test -u/-d:
114
114
115 $ hg ci --amend -u foo -d '1 0'
115 $ hg ci --amend -u foo -d '1 0'
116 saved backup bundle to $TESTTMP/.hg/strip-backup/ea6e356ff2ad-amend-backup.hg
116 saved backup bundle to $TESTTMP/.hg/strip-backup/ea6e356ff2ad-amend-backup.hg
117 $ echo a >> a
117 $ echo a >> a
118 $ hg ci --amend -u foo -d '1 0'
118 $ hg ci --amend -u foo -d '1 0'
119 saved backup bundle to $TESTTMP/.hg/strip-backup/377b91ce8b56-amend-backup.hg
119 saved backup bundle to $TESTTMP/.hg/strip-backup/377b91ce8b56-amend-backup.hg
120 $ hg log -r .
120 $ hg log -r .
121 changeset: 1:2c94e4a5756f
121 changeset: 1:2c94e4a5756f
122 tag: tip
122 tag: tip
123 user: foo
123 user: foo
124 date: Thu Jan 01 00:00:01 1970 +0000
124 date: Thu Jan 01 00:00:01 1970 +0000
125 summary: no changes, new message
125 summary: no changes, new message
126
126
127
127
128 Open editor with old commit message if a message isn't given otherwise:
128 Open editor with old commit message if a message isn't given otherwise:
129
129
130 $ cat > editor << '__EOF__'
130 $ cat > editor << '__EOF__'
131 > #!/bin/sh
131 > #!/bin/sh
132 > cat $1
132 > cat $1
133 > echo "another precious commit message" > "$1"
133 > echo "another precious commit message" > "$1"
134 > __EOF__
134 > __EOF__
135 $ chmod +x editor
135 $ chmod +x editor
136 $ HGEDITOR="'`pwd`'"/editor hg commit --amend -v
136 $ HGEDITOR="'`pwd`'"/editor hg commit --amend -v
137 amending changeset 2c94e4a5756f
137 amending changeset 2c94e4a5756f
138 copying changeset 2c94e4a5756f to ad120869acf0
138 copying changeset 2c94e4a5756f to ad120869acf0
139 no changes, new message
139 no changes, new message
140
140
141
141
142 HG: Enter commit message. Lines beginning with 'HG:' are removed.
142 HG: Enter commit message. Lines beginning with 'HG:' are removed.
143 HG: Leave message empty to abort commit.
143 HG: Leave message empty to abort commit.
144 HG: --
144 HG: --
145 HG: user: foo
145 HG: user: foo
146 HG: branch 'default'
146 HG: branch 'default'
147 HG: changed a
147 HG: changed a
148 a
148 a
149 stripping amended changeset 2c94e4a5756f
149 stripping amended changeset 2c94e4a5756f
150 1 changesets found
150 1 changesets found
151 saved backup bundle to $TESTTMP/.hg/strip-backup/2c94e4a5756f-amend-backup.hg
151 saved backup bundle to $TESTTMP/.hg/strip-backup/2c94e4a5756f-amend-backup.hg
152 1 changesets found
152 1 changesets found
153 adding branch
153 adding branch
154 adding changesets
154 adding changesets
155 adding manifests
155 adding manifests
156 adding file changes
156 adding file changes
157 added 1 changesets with 1 changes to 1 files
157 added 1 changesets with 1 changes to 1 files
158 committed changeset 1:ffb49186f961
158 committed changeset 1:ffb49186f961
159
159
160 Same, but with changes in working dir (different code path):
160 Same, but with changes in working dir (different code path):
161
161
162 $ echo a >> a
162 $ echo a >> a
163 $ HGEDITOR="'`pwd`'"/editor hg commit --amend -v
163 $ HGEDITOR="'`pwd`'"/editor hg commit --amend -v
164 amending changeset ffb49186f961
164 amending changeset ffb49186f961
165 another precious commit message
165 another precious commit message
166
166
167
167
168 HG: Enter commit message. Lines beginning with 'HG:' are removed.
168 HG: Enter commit message. Lines beginning with 'HG:' are removed.
169 HG: Leave message empty to abort commit.
169 HG: Leave message empty to abort commit.
170 HG: --
170 HG: --
171 HG: user: foo
171 HG: user: foo
172 HG: branch 'default'
172 HG: branch 'default'
173 HG: changed a
173 HG: changed a
174 a
174 a
175 copying changeset 27f3aacd3011 to ad120869acf0
175 copying changeset 27f3aacd3011 to ad120869acf0
176 a
176 a
177 stripping intermediate changeset 27f3aacd3011
177 stripping intermediate changeset 27f3aacd3011
178 stripping amended changeset ffb49186f961
178 stripping amended changeset ffb49186f961
179 2 changesets found
179 2 changesets found
180 saved backup bundle to $TESTTMP/.hg/strip-backup/ffb49186f961-amend-backup.hg
180 saved backup bundle to $TESTTMP/.hg/strip-backup/ffb49186f961-amend-backup.hg
181 1 changesets found
181 1 changesets found
182 adding branch
182 adding branch
183 adding changesets
183 adding changesets
184 adding manifests
184 adding manifests
185 adding file changes
185 adding file changes
186 added 1 changesets with 1 changes to 1 files
186 added 1 changesets with 1 changes to 1 files
187 committed changeset 1:fb6cca43446f
187 committed changeset 1:fb6cca43446f
188
188
189 $ rm editor
189 $ rm editor
190 $ hg log -r .
190 $ hg log -r .
191 changeset: 1:fb6cca43446f
191 changeset: 1:fb6cca43446f
192 tag: tip
192 tag: tip
193 user: foo
193 user: foo
194 date: Thu Jan 01 00:00:01 1970 +0000
194 date: Thu Jan 01 00:00:01 1970 +0000
195 summary: another precious commit message
195 summary: another precious commit message
196
196
197
197
198 Moving bookmarks, preserve active bookmark:
198 Moving bookmarks, preserve active bookmark:
199
199
200 $ hg book book1
200 $ hg book book1
201 $ hg book book2
201 $ hg book book2
202 $ hg ci --amend -m 'move bookmarks'
202 $ hg ci --amend -m 'move bookmarks'
203 saved backup bundle to $TESTTMP/.hg/strip-backup/fb6cca43446f-amend-backup.hg
203 saved backup bundle to $TESTTMP/.hg/strip-backup/fb6cca43446f-amend-backup.hg
204 $ hg book
204 $ hg book
205 book1 1:0cf1c7a51bcf
205 book1 1:0cf1c7a51bcf
206 * book2 1:0cf1c7a51bcf
206 * book2 1:0cf1c7a51bcf
207 $ echo a >> a
207 $ echo a >> a
208 $ hg ci --amend -m 'move bookmarks'
208 $ hg ci --amend -m 'move bookmarks'
209 saved backup bundle to $TESTTMP/.hg/strip-backup/0cf1c7a51bcf-amend-backup.hg
209 saved backup bundle to $TESTTMP/.hg/strip-backup/0cf1c7a51bcf-amend-backup.hg
210 $ hg book
210 $ hg book
211 book1 1:7344472bd951
211 book1 1:7344472bd951
212 * book2 1:7344472bd951
212 * book2 1:7344472bd951
213
213
214 $ echo '[defaults]' >> $HGRCPATH
214 $ echo '[defaults]' >> $HGRCPATH
215 $ echo "commit=-d '0 0'" >> $HGRCPATH
215 $ echo "commit=-d '0 0'" >> $HGRCPATH
216
216
217 Moving branches:
217 Moving branches:
218
218
219 $ hg branch foo
219 $ hg branch foo
220 marked working directory as branch foo
220 marked working directory as branch foo
221 (branches are permanent and global, did you want a bookmark?)
221 (branches are permanent and global, did you want a bookmark?)
222 $ echo a >> a
222 $ echo a >> a
223 $ hg ci -m 'branch foo'
223 $ hg ci -m 'branch foo'
224 $ hg branch default -f
224 $ hg branch default -f
225 marked working directory as branch default
225 marked working directory as branch default
226 (branches are permanent and global, did you want a bookmark?)
226 (branches are permanent and global, did you want a bookmark?)
227 $ hg ci --amend -m 'back to default'
227 $ hg ci --amend -m 'back to default'
228 saved backup bundle to $TESTTMP/.hg/strip-backup/1661ca36a2db-amend-backup.hg
228 saved backup bundle to $TESTTMP/.hg/strip-backup/1661ca36a2db-amend-backup.hg
229 $ hg branches
229 $ hg branches
230 default 2:f24ee5961967
230 default 2:f24ee5961967
231
231
232 Close branch:
232 Close branch:
233
233
234 $ hg up -q 0
234 $ hg up -q 0
235 $ echo b >> b
235 $ echo b >> b
236 $ hg branch foo
236 $ hg branch foo
237 marked working directory as branch foo
237 marked working directory as branch foo
238 (branches are permanent and global, did you want a bookmark?)
238 (branches are permanent and global, did you want a bookmark?)
239 $ hg ci -Am 'fork'
239 $ hg ci -Am 'fork'
240 adding b
240 adding b
241 $ echo b >> b
241 $ echo b >> b
242 $ hg ci -mb
242 $ hg ci -mb
243 $ hg ci --amend --close-branch -m 'closing branch foo'
243 $ hg ci --amend --close-branch -m 'closing branch foo'
244 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-amend-backup.hg
244 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-amend-backup.hg
245
245
246 Same thing, different code path:
246 Same thing, different code path:
247
247
248 $ echo b >> b
248 $ echo b >> b
249 $ hg ci -m 'reopen branch'
249 $ hg ci -m 'reopen branch'
250 reopening closed branch head 4
250 reopening closed branch head 4
251 $ echo b >> b
251 $ echo b >> b
252 $ hg ci --amend --close-branch
252 $ hg ci --amend --close-branch
253 saved backup bundle to $TESTTMP/.hg/strip-backup/5e302dcc12b8-amend-backup.hg
253 saved backup bundle to $TESTTMP/.hg/strip-backup/5e302dcc12b8-amend-backup.hg
254 $ hg branches
254 $ hg branches
255 default 2:f24ee5961967
255 default 2:f24ee5961967
256
256
257 Refuse to amend merges:
257 Refuse to amend merges:
258
258
259 $ hg up -q default
259 $ hg up -q default
260 $ hg merge foo
260 $ hg merge foo
261 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
261 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
262 (branch merge, don't forget to commit)
262 (branch merge, don't forget to commit)
263 $ hg ci --amend
263 $ hg ci --amend
264 abort: cannot amend while merging
264 abort: cannot amend while merging
265 [255]
265 [255]
266 $ hg ci -m 'merge'
266 $ hg ci -m 'merge'
267 $ hg ci --amend
267 $ hg ci --amend
268 abort: cannot amend merge changesets
268 abort: cannot amend merge changesets
269 [255]
269 [255]
270
270
271 Follow copies/renames:
271 Follow copies/renames:
272
272
273 $ hg mv b c
273 $ hg mv b c
274 $ hg ci -m 'b -> c'
274 $ hg ci -m 'b -> c'
275 $ hg mv c d
275 $ hg mv c d
276 $ hg ci --amend -m 'b -> d'
276 $ hg ci --amend -m 'b -> d'
277 saved backup bundle to $TESTTMP/.hg/strip-backup/9c207120aa98-amend-backup.hg
277 saved backup bundle to $TESTTMP/.hg/strip-backup/9c207120aa98-amend-backup.hg
278 $ hg st --rev '.^' --copies d
278 $ hg st --rev '.^' --copies d
279 A d
279 A d
280 b
280 b
281 $ hg cp d e
281 $ hg cp d e
282 $ hg ci -m 'e = d'
282 $ hg ci -m 'e = d'
283 $ hg cp e f
283 $ hg cp e f
284 $ hg ci --amend -m 'f = d'
284 $ hg ci --amend -m 'f = d'
285 saved backup bundle to $TESTTMP/.hg/strip-backup/fda2b3b27b22-amend-backup.hg
285 saved backup bundle to $TESTTMP/.hg/strip-backup/fda2b3b27b22-amend-backup.hg
286 $ hg st --rev '.^' --copies f
286 $ hg st --rev '.^' --copies f
287 A f
287 A f
288 d
288 d
289
289
290 $ mv f f.orig
291 $ hg rm -A f
292 $ hg ci -m removef
293 $ hg cp a f
294 $ mv f.orig f
295 $ hg ci --amend -m replacef
296 saved backup bundle to $TESTTMP/.hg/strip-backup/0ce2c92dc50d-amend-backup.hg
297 $ hg st --change . --copies
298 M f
299 $ hg log -r . --template "{file_copies}\n"
300 f (a)
301
290 Can't rollback an amend:
302 Can't rollback an amend:
291
303
292 $ hg rollback
304 $ hg rollback
293 no rollback information available
305 no rollback information available
294 [1]
306 [1]
General Comments 0
You need to be logged in to leave comments. Login now