##// END OF EJS Templates
patch: fix copies when patching over uncommitted changed (issue2459)
Patrick Mezard -
r12874:bb7bf43b stable
parent child Browse files
Show More
@@ -348,7 +348,7 b' def updatedir(ui, repo, patches, similar'
348
348
349 wctx = repo[None]
349 wctx = repo[None]
350 for src, dst in copies:
350 for src, dst in copies:
351 wctx.copy(src, dst)
351 dirstatecopy(ui, repo, wctx, src, dst, cwd=cwd)
352 if (not similarity) and removes:
352 if (not similarity) and removes:
353 wctx.remove(sorted(removes), True)
353 wctx.remove(sorted(removes), True)
354
354
@@ -367,6 +367,25 b' def updatedir(ui, repo, patches, similar'
367 files.extend([r for r in removes if r not in files])
367 files.extend([r for r in removes if r not in files])
368 return sorted(files)
368 return sorted(files)
369
369
370 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None):
371 """Update the dirstate to reflect the intent of copying src to dst. For
372 different reasons it might not end with dst being marked as copied from src.
373 """
374 origsrc = repo.dirstate.copied(src) or src
375 if dst == origsrc: # copying back a copy?
376 if repo.dirstate[dst] not in 'mn' and not dryrun:
377 repo.dirstate.normallookup(dst)
378 else:
379 if repo.dirstate[origsrc] == 'a' and origsrc == src:
380 if not ui.quiet:
381 ui.warn(_("%s has not been committed yet, so no copy "
382 "data will be stored for %s.\n")
383 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)))
384 if repo.dirstate[dst] in '?r' and not dryrun:
385 wctx.add([dst])
386 elif not dryrun:
387 wctx.copy(origsrc, dst)
388
370 def copy(ui, repo, pats, opts, rename=False):
389 def copy(ui, repo, pats, opts, rename=False):
371 # called with the repo lock held
390 # called with the repo lock held
372 #
391 #
@@ -458,21 +477,7 b' def copy(ui, repo, pats, opts, rename=Fa'
458 targets[abstarget] = abssrc
477 targets[abstarget] = abssrc
459
478
460 # fix up dirstate
479 # fix up dirstate
461 origsrc = repo.dirstate.copied(abssrc) or abssrc
480 dirstatecopy(ui, repo, wctx, abssrc, abstarget, dryrun=dryrun, cwd=cwd)
462 if abstarget == origsrc: # copying back a copy?
463 if state not in 'mn' and not dryrun:
464 repo.dirstate.normallookup(abstarget)
465 else:
466 if repo.dirstate[origsrc] == 'a' and origsrc == abssrc:
467 if not ui.quiet:
468 ui.warn(_("%s has not been committed yet, so no copy "
469 "data will be stored for %s.\n")
470 % (repo.pathto(origsrc, cwd), reltarget))
471 if repo.dirstate[abstarget] in '?r' and not dryrun:
472 wctx.add([abstarget])
473 elif not dryrun:
474 wctx.copy(origsrc, abstarget)
475
476 if rename and not dryrun:
481 if rename and not dryrun:
477 wctx.remove([abssrc], not after)
482 wctx.remove([abssrc], not after)
478
483
@@ -361,4 +361,25 b' Move text file and patch as binary'
361 A binary2
361 A binary2
362 text2
362 text2
363 R text2
363 R text2
364 $ cd ..
364
365
366 Consecutive import with renames (issue2459)
367
368 $ hg init issue2459
369 $ cd issue2459
370 $ hg import --no-commit --force - <<EOF
371 > diff --git a/a b/a
372 > new file mode 100644
373 > EOF
374 applying patch from stdin
375 $ hg import --no-commit --force - <<EOF
376 > diff --git a/a b/b
377 > rename from a
378 > rename to b
379 > EOF
380 applying patch from stdin
381 a has not been committed yet, so no copy data will be stored for b.
382 $ hg debugstate
383 a 0 -1 unset b
384 $ hg ci -m done
385 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now