comparison mercurial/cmdutil.py @ 6597:371415a2b959

match: use helpers for cmdutil
author Matt Mackall <mpm@selenic.com>
date Mon, 12 May 2008 11:37:08 -0500
parents d3463007d368
children b822a379860b
comparison
equal deleted inserted replaced
6596:7fe4610cf920 6597:371415a2b959
232 def badfn(f, msg): 232 def badfn(f, msg):
233 repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) 233 repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
234 return False 234 return False
235 m.bad = badfn 235 m.bad = badfn
236 return m 236 return m
237
238 def matchall(repo):
239 return _match.always(repo.root, repo.getcwd())
240
241 def matchfiles(repo, files):
242 return _match.exact(repo.root, repo.getcwd(), files)
237 243
238 def findrenames(repo, added=None, removed=None, threshold=0.5): 244 def findrenames(repo, added=None, removed=None, threshold=0.5):
239 '''find renamed files -- yields (before, after, score) tuples''' 245 '''find renamed files -- yields (before, after, score) tuples'''
240 if added is None or removed is None: 246 if added is None or removed is None:
241 added, removed = repo.status()[1:3] 247 added, removed = repo.status()[1:3]
883 regular display via changeset_printer() is done. 889 regular display via changeset_printer() is done.
884 """ 890 """
885 # options 891 # options
886 patch = False 892 patch = False
887 if opts.get('patch'): 893 if opts.get('patch'):
888 patch = matchfn or util.always 894 patch = matchfn or matchall(repo)
889 895
890 tmpl = opts.get('template') 896 tmpl = opts.get('template')
891 mapfile = None 897 mapfile = None
892 if tmpl: 898 if tmpl:
893 tmpl = templater.parsestring(tmpl, quoted=False) 899 tmpl = templater.parsestring(tmpl, quoted=False)
1173 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)): 1179 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
1174 raise util.Abort(_("can't commit %s: " 1180 raise util.Abort(_("can't commit %s: "
1175 "unsupported file type!") % rel) 1181 "unsupported file type!") % rel)
1176 elif f not in repo.dirstate: 1182 elif f not in repo.dirstate:
1177 raise util.Abort(_("file %s not tracked!") % rel) 1183 raise util.Abort(_("file %s not tracked!") % rel)
1178 else: 1184 m = matchfiles(repo, files)
1179 files = []
1180 try: 1185 try:
1181 return commitfunc(ui, repo, files, message, m, opts) 1186 return commitfunc(ui, repo, m.files(), message, m, opts)
1182 except ValueError, inst: 1187 except ValueError, inst:
1183 raise util.Abort(str(inst)) 1188 raise util.Abort(str(inst))