##// END OF EJS Templates
docopy: deal with globs on windows in a better way
Alexis S. L. Carvalho -
r4055:e37786b2 default
parent child Browse files
Show More
@@ -127,7 +127,7 b' def make_file(repo, pat, node=None,'
127 pathname),
127 pathname),
128 mode)
128 mode)
129
129
130 def matchpats(repo, pats=[], opts={}, head=''):
130 def matchpats(repo, pats=[], opts={}, head='', globbed=False):
131 cwd = repo.getcwd()
131 cwd = repo.getcwd()
132 if not pats and cwd:
132 if not pats and cwd:
133 opts['include'] = [os.path.join(cwd, i)
133 opts['include'] = [os.path.join(cwd, i)
@@ -136,10 +136,12 b' def matchpats(repo, pats=[], opts={}, he'
136 for x in opts.get('exclude', [])]
136 for x in opts.get('exclude', [])]
137 cwd = ''
137 cwd = ''
138 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
138 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
139 opts.get('exclude'), head)
139 opts.get('exclude'), head, globbed=globbed)
140
140
141 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None):
141 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None,
142 files, matchfn, anypats = matchpats(repo, pats, opts, head)
142 globbed=False):
143 files, matchfn, anypats = matchpats(repo, pats, opts, head,
144 globbed=globbed)
143 exact = dict.fromkeys(files)
145 exact = dict.fromkeys(files)
144 for src, fn in repo.walk(node=node, files=files, match=matchfn,
146 for src, fn in repo.walk(node=node, files=files, match=matchfn,
145 badmatch=badmatch):
147 badmatch=badmatch):
@@ -605,7 +605,7 b' def docopy(ui, repo, pats, opts, wlock):'
605 return res
605 return res
606
606
607
607
608 pats = list(pats)
608 pats = util.expand_glob(pats)
609 if not pats:
609 if not pats:
610 raise util.Abort(_('no source or destination specified'))
610 raise util.Abort(_('no source or destination specified'))
611 if len(pats) == 1:
611 if len(pats) == 1:
@@ -622,7 +622,8 b' def docopy(ui, repo, pats, opts, wlock):'
622 copylist = []
622 copylist = []
623 for pat in pats:
623 for pat in pats:
624 srcs = []
624 srcs = []
625 for tag, abssrc, relsrc, exact in cmdutil.walk(repo, [pat], opts):
625 for tag, abssrc, relsrc, exact in cmdutil.walk(repo, [pat], opts,
626 globbed=True):
626 origsrc = okaytocopy(abssrc, relsrc, exact)
627 origsrc = okaytocopy(abssrc, relsrc, exact)
627 if origsrc:
628 if origsrc:
628 srcs.append((origsrc, abssrc, relsrc, exact))
629 srcs.append((origsrc, abssrc, relsrc, exact))
@@ -375,8 +375,10 b' def canonpath(root, cwd, myname):'
375 def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None):
375 def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None):
376 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
376 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
377
377
378 def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None):
378 def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='',
379 names = expand_glob(names)
379 src=None, globbed=False):
380 if not globbed:
381 names = expand_glob(names)
380 return _matcher(canonroot, cwd, names, inc, exc, head, 'relpath', src)
382 return _matcher(canonroot, cwd, names, inc, exc, head, 'relpath', src)
381
383
382 def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
384 def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
General Comments 0
You need to be logged in to leave comments. Login now