1453 """Update the dirstate to reflect the intent of copying src to dst. For |
1453 """Update the dirstate to reflect the intent of copying src to dst. For |
1454 different reasons it might not end with dst being marked as copied from src. |
1454 different reasons it might not end with dst being marked as copied from src. |
1455 """ |
1455 """ |
1456 origsrc = repo.dirstate.copied(src) or src |
1456 origsrc = repo.dirstate.copied(src) or src |
1457 if dst == origsrc: # copying back a copy? |
1457 if dst == origsrc: # copying back a copy? |
1458 if repo.dirstate[dst] not in b'mn' and not dryrun: |
1458 entry = repo.dirstate.get_entry(dst) |
|
1459 if (entry.added or not entry.tracked) and not dryrun: |
1459 repo.dirstate.set_tracked(dst) |
1460 repo.dirstate.set_tracked(dst) |
1460 else: |
1461 else: |
1461 if repo.dirstate[origsrc] == b'a' and origsrc == src: |
1462 if repo.dirstate.get_entry(origsrc).added and origsrc == src: |
1462 if not ui.quiet: |
1463 if not ui.quiet: |
1463 ui.warn( |
1464 ui.warn( |
1464 _( |
1465 _( |
1465 b"%s has not been committed yet, so no copy " |
1466 b"%s has not been committed yet, so no copy " |
1466 b"data will be stored for %s.\n" |
1467 b"data will be stored for %s.\n" |
1467 ) |
1468 ) |
1468 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)) |
1469 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)) |
1469 ) |
1470 ) |
1470 if repo.dirstate[dst] in b'?r' and not dryrun: |
1471 if not repo.dirstate.get_entry(dst).tracked and not dryrun: |
1471 wctx.add([dst]) |
1472 wctx.add([dst]) |
1472 elif not dryrun: |
1473 elif not dryrun: |
1473 wctx.copy(origsrc, dst) |
1474 wctx.copy(origsrc, dst) |
1474 |
1475 |
1475 |
1476 |