Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 4392:9770d260a405
Make rm --after simply mark files as removed, unless --force is also given
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Mon, 30 Apr 2007 08:51:59 -0700 |
parents | caaba589d9c7 |
children | cf5f35ec4720 |
comparison
equal
deleted
inserted
replaced
4391:722417b3d7fa | 4392:9770d260a405 |
---|---|
525 if not opts.get('dry_run'): | 525 if not opts.get('dry_run'): |
526 util.copyfile(relsrc, reltarget) | 526 util.copyfile(relsrc, reltarget) |
527 restore = False | 527 restore = False |
528 finally: | 528 finally: |
529 if restore: | 529 if restore: |
530 repo.remove([abstarget], wlock) | 530 repo.remove([abstarget], wlock=wlock) |
531 except IOError, inst: | 531 except IOError, inst: |
532 if inst.errno == errno.ENOENT: | 532 if inst.errno == errno.ENOENT: |
533 ui.warn(_('%s: deleted in working copy\n') % relsrc) | 533 ui.warn(_('%s: deleted in working copy\n') % relsrc) |
534 else: | 534 else: |
535 ui.warn(_('%s: cannot copy - %s\n') % | 535 ui.warn(_('%s: cannot copy - %s\n') % |
2080 Schedule the indicated files for removal from the repository. | 2080 Schedule the indicated files for removal from the repository. |
2081 | 2081 |
2082 This only removes files from the current branch, not from the | 2082 This only removes files from the current branch, not from the |
2083 entire project history. If the files still exist in the working | 2083 entire project history. If the files still exist in the working |
2084 directory, they will be deleted from it. If invoked with --after, | 2084 directory, they will be deleted from it. If invoked with --after, |
2085 files that have been manually deleted are marked as removed. | 2085 files are marked as removed, but not actually unlinked unless --force |
2086 is also given. | |
2086 | 2087 |
2087 This command schedules the files to be removed at the next commit. | 2088 This command schedules the files to be removed at the next commit. |
2088 To undo a remove before that, see hg revert. | 2089 To undo a remove before that, see hg revert. |
2089 | 2090 |
2090 Modified files and added files are not removed by default. To | 2091 Modified files and added files are not removed by default. To |
2098 mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5] | 2099 mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5] |
2099 modified, added, removed, deleted, unknown = mardu | 2100 modified, added, removed, deleted, unknown = mardu |
2100 remove, forget = [], [] | 2101 remove, forget = [], [] |
2101 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): | 2102 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): |
2102 reason = None | 2103 reason = None |
2103 if abs not in deleted and opts['after']: | 2104 if abs in modified and not opts['force']: |
2104 reason = _('is still present') | |
2105 elif abs in modified and not opts['force']: | |
2106 reason = _('is modified (use -f to force removal)') | 2105 reason = _('is modified (use -f to force removal)') |
2107 elif abs in added: | 2106 elif abs in added: |
2108 if opts['force']: | 2107 if opts['force']: |
2109 forget.append(abs) | 2108 forget.append(abs) |
2110 continue | 2109 continue |
2119 else: | 2118 else: |
2120 if ui.verbose or not exact: | 2119 if ui.verbose or not exact: |
2121 ui.status(_('removing %s\n') % rel) | 2120 ui.status(_('removing %s\n') % rel) |
2122 remove.append(abs) | 2121 remove.append(abs) |
2123 repo.forget(forget) | 2122 repo.forget(forget) |
2124 repo.remove(remove, unlink=not opts['after']) | 2123 repo.remove(remove, unlink=opts['force'] or not opts['after']) |
2125 | 2124 |
2126 def rename(ui, repo, *pats, **opts): | 2125 def rename(ui, repo, *pats, **opts): |
2127 """rename files; equivalent of copy + remove | 2126 """rename files; equivalent of copy + remove |
2128 | 2127 |
2129 Mark dest as copies of sources; mark sources for deletion. If | 2128 Mark dest as copies of sources; mark sources for deletion. If |
2143 for abs, rel, exact in copied: | 2142 for abs, rel, exact in copied: |
2144 if ui.verbose or not exact: | 2143 if ui.verbose or not exact: |
2145 ui.status(_('removing %s\n') % rel) | 2144 ui.status(_('removing %s\n') % rel) |
2146 names.append(abs) | 2145 names.append(abs) |
2147 if not opts.get('dry_run'): | 2146 if not opts.get('dry_run'): |
2148 repo.remove(names, True, wlock) | 2147 repo.remove(names, True, wlock=wlock) |
2149 return errs | 2148 return errs |
2150 | 2149 |
2151 def revert(ui, repo, *pats, **opts): | 2150 def revert(ui, repo, *pats, **opts): |
2152 """revert files or dirs to their states as of some revision | 2151 """revert files or dirs to their states as of some revision |
2153 | 2152 |