##// END OF EJS Templates
record: add qrefresh -i/--interactive...
Idan Kamara -
r14426:1df64cce default
parent child Browse files
Show More
@@ -0,0 +1,348 b''
1 Create configuration
2
3 $ echo "[ui]" >> $HGRCPATH
4 $ echo "interactive=true" >> $HGRCPATH
5
6 help qrefresh (no record)
7
8 $ echo "[extensions]" >> $HGRCPATH
9 $ echo "mq=" >> $HGRCPATH
10 $ hg help qrefresh
11 hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...
12
13 update the current patch
14
15 If any file patterns are provided, the refreshed patch will contain only
16 the modifications that match those patterns; the remaining modifications
17 will remain in the working directory.
18
19 If -s/--short is specified, files currently included in the patch will be
20 refreshed just like matched files and remain in the patch.
21
22 If -e/--edit is specified, Mercurial will start your configured editor for
23 you to enter a message. In case qrefresh fails, you will find a backup of
24 your message in ".hg/last-message.txt".
25
26 hg add/remove/copy/rename work as usual, though you might want to use git-
27 style patches (-g/--git or [diff] git=1) to track copies and renames. See
28 the diffs help topic for more information on the git diff format.
29
30 Returns 0 on success.
31
32 options:
33
34 -e --edit edit commit message
35 -g --git use git extended diff format
36 -s --short refresh only files already in the patch and
37 specified files
38 -U --currentuser add/update author field in patch with current user
39 -u --user USER add/update author field in patch with given user
40 -D --currentdate add/update date field in patch with current date
41 -d --date DATE add/update date field in patch with given date
42 -I --include PATTERN [+] include names matching the given patterns
43 -X --exclude PATTERN [+] exclude names matching the given patterns
44 -m --message TEXT use text as commit message
45 -l --logfile FILE read commit message from file
46
47 [+] marked option can be specified multiple times
48
49 use "hg -v help qrefresh" to show global options
50
51 help qrefresh (record)
52
53 $ echo "record=" >> $HGRCPATH
54 $ hg help qrefresh
55 hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...
56
57 update the current patch
58
59 If any file patterns are provided, the refreshed patch will contain only
60 the modifications that match those patterns; the remaining modifications
61 will remain in the working directory.
62
63 If -s/--short is specified, files currently included in the patch will be
64 refreshed just like matched files and remain in the patch.
65
66 If -e/--edit is specified, Mercurial will start your configured editor for
67 you to enter a message. In case qrefresh fails, you will find a backup of
68 your message in ".hg/last-message.txt".
69
70 hg add/remove/copy/rename work as usual, though you might want to use git-
71 style patches (-g/--git or [diff] git=1) to track copies and renames. See
72 the diffs help topic for more information on the git diff format.
73
74 Returns 0 on success.
75
76 options:
77
78 -e --edit edit commit message
79 -g --git use git extended diff format
80 -s --short refresh only files already in the patch and
81 specified files
82 -U --currentuser add/update author field in patch with current user
83 -u --user USER add/update author field in patch with given user
84 -D --currentdate add/update date field in patch with current date
85 -d --date DATE add/update date field in patch with given date
86 -I --include PATTERN [+] include names matching the given patterns
87 -X --exclude PATTERN [+] exclude names matching the given patterns
88 -m --message TEXT use text as commit message
89 -l --logfile FILE read commit message from file
90 -i --interactive interactively select changes to refresh
91
92 [+] marked option can be specified multiple times
93
94 use "hg -v help qrefresh" to show global options
95
96 $ hg init a
97 $ cd a
98
99 Base commit
100
101 $ cat > 1.txt <<EOF
102 > 1
103 > 2
104 > 3
105 > 4
106 > 5
107 > EOF
108 $ cat > 2.txt <<EOF
109 > a
110 > b
111 > c
112 > d
113 > e
114 > f
115 > EOF
116
117 $ mkdir dir
118 $ cat > dir/a.txt <<EOF
119 > hello world
120 >
121 > someone
122 > up
123 > there
124 > loves
125 > me
126 > EOF
127
128 $ hg add 1.txt 2.txt dir/a.txt
129 $ hg commit -m aaa
130 $ hg qnew -d '0 0' patch
131
132 Changing files
133
134 $ sed -e 's/2/2 2/;s/4/4 4/' 1.txt > 1.txt.new
135 $ sed -e 's/b/b b/' 2.txt > 2.txt.new
136 $ sed -e 's/hello world/hello world!/' dir/a.txt > dir/a.txt.new
137
138 $ mv -f 1.txt.new 1.txt
139 $ mv -f 2.txt.new 2.txt
140 $ mv -f dir/a.txt.new dir/a.txt
141
142 Whole diff
143
144 $ hg diff --nodates
145 diff -r ed27675cb5df 1.txt
146 --- a/1.txt
147 +++ b/1.txt
148 @@ -1,5 +1,5 @@
149 1
150 -2
151 +2 2
152 3
153 -4
154 +4 4
155 5
156 diff -r ed27675cb5df 2.txt
157 --- a/2.txt
158 +++ b/2.txt
159 @@ -1,5 +1,5 @@
160 a
161 -b
162 +b b
163 c
164 d
165 e
166 diff -r ed27675cb5df dir/a.txt
167 --- a/dir/a.txt
168 +++ b/dir/a.txt
169 @@ -1,4 +1,4 @@
170 -hello world
171 +hello world!
172
173 someone
174 up
175
176 partial qrefresh
177
178 $ hg qrefresh -i -d '0 0' <<EOF
179 > y
180 > y
181 > n
182 > y
183 > y
184 > n
185 > EOF
186 diff --git a/1.txt b/1.txt
187 2 hunks, 2 lines changed
188 examine changes to '1.txt'? [Ynsfdaq?]
189 @@ -1,3 +1,3 @@
190 1
191 -2
192 +2 2
193 3
194 record change 1/4 to '1.txt'? [Ynsfdaq?]
195 @@ -3,3 +3,3 @@
196 3
197 -4
198 +4 4
199 5
200 record change 2/4 to '1.txt'? [Ynsfdaq?]
201 diff --git a/2.txt b/2.txt
202 1 hunks, 1 lines changed
203 examine changes to '2.txt'? [Ynsfdaq?]
204 @@ -1,5 +1,5 @@
205 a
206 -b
207 +b b
208 c
209 d
210 e
211 record change 3/4 to '2.txt'? [Ynsfdaq?]
212 diff --git a/dir/a.txt b/dir/a.txt
213 1 hunks, 1 lines changed
214 examine changes to 'dir/a.txt'? [Ynsfdaq?]
215
216 After partial qrefresh 'tip'
217
218 $ hg tip -p
219 changeset: 1:0738af1a8211
220 tag: patch
221 tag: qbase
222 tag: qtip
223 tag: tip
224 user: test
225 date: Thu Jan 01 00:00:00 1970 +0000
226 summary: [mq]: patch
227
228 diff -r 1fd39ab63a33 -r 0738af1a8211 1.txt
229 --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
230 +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
231 @@ -1,5 +1,5 @@
232 1
233 -2
234 +2 2
235 3
236 4
237 5
238 diff -r 1fd39ab63a33 -r 0738af1a8211 2.txt
239 --- a/2.txt Thu Jan 01 00:00:00 1970 +0000
240 +++ b/2.txt Thu Jan 01 00:00:00 1970 +0000
241 @@ -1,5 +1,5 @@
242 a
243 -b
244 +b b
245 c
246 d
247 e
248
249 After partial qrefresh 'diff'
250
251 $ hg diff --nodates
252 diff -r 0738af1a8211 1.txt
253 --- a/1.txt
254 +++ b/1.txt
255 @@ -1,5 +1,5 @@
256 1
257 2 2
258 3
259 -4
260 +4 4
261 5
262 diff -r 0738af1a8211 dir/a.txt
263 --- a/dir/a.txt
264 +++ b/dir/a.txt
265 @@ -1,4 +1,4 @@
266 -hello world
267 +hello world!
268
269 someone
270 up
271
272 qrefresh interactively everything else
273
274 $ hg qrefresh -i -d '0 0' <<EOF
275 > y
276 > y
277 > y
278 > y
279 > EOF
280 diff --git a/1.txt b/1.txt
281 1 hunks, 1 lines changed
282 examine changes to '1.txt'? [Ynsfdaq?]
283 @@ -1,5 +1,5 @@
284 1
285 2 2
286 3
287 -4
288 +4 4
289 5
290 record change 1/2 to '1.txt'? [Ynsfdaq?]
291 diff --git a/dir/a.txt b/dir/a.txt
292 1 hunks, 1 lines changed
293 examine changes to 'dir/a.txt'? [Ynsfdaq?]
294 @@ -1,4 +1,4 @@
295 -hello world
296 +hello world!
297
298 someone
299 up
300 record change 2/2 to 'dir/a.txt'? [Ynsfdaq?]
301
302 After final qrefresh 'tip'
303
304 $ hg tip -p
305 changeset: 1:2c3f66afeed9
306 tag: patch
307 tag: qbase
308 tag: qtip
309 tag: tip
310 user: test
311 date: Thu Jan 01 00:00:00 1970 +0000
312 summary: [mq]: patch
313
314 diff -r 1fd39ab63a33 -r 2c3f66afeed9 1.txt
315 --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
316 +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
317 @@ -1,5 +1,5 @@
318 1
319 -2
320 +2 2
321 3
322 -4
323 +4 4
324 5
325 diff -r 1fd39ab63a33 -r 2c3f66afeed9 2.txt
326 --- a/2.txt Thu Jan 01 00:00:00 1970 +0000
327 +++ b/2.txt Thu Jan 01 00:00:00 1970 +0000
328 @@ -1,5 +1,5 @@
329 a
330 -b
331 +b b
332 c
333 d
334 e
335 diff -r 1fd39ab63a33 -r 2c3f66afeed9 dir/a.txt
336 --- a/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
337 +++ b/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
338 @@ -1,4 +1,4 @@
339 -hello world
340 +hello world!
341
342 someone
343 up
344
345
346 After qrefresh 'diff'
347
348 $ hg diff --nodates
@@ -376,6 +376,18 b' def record(ui, repo, *pats, **opts):'
376
376
377 dorecord(ui, repo, commands.commit, 'commit', False, *pats, **opts)
377 dorecord(ui, repo, commands.commit, 'commit', False, *pats, **opts)
378
378
379 def qrefresh(ui, repo, *pats, **opts):
380 mq = extensions.find('mq')
381
382 def committomq(ui, repo, *pats, **opts):
383 # At this point the working copy contains only changes that
384 # were accepted. All other changes were reverted.
385 # We can't pass *pats here since qrefresh will undo all other
386 # changed files in the patch that aren't in pats.
387 mq.refresh(ui, repo, **opts)
388
389 # backup all changed files
390 dorecord(ui, repo, committomq, 'qrefresh', True, *pats, **opts)
379
391
380 def qrecord(ui, repo, patch, *pats, **opts):
392 def qrecord(ui, repo, patch, *pats, **opts):
381 '''interactively record a new patch
393 '''interactively record a new patch
@@ -555,3 +567,15 b' def uisetup(ui):'
555 cmdtable["qrecord"] = \
567 cmdtable["qrecord"] = \
556 (qrecord, mq.cmdtable['^qnew'][1], # same options as qnew
568 (qrecord, mq.cmdtable['^qnew'][1], # same options as qnew
557 _('hg qrecord [OPTION]... PATCH [FILE]...'))
569 _('hg qrecord [OPTION]... PATCH [FILE]...'))
570
571 _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
572 _("interactively select changes to refresh"))
573
574 def _wrapcmd(cmd, table, wrapfn, msg):
575 '''wrap the command'''
576 def wrapper(orig, *args, **kwargs):
577 if kwargs['interactive']:
578 return wrapfn(*args, **kwargs)
579 return orig(*args, **kwargs)
580 entry = extensions.wrapcommand(table, cmd, wrapper)
581 entry[1].append(('i', 'interactive', None, msg))
General Comments 0
You need to be logged in to leave comments. Login now