##// END OF EJS Templates
mq: disable qrecord during histedit (issue5981)...
Navaneeth Suresh -
r41956:4d21ebc4 default
parent child Browse files
Show More
@@ -1,150 +1,151 b''
1 1 # record.py
2 2 #
3 3 # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com>
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
8 8 '''commands to interactively select changes for commit/qrefresh (DEPRECATED)
9 9
10 10 The feature provided by this extension has been moved into core Mercurial as
11 11 :hg:`commit --interactive`.'''
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 error,
20 20 extensions,
21 21 registrar,
22 22 )
23 23
24 24 cmdtable = {}
25 25 command = registrar.command(cmdtable)
26 26 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
27 27 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
28 28 # be specifying the version(s) of Mercurial they are tested with, or
29 29 # leave the attribute unspecified.
30 30 testedwith = 'ships-with-hg-core'
31 31
32 32
33 33 @command("record",
34 34 # same options as commit + white space diff options
35 35 [c for c in commands.table['commit|ci'][1][:]
36 36 if c[1] != "interactive"] + cmdutil.diffwsopts,
37 37 _('hg record [OPTION]... [FILE]...'),
38 38 helpcategory=command.CATEGORY_COMMITTING)
39 39 def record(ui, repo, *pats, **opts):
40 40 '''interactively select changes to commit
41 41
42 42 If a list of files is omitted, all changes reported by :hg:`status`
43 43 will be candidates for recording.
44 44
45 45 See :hg:`help dates` for a list of formats valid for -d/--date.
46 46
47 47 If using the text interface (see :hg:`help config`),
48 48 you will be prompted for whether to record changes to each
49 49 modified file, and for files with multiple changes, for each
50 50 change to use. For each query, the following responses are
51 51 possible::
52 52
53 53 y - record this change
54 54 n - skip this change
55 55 e - edit this change manually
56 56
57 57 s - skip remaining changes to this file
58 58 f - record remaining changes to this file
59 59
60 60 d - done, skip remaining changes and files
61 61 a - record all changes to all remaining files
62 62 q - quit, recording no changes
63 63
64 64 ? - display help
65 65
66 66 This command is not available when committing a merge.'''
67 67
68 68 if not ui.interactive():
69 69 raise error.Abort(_('running non-interactively, use %s instead') %
70 70 'commit')
71 71
72 72 opts[r"interactive"] = True
73 73 overrides = {('experimental', 'crecord'): False}
74 74 with ui.configoverride(overrides, 'record'):
75 75 return commands.commit(ui, repo, *pats, **opts)
76 76
77 77 def qrefresh(origfn, ui, repo, *pats, **opts):
78 78 if not opts[r'interactive']:
79 79 return origfn(ui, repo, *pats, **opts)
80 80
81 81 mq = extensions.find('mq')
82 82
83 83 def committomq(ui, repo, *pats, **opts):
84 84 # At this point the working copy contains only changes that
85 85 # were accepted. All other changes were reverted.
86 86 # We can't pass *pats here since qrefresh will undo all other
87 87 # changed files in the patch that aren't in pats.
88 88 mq.refresh(ui, repo, **opts)
89 89
90 90 # backup all changed files
91 91 cmdutil.dorecord(ui, repo, committomq, None, True,
92 92 cmdutil.recordfilter, *pats, **opts)
93 93
94 94 # This command registration is replaced during uisetup().
95 95 @command('qrecord',
96 96 [],
97 97 _('hg qrecord [OPTION]... PATCH [FILE]...'),
98 98 helpcategory=command.CATEGORY_COMMITTING,
99 99 inferrepo=True)
100 100 def qrecord(ui, repo, patch, *pats, **opts):
101 101 '''interactively record a new patch
102 102
103 103 See :hg:`help qnew` & :hg:`help record` for more information and
104 104 usage.
105 105 '''
106 106 return _qrecord('qnew', ui, repo, patch, *pats, **opts)
107 107
108 108 def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts):
109 109 try:
110 110 mq = extensions.find('mq')
111 111 except KeyError:
112 112 raise error.Abort(_("'mq' extension not loaded"))
113 113
114 114 repo.mq.checkpatchname(patch)
115 115
116 116 def committomq(ui, repo, *pats, **opts):
117 117 opts[r'checkname'] = False
118 118 mq.new(ui, repo, patch, *pats, **opts)
119 119
120 120 overrides = {('experimental', 'crecord'): False}
121 121 with ui.configoverride(overrides, 'record'):
122 cmdutil.checkunfinished(repo)
122 123 cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
123 124 cmdutil.recordfilter, *pats, **opts)
124 125
125 126 def qnew(origfn, ui, repo, patch, *args, **opts):
126 127 if opts[r'interactive']:
127 128 return _qrecord(None, ui, repo, patch, *args, **opts)
128 129 return origfn(ui, repo, patch, *args, **opts)
129 130
130 131
131 132 def uisetup(ui):
132 133 try:
133 134 mq = extensions.find('mq')
134 135 except KeyError:
135 136 return
136 137
137 138 cmdtable["qrecord"] = (
138 139 qrecord,
139 140 # same options as qnew, but copy them so we don't get
140 141 # -i/--interactive for qrecord and add white space diff options
141 142 mq.cmdtable['qnew'][1][:] + cmdutil.diffwsopts,
142 143 _('hg qrecord [OPTION]... PATCH [FILE]...'))
143 144
144 145 _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
145 146 _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
146 147 _("interactively select changes to refresh"))
147 148
148 149 def _wrapcmd(cmd, table, wrapfn, msg):
149 150 entry = extensions.wrapcommand(table, cmd, wrapfn)
150 151 entry[1].append(('i', 'interactive', None, msg))
@@ -1,424 +1,464 b''
1 1 Create configuration
2 2
3 3 $ echo "[ui]" >> $HGRCPATH
4 4 $ echo "interactive=true" >> $HGRCPATH
5 5
6 6 help record (no record)
7 7
8 8 $ hg help record
9 9 record extension - commands to interactively select changes for
10 10 commit/qrefresh (DEPRECATED)
11 11
12 12 The feature provided by this extension has been moved into core Mercurial as
13 13 'hg commit --interactive'.
14 14
15 15 (use 'hg help extensions' for information on enabling extensions)
16 16
17 17 help qrecord (no record)
18 18
19 19 $ hg help qrecord
20 20 'qrecord' is provided by the following extension:
21 21
22 22 record commands to interactively select changes for commit/qrefresh
23 23 (DEPRECATED)
24 24
25 25 (use 'hg help extensions' for information on enabling extensions)
26 26
27 27 $ echo "[extensions]" >> $HGRCPATH
28 28 $ echo "record=" >> $HGRCPATH
29 29
30 30 help record (record)
31 31
32 32 $ hg help record
33 33 hg record [OPTION]... [FILE]...
34 34
35 35 interactively select changes to commit
36 36
37 37 If a list of files is omitted, all changes reported by 'hg status' will be
38 38 candidates for recording.
39 39
40 40 See 'hg help dates' for a list of formats valid for -d/--date.
41 41
42 42 If using the text interface (see 'hg help config'), you will be prompted
43 43 for whether to record changes to each modified file, and for files with
44 44 multiple changes, for each change to use. For each query, the following
45 45 responses are possible:
46 46
47 47 y - record this change
48 48 n - skip this change
49 49 e - edit this change manually
50 50
51 51 s - skip remaining changes to this file
52 52 f - record remaining changes to this file
53 53
54 54 d - done, skip remaining changes and files
55 55 a - record all changes to all remaining files
56 56 q - quit, recording no changes
57 57
58 58 ? - display help
59 59
60 60 This command is not available when committing a merge.
61 61
62 62 (use 'hg help -e record' to show help for the record extension)
63 63
64 64 options ([+] can be repeated):
65 65
66 66 -A --addremove mark new/missing files as added/removed before
67 67 committing
68 68 --close-branch mark a branch head as closed
69 69 --amend amend the parent of the working directory
70 70 -s --secret use the secret phase for committing
71 71 -e --edit invoke editor on commit messages
72 72 -I --include PATTERN [+] include names matching the given patterns
73 73 -X --exclude PATTERN [+] exclude names matching the given patterns
74 74 -m --message TEXT use text as commit message
75 75 -l --logfile FILE read commit message from file
76 76 -d --date DATE record the specified date as commit date
77 77 -u --user USER record the specified user as committer
78 78 -S --subrepos recurse into subrepositories
79 79 -w --ignore-all-space ignore white space when comparing lines
80 80 -b --ignore-space-change ignore changes in the amount of white space
81 81 -B --ignore-blank-lines ignore changes whose lines are all blank
82 82 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
83 83
84 84 (some details hidden, use --verbose to show complete help)
85 85
86 86 help (no mq, so no qrecord)
87 87
88 88 $ hg help qrecord
89 89 hg qrecord [OPTION]... PATCH [FILE]...
90 90
91 91 interactively record a new patch
92 92
93 93 See 'hg help qnew' & 'hg help record' for more information and usage.
94 94
95 95 (some details hidden, use --verbose to show complete help)
96 96
97 97 $ hg init a
98 98
99 99 qrecord (mq not present)
100 100
101 101 $ hg -R a qrecord
102 102 hg qrecord: invalid arguments
103 103 hg qrecord [OPTION]... PATCH [FILE]...
104 104
105 105 interactively record a new patch
106 106
107 107 (use 'hg qrecord -h' to show more help)
108 108 [255]
109 109
110 110 qrecord patch (mq not present)
111 111
112 112 $ hg -R a qrecord patch
113 113 abort: 'mq' extension not loaded
114 114 [255]
115 115
116 116 help (bad mq)
117 117
118 118 $ echo "mq=nonexistent" >> $HGRCPATH
119 119 $ hg help qrecord
120 120 *** failed to import extension mq from nonexistent: [Errno *] * (glob)
121 121 hg qrecord [OPTION]... PATCH [FILE]...
122 122
123 123 interactively record a new patch
124 124
125 125 See 'hg help qnew' & 'hg help record' for more information and usage.
126 126
127 127 (some details hidden, use --verbose to show complete help)
128 128
129 129 help (mq present)
130 130
131 131 $ sed 's/mq=nonexistent/mq=/' $HGRCPATH > hgrc.tmp
132 132 $ mv hgrc.tmp $HGRCPATH
133 133
134 134 $ hg help qrecord
135 135 hg qrecord [OPTION]... PATCH [FILE]...
136 136
137 137 interactively record a new patch
138 138
139 139 See 'hg help qnew' & 'hg help record' for more information and usage.
140 140
141 141 options ([+] can be repeated):
142 142
143 143 -e --edit invoke editor on commit messages
144 144 -g --git use git extended diff format
145 145 -U --currentuser add "From: <current user>" to patch
146 146 -u --user USER add "From: <USER>" to patch
147 147 -D --currentdate add "Date: <current date>" to patch
148 148 -d --date DATE add "Date: <DATE>" to patch
149 149 -I --include PATTERN [+] include names matching the given patterns
150 150 -X --exclude PATTERN [+] exclude names matching the given patterns
151 151 -m --message TEXT use text as commit message
152 152 -l --logfile FILE read commit message from file
153 153 -w --ignore-all-space ignore white space when comparing lines
154 154 -b --ignore-space-change ignore changes in the amount of white space
155 155 -B --ignore-blank-lines ignore changes whose lines are all blank
156 156 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
157 157 --mq operate on patch repository
158 158
159 159 (some details hidden, use --verbose to show complete help)
160 160
161 161 $ cd a
162 162
163 163 Base commit
164 164
165 165 $ cat > 1.txt <<EOF
166 166 > 1
167 167 > 2
168 168 > 3
169 169 > 4
170 170 > 5
171 171 > EOF
172 172 $ cat > 2.txt <<EOF
173 173 > a
174 174 > b
175 175 > c
176 176 > d
177 177 > e
178 178 > f
179 179 > EOF
180 180
181 181 $ mkdir dir
182 182 $ cat > dir/a.txt <<EOF
183 183 > hello world
184 184 >
185 185 > someone
186 186 > up
187 187 > there
188 188 > loves
189 189 > me
190 190 > EOF
191 191
192 192 $ hg add 1.txt 2.txt dir/a.txt
193 193 $ hg commit -m 'initial checkin'
194 194
195 195 Changing files
196 196
197 197 $ sed -e 's/2/2 2/;s/4/4 4/' 1.txt > 1.txt.new
198 198 $ sed -e 's/b/b b/' 2.txt > 2.txt.new
199 199 $ sed -e 's/hello world/hello world!/' dir/a.txt > dir/a.txt.new
200 200
201 201 $ mv -f 1.txt.new 1.txt
202 202 $ mv -f 2.txt.new 2.txt
203 203 $ mv -f dir/a.txt.new dir/a.txt
204 204
205 205 Whole diff
206 206
207 207 $ hg diff --nodates
208 208 diff -r 1057167b20ef 1.txt
209 209 --- a/1.txt
210 210 +++ b/1.txt
211 211 @@ -1,5 +1,5 @@
212 212 1
213 213 -2
214 214 +2 2
215 215 3
216 216 -4
217 217 +4 4
218 218 5
219 219 diff -r 1057167b20ef 2.txt
220 220 --- a/2.txt
221 221 +++ b/2.txt
222 222 @@ -1,5 +1,5 @@
223 223 a
224 224 -b
225 225 +b b
226 226 c
227 227 d
228 228 e
229 229 diff -r 1057167b20ef dir/a.txt
230 230 --- a/dir/a.txt
231 231 +++ b/dir/a.txt
232 232 @@ -1,4 +1,4 @@
233 233 -hello world
234 234 +hello world!
235 235
236 236 someone
237 237 up
238 238
239 239 qrecord with bad patch name, should abort before prompting
240 240
241 241 $ hg qrecord .hg
242 242 abort: patch name cannot begin with ".hg"
243 243 [255]
244 244 $ hg qrecord ' foo'
245 245 abort: patch name cannot begin or end with whitespace
246 246 [255]
247 247 $ hg qrecord 'foo '
248 248 abort: patch name cannot begin or end with whitespace
249 249 [255]
250 250
251 251 qrecord a.patch
252 252
253 253 $ hg qrecord -d '0 0' -m aaa a.patch <<EOF
254 254 > y
255 255 > y
256 256 > n
257 257 > y
258 258 > y
259 259 > n
260 260 > EOF
261 261 diff --git a/1.txt b/1.txt
262 262 2 hunks, 2 lines changed
263 263 examine changes to '1.txt'? [Ynesfdaq?] y
264 264
265 265 @@ -1,3 +1,3 @@
266 266 1
267 267 -2
268 268 +2 2
269 269 3
270 270 record change 1/4 to '1.txt'? [Ynesfdaq?] y
271 271
272 272 @@ -3,3 +3,3 @@
273 273 3
274 274 -4
275 275 +4 4
276 276 5
277 277 record change 2/4 to '1.txt'? [Ynesfdaq?] n
278 278
279 279 diff --git a/2.txt b/2.txt
280 280 1 hunks, 1 lines changed
281 281 examine changes to '2.txt'? [Ynesfdaq?] y
282 282
283 283 @@ -1,5 +1,5 @@
284 284 a
285 285 -b
286 286 +b b
287 287 c
288 288 d
289 289 e
290 290 record change 3/4 to '2.txt'? [Ynesfdaq?] y
291 291
292 292 diff --git a/dir/a.txt b/dir/a.txt
293 293 1 hunks, 1 lines changed
294 294 examine changes to 'dir/a.txt'? [Ynesfdaq?] n
295 295
296 296
297 297 After qrecord a.patch 'tip'"
298 298
299 299 $ hg tip -p
300 300 changeset: 1:5d1ca63427ee
301 301 tag: a.patch
302 302 tag: qbase
303 303 tag: qtip
304 304 tag: tip
305 305 user: test
306 306 date: Thu Jan 01 00:00:00 1970 +0000
307 307 summary: aaa
308 308
309 309 diff -r 1057167b20ef -r 5d1ca63427ee 1.txt
310 310 --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
311 311 +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
312 312 @@ -1,5 +1,5 @@
313 313 1
314 314 -2
315 315 +2 2
316 316 3
317 317 4
318 318 5
319 319 diff -r 1057167b20ef -r 5d1ca63427ee 2.txt
320 320 --- a/2.txt Thu Jan 01 00:00:00 1970 +0000
321 321 +++ b/2.txt Thu Jan 01 00:00:00 1970 +0000
322 322 @@ -1,5 +1,5 @@
323 323 a
324 324 -b
325 325 +b b
326 326 c
327 327 d
328 328 e
329 329
330 330
331 331 After qrecord a.patch 'diff'"
332 332
333 333 $ hg diff --nodates
334 334 diff -r 5d1ca63427ee 1.txt
335 335 --- a/1.txt
336 336 +++ b/1.txt
337 337 @@ -1,5 +1,5 @@
338 338 1
339 339 2 2
340 340 3
341 341 -4
342 342 +4 4
343 343 5
344 344 diff -r 5d1ca63427ee dir/a.txt
345 345 --- a/dir/a.txt
346 346 +++ b/dir/a.txt
347 347 @@ -1,4 +1,4 @@
348 348 -hello world
349 349 +hello world!
350 350
351 351 someone
352 352 up
353 353
354 354 qrecord b.patch
355 355
356 356 $ hg qrecord -d '0 0' -m bbb b.patch <<EOF
357 357 > y
358 358 > y
359 359 > y
360 360 > y
361 361 > EOF
362 362 diff --git a/1.txt b/1.txt
363 363 1 hunks, 1 lines changed
364 364 examine changes to '1.txt'? [Ynesfdaq?] y
365 365
366 366 @@ -1,5 +1,5 @@
367 367 1
368 368 2 2
369 369 3
370 370 -4
371 371 +4 4
372 372 5
373 373 record change 1/2 to '1.txt'? [Ynesfdaq?] y
374 374
375 375 diff --git a/dir/a.txt b/dir/a.txt
376 376 1 hunks, 1 lines changed
377 377 examine changes to 'dir/a.txt'? [Ynesfdaq?] y
378 378
379 379 @@ -1,4 +1,4 @@
380 380 -hello world
381 381 +hello world!
382 382
383 383 someone
384 384 up
385 385 record change 2/2 to 'dir/a.txt'? [Ynesfdaq?] y
386 386
387 387
388 388 After qrecord b.patch 'tip'
389 389
390 390 $ hg tip -p
391 391 changeset: 2:b056198bf878
392 392 tag: b.patch
393 393 tag: qtip
394 394 tag: tip
395 395 user: test
396 396 date: Thu Jan 01 00:00:00 1970 +0000
397 397 summary: bbb
398 398
399 399 diff -r 5d1ca63427ee -r b056198bf878 1.txt
400 400 --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
401 401 +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
402 402 @@ -1,5 +1,5 @@
403 403 1
404 404 2 2
405 405 3
406 406 -4
407 407 +4 4
408 408 5
409 409 diff -r 5d1ca63427ee -r b056198bf878 dir/a.txt
410 410 --- a/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
411 411 +++ b/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
412 412 @@ -1,4 +1,4 @@
413 413 -hello world
414 414 +hello world!
415 415
416 416 someone
417 417 up
418 418
419 419
420 420 After qrecord b.patch 'diff'
421 421
422 422 $ hg diff --nodates
423 423
424 424 $ cd ..
425
426 qrecord should throw an error when histedit in process
427
428 $ hg init issue5981
429 $ cd issue5981
430 $ cat >> $HGRCPATH <<EOF
431 > [extensions]
432 > histedit=
433 > mq=
434 > EOF
435 $ echo > a
436 $ hg ci -Am 'foo bar'
437 adding a
438 $ hg log
439 changeset: 0:ea55e2ae468f
440 tag: tip
441 user: test
442 date: Thu Jan 01 00:00:00 1970 +0000
443 summary: foo bar
444
445 $ hg histedit tip --commands - 2>&1 <<EOF
446 > edit ea55e2ae468f foo bar
447 > EOF
448 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
449 adding a
450 Editing (ea55e2ae468f), you may commit or record as needed now.
451 (hg histedit --continue to resume)
452 [1]
453 $ echo 'foo bar' > a
454 $ hg qrecord -d '0 0' -m aaa a.patch <<EOF
455 > y
456 > y
457 > n
458 > y
459 > y
460 > n
461 > EOF
462 abort: histedit in progress
463 (use 'hg histedit --continue' or 'hg histedit --abort')
464 [255]
General Comments 0
You need to be logged in to leave comments. Login now