##// END OF EJS Templates
Add rename/mv command....
Bryan O'Sullivan -
r1253:a45e717c default
parent child Browse files
Show More
@@ -173,13 +173,15 b' copy <source ...> <dest>::'
173 173 stand in the working directory. If invoked with --after, the
174 174 operation is recorded, but no copying is performed.
175 175
176 This command takes effect for the next commit.
176 This command takes effect in the next commit.
177 177
178 178 Options:
179 179 -A, --after record a copy that has already occurred
180 180 -f, --force forcibly copy over an existing managed file
181 181 -p, --parents append source path to dest
182 182
183 aliases: cp
184
183 185 diff [-a] [-r revision] [-r revision] [files ...]::
184 186 Show differences between revisions for the specified files.
185 187
@@ -448,6 +450,24 b' remove [options] [files ...]::'
448 450
449 451 aliases: rm
450 452
453 rename <source ...> <dest>::
454 Mark dest as copies of sources; mark sources for deletion. If
455 dest is a directory, copies are put in that directory. If dest is
456 a file, there can only be one source.
457
458 By default, this command copies the contents of files as they
459 stand in the working directory. If invoked with --after, the
460 operation is recorded, but no copying is performed.
461
462 This command takes effect in the next commit.
463
464 Options:
465 -A, --after record a rename that has already occurred
466 -f, --force forcibly copy over an existing managed file
467 -p, --parents append source path to dest
468
469 aliases: mv
470
451 471 revert [names ...]::
452 472 Revert any uncommitted modifications made to the named files or
453 473 directories. This restores the contents of the affected files to
@@ -696,8 +696,7 b' def commit(ui, repo, *pats, **opts):'
696 696 except ValueError, inst:
697 697 raise util.Abort(str(inst))
698 698
699 def copy(ui, repo, *pats, **opts):
700 """mark files as copied for the next commit"""
699 def docopy(ui, repo, pats, opts):
701 700 if not pats:
702 701 raise util.Abort('no source or destination specified')
703 702 elif len(pats) == 1:
@@ -735,7 +734,7 b' def copy(ui, repo, *pats, **opts):'
735 734 elif len(sources) > 1:
736 735 raise util.Abort('with multiple sources, destination must be a '
737 736 'directory')
738 errs = 0
737 errs, copied = 0, []
739 738 for abs, rel, exact in sources:
740 739 if opts['parents']:
741 740 mydest = os.path.join(dest, rel)
@@ -763,6 +762,8 b' def copy(ui, repo, *pats, **opts):'
763 762 n = repo.manifest.tip()
764 763 mf = repo.manifest.readflags(n)
765 764 util.set_exec(myreldest, util.is_exec(rel, mf[abs]))
765 except shutil.Error, inst:
766 raise util.Abort(str(inst))
766 767 except IOError, inst:
767 768 if inst.errno == errno.ENOENT:
768 769 ui.warn('%s: deleted in working copy\n' % rel)
@@ -771,8 +772,14 b' def copy(ui, repo, *pats, **opts):'
771 772 errs += 1
772 773 continue
773 774 repo.copy(abs, myabsdest)
775 copied.append((abs, rel, exact))
774 776 if errs:
775 ui.warn('(consider using --after to record failed copies)\n')
777 ui.warn('(consider using --after)\n')
778 return errs, copied
779
780 def copy(ui, repo, *pats, **opts):
781 """mark files as copied for the next commit"""
782 errs, copied = docopy(ui, repo, pats, opts)
776 783 return errs
777 784
778 785 def debugcheckstate(ui, repo):
@@ -1390,14 +1397,14 b' def remove(ui, repo, pat, *pats, **opts)'
1390 1397 reason = None
1391 1398 if c: reason = 'is modified'
1392 1399 elif a: reason = 'has been marked for add'
1393 elif u: reason = 'not managed'
1400 elif u: reason = 'is not managed'
1394 1401 if reason and exact:
1395 1402 ui.warn('not removing %s: file %s\n' % (rel, reason))
1396 1403 else:
1397 1404 return True
1398 1405 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts):
1399 1406 if okaytoremove(abs, rel, exact):
1400 if not exact: ui.status('removing %s\n' % rel)
1407 if ui.verbose or not exact: ui.status('removing %s\n' % rel)
1401 1408 names.append(abs)
1402 1409 for name in names:
1403 1410 try:
@@ -1406,6 +1413,20 b' def remove(ui, repo, pat, *pats, **opts)'
1406 1413 if inst.errno != errno.ENOENT: raise
1407 1414 repo.remove(names)
1408 1415
1416 def rename(ui, repo, *pats, **opts):
1417 """rename files; equivalent of copy + remove"""
1418 errs, copied = docopy(ui, repo, pats, opts)
1419 names = []
1420 for abs, rel, exact in copied:
1421 if ui.verbose or not exact: ui.status('removing %s\n' % rel)
1422 try:
1423 os.unlink(rel)
1424 except OSError, inst:
1425 if inst.errno != errno.ENOENT: raise
1426 names.append(abs)
1427 repo.remove(names)
1428 return errs
1429
1409 1430 def revert(ui, repo, *names, **opts):
1410 1431 """revert modified files or dirs back to their unmodified states"""
1411 1432 node = opts['rev'] and repo.lookup(opts['rev']) or \
@@ -1876,6 +1897,13 b' table = {'
1876 1897 [('I', 'include', [], 'include path in search'),
1877 1898 ('X', 'exclude', [], 'exclude path from search')],
1878 1899 "hg remove [OPTION]... FILE..."),
1900 "rename|mv": (rename,
1901 [('I', 'include', [], 'include path in search'),
1902 ('X', 'exclude', [], 'exclude path from search'),
1903 ('A', 'after', None, 'record a copy after it has happened'),
1904 ('f', 'force', None, 'replace destination if it exists'),
1905 ('p', 'parents', None, 'append source path to dest')],
1906 'hg rename [OPTION]... [SOURCE]... DEST'),
1879 1907 "^revert":
1880 1908 (revert,
1881 1909 [("n", "nonrecursive", None, "don't recurse into subdirs"),
@@ -65,6 +65,7 b' list of commands (use "hg help -v" to sh'
65 65 rawcommit raw commit interface
66 66 recover roll back an interrupted transaction
67 67 remove remove the specified files on the next commit
68 rename rename files; equivalent of copy + remove
68 69 revert revert modified files or dirs back to their unmodified states
69 70 root print the root (top) of the current working dir
70 71 serve export the repository via HTTP
@@ -106,6 +107,7 b' list of commands (use "hg help -v" to sh'
106 107 rawcommit raw commit interface
107 108 recover roll back an interrupted transaction
108 109 remove remove the specified files on the next commit
110 rename rename files; equivalent of copy + remove
109 111 revert revert modified files or dirs back to their unmodified states
110 112 root print the root (top) of the current working dir
111 113 serve export the repository via HTTP
General Comments 0
You need to be logged in to leave comments. Login now