Commit Graph

59 Commits

Author SHA1 Message Date
Mads Kiilerich
2372d51b68 fix wording and not-completely-trivial spelling errors and bad docstrings 2012-08-15 22:39:18 +02:00
Bryan O'Sullivan
3f45806d34 matcher: use re2 bindings if available
There are two sets of Python re2 bindings available on the internet;
this code works with both.

Using re2 can greatly improve "hg status" performance when a .hgignore
file becomes even modestly complex.

Example: "hg status" on a clean tree with 134K files, where "hg
debugignore" reports a regexp 4256 bytes in size.

  no .hgignore: 1.76 sec
  Python re:    2.79
  re2:          1.82

The overhead of regexp matching drops from 1.03 seconds with stock
re to 0.06 with re2.

(For comparison, a git repo with the same contents and .gitignore
file runs "git status -s" in 1.71 seconds, i.e. only slightly faster
than hg with re2.)
2012-06-01 15:26:20 -07:00
Matt Mackall
bfe92722a0 merge with stable 2012-05-30 14:21:58 -05:00
FUJIWARA Katsunori
abfb6c35d4 match: make 'match.files()' return list object always
'exact' match objects are sometimes created with a non-list 'pattern'
argument:

  - using 'set' in queue.refresh():hgext/mq.py
        match = scmutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs))

  - using 'dict' in revert():mercurial/cmdutil.py (names = {})
        m = scmutil.matchfiles(repo, names)

'exact' match objects return specified 'pattern' to callers of
'match.files()' as it is, so it is a non-list object.

but almost all implementations expect 'match.files()' to return a list
object, so this may causes problems: e.g. exception for "+" with
another list object.

this patch ensures that '_files' of 'exact' match objects is a list
object.

for non 'exact' match objects, parsing specified 'pattern' already
ensures that it it a list one.
2012-05-23 00:25:29 +09:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Jesse Glick
17675847fa localrepo: optimize internode status calls using match.always
Introduce match.always() to check if a match object always says yes, i.e.
None was passed in. If so, mfmatches should not bother iterating every file in
the repository.
2012-05-04 15:54:55 -04:00
Patrick Mezard
8d52be3d10 match: consider filesets as "anypats"
Matt suggested this on IRC, I do not think the choice is obvious, but this one
makes things simpler because while filesets are turned into a list of files
into the match objects, it would more be difficult to tell invalid files passed
in pats from those expanded from filesets.
2012-02-26 17:10:55 +01:00
Martin Geisler
543f0688d9 match: remove unused assignment
The field is assigned again below with the constructor argument.
2011-08-09 11:05:13 +02:00
Peter Arrenbrecht
aa36fb062f match: fix bug caused by refactoring in fb457d08da0b 2011-06-23 14:40:57 +02:00
Matt Mackall
1dc7f878ce match: introduce basic fileset support 2011-06-18 16:53:44 -05:00
Matt Mackall
b662345d91 match: allow passing a context object to match core 2011-06-18 16:52:51 -05:00
Patrick Mezard
37e2e503d6 match: make 'listfile:' split on LF and CRLF
We want util.readfile() to operate in binary mode, so EOLs have to be handled
correctly depending on the platform. It seems both easier and more convenient
to treat LF and CRLF the same way on all platforms.
2011-05-07 21:12:30 +02:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02:00
Adrian Buehlmann
f3e8eae526 move canonpath from util to scmutil 2011-04-20 21:41:41 +02:00
Steve Borho
909958e650 match: fix subtle error in _buildmatch
The trailing comma was causing a ValueError.  See
https://bitbucket.org/tortoisehg/thg/issue/132
2011-02-18 10:28:20 -06:00
jfh
76026ecba1 add debugignore which yields the combined ignore patten of the .hgignore files
For GUI clients its sometimes important to know which files will be ignored and
which files will be important. This allows the GUI client to skipping redoing a
'hg status' when the files are ignored but have changed. (For instance, a
typical case is that the "build" directory inside some project is ignored but
files in it frequently change.)
2011-01-15 16:02:03 +01:00
Steve Borho
5d527f9378 match: support reading pattern lists from files 2010-12-23 15:12:24 -06:00
Martin Geisler
ca9cbd61a1 narrowmatcher: propagate bad method
The full path is propagated to the original match object since this is
often used directly for printing an error to the user.
2010-09-13 13:09:09 +02:00
Martin Geisler
3dafdd42e0 narrowmatcher: fix broken rel method 2010-09-13 13:08:18 +02:00
Martin Geisler
e0e3bf4835 match: add narrowmatcher class
This class can be used to adapt an existing match object to a new
match object that only cares about paths within a certain
subdirectory.
2010-09-03 12:58:51 +02:00
Martin Geisler
34c8204207 match: accept auditor argument
This is used when normalizing filenames and patterns.
2010-09-03 12:58:51 +02:00
Martin Geisler
b9c719086c match: mark error messages for translation 2010-08-30 17:11:51 +02:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Alejandro Santos
ebe339890f split local and stdlib module imports (eases migration issues) 2009-07-05 11:06:09 +02:00
timeless
fb33de67af Generally replace "file name" with "filename" in help and comments. 2009-06-09 09:25:17 -04:00
Matt Mackall
e802acf0e9 match: remove match.never
Only one user, can be translated to match.exact()
2009-05-31 17:54:18 -05:00
Matt Mackall
37eaadf540 match: ignore return of match.bad
All users returned false, return can now be dropped
2009-05-31 17:54:18 -05:00
Matt Mackall
2940d96bce match: document bad callback semantics 2009-05-31 17:54:18 -05:00
Matt Mackall
bd7c2104ff match: fix _patsplit breakage with drive letters 2009-05-24 16:37:34 -05:00
Matt Mackall
f1416e098e match: fold match into _match base class 2009-05-24 02:56:22 -05:00
Matt Mackall
50be99f7cb match: add exact flag to match() to unify all match forms 2009-05-24 02:56:20 -05:00
Matt Mackall
e8c6616c42 match: redefine always and never in terms of match and exact 2009-05-24 02:56:14 -05:00
Matt Mackall
dad8161beb match: fold _globprefix into _roots 2009-05-24 02:56:14 -05:00
Matt Mackall
870bafcadb match: optimize escaping in _globre
- localize re.escape
- fastpath escaping of non-special characters
2009-05-24 02:56:14 -05:00
Matt Mackall
fb6d5f4ec6 match: remove head and tail args from _globre 2009-05-24 02:56:14 -05:00
Matt Mackall
6cec04c6af match: fold _matcher into match.__init__ 2009-05-24 02:56:14 -05:00
Matt Mackall
0b844e4b36 match: rename _matchfn to _buildmatch 2009-05-24 02:56:14 -05:00
Matt Mackall
64e6241687 match: optimize _patsplit 2009-05-24 02:56:14 -05:00
Matt Mackall
8ba6e48c01 match: tweak some names 2009-05-24 02:56:14 -05:00
Matt Mackall
cb5cd35394 match: simplify _matcher
- get rid of special case
- simplify anypats logic
- fold inckinds and exckinds
2009-05-24 02:56:14 -05:00
Matt Mackall
d9e0a2ed6d match: split up _normalizepats 2009-05-24 02:56:14 -05:00
Matt Mackall
3d1ba9cdd7 match: optimize _globprefix 2009-05-24 02:56:14 -05:00
Matt Mackall
e01c72ad8b match: unnest functions in _matcher 2009-05-24 02:56:14 -05:00
Matt Mackall
556e496bdb match: kill unused defaults on _globre 2009-05-24 02:56:14 -05:00
Matt Mackall
85df20c19d match: kill test in matchfn 2009-05-24 02:56:14 -05:00
Matt Mackall
d65d73641a match: refactor matchfn generation 2009-05-24 02:56:14 -05:00
Matt Mackall
f1f37a33cf match: move util match functions over 2009-05-24 02:56:14 -05:00
Matt Mackall
b287cf72fe match: refactor patkind
add patkind(pat) to match
change external users
change util.patkind to _patsplit
2009-05-24 02:56:14 -05:00
Matt Mackall
89c18ad8ce match: add some default args 2009-05-24 02:56:14 -05:00