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