Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 4744:44e17f5029d0
Make hg add foo; hg mv foo bar work.
- foo will be removed (the user has a copy of its contents in bar)
- bar will not be marked as a copy (there was no committed version of foo).
We print a warning telling that to the user.
Fixes issue269.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Tue, 03 Jul 2007 03:06:40 -0300 |
parents | c41a404ac387 |
children | 452d171a1b39 |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Jul 03 03:06:40 2007 -0300 +++ b/mercurial/commands.py Tue Jul 03 03:06:40 2007 -0300 @@ -466,18 +466,17 @@ # return: hgsep def okaytocopy(abs, rel, exact): reasons = {'?': _('is not managed'), - 'a': _('has been marked for add'), 'r': _('has been marked for remove')} state = repo.dirstate.state(abs) reason = reasons.get(state) if reason: + if exact: + ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) + else: if state == 'a': origsrc = repo.dirstate.copied(abs) if origsrc is not None: return origsrc - if exact: - ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) - else: return abs # origsrc: hgsep @@ -532,8 +531,15 @@ if ui.verbose or not exact: ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) targets[abstarget] = abssrc - if abstarget != origsrc and not opts.get('dry_run'): - repo.copy(origsrc, abstarget, wlock) + if abstarget != origsrc: + if repo.dirstate.state(origsrc) == 'a': + ui.warn(_("%s was marked for addition. " + "%s will not be committed as a copy.\n") + % (repo.pathto(origsrc, cwd), reltarget)) + if abstarget not in repo.dirstate and not opts.get('dry_run'): + repo.add([abstarget], wlock) + elif not opts.get('dry_run'): + repo.copy(origsrc, abstarget, wlock) copied.append((abssrc, relsrc, exact)) # pat: ossep