[PATCH STABLE] scmutil: add missing import of re

Adrian Buehlmann adrian at cadifra.com
Sat Jul 9 01:42:52 CDT 2011


On 2011-07-09 03:27, Steve Borho wrote:
> # HG changeset patch
> # User Steve Borho <steve at borho.org>
> # Date 1310174659 18000
> # Branch stable
> # Node ID f736ce9be7bd5176fa21463da36adca0e1b3e9b5
> # Parent  e9264b45237d94ca0953daac9333444bfa40ce5c
> scmutil: add missing import of re
> 
> see https://bitbucket.org/tortoisehg/thg/issue/929
> 
> diff -r e9264b45237d -r f736ce9be7bd mercurial/scmutil.py
> --- a/mercurial/scmutil.py	Wed Jul 06 13:43:29 2011 -0500
> +++ b/mercurial/scmutil.py	Fri Jul 08 20:24:19 2011 -0500
> @@ -8,7 +8,7 @@
>  from i18n import _
>  import util, error, osutil, revset, similar
>  import match as matchmod
> -import os, errno, stat, sys, glob
> +import os, errno, re, stat, sys, glob
>  
>  def checkfilename(f):
>      '''Check that the filename f is an acceptable filename for a tracked file'''

Seems to fix

changeset:   14320:3438417a6657
user:        Matt Mackall <mpm at selenic.com>
date:        Fri May 13 14:07:16 2011 -0500
summary:     scmutil: fold in wdutil

which inserted expandpats in scmutil without adding a 're' import

Matt committed:
> # HG changeset patch
> # User Matt Mackall <mpm at selenic.com>
> # Date 1305313636 18000
> # Node ID 3438417a66571d080eb6d9f48bbb88fa1390133b
> # Parent  b33f3e35efb01e410d59f313e6f1b158206f1241
> scmutil: fold in wdutil
> 
[snip]
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -6,8 +6,9 @@
>  # GNU General Public License version 2 or any later version.
>  
>  from i18n import _
> -import util, error, osutil, revset
> -import os, errno, stat, sys
> +import util, error, osutil, revset, similar
> +import match as matchmod
> +import os, errno, stat, sys, glob
>  
>  def checkfilename(f):
>      '''Check that the filename f is an acceptable filename for a tracked file'''
> @@ -536,3 +537,154 @@
>          seen.update(l)
>  
>      return l
> +
> +def expandpats(pats):
> +    if not util.expandglobs:
> +        return list(pats)
> +    ret = []
> +    for p in pats:
> +        kind, name = matchmod._patsplit(p, None)
> +        if kind is None:
> +            try:
> +                globbed = glob.glob(name)
> +            except re.error:
> +                globbed = [name]
> +            if globbed:
> +                ret.extend(globbed)
> +                continue
> +        ret.append(p)
> +    return ret


More information about the Mercurial-devel mailing list