Show More
@@ -1,60 +1,61 b'' | |||
|
1 | 1 | # amend.py - provide the amend command |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2017 Facebook, Inc. |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | """provide the amend command (EXPERIMENTAL) |
|
8 | 8 | |
|
9 | 9 | This extension provides an ``amend`` command that is similar to |
|
10 | 10 | ``commit --amend`` but does not prompt an editor. |
|
11 | 11 | """ |
|
12 | 12 | |
|
13 | 13 | from __future__ import absolute_import |
|
14 | 14 | |
|
15 | 15 | from mercurial.i18n import _ |
|
16 | 16 | from mercurial import ( |
|
17 | 17 | cmdutil, |
|
18 | 18 | commands, |
|
19 | 19 | pycompat, |
|
20 | 20 | registrar, |
|
21 | 21 | ) |
|
22 | 22 | |
|
23 | 23 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
24 | 24 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
25 | 25 | # be specifying the version(s) of Mercurial they are tested with, or |
|
26 | 26 | # leave the attribute unspecified. |
|
27 | 27 | testedwith = 'ships-with-hg-core' |
|
28 | 28 | |
|
29 | 29 | cmdtable = {} |
|
30 | 30 | command = registrar.command(cmdtable) |
|
31 | 31 | |
|
32 | 32 | @command('amend', |
|
33 | 33 | [('A', 'addremove', None, |
|
34 | 34 | _('mark new/missing files as added/removed before committing')), |
|
35 | 35 | ('e', 'edit', None, _('invoke editor on commit messages')), |
|
36 | 36 | ('i', 'interactive', None, _('use interactive mode')), |
|
37 | 37 | (b'', b'close-branch', None, |
|
38 | 38 | _(b'mark a branch as closed, hiding it from the branch list')), |
|
39 | (b's', b'secret', None, _(b'use the secret phase for committing')), | |
|
39 | 40 | ('n', 'note', '', _('store a note on the amend')), |
|
40 | 41 | ] + cmdutil.walkopts + cmdutil.commitopts + cmdutil.commitopts2 |
|
41 | 42 | + cmdutil.commitopts3, |
|
42 | 43 | _('[OPTION]... [FILE]...'), |
|
43 | 44 | helpcategory=command.CATEGORY_COMMITTING, |
|
44 | 45 | inferrepo=True) |
|
45 | 46 | def amend(ui, repo, *pats, **opts): |
|
46 | 47 | """amend the working copy parent with all or specified outstanding changes |
|
47 | 48 | |
|
48 | 49 | Similar to :hg:`commit --amend`, but reuse the commit message without |
|
49 | 50 | invoking editor, unless ``--edit`` was set. |
|
50 | 51 | |
|
51 | 52 | See :hg:`help commit` for more details. |
|
52 | 53 | """ |
|
53 | 54 | opts = pycompat.byteskwargs(opts) |
|
54 | 55 | cmdutil.checknotesize(ui, opts) |
|
55 | 56 | |
|
56 | 57 | with repo.wlock(), repo.lock(): |
|
57 | 58 | if not opts.get('logfile'): |
|
58 | 59 | opts['message'] = opts.get('message') or repo['.'].description() |
|
59 | 60 | opts['amend'] = True |
|
60 | 61 | return commands._docommit(ui, repo, *pats, **pycompat.strkwargs(opts)) |
@@ -1,24 +1,26 b'' | |||
|
1 | 1 | == New Features == |
|
2 | 2 | |
|
3 | 3 | * The amend extension supports the `--currentuser` argument. |
|
4 | 4 | |
|
5 | 5 | * The amend extension supports the `--close-branch` argument. |
|
6 | 6 | |
|
7 | * The amend extension supports the `--secret` argument. | |
|
8 | ||
|
7 | 9 | * The uncommit extension supports the `rewrite.update-timestamp` config option. |
|
8 | 10 | |
|
9 | 11 | == New Experimental Features == |
|
10 | 12 | |
|
11 | 13 | |
|
12 | 14 | == Bug Fixes == |
|
13 | 15 | |
|
14 | 16 | |
|
15 | 17 | == Backwards Compatibility Changes == |
|
16 | 18 | |
|
17 | 19 | * A shell that supports `$(command)`` syntax for command substitution is now |
|
18 | 20 | required for running the test suite. The test runner normally uses |
|
19 | 21 | `sh`, so if that is a shell that doesn't support `$(command)` syntax, |
|
20 | 22 | you can override it by setting `$HGTEST_SHELL` or by passing it to |
|
21 | 23 | `run-tests.py --shell <shell>`. |
|
22 | 24 | |
|
23 | 25 | == Internal API Changes == |
|
24 | 26 |
@@ -1,477 +1,478 b'' | |||
|
1 | 1 | #testcases obsstore-off obsstore-on |
|
2 | 2 | |
|
3 | 3 | $ cat << EOF >> $HGRCPATH |
|
4 | 4 | > [extensions] |
|
5 | 5 | > amend= |
|
6 | 6 | > debugdrawdag=$TESTDIR/drawdag.py |
|
7 | 7 | > [diff] |
|
8 | 8 | > git=1 |
|
9 | 9 | > EOF |
|
10 | 10 | |
|
11 | 11 | #if obsstore-on |
|
12 | 12 | $ cat << EOF >> $HGRCPATH |
|
13 | 13 | > [experimental] |
|
14 | 14 | > evolution.createmarkers=True |
|
15 | 15 | > EOF |
|
16 | 16 | #endif |
|
17 | 17 | |
|
18 | 18 | Basic amend |
|
19 | 19 | |
|
20 | 20 | $ hg init repo1 |
|
21 | 21 | $ cd repo1 |
|
22 | 22 | $ hg debugdrawdag <<'EOS' |
|
23 | 23 | > B |
|
24 | 24 | > | |
|
25 | 25 | > A |
|
26 | 26 | > EOS |
|
27 | 27 | |
|
28 | 28 | $ hg update B -q |
|
29 | 29 | $ echo 2 >> B |
|
30 | 30 | |
|
31 | 31 | $ hg amend |
|
32 | 32 | saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/112478962961-7e959a55-amend.hg (obsstore-off !) |
|
33 | 33 | #if obsstore-off |
|
34 | 34 | $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n' |
|
35 | 35 | @ 1 be169c7e8dbe B |
|
36 | 36 | | diff --git a/B b/B |
|
37 | 37 | | new file mode 100644 |
|
38 | 38 | | --- /dev/null |
|
39 | 39 | | +++ b/B |
|
40 | 40 | | @@ -0,0 +1,1 @@ |
|
41 | 41 | | +B2 |
|
42 | 42 | | |
|
43 | 43 | o 0 426bada5c675 A |
|
44 | 44 | diff --git a/A b/A |
|
45 | 45 | new file mode 100644 |
|
46 | 46 | --- /dev/null |
|
47 | 47 | +++ b/A |
|
48 | 48 | @@ -0,0 +1,1 @@ |
|
49 | 49 | +A |
|
50 | 50 | \ No newline at end of file |
|
51 | 51 | |
|
52 | 52 | #else |
|
53 | 53 | $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n' |
|
54 | 54 | @ 2 be169c7e8dbe B |
|
55 | 55 | | diff --git a/B b/B |
|
56 | 56 | | new file mode 100644 |
|
57 | 57 | | --- /dev/null |
|
58 | 58 | | +++ b/B |
|
59 | 59 | | @@ -0,0 +1,1 @@ |
|
60 | 60 | | +B2 |
|
61 | 61 | | |
|
62 | 62 | | x 1 112478962961 B |
|
63 | 63 | |/ diff --git a/B b/B |
|
64 | 64 | | new file mode 100644 |
|
65 | 65 | | --- /dev/null |
|
66 | 66 | | +++ b/B |
|
67 | 67 | | @@ -0,0 +1,1 @@ |
|
68 | 68 | | +B |
|
69 | 69 | | \ No newline at end of file |
|
70 | 70 | | |
|
71 | 71 | o 0 426bada5c675 A |
|
72 | 72 | diff --git a/A b/A |
|
73 | 73 | new file mode 100644 |
|
74 | 74 | --- /dev/null |
|
75 | 75 | +++ b/A |
|
76 | 76 | @@ -0,0 +1,1 @@ |
|
77 | 77 | +A |
|
78 | 78 | \ No newline at end of file |
|
79 | 79 | |
|
80 | 80 | #endif |
|
81 | 81 | |
|
82 | 82 | Nothing changed |
|
83 | 83 | |
|
84 | 84 | $ hg amend |
|
85 | 85 | nothing changed |
|
86 | 86 | [1] |
|
87 | 87 | |
|
88 | 88 | $ hg amend -d "0 0" |
|
89 | 89 | nothing changed |
|
90 | 90 | [1] |
|
91 | 91 | |
|
92 | 92 | $ hg amend -d "Thu Jan 01 00:00:00 1970 UTC" |
|
93 | 93 | nothing changed |
|
94 | 94 | [1] |
|
95 | 95 | |
|
96 | 96 | Matcher and metadata options |
|
97 | 97 | |
|
98 | 98 | $ echo 3 > C |
|
99 | 99 | $ echo 4 > D |
|
100 | 100 | $ hg add C D |
|
101 | 101 | $ hg amend -m NEWMESSAGE -I C |
|
102 | 102 | saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/be169c7e8dbe-7684ddc5-amend.hg (obsstore-off !) |
|
103 | 103 | $ hg log -r . -T '{node|short} {desc} {files}\n' |
|
104 | 104 | c7ba14d9075b NEWMESSAGE B C |
|
105 | 105 | $ echo 5 > E |
|
106 | 106 | $ rm C |
|
107 | 107 | $ hg amend -d '2000 1000' -u 'Foo <foo@example.com>' -A C D |
|
108 | 108 | saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/c7ba14d9075b-b3e76daa-amend.hg (obsstore-off !) |
|
109 | 109 | $ hg log -r . -T '{node|short} {desc} {files} {author} {date}\n' |
|
110 | 110 | 14f6c4bcc865 NEWMESSAGE B D Foo <foo@example.com> 2000.01000 |
|
111 | 111 | |
|
112 | 112 | Amend with editor |
|
113 | 113 | |
|
114 | 114 | $ cat > $TESTTMP/prefix.sh <<'EOF' |
|
115 | 115 | > printf 'EDITED: ' > $TESTTMP/msg |
|
116 | 116 | > cat "$1" >> $TESTTMP/msg |
|
117 | 117 | > mv $TESTTMP/msg "$1" |
|
118 | 118 | > EOF |
|
119 | 119 | $ chmod +x $TESTTMP/prefix.sh |
|
120 | 120 | |
|
121 | 121 | $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend --edit |
|
122 | 122 | saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/14f6c4bcc865-6591f15d-amend.hg (obsstore-off !) |
|
123 | 123 | $ hg log -r . -T '{node|short} {desc}\n' |
|
124 | 124 | 298f085230c3 EDITED: NEWMESSAGE |
|
125 | 125 | $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend -e -m MSG |
|
126 | 126 | saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/298f085230c3-d81a6ad3-amend.hg (obsstore-off !) |
|
127 | 127 | $ hg log -r . -T '{node|short} {desc}\n' |
|
128 | 128 | 974f07f28537 EDITED: MSG |
|
129 | 129 | |
|
130 | 130 | $ echo FOO > $TESTTMP/msg |
|
131 | 131 | $ hg amend -l $TESTTMP/msg -m BAR |
|
132 | 132 | abort: options --message and --logfile are mutually exclusive |
|
133 | 133 | [255] |
|
134 | 134 | $ hg amend -l $TESTTMP/msg |
|
135 | 135 | saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/974f07f28537-edb6470a-amend.hg (obsstore-off !) |
|
136 | 136 | $ hg log -r . -T '{node|short} {desc}\n' |
|
137 | 137 | 507be9bdac71 FOO |
|
138 | 138 | |
|
139 | 139 | Interactive mode |
|
140 | 140 | |
|
141 | 141 | $ touch F G |
|
142 | 142 | $ hg add F G |
|
143 | 143 | $ cat <<EOS | hg amend -i --config ui.interactive=1 |
|
144 | 144 | > y |
|
145 | 145 | > n |
|
146 | 146 | > EOS |
|
147 | 147 | diff --git a/F b/F |
|
148 | 148 | new file mode 100644 |
|
149 | 149 | examine changes to 'F'? |
|
150 | 150 | (enter ? for help) [Ynesfdaq?] y |
|
151 | 151 | |
|
152 | 152 | diff --git a/G b/G |
|
153 | 153 | new file mode 100644 |
|
154 | 154 | examine changes to 'G'? |
|
155 | 155 | (enter ? for help) [Ynesfdaq?] n |
|
156 | 156 | |
|
157 | 157 | saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/507be9bdac71-c8077452-amend.hg (obsstore-off !) |
|
158 | 158 | $ hg log -r . -T '{files}\n' |
|
159 | 159 | B D F |
|
160 | 160 | |
|
161 | 161 | Amend in the middle of a stack |
|
162 | 162 | |
|
163 | 163 | $ hg init $TESTTMP/repo2 |
|
164 | 164 | $ cd $TESTTMP/repo2 |
|
165 | 165 | $ hg debugdrawdag <<'EOS' |
|
166 | 166 | > C |
|
167 | 167 | > | |
|
168 | 168 | > B |
|
169 | 169 | > | |
|
170 | 170 | > A |
|
171 | 171 | > EOS |
|
172 | 172 | |
|
173 | 173 | $ hg update -q B |
|
174 | 174 | $ echo 2 >> B |
|
175 | 175 | $ hg amend |
|
176 | 176 | abort: cannot amend changeset with children |
|
177 | 177 | [255] |
|
178 | 178 | |
|
179 | 179 | #if obsstore-on |
|
180 | 180 | |
|
181 | 181 | With allowunstable, amend could work in the middle of a stack |
|
182 | 182 | |
|
183 | 183 | $ cat >> $HGRCPATH <<EOF |
|
184 | 184 | > [experimental] |
|
185 | 185 | > evolution.createmarkers=True |
|
186 | 186 | > evolution.allowunstable=True |
|
187 | 187 | > EOF |
|
188 | 188 | |
|
189 | 189 | $ hg amend |
|
190 | 190 | 1 new orphan changesets |
|
191 | 191 | $ hg log -T '{rev} {node|short} {desc}\n' -G |
|
192 | 192 | @ 3 be169c7e8dbe B |
|
193 | 193 | | |
|
194 | 194 | | * 2 26805aba1e60 C |
|
195 | 195 | | | |
|
196 | 196 | | x 1 112478962961 B |
|
197 | 197 | |/ |
|
198 | 198 | o 0 426bada5c675 A |
|
199 | 199 | |
|
200 | 200 | Checking the note stored in the obsmarker |
|
201 | 201 | |
|
202 | 202 | $ echo foo > bar |
|
203 | 203 | $ hg add bar |
|
204 | 204 | $ hg amend --note 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' |
|
205 | 205 | abort: cannot store a note of more than 255 bytes |
|
206 | 206 | [255] |
|
207 | 207 | $ hg amend --note "adding bar" |
|
208 | 208 | $ hg debugobsolete -r . |
|
209 | 209 | 112478962961147124edd43549aedd1a335e44bf be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'} |
|
210 | 210 | be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 16084da537dd8f84cfdb3055c633772269d62e1b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'adding bar', 'operation': 'amend', 'user': 'test'} |
|
211 | 211 | #endif |
|
212 | 212 | |
|
213 | 213 | Cannot amend public changeset |
|
214 | 214 | |
|
215 | 215 | $ hg phase -r A --public |
|
216 | 216 | $ hg update -C -q A |
|
217 | 217 | $ hg amend -m AMEND |
|
218 | 218 | abort: cannot amend public changesets |
|
219 | 219 | (see 'hg help phases' for details) |
|
220 | 220 | [255] |
|
221 | 221 | |
|
222 | 222 | Amend a merge changeset |
|
223 | 223 | |
|
224 | 224 | $ hg init $TESTTMP/repo3 |
|
225 | 225 | $ cd $TESTTMP/repo3 |
|
226 | 226 | $ hg debugdrawdag <<'EOS' |
|
227 | 227 | > C |
|
228 | 228 | > /| |
|
229 | 229 | > A B |
|
230 | 230 | > EOS |
|
231 | 231 | $ hg update -q C |
|
232 | 232 | $ hg amend -m FOO |
|
233 | 233 | saved backup bundle to $TESTTMP/repo3/.hg/strip-backup/a35c07e8a2a4-15ff4612-amend.hg (obsstore-off !) |
|
234 | 234 | $ rm .hg/localtags |
|
235 | 235 | $ hg log -G -T '{desc}\n' |
|
236 | 236 | @ FOO |
|
237 | 237 | |\ |
|
238 | 238 | | o B |
|
239 | 239 | | |
|
240 | 240 | o A |
|
241 | 241 | |
|
242 | 242 | |
|
243 | 243 | More complete test for status changes (issue5732) |
|
244 | 244 | ------------------------------------------------- |
|
245 | 245 | |
|
246 | 246 | Generates history of files having 3 states, r0_r1_wc: |
|
247 | 247 | |
|
248 | 248 | r0: ground (content/missing) |
|
249 | 249 | r1: old state to be amended (content/missing, where missing means removed) |
|
250 | 250 | wc: changes to be included in r1 (content/missing-tracked/untracked) |
|
251 | 251 | |
|
252 | 252 | $ hg init $TESTTMP/wcstates |
|
253 | 253 | $ cd $TESTTMP/wcstates |
|
254 | 254 | |
|
255 | 255 | $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 1 |
|
256 | 256 | $ hg addremove -q --similarity 0 |
|
257 | 257 | $ hg commit -m0 |
|
258 | 258 | |
|
259 | 259 | $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 2 |
|
260 | 260 | $ hg addremove -q --similarity 0 |
|
261 | 261 | $ hg commit -m1 |
|
262 | 262 | |
|
263 | 263 | $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 wc |
|
264 | 264 | $ hg addremove -q --similarity 0 |
|
265 | 265 | $ hg forget *_*_*-untracked |
|
266 | 266 | $ rm *_*_missing-* |
|
267 | 267 | |
|
268 | 268 | amend r1 to include wc changes |
|
269 | 269 | |
|
270 | 270 | $ hg amend |
|
271 | 271 | saved backup bundle to * (glob) (obsstore-off !) |
|
272 | 272 | |
|
273 | 273 | clean/modified/removed/added states of the amended revision |
|
274 | 274 | |
|
275 | 275 | $ hg status --all --change . 'glob:content1_*_content1-tracked' |
|
276 | 276 | C content1_content1_content1-tracked |
|
277 | 277 | C content1_content2_content1-tracked |
|
278 | 278 | C content1_missing_content1-tracked |
|
279 | 279 | $ hg status --all --change . 'glob:content1_*_content[23]-tracked' |
|
280 | 280 | M content1_content1_content3-tracked |
|
281 | 281 | M content1_content2_content2-tracked |
|
282 | 282 | M content1_content2_content3-tracked |
|
283 | 283 | M content1_missing_content3-tracked |
|
284 | 284 | $ hg status --all --change . 'glob:content1_*_missing-tracked' |
|
285 | 285 | M content1_content2_missing-tracked |
|
286 | 286 | R content1_missing_missing-tracked |
|
287 | 287 | C content1_content1_missing-tracked |
|
288 | 288 | $ hg status --all --change . 'glob:content1_*_*-untracked' |
|
289 | 289 | R content1_content1_content1-untracked |
|
290 | 290 | R content1_content1_content3-untracked |
|
291 | 291 | R content1_content1_missing-untracked |
|
292 | 292 | R content1_content2_content1-untracked |
|
293 | 293 | R content1_content2_content2-untracked |
|
294 | 294 | R content1_content2_content3-untracked |
|
295 | 295 | R content1_content2_missing-untracked |
|
296 | 296 | R content1_missing_content1-untracked |
|
297 | 297 | R content1_missing_content3-untracked |
|
298 | 298 | R content1_missing_missing-untracked |
|
299 | 299 | $ hg status --all --change . 'glob:missing_content2_*' |
|
300 | 300 | A missing_content2_content2-tracked |
|
301 | 301 | A missing_content2_content3-tracked |
|
302 | 302 | A missing_content2_missing-tracked |
|
303 | 303 | $ hg status --all --change . 'glob:missing_missing_*' |
|
304 | 304 | A missing_missing_content3-tracked |
|
305 | 305 | |
|
306 | 306 | working directory should be all clean (with some missing/untracked files) |
|
307 | 307 | |
|
308 | 308 | $ hg status --all 'glob:*_content?-tracked' |
|
309 | 309 | C content1_content1_content1-tracked |
|
310 | 310 | C content1_content1_content3-tracked |
|
311 | 311 | C content1_content2_content1-tracked |
|
312 | 312 | C content1_content2_content2-tracked |
|
313 | 313 | C content1_content2_content3-tracked |
|
314 | 314 | C content1_missing_content1-tracked |
|
315 | 315 | C content1_missing_content3-tracked |
|
316 | 316 | C missing_content2_content2-tracked |
|
317 | 317 | C missing_content2_content3-tracked |
|
318 | 318 | C missing_missing_content3-tracked |
|
319 | 319 | $ hg status --all 'glob:*_missing-tracked' |
|
320 | 320 | ! content1_content1_missing-tracked |
|
321 | 321 | ! content1_content2_missing-tracked |
|
322 | 322 | ! content1_missing_missing-tracked |
|
323 | 323 | ! missing_content2_missing-tracked |
|
324 | 324 | ! missing_missing_missing-tracked |
|
325 | 325 | $ hg status --all 'glob:*-untracked' |
|
326 | 326 | ? content1_content1_content1-untracked |
|
327 | 327 | ? content1_content1_content3-untracked |
|
328 | 328 | ? content1_content2_content1-untracked |
|
329 | 329 | ? content1_content2_content2-untracked |
|
330 | 330 | ? content1_content2_content3-untracked |
|
331 | 331 | ? content1_missing_content1-untracked |
|
332 | 332 | ? content1_missing_content3-untracked |
|
333 | 333 | ? missing_content2_content2-untracked |
|
334 | 334 | ? missing_content2_content3-untracked |
|
335 | 335 | ? missing_missing_content3-untracked |
|
336 | 336 | |
|
337 | 337 | ================================= |
|
338 | 338 | Test backup-bundle config option| |
|
339 | 339 | ================================= |
|
340 | 340 | $ hg init $TESTTMP/repo4 |
|
341 | 341 | $ cd $TESTTMP/repo4 |
|
342 | 342 | $ echo a>a |
|
343 | 343 | $ hg ci -Aqma |
|
344 | 344 | $ echo oops>b |
|
345 | 345 | $ hg ci -Aqm "b" |
|
346 | 346 | $ echo partiallyfixed > b |
|
347 | 347 | |
|
348 | 348 | #if obsstore-off |
|
349 | 349 | $ hg amend |
|
350 | 350 | saved backup bundle to $TESTTMP/repo4/.hg/strip-backup/95e899acf2ce-f11cb050-amend.hg |
|
351 | 351 | When backup-bundle config option is set: |
|
352 | 352 | $ cat << EOF >> $HGRCPATH |
|
353 | 353 | > [rewrite] |
|
354 | 354 | > backup-bundle = False |
|
355 | 355 | > EOF |
|
356 | 356 | $ echo fixed > b |
|
357 | 357 | $ hg amend |
|
358 | 358 | |
|
359 | 359 | #else |
|
360 | 360 | $ hg amend |
|
361 | 361 | When backup-bundle config option is set: |
|
362 | 362 | $ cat << EOF >> $HGRCPATH |
|
363 | 363 | > [rewrite] |
|
364 | 364 | > backup-bundle = False |
|
365 | 365 | > EOF |
|
366 | 366 | $ echo fixed > b |
|
367 | 367 | $ hg amend |
|
368 | 368 | |
|
369 | 369 | #endif |
|
370 | 370 | ========================================== |
|
371 | 371 | Test update-timestamp config option| |
|
372 | 372 | ========================================== |
|
373 | 373 | |
|
374 | 374 | $ cat >> $HGRCPATH << EOF |
|
375 | 375 | > [extensions] |
|
376 | 376 | > amend= |
|
377 | 377 | > mockmakedate = $TESTDIR/mockmakedate.py |
|
378 | 378 | > EOF |
|
379 | 379 | |
|
380 | 380 | $ hg init $TESTTMP/repo5 |
|
381 | 381 | $ cd $TESTTMP/repo5 |
|
382 | 382 | $ cat <<'EOF' >> .hg/hgrc |
|
383 | 383 | > [ui] |
|
384 | 384 | > logtemplate = 'user: {user} |
|
385 | 385 | > date: {date|date} |
|
386 | 386 | > summary: {desc|firstline}\n' |
|
387 | 387 | > EOF |
|
388 | 388 | |
|
389 | 389 | $ echo a>a |
|
390 | 390 | $ hg ci -Am 'commit 1' |
|
391 | 391 | adding a |
|
392 | 392 | |
|
393 | 393 | When updatetimestamp is False |
|
394 | 394 | |
|
395 | 395 | $ hg amend --date '1997-1-1 0:1' |
|
396 | 396 | $ hg log --limit 1 |
|
397 | 397 | user: test |
|
398 | 398 | date: Wed Jan 01 00:01:00 1997 +0000 |
|
399 | 399 | summary: commit 1 |
|
400 | 400 | |
|
401 | 401 | When update-timestamp is True and no other change than the date |
|
402 | 402 | |
|
403 | 403 | $ hg amend --config rewrite.update-timestamp=True |
|
404 | 404 | nothing changed |
|
405 | 405 | [1] |
|
406 | 406 | $ hg log --limit 1 |
|
407 | 407 | user: test |
|
408 | 408 | date: Wed Jan 01 00:01:00 1997 +0000 |
|
409 | 409 | summary: commit 1 |
|
410 | 410 | |
|
411 | 411 | When update-timestamp is True and there is other change than the date |
|
412 | 412 | $ hg amend --user foobar --config rewrite.update-timestamp=True |
|
413 | 413 | $ hg log --limit 1 |
|
414 | 414 | user: foobar |
|
415 | 415 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
416 | 416 | summary: commit 1 |
|
417 | 417 | |
|
418 | 418 | When date option is applicable and update-timestamp is True |
|
419 | 419 | $ hg amend --date '1998-1-1 0:1' --config rewrite.update-timestamp=True |
|
420 | 420 | $ hg log --limit 1 |
|
421 | 421 | user: foobar |
|
422 | 422 | date: Thu Jan 01 00:01:00 1998 +0000 |
|
423 | 423 | summary: commit 1 |
|
424 | 424 | |
|
425 | 425 | Unlike rewrite.update-timestamp, -D/--currentdate always updates the timestamp |
|
426 | 426 | |
|
427 | 427 | $ hg amend -D |
|
428 | 428 | $ hg log --limit 1 |
|
429 | 429 | user: foobar |
|
430 | 430 | date: Thu Jan 01 00:00:04 1970 +0000 |
|
431 | 431 | summary: commit 1 |
|
432 | 432 | |
|
433 | 433 | $ hg amend -D --config rewrite.update-timestamp=True |
|
434 | 434 | $ hg log --limit 1 |
|
435 | 435 | user: foobar |
|
436 | 436 | date: Thu Jan 01 00:00:05 1970 +0000 |
|
437 | 437 | summary: commit 1 |
|
438 | 438 | |
|
439 | 439 | rewrite.update-timestamp can be negated by --no-currentdate |
|
440 | 440 | |
|
441 | 441 | $ hg amend --config rewrite.update-timestamp=True --no-currentdate -u baz |
|
442 | 442 | $ hg log --limit 1 |
|
443 | 443 | user: baz |
|
444 | 444 | date: Thu Jan 01 00:00:05 1970 +0000 |
|
445 | 445 | summary: commit 1 |
|
446 | 446 | |
|
447 | 447 | Bad combination of date options: |
|
448 | 448 | |
|
449 | 449 | $ hg amend -D --date '0 0' |
|
450 | 450 | abort: --date and --currentdate are mutually exclusive |
|
451 | 451 | [255] |
|
452 | 452 | |
|
453 | 453 | Close branch |
|
454 | 454 | |
|
455 | $ hg amend --close-branch | |
|
456 | $ hg log --limit 1 -T 'close={get(extras, "close")}\n' | |
|
455 | $ hg amend --secret --close-branch | |
|
456 | $ hg log --limit 1 -T 'close={get(extras, "close")}\nphase={phase}\n' | |
|
457 | 457 | close=1 |
|
458 | phase=secret | |
|
458 | 459 | |
|
459 | 460 | $ cd .. |
|
460 | 461 | |
|
461 | 462 | Corner case of amend from issue6157: |
|
462 | 463 | - working copy parent has a change to file `a` |
|
463 | 464 | - working copy has the inverse change |
|
464 | 465 | - we amend the working copy parent for files other than `a` |
|
465 | 466 | hg used to include the changes to `a` anyway. |
|
466 | 467 | |
|
467 | 468 | $ hg init 6157; cd 6157 |
|
468 | 469 | $ echo a > a; echo b > b; hg commit -qAm_ |
|
469 | 470 | $ echo a2 > a; hg commit -qm_ |
|
470 | 471 | $ hg diff --stat -c . |
|
471 | 472 | a | 2 +- |
|
472 | 473 | 1 files changed, 1 insertions(+), 1 deletions(-) |
|
473 | 474 | $ echo a > a; echo b2 > b; hg amend -q b |
|
474 | 475 | $ hg diff --stat -c . |
|
475 | 476 | a | 2 +- |
|
476 | 477 | b | 2 +- |
|
477 | 478 | 2 files changed, 2 insertions(+), 2 deletions(-) |
General Comments 0
You need to be logged in to leave comments.
Login now