##// END OF EJS Templates
copy: distinguish "file exists" cases and add a hint (BC)...
Augie Fackler -
r30151:381293e1 default
parent child Browse files
Show More
@@ -646,8 +646,26 b' def copy(ui, repo, pats, opts, rename=Fa'
646
646
647 if not after and exists or after and state in 'mn':
647 if not after and exists or after and state in 'mn':
648 if not opts['force']:
648 if not opts['force']:
649 ui.warn(_('%s: not overwriting - file exists\n') %
649 if state in 'mn':
650 reltarget)
650 msg = _('%s: not overwriting - file already committed\n')
651 if after:
652 flags = '--after --force'
653 else:
654 flags = '--force'
655 if rename:
656 hint = _('(hg rename %s to replace the file by '
657 'recording a rename)\n') % flags
658 else:
659 hint = _('(hg copy %s to replace the file by '
660 'recording a copy)\n') % flags
661 else:
662 msg = _('%s: not overwriting - file exists\n')
663 if rename:
664 hint = _('(hg rename --after to record the rename)\n')
665 else:
666 hint = _('(hg copy --after to record the copy)\n')
667 ui.warn(msg % reltarget)
668 ui.warn(hint)
651 return
669 return
652
670
653 if after:
671 if after:
@@ -226,11 +226,23 b' foo was clean:'
226 C foo
226 C foo
227 Trying to copy on top of an existing file fails,
227 Trying to copy on top of an existing file fails,
228 $ hg copy -A bar foo
228 $ hg copy -A bar foo
229 foo: not overwriting - file exists
229 foo: not overwriting - file already committed
230 (hg copy --after --force to replace the file by recording a copy)
231 same error without the --after, so the user doesn't have to go through
232 two hints:
233 $ hg copy bar foo
234 foo: not overwriting - file already committed
235 (hg copy --force to replace the file by recording a copy)
230 but it's considered modified after a copy --after --force
236 but it's considered modified after a copy --after --force
231 $ hg copy -Af bar foo
237 $ hg copy -Af bar foo
232 $ hg st -AC foo
238 $ hg st -AC foo
233 M foo
239 M foo
234 bar
240 bar
241 The hint for a file that exists but is not in file history doesn't
242 mention --force:
243 $ touch xyzzy
244 $ hg cp bar xyzzy
245 xyzzy: not overwriting - file exists
246 (hg copy --after to record the copy)
235
247
236 $ cd ..
248 $ cd ..
@@ -265,7 +265,8 b' move everything under directory d1 to ex'
265 overwrite existing files (d2/b)
265 overwrite existing files (d2/b)
266
266
267 $ hg rename d1/* d2
267 $ hg rename d1/* d2
268 d2/b: not overwriting - file exists
268 d2/b: not overwriting - file already committed
269 (hg rename --force to replace the file by recording a rename)
269 moving d1/d11/a1 to d2/d11/a1 (glob)
270 moving d1/d11/a1 to d2/d11/a1 (glob)
270 $ hg status -C
271 $ hg status -C
271 A d2/a
272 A d2/a
@@ -370,6 +371,7 b' attempt to overwrite an existing file'
370 $ echo "ca" > d1/ca
371 $ echo "ca" > d1/ca
371 $ hg rename d1/ba d1/ca
372 $ hg rename d1/ba d1/ca
372 d1/ca: not overwriting - file exists
373 d1/ca: not overwriting - file exists
374 (hg rename --after to record the rename)
373 $ hg status -C
375 $ hg status -C
374 ? d1/ca
376 ? d1/ca
375 $ hg update -C
377 $ hg update -C
@@ -393,6 +395,7 b' attempt to overwrite an existing broken '
393 $ ln -s ba d1/ca
395 $ ln -s ba d1/ca
394 $ hg rename --traceback d1/ba d1/ca
396 $ hg rename --traceback d1/ba d1/ca
395 d1/ca: not overwriting - file exists
397 d1/ca: not overwriting - file exists
398 (hg rename --after to record the rename)
396 $ hg status -C
399 $ hg status -C
397 ? d1/ca
400 ? d1/ca
398 $ hg update -C
401 $ hg update -C
General Comments 0
You need to be logged in to leave comments. Login now