##// END OF EJS Templates
Make hg add foo; hg mv foo bar work....
Alexis S. L. Carvalho -
r4744:44e17f50 default
parent child Browse files
Show More
@@ -466,18 +466,17 b' def docopy(ui, repo, pats, opts, wlock):'
466 # return: hgsep
466 # return: hgsep
467 def okaytocopy(abs, rel, exact):
467 def okaytocopy(abs, rel, exact):
468 reasons = {'?': _('is not managed'),
468 reasons = {'?': _('is not managed'),
469 'a': _('has been marked for add'),
470 'r': _('has been marked for remove')}
469 'r': _('has been marked for remove')}
471 state = repo.dirstate.state(abs)
470 state = repo.dirstate.state(abs)
472 reason = reasons.get(state)
471 reason = reasons.get(state)
473 if reason:
472 if reason:
473 if exact:
474 ui.warn(_('%s: not copying - file %s\n') % (rel, reason))
475 else:
474 if state == 'a':
476 if state == 'a':
475 origsrc = repo.dirstate.copied(abs)
477 origsrc = repo.dirstate.copied(abs)
476 if origsrc is not None:
478 if origsrc is not None:
477 return origsrc
479 return origsrc
478 if exact:
479 ui.warn(_('%s: not copying - file %s\n') % (rel, reason))
480 else:
481 return abs
480 return abs
482
481
483 # origsrc: hgsep
482 # origsrc: hgsep
@@ -532,8 +531,15 b' def docopy(ui, repo, pats, opts, wlock):'
532 if ui.verbose or not exact:
531 if ui.verbose or not exact:
533 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
532 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
534 targets[abstarget] = abssrc
533 targets[abstarget] = abssrc
535 if abstarget != origsrc and not opts.get('dry_run'):
534 if abstarget != origsrc:
536 repo.copy(origsrc, abstarget, wlock)
535 if repo.dirstate.state(origsrc) == 'a':
536 ui.warn(_("%s was marked for addition. "
537 "%s will not be committed as a copy.\n")
538 % (repo.pathto(origsrc, cwd), reltarget))
539 if abstarget not in repo.dirstate and not opts.get('dry_run'):
540 repo.add([abstarget], wlock)
541 elif not opts.get('dry_run'):
542 repo.copy(origsrc, abstarget, wlock)
537 copied.append((abssrc, relsrc, exact))
543 copied.append((abssrc, relsrc, exact))
538
544
539 # pat: ossep
545 # pat: ossep
@@ -2,9 +2,26 b''
2
2
3 hg init
3 hg init
4 echo foo > foo
4 echo foo > foo
5 echo "# should fail - foo is not managed"
6 hg mv foo bar
7 hg st -A
5 hg add foo
8 hg add foo
9 echo "# dry-run; print a warning that this is not a real copy; foo is added"
10 hg mv --dry-run foo bar
11 hg st -A
12 echo "# should print a warning that this is not a real copy; bar is added"
13 hg mv foo bar
14 hg st -A
15 echo "# should print a warning that this is not a real copy; foo is added"
16 hg cp bar foo
17 hg rm -f bar
18 rm bar
19 hg st -A
6 hg commit -m1 -d"0 0"
20 hg commit -m1 -d"0 0"
7
21
22 echo "# dry-run; should show that foo is clean"
23 hg copy --dry-run foo bar
24 hg st -A
8 echo "# should show copy"
25 echo "# should show copy"
9 hg copy foo bar
26 hg copy foo bar
10 hg st -C
27 hg st -C
@@ -1,3 +1,18 b''
1 # should fail - foo is not managed
2 foo: not copying - file is not managed
3 abort: no files to copy
4 ? foo
5 # dry-run; print a warning that this is not a real copy; foo is added
6 foo was marked for addition. bar will not be committed as a copy.
7 A foo
8 # should print a warning that this is not a real copy; bar is added
9 foo was marked for addition. bar will not be committed as a copy.
10 A bar
11 # should print a warning that this is not a real copy; foo is added
12 bar was marked for addition. foo will not be committed as a copy.
13 A foo
14 # dry-run; should show that foo is clean
15 C foo
1 # should show copy
16 # should show copy
2 A bar
17 A bar
3 foo
18 foo
General Comments 0
You need to be logged in to leave comments. Login now