##// END OF EJS Templates
make revert use standard matcher
Benoit Boissinot -
r1472:3c909a74 default
parent child Browse files
Show More
@@ -1790,7 +1790,7 b' def rename(ui, repo, *pats, **opts):'
1790 repo.remove(names, unlink=True)
1790 repo.remove(names, unlink=True)
1791 return errs
1791 return errs
1792
1792
1793 def revert(ui, repo, *names, **opts):
1793 def revert(ui, repo, *pats, **opts):
1794 """revert modified files or dirs back to their unmodified states
1794 """revert modified files or dirs back to their unmodified states
1795
1795
1796 Revert any uncommitted modifications made to the named files or
1796 Revert any uncommitted modifications made to the named files or
@@ -1800,61 +1800,20 b' def revert(ui, repo, *names, **opts):'
1800 If a file has been deleted, it is recreated. If the executable
1800 If a file has been deleted, it is recreated. If the executable
1801 mode of a file was changed, it is reset.
1801 mode of a file was changed, it is reset.
1802
1802
1803 If a directory is given, all files in that directory and its
1803 If names are given, all files matching the names are reverted.
1804 subdirectories are reverted.
1805
1804
1806 If no arguments are given, all files in the current directory and
1805 If no names are given, all files in the current directory and
1807 its subdirectories are reverted.
1806 its subdirectories are reverted.
1808 """
1807 """
1809 node = opts['rev'] and repo.lookup(opts['rev']) or \
1808 node = opts['rev'] and repo.lookup(opts['rev']) or \
1810 repo.dirstate.parents()[0]
1809 repo.dirstate.parents()[0]
1811 root = os.path.realpath(repo.root)
1812
1813 def trimpath(p):
1814 p = os.path.realpath(p)
1815 if p.startswith(root):
1816 rest = p[len(root):]
1817 if not rest:
1818 return rest
1819 if p.startswith(os.sep):
1820 return rest[1:]
1821 return p
1822
1823 relnames = map(trimpath, names or [os.getcwd()])
1824 chosen = {}
1825
1810
1826 def choose(name):
1811 files, choose, anypats = matchpats(repo, repo.getcwd(), pats, opts)
1827 def body(name):
1812 (c, a, d, u) = repo.changes(match=choose)
1828 for r in relnames:
1813 repo.forget(a)
1829 if not name.startswith(r):
1814 repo.undelete(d)
1830 continue
1831 rest = name[len(r):]
1832 if not rest:
1833 return r, True
1834 depth = rest.count(os.sep)
1835 if not r:
1836 if depth == 0 or not opts['nonrecursive']:
1837 return r, True
1838 elif rest[0] == os.sep:
1839 if depth == 1 or not opts['nonrecursive']:
1840 return r, True
1841 return None, False
1842 relname, ret = body(name)
1843 if ret:
1844 chosen[relname] = 1
1845 return ret
1846
1815
1847 (c, a, d, u) = repo.changes()
1816 return repo.update(node, False, True, choose, False)
1848 repo.forget(filter(choose, a))
1849 repo.undelete(filter(choose, d))
1850
1851 r = repo.update(node, False, True, choose, False)
1852 for n in relnames:
1853 if n not in chosen:
1854 ui.warn(_('error: no matches for %s\n') % n)
1855 r = 1
1856 sys.stdout.flush()
1857 return r
1858
1817
1859 def root(ui, repo):
1818 def root(ui, repo):
1860 """print the root (top) of the current working dir
1819 """print the root (top) of the current working dir
@@ -2348,7 +2307,8 b' table = {'
2348 _('hg rename [OPTION]... [SOURCE]... DEST')),
2307 _('hg rename [OPTION]... [SOURCE]... DEST')),
2349 "^revert":
2308 "^revert":
2350 (revert,
2309 (revert,
2351 [("n", "nonrecursive", None, _("do not recurse into subdirectories")),
2310 [('I', 'include', [], _('include names matching the given patterns')),
2311 ('X', 'exclude', [], _('exclude names matching the given patterns')),
2352 ("r", "rev", "", _("revision to revert to"))],
2312 ("r", "rev", "", _("revision to revert to"))],
2353 _("hg revert [-n] [-r REV] [NAME]...")),
2313 _("hg revert [-n] [-r REV] [NAME]...")),
2354 "root": (root, [], _("hg root")),
2314 "root": (root, [], _("hg root")),
General Comments 0
You need to be logged in to leave comments. Login now