Show More
@@ -447,7 +447,7 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
447 | # srcs: list of (hgsep, hgsep, ossep, bool) |
|
447 | # srcs: list of (hgsep, hgsep, ossep, bool) | |
448 | # return: function that takes hgsep and returns ossep |
|
448 | # return: function that takes hgsep and returns ossep | |
449 | def targetpathafterfn(pat, dest, srcs): |
|
449 | def targetpathafterfn(pat, dest, srcs): | |
450 |
if |
|
450 | if _match.patkind(pat): | |
451 | # a mercurial pattern |
|
451 | # a mercurial pattern | |
452 | res = lambda p: os.path.join(dest, |
|
452 | res = lambda p: os.path.join(dest, | |
453 | os.path.basename(util.localpath(p))) |
|
453 | os.path.basename(util.localpath(p))) | |
@@ -495,7 +495,7 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
495 | dest = pats.pop() |
|
495 | dest = pats.pop() | |
496 | destdirexists = os.path.isdir(dest) and not os.path.islink(dest) |
|
496 | destdirexists = os.path.isdir(dest) and not os.path.islink(dest) | |
497 | if not destdirexists: |
|
497 | if not destdirexists: | |
498 |
if len(pats) > 1 or |
|
498 | if len(pats) > 1 or _match.patkind(pats[0]): | |
499 | raise util.Abort(_('with multiple sources, destination must be an ' |
|
499 | raise util.Abort(_('with multiple sources, destination must be an ' | |
500 | 'existing directory')) |
|
500 | 'existing directory')) | |
501 | if util.endswithsep(dest): |
|
501 | if util.endswithsep(dest): |
@@ -53,3 +53,7 b' class match(_match):' | |||||
53 | f, mf, ap = util.matcher(root, cwd, patterns, include, exclude, |
|
53 | f, mf, ap = util.matcher(root, cwd, patterns, include, exclude, | |
54 | default) |
|
54 | default) | |
55 | _match.__init__(self, root, cwd, f, mf, ap) |
|
55 | _match.__init__(self, root, cwd, f, mf, ap) | |
|
56 | ||||
|
57 | def patkind(pat): | |||
|
58 | return util._patsplit(pat, None)[0] | |||
|
59 |
@@ -207,12 +207,12 b' Abort = error.Abort' | |||||
207 | def always(fn): return True |
|
207 | def always(fn): return True | |
208 | def never(fn): return False |
|
208 | def never(fn): return False | |
209 |
|
209 | |||
210 |
def |
|
210 | def _patsplit(pat, default): | |
211 | """Split a string into an optional pattern kind prefix and the |
|
211 | """Split a string into an optional pattern kind prefix and the | |
212 | actual pattern.""" |
|
212 | actual pattern.""" | |
213 | for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': |
|
213 | for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': | |
214 |
if |
|
214 | if pat.startswith(prefix + ':'): return pat.split(':', 1) | |
215 |
return default, |
|
215 | return default, pat | |
216 |
|
216 | |||
217 | def globre(pat, head='^', tail='$'): |
|
217 | def globre(pat, head='^', tail='$'): | |
218 | "convert a glob pattern into a regexp" |
|
218 | "convert a glob pattern into a regexp" | |
@@ -436,7 +436,7 b" def matcher(canonroot, cwd='', names=[]," | |||||
436 | pats = [] |
|
436 | pats = [] | |
437 | roots = [] |
|
437 | roots = [] | |
438 | anypats = False |
|
438 | anypats = False | |
439 |
for kind, name in [ |
|
439 | for kind, name in [_patsplit(p, default) for p in names]: | |
440 | if kind in ('glob', 'relpath'): |
|
440 | if kind in ('glob', 'relpath'): | |
441 | name = canonpath(canonroot, cwd, name) |
|
441 | name = canonpath(canonroot, cwd, name) | |
442 | elif kind in ('relglob', 'path'): |
|
442 | elif kind in ('relglob', 'path'): | |
@@ -739,7 +739,7 b" if os.name == 'nt':" | |||||
739 | '''On Windows, expand the implicit globs in a list of patterns''' |
|
739 | '''On Windows, expand the implicit globs in a list of patterns''' | |
740 | ret = [] |
|
740 | ret = [] | |
741 | for p in pats: |
|
741 | for p in pats: | |
742 |
kind, name = |
|
742 | kind, name = _patsplit(p, None) | |
743 | if kind is None: |
|
743 | if kind is None: | |
744 | globbed = glob.glob(name) |
|
744 | globbed = glob.glob(name) | |
745 | if globbed: |
|
745 | if globbed: |
General Comments 0
You need to be logged in to leave comments.
Login now