comparison mercurial/cmdutil.py @ 12085:6f833fc3ccab

Consistently import foo as foomod when foo to avoid shadowing This is in the style of 5f091fc1bab7.
author Martin Geisler <mg@aragost.com>
date Mon, 30 Aug 2010 14:38:24 +0200
parents ad787252fed6
children 1849b6147831
comparison
equal deleted inserted replaced
12084:ff7c1118a83a 12085:6f833fc3ccab
7 7
8 from node import hex, nullid, nullrev, short 8 from node import hex, nullid, nullrev, short
9 from i18n import _ 9 from i18n import _
10 import os, sys, errno, re, glob, tempfile 10 import os, sys, errno, re, glob, tempfile
11 import util, templater, patch, error, encoding, templatekw 11 import util, templater, patch, error, encoding, templatekw
12 import match as _match 12 import match as matchmod
13 import similar, revset 13 import similar, revset
14 14
15 revrangesep = ':' 15 revrangesep = ':'
16 16
17 def parsealiases(cmd): 17 def parsealiases(cmd):
245 def expandpats(pats): 245 def expandpats(pats):
246 if not util.expandglobs: 246 if not util.expandglobs:
247 return list(pats) 247 return list(pats)
248 ret = [] 248 ret = []
249 for p in pats: 249 for p in pats:
250 kind, name = _match._patsplit(p, None) 250 kind, name = matchmod._patsplit(p, None)
251 if kind is None: 251 if kind is None:
252 try: 252 try:
253 globbed = glob.glob(name) 253 globbed = glob.glob(name)
254 except re.error: 254 except re.error:
255 globbed = [name] 255 globbed = [name]
260 return ret 260 return ret
261 261
262 def match(repo, pats=[], opts={}, globbed=False, default='relpath'): 262 def match(repo, pats=[], opts={}, globbed=False, default='relpath'):
263 if not globbed and default == 'relpath': 263 if not globbed and default == 'relpath':
264 pats = expandpats(pats or []) 264 pats = expandpats(pats or [])
265 m = _match.match(repo.root, repo.getcwd(), pats, 265 m = matchmod.match(repo.root, repo.getcwd(), pats,
266 opts.get('include'), opts.get('exclude'), default) 266 opts.get('include'), opts.get('exclude'), default)
267 def badfn(f, msg): 267 def badfn(f, msg):
268 repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) 268 repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
269 m.bad = badfn 269 m.bad = badfn
270 return m 270 return m
271 271
272 def matchall(repo): 272 def matchall(repo):
273 return _match.always(repo.root, repo.getcwd()) 273 return matchmod.always(repo.root, repo.getcwd())
274 274
275 def matchfiles(repo, files): 275 def matchfiles(repo, files):
276 return _match.exact(repo.root, repo.getcwd(), files) 276 return matchmod.exact(repo.root, repo.getcwd(), files)
277 277
278 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): 278 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
279 if dry_run is None: 279 if dry_run is None:
280 dry_run = opts.get('dry_run') 280 dry_run = opts.get('dry_run')
281 if similarity is None: 281 if similarity is None:
462 # pat: ossep 462 # pat: ossep
463 # dest ossep 463 # dest ossep
464 # srcs: list of (hgsep, hgsep, ossep, bool) 464 # srcs: list of (hgsep, hgsep, ossep, bool)
465 # return: function that takes hgsep and returns ossep 465 # return: function that takes hgsep and returns ossep
466 def targetpathafterfn(pat, dest, srcs): 466 def targetpathafterfn(pat, dest, srcs):
467 if _match.patkind(pat): 467 if matchmod.patkind(pat):
468 # a mercurial pattern 468 # a mercurial pattern
469 res = lambda p: os.path.join(dest, 469 res = lambda p: os.path.join(dest,
470 os.path.basename(util.localpath(p))) 470 os.path.basename(util.localpath(p)))
471 else: 471 else:
472 abspfx = util.canonpath(repo.root, cwd, pat) 472 abspfx = util.canonpath(repo.root, cwd, pat)
510 if len(pats) == 1: 510 if len(pats) == 1:
511 raise util.Abort(_('no destination specified')) 511 raise util.Abort(_('no destination specified'))
512 dest = pats.pop() 512 dest = pats.pop()
513 destdirexists = os.path.isdir(dest) and not os.path.islink(dest) 513 destdirexists = os.path.isdir(dest) and not os.path.islink(dest)
514 if not destdirexists: 514 if not destdirexists:
515 if len(pats) > 1 or _match.patkind(pats[0]): 515 if len(pats) > 1 or matchmod.patkind(pats[0]):
516 raise util.Abort(_('with multiple sources, destination must be an ' 516 raise util.Abort(_('with multiple sources, destination must be an '
517 'existing directory')) 517 'existing directory'))
518 if util.endswithsep(dest): 518 if util.endswithsep(dest):
519 raise util.Abort(_('destination %s is not a directory') % dest) 519 raise util.Abort(_('destination %s is not a directory') % dest)
520 520