##// END OF EJS Templates
revert: fix edition of newly added file during --interactive...
Laurent Charignon -
r25259:5b05f10c default
parent child Browse files
Show More
@@ -3123,6 +3123,7 b' def _performrevert(repo, parents, ctx, a'
3123 else:
3123 else:
3124 normal = repo.dirstate.normal
3124 normal = repo.dirstate.normal
3125
3125
3126 newlyaddedandmodifiedfiles = set()
3126 if interactive:
3127 if interactive:
3127 # Prompt the user for changes to revert
3128 # Prompt the user for changes to revert
3128 torevert = [repo.wjoin(f) for f in actions['revert'][0]]
3129 torevert = [repo.wjoin(f) for f in actions['revert'][0]]
@@ -3137,6 +3138,7 b' def _performrevert(repo, parents, ctx, a'
3137 except patch.PatchError, err:
3138 except patch.PatchError, err:
3138 raise util.Abort(_('error parsing patch: %s') % err)
3139 raise util.Abort(_('error parsing patch: %s') % err)
3139
3140
3141 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
3140 # Apply changes
3142 # Apply changes
3141 fp = cStringIO.StringIO()
3143 fp = cStringIO.StringIO()
3142 for c in chunks:
3144 for c in chunks:
@@ -3160,8 +3162,10 b' def _performrevert(repo, parents, ctx, a'
3160 repo.dirstate.normallookup(f)
3162 repo.dirstate.normallookup(f)
3161
3163
3162 for f in actions['add'][0]:
3164 for f in actions['add'][0]:
3163 checkout(f)
3165 # Don't checkout modified files, they are already created by the diff
3164 repo.dirstate.add(f)
3166 if f not in newlyaddedandmodifiedfiles:
3167 checkout(f)
3168 repo.dirstate.add(f)
3165
3169
3166 normal = repo.dirstate.normallookup
3170 normal = repo.dirstate.normallookup
3167 if node == parent and p2 == nullid:
3171 if node == parent and p2 == nullid:
@@ -270,3 +270,53 b' Test that --interactive lift the need fo'
270 3
270 3
271 4
271 4
272 5
272 5
273 $ rm f.orig
274 $ hg update -C .
275 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
276
277 Check editing files newly added by a revert
278
279 1) Create a dummy editor changing 1 to 42
280 $ cat > $TESTTMP/editor.sh << '__EOF__'
281 > cat "$1" | sed "s/1/42/g" > tt
282 > mv tt "$1"
283 > __EOF__
284
285 2) Remove f
286 $ hg rm f
287 $ hg commit -m "remove f"
288
289 3) Do another commit on top
290 $ touch k; hg add k
291 $ hg commit -m "add k"
292 $ hg st
293
294 4) Use interactive revert to recover f and change it on the fly
295 $ HGEDITOR="\"sh\" \"\${TESTTMP}/editor.sh\"" PRINTHUNK="YES" hg revert -i -r ".^^" <<EOF
296 > y
297 > e
298 > EOF
299 adding f
300 removing k
301 diff --git a/f b/f
302 new file mode 100644
303 examine changes to 'f'? [Ynesfdaq?] y
304
305 @@ -0,0 +1,7 @@
306 +a
307 +1
308 +2
309 +3
310 +4
311 +5
312 +b
313 record this change to 'f'? [Ynesfdaq?] e
314
315 $ cat f
316 a
317 42
318 2
319 3
320 4
321 5
322 b
General Comments 0
You need to be logged in to leave comments. Login now