##// END OF EJS Templates
crecord: re-enable reviewing a patch before comitting it...
Jordi Gutiérrez Hermoso -
r28638:44319097 default
parent child Browse files
Show More
@@ -207,6 +207,17 b' def dorecord(ui, repo, commitfunc, cmdsu'
207 dopatch = fp.tell()
207 dopatch = fp.tell()
208 fp.seek(0)
208 fp.seek(0)
209
209
210 # 2.5 optionally review / modify patch in text editor
211 if opts.get('review', False):
212 patchtext = (crecordmod.diffhelptext
213 + crecordmod.patchhelptext
214 + fp.read())
215 reviewedpatch = ui.edit(patchtext, "",
216 extra={"suffix": ".diff"})
217 fp.truncate(0)
218 fp.write(reviewedpatch)
219 fp.seek(0)
220
210 [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles]
221 [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles]
211 # 3a. apply filtered patch to clean repo (clean)
222 # 3a. apply filtered patch to clean repo (clean)
212 if backups:
223 if backups:
@@ -43,6 +43,13 b' hunkhelptext = _("""#'
43 # of the hunk are removed, then the edit is aborted and the hunk is left
43 # of the hunk are removed, then the edit is aborted and the hunk is left
44 # unchanged.
44 # unchanged.
45 """)
45 """)
46
47 patchhelptext = _("""#
48 # If the patch applies cleanly, the edited patch will immediately
49 # be finalised. If it does not apply cleanly, rejects files will be
50 # generated. You can use those when you try again.
51 """)
52
46 try:
53 try:
47 import curses
54 import curses
48 import fcntl
55 import fcntl
@@ -1595,10 +1602,14 b' are you sure you want to review/edit and'
1595 elif keypressed in ["c"]:
1602 elif keypressed in ["c"]:
1596 if self.confirmcommit():
1603 if self.confirmcommit():
1597 return True
1604 return True
1605 elif test and keypressed in ['X']:
1606 return True
1598 elif keypressed in ["r"]:
1607 elif keypressed in ["r"]:
1599 if self.confirmcommit(review=True):
1608 if self.confirmcommit(review=True):
1609 self.opts['review'] = True
1600 return True
1610 return True
1601 elif test and keypressed in ['X']:
1611 elif test and keypressed in ['R']:
1612 self.opts['review'] = True
1602 return True
1613 return True
1603 elif keypressed in [' '] or (test and keypressed in ["TOGGLE"]):
1614 elif keypressed in [' '] or (test and keypressed in ["TOGGLE"]):
1604 self.toggleapply()
1615 self.toggleapply()
@@ -223,7 +223,82 b' of the edit.'
223 foo
223 foo
224 hello world
224 hello world
225
225
226 Testing the review option. The entire final filtered patch should show
227 up in the editor and be editable. We will unselect the second file and
228 the first hunk of the third file. During review, we will decide that
229 "lower" sounds better than "bottom", and the final commit should
230 reflect this edition.
226
231
232 $ hg update -C .
233 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
234 $ echo "top" > c
235 $ cat x >> c
236 $ echo "bottom" >> c
237 $ mv c x
238 $ echo "third a" >> a
239 $ echo "we will unselect this" >> b
240
241 $ cat > editor.sh <<EOF
242 > cat "\$1"
243 > cat "\$1" | sed s/bottom/lower/ > tmp
244 > mv tmp "\$1"
245 > EOF
246 $ cat > testModeCommands <<EOF
247 > KEY_DOWN
248 > TOGGLE
249 > KEY_DOWN
250 > f
251 > KEY_DOWN
252 > TOGGLE
253 > R
254 > EOF
255
256 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "review hunks" -d "0 0"
257 # To remove '-' lines, make them ' ' lines (context).
258 # To remove '+' lines, delete them.
259 # Lines starting with # will be removed from the patch.
260 #
261 # If the patch applies cleanly, the edited patch will immediately
262 # be finalised. If it does not apply cleanly, rejects files will be
263 # generated. You can use those when you try again.
264 diff --git a/a b/a
265 --- a/a
266 +++ b/a
267 @@ -1,2 +1,3 @@
268 a
269 a
270 +third a
271 diff --git a/x b/x
272 --- a/x
273 +++ b/x
274 @@ -1,2 +1,3 @@
275 foo
276 hello world
277 +bottom
278
279 $ hg cat -r . a
280 a
281 a
282 third a
283
284 $ hg cat -r . b
285 x
286 1
287 2
288 3
289 4
290 5
291 6
292 7
293 8
294 9
295 10
296 y
297
298 $ hg cat -r . x
299 foo
300 hello world
301 lower
227 Check ui.interface logic for the chunkselector
302 Check ui.interface logic for the chunkselector
228
303
229 The default interface is text
304 The default interface is text
General Comments 0
You need to be logged in to leave comments. Login now