##// END OF EJS Templates
record: allow splitting of hunks by manually editing patches...
A. S. Budden -
r16324:46b991a1 default
parent child Browse files
Show More
@@ -261,7 +261,7 b' def parsepatch(fp):'
261 261 def filterpatch(ui, headers):
262 262 """Interactively filter patch chunks into applied-only chunks"""
263 263
264 def prompt(skipfile, skipall, query):
264 def prompt(skipfile, skipall, query, chunk):
265 265 """prompt query, and process base inputs
266 266
267 267 - y/n for the rest of file
@@ -271,14 +271,16 b' def filterpatch(ui, headers):'
271 271
272 272 Return True/False and possibly updated skipfile and skipall.
273 273 """
274 newpatches = None
274 275 if skipall is not None:
275 return skipall, skipfile, skipall
276 return skipall, skipfile, skipall, newpatches
276 277 if skipfile is not None:
277 return skipfile, skipfile, skipall
278 return skipfile, skipfile, skipall, newpatches
278 279 while True:
279 resps = _('[Ynsfdaq?]')
280 resps = _('[Ynesfdaq?]')
280 281 choices = (_('&Yes, record this change'),
281 282 _('&No, skip this change'),
283 _('&Edit the change manually'),
282 284 _('&Skip remaining changes to this file'),
283 285 _('Record remaining changes to this &file'),
284 286 _('&Done, skip remaining changes and files'),
@@ -287,7 +289,7 b' def filterpatch(ui, headers):'
287 289 _('&?'))
288 290 r = ui.promptchoice("%s %s" % (query, resps), choices)
289 291 ui.write("\n")
290 if r == 7: # ?
292 if r == 8: # ?
291 293 doc = gettext(record.__doc__)
292 294 c = doc.find('::') + 2
293 295 for l in doc[c:].splitlines():
@@ -298,17 +300,69 b' def filterpatch(ui, headers):'
298 300 ret = True
299 301 elif r == 1: # no
300 302 ret = False
301 elif r == 2: # Skip
303 elif r == 2: # Edit patch
304 if chunk is None:
305 ui.write(_('cannot edit patch for whole file'))
306 ui.write("\n")
307 continue
308 if chunk.header.binary():
309 ui.write(_('cannot edit patch for binary file'))
310 ui.write("\n")
311 continue
312 # Patch comment based on the Git one (based on comment at end of
313 # http://mercurial.selenic.com/wiki/RecordExtension)
314 phelp = '---' + _("""
315 To remove '-' lines, make them ' ' lines (context).
316 To remove '+' lines, delete them.
317 Lines starting with # will be removed from the patch.
318
319 If the patch applies cleanly, the edited hunk will immediately be
320 added to the record list. If it does not apply cleanly, a rejects
321 file will be generated: you can use that when you try again. If
322 all lines of the hunk are removed, then the edit is aborted and
323 the hunk is left unchanged.
324 """)
325 (patchfd, patchfn) = tempfile.mkstemp(prefix="hg-editor-",
326 suffix=".diff", text=True)
327 try:
328 # Write the initial patch
329 f = os.fdopen(patchfd, "w")
330 chunk.header.write(f)
331 chunk.write(f)
332 f.write('\n'.join(['# ' + i for i in phelp.splitlines()]))
333 f.close()
334 # Start the editor and wait for it to complete
335 editor = ui.geteditor()
336 util.system("%s \"%s\"" % (editor, patchfn),
337 environ={'HGUSER': ui.username()},
338 onerr=util.Abort, errprefix=_("edit failed"),
339 out=ui.fout)
340 # Remove comment lines
341 patchfp = open(patchfn)
342 ncpatchfp = cStringIO.StringIO()
343 for line in patchfp:
344 if not line.startswith('#'):
345 ncpatchfp.write(line)
346 patchfp.close()
347 ncpatchfp.seek(0)
348 newpatches = parsepatch(ncpatchfp)
349 finally:
350 os.unlink(patchfn)
351 del ncpatchfp
352 # Signal that the chunk shouldn't be applied as-is, but
353 # provide the new patch to be used instead.
354 ret = False
355 elif r == 3: # Skip
302 356 ret = skipfile = False
303 elif r == 3: # file (Record remaining)
357 elif r == 4: # file (Record remaining)
304 358 ret = skipfile = True
305 elif r == 4: # done, skip remaining
359 elif r == 5: # done, skip remaining
306 360 ret = skipall = False
307 elif r == 5: # all
361 elif r == 6: # all
308 362 ret = skipall = True
309 elif r == 6: # quit
363 elif r == 7: # quit
310 364 raise util.Abort(_('user quit'))
311 return ret, skipfile, skipall
365 return ret, skipfile, skipall, newpatches
312 366
313 367 seen = set()
314 368 applied = {} # 'filename' -> [] of chunks
@@ -326,7 +380,7 b' def filterpatch(ui, headers):'
326 380 h.pretty(ui)
327 381 msg = (_('examine changes to %s?') %
328 382 _(' and ').join(map(repr, h.files())))
329 r, skipfile, skipall = prompt(skipfile, skipall, msg)
383 r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None)
330 384 if not r:
331 385 continue
332 386 applied[h.filename()] = [h]
@@ -342,12 +396,19 b' def filterpatch(ui, headers):'
342 396 idx = pos - len(h.hunks) + i
343 397 msg = _('record change %d/%d to %r?') % (idx, total,
344 398 chunk.filename())
345 r, skipfile, skipall = prompt(skipfile, skipall, msg)
399 r, skipfile, skipall, newpatches = prompt(skipfile,
400 skipall, msg, chunk)
346 401 if r:
347 402 if fixoffset:
348 403 chunk = copy.copy(chunk)
349 404 chunk.toline += fixoffset
350 405 applied[chunk.filename()].append(chunk)
406 elif newpatches is not None:
407 for newpatch in newpatches:
408 for newhunk in newpatch.hunks:
409 if fixoffset:
410 newhunk.toline += fixoffset
411 applied[newhunk.filename()].append(newhunk)
351 412 else:
352 413 fixoffset += chunk.removed - chunk.added
353 414 return sum([h for h in applied.itervalues()
@@ -372,6 +433,7 b' def record(ui, repo, *pats, **opts):'
372 433
373 434 y - record this change
374 435 n - skip this change
436 e - edit this change manually
375 437
376 438 s - skip remaining changes to this file
377 439 f - record remaining changes to this file
@@ -85,7 +85,7 b' record'
85 85 \x1b[0;36;1mold mode 100644\x1b[0m (esc)
86 86 \x1b[0;36;1mnew mode 100755\x1b[0m (esc)
87 87 1 hunks, 1 lines changed
88 \x1b[0;33mexamine changes to 'a'? [Ynsfdaq?]\x1b[0m (esc)
88 \x1b[0;33mexamine changes to 'a'? [Ynesfdaq?]\x1b[0m (esc)
89 89 \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc)
90 90 c
91 91 a
@@ -95,7 +95,7 b' record'
95 95 a
96 96 a
97 97 c
98 \x1b[0;33mrecord this change to 'a'? [Ynsfdaq?]\x1b[0m (esc)
98 \x1b[0;33mrecord this change to 'a'? [Ynesfdaq?]\x1b[0m (esc)
99 99
100 100 $ echo "[extensions]" >> $HGRCPATH
101 101 $ echo "mq=" >> $HGRCPATH
@@ -113,7 +113,7 b' qrecord'
113 113 \x1b[0;36;1mold mode 100644\x1b[0m (esc)
114 114 \x1b[0;36;1mnew mode 100755\x1b[0m (esc)
115 115 1 hunks, 1 lines changed
116 \x1b[0;33mexamine changes to 'a'? [Ynsfdaq?]\x1b[0m (esc)
116 \x1b[0;33mexamine changes to 'a'? [Ynesfdaq?]\x1b[0m (esc)
117 117 \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc)
118 118 c
119 119 a
@@ -123,4 +123,4 b' qrecord'
123 123 a
124 124 a
125 125 c
126 \x1b[0;33mrecord this change to 'a'? [Ynsfdaq?]\x1b[0m (esc)
126 \x1b[0;33mrecord this change to 'a'? [Ynesfdaq?]\x1b[0m (esc)
@@ -338,18 +338,18 b' record chunk'
338 338 > EOF
339 339 diff --git a/a b/a
340 340 2 hunks, 2 lines changed
341 examine changes to 'a'? [Ynsfdaq?]
341 examine changes to 'a'? [Ynesfdaq?]
342 342 @@ -1,3 +1,4 @@
343 343 expand $Id$
344 344 +foo
345 345 do not process $Id:
346 346 xxx $
347 record change 1/2 to 'a'? [Ynsfdaq?]
347 record change 1/2 to 'a'? [Ynesfdaq?]
348 348 @@ -2,2 +3,3 @@
349 349 do not process $Id:
350 350 xxx $
351 351 +bar
352 record change 2/2 to 'a'? [Ynsfdaq?]
352 record change 2/2 to 'a'? [Ynesfdaq?]
353 353
354 354 $ hg identify
355 355 d17e03c92c97+ tip
@@ -395,18 +395,18 b' Record all chunks in file a'
395 395 > EOF
396 396 diff --git a/a b/a
397 397 2 hunks, 2 lines changed
398 examine changes to 'a'? [Ynsfdaq?]
398 examine changes to 'a'? [Ynesfdaq?]
399 399 @@ -1,3 +1,4 @@
400 400 expand $Id$
401 401 +foo
402 402 do not process $Id:
403 403 xxx $
404 record change 1/2 to 'a'? [Ynsfdaq?]
404 record change 1/2 to 'a'? [Ynesfdaq?]
405 405 @@ -2,2 +3,3 @@
406 406 do not process $Id:
407 407 xxx $
408 408 +bar
409 record change 2/2 to 'a'? [Ynsfdaq?]
409 record change 2/2 to 'a'? [Ynesfdaq?]
410 410
411 411 File a should be clean
412 412
@@ -462,7 +462,7 b' record added file alone'
462 462 > EOF
463 463 diff --git a/r b/r
464 464 new file mode 100644
465 examine changes to 'r'? [Ynsfdaq?]
465 examine changes to 'r'? [Ynesfdaq?]
466 466 r
467 467 committed changeset 3:899491280810
468 468 overwriting r expanding keywords
@@ -486,7 +486,7 b' record added keyword ignored file'
486 486 > EOF
487 487 diff --git a/i b/i
488 488 new file mode 100644
489 examine changes to 'i'? [Ynsfdaq?]
489 examine changes to 'i'? [Ynesfdaq?]
490 490 i
491 491 committed changeset 3:5f40fe93bbdc
492 492 $ cat i
@@ -185,22 +185,22 b' partial qrefresh'
185 185 > EOF
186 186 diff --git a/1.txt b/1.txt
187 187 2 hunks, 2 lines changed
188 examine changes to '1.txt'? [Ynsfdaq?]
188 examine changes to '1.txt'? [Ynesfdaq?]
189 189 @@ -1,3 +1,3 @@
190 190 1
191 191 -2
192 192 +2 2
193 193 3
194 record change 1/4 to '1.txt'? [Ynsfdaq?]
194 record change 1/4 to '1.txt'? [Ynesfdaq?]
195 195 @@ -3,3 +3,3 @@
196 196 3
197 197 -4
198 198 +4 4
199 199 5
200 record change 2/4 to '1.txt'? [Ynsfdaq?]
200 record change 2/4 to '1.txt'? [Ynesfdaq?]
201 201 diff --git a/2.txt b/2.txt
202 202 1 hunks, 1 lines changed
203 examine changes to '2.txt'? [Ynsfdaq?]
203 examine changes to '2.txt'? [Ynesfdaq?]
204 204 @@ -1,5 +1,5 @@
205 205 a
206 206 -b
@@ -208,10 +208,10 b' partial qrefresh'
208 208 c
209 209 d
210 210 e
211 record change 3/4 to '2.txt'? [Ynsfdaq?]
211 record change 3/4 to '2.txt'? [Ynesfdaq?]
212 212 diff --git a/dir/a.txt b/dir/a.txt
213 213 1 hunks, 1 lines changed
214 examine changes to 'dir/a.txt'? [Ynsfdaq?]
214 examine changes to 'dir/a.txt'? [Ynesfdaq?]
215 215
216 216 After partial qrefresh 'tip'
217 217
@@ -279,7 +279,7 b' qrefresh interactively everything else'
279 279 > EOF
280 280 diff --git a/1.txt b/1.txt
281 281 1 hunks, 1 lines changed
282 examine changes to '1.txt'? [Ynsfdaq?]
282 examine changes to '1.txt'? [Ynesfdaq?]
283 283 @@ -1,5 +1,5 @@
284 284 1
285 285 2 2
@@ -287,17 +287,17 b' qrefresh interactively everything else'
287 287 -4
288 288 +4 4
289 289 5
290 record change 1/2 to '1.txt'? [Ynsfdaq?]
290 record change 1/2 to '1.txt'? [Ynesfdaq?]
291 291 diff --git a/dir/a.txt b/dir/a.txt
292 292 1 hunks, 1 lines changed
293 examine changes to 'dir/a.txt'? [Ynsfdaq?]
293 examine changes to 'dir/a.txt'? [Ynesfdaq?]
294 294 @@ -1,4 +1,4 @@
295 295 -hello world
296 296 +hello world!
297 297
298 298 someone
299 299 up
300 record change 2/2 to 'dir/a.txt'? [Ynsfdaq?]
300 record change 2/2 to 'dir/a.txt'? [Ynesfdaq?]
301 301
302 302 After final qrefresh 'tip'
303 303
@@ -263,7 +263,7 b' handle subrepos safely on qrecord'
263 263 % qrecord --config ui.interactive=1 -m0 0.diff
264 264 diff --git a/.hgsub b/.hgsub
265 265 new file mode 100644
266 examine changes to '.hgsub'? [Ynsfdaq?]
266 examine changes to '.hgsub'? [Ynesfdaq?]
267 267 abort: uncommitted changes in subrepository sub
268 268 [255]
269 269 % update substate when adding .hgsub w/clean updated subrepo
@@ -271,7 +271,7 b' handle subrepos safely on qrecord'
271 271 % qrecord --config ui.interactive=1 -m0 0.diff
272 272 diff --git a/.hgsub b/.hgsub
273 273 new file mode 100644
274 examine changes to '.hgsub'? [Ynsfdaq?]
274 examine changes to '.hgsub'? [Ynesfdaq?]
275 275 path sub
276 276 source sub
277 277 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -287,11 +287,11 b' handle subrepos safely on qrecord'
287 287 % qrecord --config ui.interactive=1 -m1 1.diff
288 288 diff --git a/.hgsub b/.hgsub
289 289 1 hunks, 1 lines changed
290 examine changes to '.hgsub'? [Ynsfdaq?]
290 examine changes to '.hgsub'? [Ynesfdaq?]
291 291 @@ -1,1 +1,2 @@
292 292 sub = sub
293 293 +sub2 = sub2
294 record this change to '.hgsub'? [Ynsfdaq?]
294 record this change to '.hgsub'? [Ynesfdaq?]
295 295 abort: uncommitted changes in subrepository sub2
296 296 [255]
297 297 % update substate when modifying .hgsub w/clean updated subrepo
@@ -299,11 +299,11 b' handle subrepos safely on qrecord'
299 299 % qrecord --config ui.interactive=1 -m1 1.diff
300 300 diff --git a/.hgsub b/.hgsub
301 301 1 hunks, 1 lines changed
302 examine changes to '.hgsub'? [Ynsfdaq?]
302 examine changes to '.hgsub'? [Ynesfdaq?]
303 303 @@ -1,1 +1,2 @@
304 304 sub = sub
305 305 +sub2 = sub2
306 record this change to '.hgsub'? [Ynsfdaq?]
306 record this change to '.hgsub'? [Ynesfdaq?]
307 307 path sub
308 308 source sub
309 309 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -324,7 +324,7 b' handle subrepos safely on qrecord'
324 324 % qrecord --config ui.interactive=1 -m2 2.diff
325 325 diff --git a/.hgsub b/.hgsub
326 326 deleted file mode 100644
327 examine changes to '.hgsub'? [Ynsfdaq?]
327 examine changes to '.hgsub'? [Ynesfdaq?]
328 328 % debugsub should be empty
329 329
330 330 $ hg qpop -qa
@@ -339,7 +339,7 b' handle subrepos safely on qrecord'
339 339 % qrecord --config ui.interactive=1 -m3 3.diff
340 340 diff --git a/.hgsub b/.hgsub
341 341 deleted file mode 100644
342 examine changes to '.hgsub'? [Ynsfdaq?]
342 examine changes to '.hgsub'? [Ynesfdaq?]
343 343 % debugsub should be empty
344 344
345 345 $ cd ..
@@ -40,6 +40,7 b' help record (record)'
40 40
41 41 y - record this change
42 42 n - skip this change
43 e - edit this change manually
43 44
44 45 s - skip remaining changes to this file
45 46 f - record remaining changes to this file
@@ -245,22 +246,22 b' qrecord a.patch'
245 246 > EOF
246 247 diff --git a/1.txt b/1.txt
247 248 2 hunks, 2 lines changed
248 examine changes to '1.txt'? [Ynsfdaq?]
249 examine changes to '1.txt'? [Ynesfdaq?]
249 250 @@ -1,3 +1,3 @@
250 251 1
251 252 -2
252 253 +2 2
253 254 3
254 record change 1/4 to '1.txt'? [Ynsfdaq?]
255 record change 1/4 to '1.txt'? [Ynesfdaq?]
255 256 @@ -3,3 +3,3 @@
256 257 3
257 258 -4
258 259 +4 4
259 260 5
260 record change 2/4 to '1.txt'? [Ynsfdaq?]
261 record change 2/4 to '1.txt'? [Ynesfdaq?]
261 262 diff --git a/2.txt b/2.txt
262 263 1 hunks, 1 lines changed
263 examine changes to '2.txt'? [Ynsfdaq?]
264 examine changes to '2.txt'? [Ynesfdaq?]
264 265 @@ -1,5 +1,5 @@
265 266 a
266 267 -b
@@ -268,10 +269,10 b' qrecord a.patch'
268 269 c
269 270 d
270 271 e
271 record change 3/4 to '2.txt'? [Ynsfdaq?]
272 record change 3/4 to '2.txt'? [Ynesfdaq?]
272 273 diff --git a/dir/a.txt b/dir/a.txt
273 274 1 hunks, 1 lines changed
274 examine changes to 'dir/a.txt'? [Ynsfdaq?]
275 examine changes to 'dir/a.txt'? [Ynesfdaq?]
275 276
276 277 After qrecord a.patch 'tip'"
277 278
@@ -340,7 +341,7 b' qrecord b.patch'
340 341 > EOF
341 342 diff --git a/1.txt b/1.txt
342 343 1 hunks, 1 lines changed
343 examine changes to '1.txt'? [Ynsfdaq?]
344 examine changes to '1.txt'? [Ynesfdaq?]
344 345 @@ -1,5 +1,5 @@
345 346 1
346 347 2 2
@@ -348,17 +349,17 b' qrecord b.patch'
348 349 -4
349 350 +4 4
350 351 5
351 record change 1/2 to '1.txt'? [Ynsfdaq?]
352 record change 1/2 to '1.txt'? [Ynesfdaq?]
352 353 diff --git a/dir/a.txt b/dir/a.txt
353 354 1 hunks, 1 lines changed
354 examine changes to 'dir/a.txt'? [Ynsfdaq?]
355 examine changes to 'dir/a.txt'? [Ynesfdaq?]
355 356 @@ -1,4 +1,4 @@
356 357 -hello world
357 358 +hello world!
358 359
359 360 someone
360 361 up
361 record change 2/2 to 'dir/a.txt'? [Ynsfdaq?]
362 record change 2/2 to 'dir/a.txt'? [Ynesfdaq?]
362 363
363 364 After qrecord b.patch 'tip'
364 365
@@ -20,7 +20,7 b' Select no files'
20 20 > EOF
21 21 diff --git a/empty-rw b/empty-rw
22 22 new file mode 100644
23 examine changes to 'empty-rw'? [Ynsfdaq?]
23 examine changes to 'empty-rw'? [Ynesfdaq?]
24 24 no changes to record
25 25
26 26 $ hg tip -p
@@ -39,7 +39,7 b' Select files but no hunks'
39 39 > EOF
40 40 diff --git a/empty-rw b/empty-rw
41 41 new file mode 100644
42 examine changes to 'empty-rw'? [Ynsfdaq?]
42 examine changes to 'empty-rw'? [Ynesfdaq?]
43 43 abort: empty commit message
44 44 [255]
45 45
@@ -59,7 +59,7 b' Record empty file'
59 59 > EOF
60 60 diff --git a/empty-rw b/empty-rw
61 61 new file mode 100644
62 examine changes to 'empty-rw'? [Ynsfdaq?]
62 examine changes to 'empty-rw'? [Ynesfdaq?]
63 63
64 64 $ hg tip -p
65 65 changeset: 0:c0708cf4e46e
@@ -88,7 +88,7 b' Rename empty file'
88 88 diff --git a/empty-rw b/empty-rename
89 89 rename from empty-rw
90 90 rename to empty-rename
91 examine changes to 'empty-rw' and 'empty-rename'? [Ynsfdaq?]
91 examine changes to 'empty-rw' and 'empty-rename'? [Ynesfdaq?]
92 92
93 93 $ hg tip -p
94 94 changeset: 1:d695e8dcb197
@@ -108,7 +108,7 b' Copy empty file'
108 108 diff --git a/empty-rename b/empty-copy
109 109 copy from empty-rename
110 110 copy to empty-copy
111 examine changes to 'empty-rename' and 'empty-copy'? [Ynsfdaq?]
111 examine changes to 'empty-rename' and 'empty-copy'? [Ynesfdaq?]
112 112
113 113 $ hg tip -p
114 114 changeset: 2:1d4b90bea524
@@ -127,7 +127,7 b' Delete empty file'
127 127 > EOF
128 128 diff --git a/empty-copy b/empty-copy
129 129 deleted file mode 100644
130 examine changes to 'empty-copy'? [Ynsfdaq?]
130 examine changes to 'empty-copy'? [Ynesfdaq?]
131 131
132 132 $ hg tip -p
133 133 changeset: 3:b39a238f01a1
@@ -149,7 +149,7 b' Add binary file'
149 149 diff --git a/tip.bundle b/tip.bundle
150 150 new file mode 100644
151 151 this is a binary file
152 examine changes to 'tip.bundle'? [Ynsfdaq?]
152 examine changes to 'tip.bundle'? [Ynesfdaq?]
153 153
154 154 $ hg tip -p
155 155 changeset: 4:ad816da3711e
@@ -171,7 +171,7 b' Change binary file'
171 171 > EOF
172 172 diff --git a/tip.bundle b/tip.bundle
173 173 this modifies a binary file (all or nothing)
174 examine changes to 'tip.bundle'? [Ynsfdaq?]
174 examine changes to 'tip.bundle'? [Ynesfdaq?]
175 175
176 176 $ hg tip -p
177 177 changeset: 5:dccd6f3eb485
@@ -196,7 +196,7 b' Rename and change binary file'
196 196 rename from tip.bundle
197 197 rename to top.bundle
198 198 this modifies a binary file (all or nothing)
199 examine changes to 'tip.bundle' and 'top.bundle'? [Ynsfdaq?]
199 examine changes to 'tip.bundle' and 'top.bundle'? [Ynesfdaq?]
200 200
201 201 $ hg tip -p
202 202 changeset: 6:7fa44105f5b3
@@ -224,7 +224,7 b' Add plain file'
224 224 > EOF
225 225 diff --git a/plain b/plain
226 226 new file mode 100644
227 examine changes to 'plain'? [Ynsfdaq?]
227 examine changes to 'plain'? [Ynesfdaq?]
228 228
229 229 $ hg tip -p
230 230 changeset: 7:11fb457c1be4
@@ -258,13 +258,13 b' Modify end of plain file'
258 258 > EOF
259 259 diff --git a/plain b/plain
260 260 1 hunks, 1 lines changed
261 examine changes to 'plain'? [Ynsfdaq?]
261 examine changes to 'plain'? [Ynesfdaq?]
262 262 @@ -8,3 +8,4 @@
263 263 8
264 264 9
265 265 10
266 266 +11
267 record this change to 'plain'? [Ynsfdaq?]
267 record this change to 'plain'? [Ynesfdaq?]
268 268
269 269 Modify end of plain file, no EOL
270 270
@@ -275,14 +275,14 b' Modify end of plain file, no EOL'
275 275 > EOF
276 276 diff --git a/plain b/plain
277 277 1 hunks, 1 lines changed
278 examine changes to 'plain'? [Ynsfdaq?]
278 examine changes to 'plain'? [Ynesfdaq?]
279 279 @@ -9,3 +9,4 @@
280 280 9
281 281 10
282 282 11
283 283 +7264f99c5f5ff3261504828afa4fb4d406c3af54
284 284 \ No newline at end of file
285 record this change to 'plain'? [Ynsfdaq?]
285 record this change to 'plain'? [Ynesfdaq?]
286 286
287 287 Modify end of plain file, add EOL
288 288
@@ -296,7 +296,7 b' Modify end of plain file, add EOL'
296 296 > EOF
297 297 diff --git a/plain b/plain
298 298 1 hunks, 1 lines changed
299 examine changes to 'plain'? [Ynsfdaq?]
299 examine changes to 'plain'? [Ynesfdaq?]
300 300 @@ -9,4 +9,4 @@
301 301 9
302 302 10
@@ -304,10 +304,10 b' Modify end of plain file, add EOL'
304 304 -7264f99c5f5ff3261504828afa4fb4d406c3af54
305 305 \ No newline at end of file
306 306 +7264f99c5f5ff3261504828afa4fb4d406c3af54
307 record change 1/2 to 'plain'? [Ynsfdaq?]
307 record change 1/2 to 'plain'? [Ynesfdaq?]
308 308 diff --git a/plain2 b/plain2
309 309 new file mode 100644
310 examine changes to 'plain2'? [Ynsfdaq?]
310 examine changes to 'plain2'? [Ynesfdaq?]
311 311
312 312 Modify beginning, trim end, record both, add another file to test
313 313 changes numbering
@@ -327,28 +327,28 b' changes numbering'
327 327 > EOF
328 328 diff --git a/plain b/plain
329 329 2 hunks, 3 lines changed
330 examine changes to 'plain'? [Ynsfdaq?]
330 examine changes to 'plain'? [Ynesfdaq?]
331 331 @@ -1,4 +1,4 @@
332 332 -1
333 333 +2
334 334 2
335 335 3
336 336 4
337 record change 1/3 to 'plain'? [Ynsfdaq?]
337 record change 1/3 to 'plain'? [Ynesfdaq?]
338 338 @@ -8,5 +8,3 @@
339 339 8
340 340 9
341 341 10
342 342 -11
343 343 -7264f99c5f5ff3261504828afa4fb4d406c3af54
344 record change 2/3 to 'plain'? [Ynsfdaq?]
344 record change 2/3 to 'plain'? [Ynesfdaq?]
345 345 diff --git a/plain2 b/plain2
346 346 1 hunks, 1 lines changed
347 examine changes to 'plain2'? [Ynsfdaq?]
347 examine changes to 'plain2'? [Ynesfdaq?]
348 348 @@ -1,1 +1,2 @@
349 349 1
350 350 +2
351 record change 3/3 to 'plain2'? [Ynsfdaq?]
351 record change 3/3 to 'plain2'? [Ynesfdaq?]
352 352
353 353 $ hg tip -p
354 354 changeset: 11:21df83db12b8
@@ -396,7 +396,7 b' Record end'
396 396 > EOF
397 397 diff --git a/plain b/plain
398 398 2 hunks, 4 lines changed
399 examine changes to 'plain'? [Ynsfdaq?]
399 examine changes to 'plain'? [Ynesfdaq?]
400 400 @@ -1,9 +1,6 @@
401 401 -2
402 402 -2
@@ -407,7 +407,7 b' Record end'
407 407 7
408 408 8
409 409 9
410 record change 1/2 to 'plain'? [Ynsfdaq?]
410 record change 1/2 to 'plain'? [Ynesfdaq?]
411 411 @@ -4,7 +1,7 @@
412 412 4
413 413 5
@@ -417,7 +417,7 b' Record end'
417 417 9
418 418 -10
419 419 +10.new
420 record change 2/2 to 'plain'? [Ynsfdaq?]
420 record change 2/2 to 'plain'? [Ynesfdaq?]
421 421
422 422 $ hg tip -p
423 423 changeset: 12:99337501826f
@@ -445,7 +445,7 b' Record beginning'
445 445 > EOF
446 446 diff --git a/plain b/plain
447 447 1 hunks, 3 lines changed
448 examine changes to 'plain'? [Ynsfdaq?]
448 examine changes to 'plain'? [Ynesfdaq?]
449 449 @@ -1,6 +1,3 @@
450 450 -2
451 451 -2
@@ -453,7 +453,7 b' Record beginning'
453 453 4
454 454 5
455 455 6
456 record this change to 'plain'? [Ynsfdaq?]
456 record this change to 'plain'? [Ynesfdaq?]
457 457
458 458 $ hg tip -p
459 459 changeset: 13:bbd45465d540
@@ -490,7 +490,7 b' Record end'
490 490 > EOF
491 491 diff --git a/plain b/plain
492 492 2 hunks, 4 lines changed
493 examine changes to 'plain'? [Ynsfdaq?]
493 examine changes to 'plain'? [Ynesfdaq?]
494 494 @@ -1,6 +1,9 @@
495 495 +1
496 496 +2
@@ -501,7 +501,7 b' Record end'
501 501 7
502 502 8
503 503 9
504 record change 1/2 to 'plain'? [Ynsfdaq?]
504 record change 1/2 to 'plain'? [Ynesfdaq?]
505 505 @@ -1,7 +4,6 @@
506 506 4
507 507 5
@@ -510,7 +510,7 b' Record end'
510 510 8
511 511 9
512 512 -10.new
513 record change 2/2 to 'plain'? [Ynsfdaq?]
513 record change 2/2 to 'plain'? [Ynesfdaq?]
514 514
515 515 Add to beginning, middle, end
516 516
@@ -529,14 +529,14 b' Record beginning, middle'
529 529 > EOF
530 530 diff --git a/plain b/plain
531 531 3 hunks, 7 lines changed
532 examine changes to 'plain'? [Ynsfdaq?]
532 examine changes to 'plain'? [Ynesfdaq?]
533 533 @@ -1,2 +1,5 @@
534 534 +1
535 535 +2
536 536 +3
537 537 4
538 538 5
539 record change 1/3 to 'plain'? [Ynsfdaq?]
539 record change 1/3 to 'plain'? [Ynesfdaq?]
540 540 @@ -1,6 +4,8 @@
541 541 4
542 542 5
@@ -546,7 +546,7 b' Record beginning, middle'
546 546 7
547 547 8
548 548 9
549 record change 2/3 to 'plain'? [Ynsfdaq?]
549 record change 2/3 to 'plain'? [Ynesfdaq?]
550 550 @@ -3,4 +8,6 @@
551 551 6
552 552 7
@@ -554,7 +554,7 b' Record beginning, middle'
554 554 9
555 555 +10
556 556 +11
557 record change 3/3 to 'plain'? [Ynsfdaq?]
557 record change 3/3 to 'plain'? [Ynesfdaq?]
558 558
559 559 $ hg tip -p
560 560 changeset: 15:f34a7937ec33
@@ -587,14 +587,14 b' Record end'
587 587 > EOF
588 588 diff --git a/plain b/plain
589 589 1 hunks, 2 lines changed
590 examine changes to 'plain'? [Ynsfdaq?]
590 examine changes to 'plain'? [Ynesfdaq?]
591 591 @@ -9,3 +9,5 @@
592 592 7
593 593 8
594 594 9
595 595 +10
596 596 +11
597 record this change to 'plain'? [Ynsfdaq?]
597 record this change to 'plain'? [Ynesfdaq?]
598 598
599 599 $ hg tip -p
600 600 changeset: 16:f9900b71a04c
@@ -627,11 +627,11 b' Record end'
627 627 > EOF
628 628 diff --git a/subdir/a b/subdir/a
629 629 1 hunks, 1 lines changed
630 examine changes to 'subdir/a'? [Ynsfdaq?]
630 examine changes to 'subdir/a'? [Ynesfdaq?]
631 631 @@ -1,1 +1,2 @@
632 632 a
633 633 +a
634 record this change to 'subdir/a'? [Ynsfdaq?]
634 record this change to 'subdir/a'? [Ynesfdaq?]
635 635
636 636 $ hg tip -p
637 637 changeset: 18:61be427a9deb
@@ -665,16 +665,17 b' Help, quit'
665 665 > EOF
666 666 diff --git a/subdir/f1 b/subdir/f1
667 667 1 hunks, 1 lines changed
668 examine changes to 'subdir/f1'? [Ynsfdaq?]
668 examine changes to 'subdir/f1'? [Ynesfdaq?]
669 669 y - record this change
670 670 n - skip this change
671 e - edit this change manually
671 672 s - skip remaining changes to this file
672 673 f - record remaining changes to this file
673 674 d - done, skip remaining changes and files
674 675 a - record all changes to all remaining files
675 676 q - quit, recording no changes
676 677 ? - display help
677 examine changes to 'subdir/f1'? [Ynsfdaq?]
678 examine changes to 'subdir/f1'? [Ynesfdaq?]
678 679 abort: user quit
679 680 [255]
680 681
@@ -685,10 +686,10 b' Skip'
685 686 > EOF
686 687 diff --git a/subdir/f1 b/subdir/f1
687 688 1 hunks, 1 lines changed
688 examine changes to 'subdir/f1'? [Ynsfdaq?]
689 examine changes to 'subdir/f1'? [Ynesfdaq?]
689 690 diff --git a/subdir/f2 b/subdir/f2
690 691 1 hunks, 1 lines changed
691 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: response expected
692 examine changes to 'subdir/f2'? [Ynesfdaq?] abort: response expected
692 693 [255]
693 694
694 695 No
@@ -698,10 +699,10 b' No'
698 699 > EOF
699 700 diff --git a/subdir/f1 b/subdir/f1
700 701 1 hunks, 1 lines changed
701 examine changes to 'subdir/f1'? [Ynsfdaq?]
702 examine changes to 'subdir/f1'? [Ynesfdaq?]
702 703 diff --git a/subdir/f2 b/subdir/f2
703 704 1 hunks, 1 lines changed
704 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: response expected
705 examine changes to 'subdir/f2'? [Ynesfdaq?] abort: response expected
705 706 [255]
706 707
707 708 f, quit
@@ -712,10 +713,10 b' f, quit'
712 713 > EOF
713 714 diff --git a/subdir/f1 b/subdir/f1
714 715 1 hunks, 1 lines changed
715 examine changes to 'subdir/f1'? [Ynsfdaq?]
716 examine changes to 'subdir/f1'? [Ynesfdaq?]
716 717 diff --git a/subdir/f2 b/subdir/f2
717 718 1 hunks, 1 lines changed
718 examine changes to 'subdir/f2'? [Ynsfdaq?]
719 examine changes to 'subdir/f2'? [Ynesfdaq?]
719 720 abort: user quit
720 721 [255]
721 722
@@ -727,10 +728,10 b' s, all'
727 728 > EOF
728 729 diff --git a/subdir/f1 b/subdir/f1
729 730 1 hunks, 1 lines changed
730 examine changes to 'subdir/f1'? [Ynsfdaq?]
731 examine changes to 'subdir/f1'? [Ynesfdaq?]
731 732 diff --git a/subdir/f2 b/subdir/f2
732 733 1 hunks, 1 lines changed
733 examine changes to 'subdir/f2'? [Ynsfdaq?]
734 examine changes to 'subdir/f2'? [Ynesfdaq?]
734 735
735 736 $ hg tip -p
736 737 changeset: 20:b3df3dda369a
@@ -754,7 +755,7 b' f'
754 755 > EOF
755 756 diff --git a/subdir/f1 b/subdir/f1
756 757 1 hunks, 1 lines changed
757 examine changes to 'subdir/f1'? [Ynsfdaq?]
758 examine changes to 'subdir/f1'? [Ynesfdaq?]
758 759
759 760 $ hg tip -p
760 761 changeset: 21:38ec577f126b
@@ -784,12 +785,12 b' Preserve chmod +x'
784 785 old mode 100644
785 786 new mode 100755
786 787 1 hunks, 1 lines changed
787 examine changes to 'subdir/f1'? [Ynsfdaq?]
788 examine changes to 'subdir/f1'? [Ynesfdaq?]
788 789 @@ -1,2 +1,3 @@
789 790 a
790 791 a
791 792 +a
792 record this change to 'subdir/f1'? [Ynsfdaq?]
793 record this change to 'subdir/f1'? [Ynesfdaq?]
793 794
794 795 $ hg tip --config diff.git=True -p
795 796 changeset: 22:3261adceb075
@@ -819,13 +820,13 b' Preserve execute permission on original'
819 820 > EOF
820 821 diff --git a/subdir/f1 b/subdir/f1
821 822 1 hunks, 1 lines changed
822 examine changes to 'subdir/f1'? [Ynsfdaq?]
823 examine changes to 'subdir/f1'? [Ynesfdaq?]
823 824 @@ -1,3 +1,4 @@
824 825 a
825 826 a
826 827 a
827 828 +b
828 record this change to 'subdir/f1'? [Ynsfdaq?]
829 record this change to 'subdir/f1'? [Ynesfdaq?]
829 830
830 831 $ hg tip --config diff.git=True -p
831 832 changeset: 23:b429867550db
@@ -857,13 +858,13 b' Preserve chmod -x'
857 858 old mode 100755
858 859 new mode 100644
859 860 1 hunks, 1 lines changed
860 examine changes to 'subdir/f1'? [Ynsfdaq?]
861 examine changes to 'subdir/f1'? [Ynesfdaq?]
861 862 @@ -2,3 +2,4 @@
862 863 a
863 864 a
864 865 b
865 866 +c
866 record this change to 'subdir/f1'? [Ynsfdaq?]
867 record this change to 'subdir/f1'? [Ynesfdaq?]
867 868
868 869 $ hg tip --config diff.git=True -p
869 870 changeset: 24:0b082130c20a
@@ -914,6 +915,150 b' Abort early when a merge is in progress'
914 915 $ hg up -C
915 916 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
916 917
918 Editing patch
919
920 $ cat > editor << '__EOF__'
921 > #!/bin/sh
922 > sed -i -e 7d -e '5s/^-/ /' "$1"
923 > __EOF__
924 $ chmod +x editor
925 $ cat > editedfile << '__EOF__'
926 > This is the first line
927 > This is the second line
928 > This is the third line
929 > __EOF__
930 $ hg add editedfile
931 $ hg commit -medit-patch-1
932 $ cat > editedfile << '__EOF__'
933 > This line has changed
934 > This change will be committed
935 > This is the third line
936 > __EOF__
937 $ HGEDITOR="'`pwd`'"/editor hg record -d '23 0' -medit-patch-2 <<EOF
938 > y
939 > e
940 > EOF
941 diff --git a/editedfile b/editedfile
942 1 hunks, 2 lines changed
943 examine changes to 'editedfile'? [Ynesfdaq?]
944 @@ -1,3 +1,3 @@
945 -This is the first line
946 -This is the second line
947 +This line has changed
948 +This change will be committed
949 This is the third line
950 record this change to 'editedfile'? [Ynesfdaq?]
951 $ cat editedfile
952 This line has changed
953 This change will be committed
954 This is the third line
955 $ hg cat -r tip editedfile
956 This is the first line
957 This change will be committed
958 This is the third line
959 $ hg revert editedfile
960
961 Trying to edit patch for whole file
962
963 $ echo "This is the fourth line" >> editedfile
964 $ hg record <<EOF
965 > e
966 > q
967 > EOF
968 diff --git a/editedfile b/editedfile
969 1 hunks, 1 lines changed
970 examine changes to 'editedfile'? [Ynesfdaq?]
971 cannot edit patch for whole file
972 examine changes to 'editedfile'? [Ynesfdaq?]
973 abort: user quit
974 [255]
975 $ hg revert editedfile
976
977 Removing changes from patch
978
979 $ sed -i -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile
980 $ echo "This line has been added" >> editedfile
981 $ cat > editor << '__EOF__'
982 > #!/bin/sh
983 > sed -i -e 's/^[-+]/ /' "$1"
984 > __EOF__
985 $ chmod +x editor
986 $ HGEDITOR="'`pwd`'"/editor hg record <<EOF
987 > y
988 > e
989 > EOF
990 diff --git a/editedfile b/editedfile
991 1 hunks, 3 lines changed
992 examine changes to 'editedfile'? [Ynesfdaq?]
993 @@ -1,3 +1,3 @@
994 -This is the first line
995 -This change will be committed
996 -This is the third line
997 +This change will not be committed
998 +This is the second line
999 +This line has been added
1000 record this change to 'editedfile'? [Ynesfdaq?]
1001 no changes to record
1002 $ cat editedfile
1003 This change will not be committed
1004 This is the second line
1005 This line has been added
1006 $ hg cat -r tip editedfile
1007 This is the first line
1008 This change will be committed
1009 This is the third line
1010 $ hg revert editedfile
1011
1012 Invalid patch
1013
1014 $ sed -i -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile
1015 $ echo "This line has been added" >> editedfile
1016 $ cat > editor << '__EOF__'
1017 > #!/bin/sh
1018 > sed -i s/This/That/ "$1"
1019 > __EOF__
1020 $ chmod +x editor
1021 $ HGEDITOR="'`pwd`'"/editor hg record <<EOF
1022 > y
1023 > e
1024 > EOF
1025 diff --git a/editedfile b/editedfile
1026 1 hunks, 3 lines changed
1027 examine changes to 'editedfile'? [Ynesfdaq?]
1028 @@ -1,3 +1,3 @@
1029 -This is the first line
1030 -This change will be committed
1031 -This is the third line
1032 +This change will not be committed
1033 +This is the second line
1034 +This line has been added
1035 record this change to 'editedfile'? [Ynesfdaq?]
1036 patching file editedfile
1037 Hunk #1 FAILED at 0
1038 1 out of 1 hunks FAILED -- saving rejects to file editedfile.rej
1039 abort: patch failed to apply
1040 [255]
1041 $ cat editedfile
1042 This change will not be committed
1043 This is the second line
1044 This line has been added
1045 $ hg cat -r tip editedfile
1046 This is the first line
1047 This change will be committed
1048 This is the third line
1049 $ cat editedfile.rej
1050 --- editedfile
1051 +++ editedfile
1052 @@ -1,3 +1,3 @@
1053 -That is the first line
1054 -That change will be committed
1055 -That is the third line
1056 +That change will not be committed
1057 +That is the second line
1058 +That line has been added
1059 $ hg up -C
1060 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1061
917 1062 With win32text
918 1063
919 1064 $ echo '[extensions]' >> .hg/hgrc
@@ -931,31 +1076,30 b' Ignore win32text deprecation warning for'
931 1076 $ echo 'warn = no' >> .hg/hgrc
932 1077
933 1078 $ echo d >> subdir/f1
934 $ hg record -d '23 0' -mw1 <<EOF
1079 $ hg record -d '24 0' -mw1 <<EOF
935 1080 > y
936 1081 > y
937 1082 > EOF
938 1083 diff --git a/subdir/f1 b/subdir/f1
939 1084 1 hunks, 1 lines changed
940 examine changes to 'subdir/f1'? [Ynsfdaq?]
1085 examine changes to 'subdir/f1'? [Ynesfdaq?]
941 1086 @@ -3,3 +3,4 @@
942 1087 a
943 1088 b
944 1089 c
945 1090 +d
946 record this change to 'subdir/f1'? [Ynsfdaq?]
1091 record this change to 'subdir/f1'? [Ynesfdaq?]
947 1092
948 1093 $ hg tip -p
949 changeset: 26:b8306e70edc4
1094 changeset: 28:287ad1f41a72
950 1095 tag: tip
951 parent: 24:0b082130c20a
952 1096 user: test
953 date: Thu Jan 01 00:00:23 1970 +0000
1097 date: Thu Jan 01 00:00:24 1970 +0000
954 1098 summary: w1
955 1099
956 diff -r 0b082130c20a -r b8306e70edc4 subdir/f1
957 --- a/subdir/f1 Thu Jan 01 00:00:22 1970 +0000
958 +++ b/subdir/f1 Thu Jan 01 00:00:23 1970 +0000
1100 diff -r 65ce23a81197 -r 287ad1f41a72 subdir/f1
1101 --- a/subdir/f1 Thu Jan 01 00:00:23 1970 +0000
1102 +++ b/subdir/f1 Thu Jan 01 00:00:24 1970 +0000
959 1103 @@ -3,3 +3,4 @@
960 1104 a
961 1105 b
General Comments 0
You need to be logged in to leave comments. Login now