Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 12874:bb7bf43b72fb stable
patch: fix copies when patching over uncommitted changed (issue2459)
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 28 Oct 2010 21:25:53 +0200 |
parents | 642afc8f50e7 |
children | 4ff61287bde2 |
comparison
equal
deleted
inserted
replaced
12873:e1855dee28c1 | 12874:bb7bf43b72fb |
---|---|
346 elif gp.op == 'DELETE': | 346 elif gp.op == 'DELETE': |
347 removes.add(gp.path) | 347 removes.add(gp.path) |
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 |
355 for f in patches: | 355 for f in patches: |
356 gp = patches[f] | 356 gp = patches[f] |
364 util.set_flags(dst, islink, isexec) | 364 util.set_flags(dst, islink, isexec) |
365 addremove(repo, cfiles, similarity=similarity) | 365 addremove(repo, cfiles, similarity=similarity) |
366 files = patches.keys() | 366 files = patches.keys() |
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 | |
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) | |
369 | 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 # |
373 # hgsep => pathname that uses "/" to separate directories | 392 # hgsep => pathname that uses "/" to separate directories |
456 ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | 475 ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
457 | 476 |
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 |
479 # pat: ossep | 484 # pat: ossep |
480 # dest ossep | 485 # dest ossep |