##// END OF EJS Templates
copy: recommend `--at-rev .` if target was added in parent commit...
Martin von Zweigbergk -
r49061:c62e4397 default
parent child Browse files
Show More
@@ -1678,26 +1678,44 b' def copy(ui, repo, pats, opts, rename=Fa'
1678 if not opts[b'force']:
1678 if not opts[b'force']:
1679 if already_commited:
1679 if already_commited:
1680 msg = _(b'%s: not overwriting - file already committed\n')
1680 msg = _(b'%s: not overwriting - file already committed\n')
1681 if after:
1681 # Check if if the target was added in the parent and the
1682 flags = b'--after --force'
1682 # source already existed in the grandparent.
1683 else:
1683 looks_like_copy_in_pctx = abstarget in pctx and any(
1684 flags = b'--force'
1684 abssrc in gpctx and abstarget not in gpctx
1685 if rename:
1685 for gpctx in pctx.parents()
1686 hint = (
1686 )
1687 _(
1687 if looks_like_copy_in_pctx:
1688 b"('hg rename %s' to replace the file by "
1688 if rename:
1689 b'recording a rename)\n'
1689 hint = _(
1690 b"('hg rename --at-rev .' to record the rename "
1691 b"in the parent of the working copy)\n"
1692 )
1693 else:
1694 hint = _(
1695 b"('hg copy --at-rev .' to record the copy in "
1696 b"the parent of the working copy)\n"
1690 )
1697 )
1691 % flags
1692 )
1693 else:
1698 else:
1694 hint = (
1699 if after:
1695 _(
1700 flags = b'--after --force'
1696 b"('hg copy %s' to replace the file by "
1701 else:
1697 b'recording a copy)\n'
1702 flags = b'--force'
1703 if rename:
1704 hint = (
1705 _(
1706 b"('hg rename %s' to replace the file by "
1707 b'recording a rename)\n'
1708 )
1709 % flags
1698 )
1710 )
1699 % flags
1711 else:
1700 )
1712 hint = (
1713 _(
1714 b"('hg copy %s' to replace the file by "
1715 b'recording a copy)\n'
1716 )
1717 % flags
1718 )
1701 else:
1719 else:
1702 msg = _(b'%s: not overwriting - file exists\n')
1720 msg = _(b'%s: not overwriting - file exists\n')
1703 if rename:
1721 if rename:
@@ -42,6 +42,17 b' Test single file'
42 d1/b
42 d1/b
43 A d1/d
43 A d1/d
44 d1/b
44 d1/b
45 # Should get helpful message if we try to copy or rename after commit
46 $ hg cp --forget --at-rev . d1/d
47 saved backup bundle to $TESTTMP/.hg/strip-backup/3f7c325d3f9e-46f377bb-uncopy.hg
48 $ hg cp d1/b d1/d
49 d1/d: not overwriting - file already committed
50 ('hg copy --at-rev .' to record the copy in the parent of the working copy)
51 [1]
52 $ hg mv d1/b d1/d
53 d1/d: not overwriting - file already committed
54 ('hg rename --at-rev .' to record the rename in the parent of the working copy)
55 [1]
45
56
46 Test moved file (not copied) using 'hg cp' command
57 Test moved file (not copied) using 'hg cp' command
47
58
General Comments 0
You need to be logged in to leave comments. Login now