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