Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 1415:c6e6ca96a033
refactor some unlink/remove code and make sure we prune empty dir
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 19 Oct 2005 00:10:52 -0700 |
parents | 1c64c628d15f |
children | b32b3509c7ab |
comparison
equal
deleted
inserted
replaced
1414:32fde51910c0 | 1415:c6e6ca96a033 |
---|---|
1439 return True | 1439 return True |
1440 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): | 1440 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): |
1441 if okaytoremove(abs, rel, exact): | 1441 if okaytoremove(abs, rel, exact): |
1442 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel) | 1442 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel) |
1443 names.append(abs) | 1443 names.append(abs) |
1444 for name in names: | 1444 repo.remove(names, unlink=True) |
1445 try: | |
1446 os.unlink(name) | |
1447 except OSError, inst: | |
1448 if inst.errno != errno.ENOENT: raise | |
1449 repo.remove(names) | |
1450 | 1445 |
1451 def rename(ui, repo, *pats, **opts): | 1446 def rename(ui, repo, *pats, **opts): |
1452 """rename files; equivalent of copy + remove""" | 1447 """rename files; equivalent of copy + remove""" |
1453 errs, copied = docopy(ui, repo, pats, opts) | 1448 errs, copied = docopy(ui, repo, pats, opts) |
1454 names = [] | 1449 names = [] |
1455 for abs, rel, exact in copied: | 1450 for abs, rel, exact in copied: |
1456 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel) | 1451 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel) |
1457 try: | |
1458 os.unlink(rel) | |
1459 except OSError, inst: | |
1460 if inst.errno != errno.ENOENT: raise | |
1461 names.append(abs) | 1452 names.append(abs) |
1462 repo.remove(names) | 1453 repo.remove(names, unlink=True) |
1463 return errs | 1454 return errs |
1464 | 1455 |
1465 def revert(ui, repo, *names, **opts): | 1456 def revert(ui, repo, *names, **opts): |
1466 """revert modified files or dirs back to their unmodified states""" | 1457 """revert modified files or dirs back to their unmodified states""" |
1467 node = opts['rev'] and repo.lookup(opts['rev']) or \ | 1458 node = opts['rev'] and repo.lookup(opts['rev']) or \ |