Commit Graph

268 Commits

Author SHA1 Message Date
Gregory Szorc
3aa1c73868 global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.

Mass rewrite all instances of the old octal syntax to the new syntax.

This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
2015-06-23 22:30:33 -07:00
Pierre-Yves David
40147b2819 devel-warn: move the develwarn function as a method of the ui object
We are going to use this feature in more and more place. Having to import
scmutil makes it an import cycle hell.
2015-06-19 11:19:45 -07:00
Matt Harbison
39e618db88 scmutil: add an optional parameter to matcher factories for a bad() override
Even though scmutil.matchandpats() is documented to warn about bad files,
several callers silence the warning.
2015-06-05 19:24:32 -04:00
Matt Harbison
9596aa8c5b scmutil: use the optional badfn argument when building a matcher 2015-06-05 19:07:54 -04:00
Matt Harbison
c0ea0f263e addremove: replace match.bad() monkey patching with match.badmatch()
No known issues with the previous code since it restored the original method,
but this is cleaner.
2015-06-04 21:25:07 -04:00
Matt Harbison
d7353508b0 scmutil: consistently return subrepos relative to ctx1 from itersubrepos()
Previously, if a subrepo was added in ctx2 and then compared to another without
it (ctx1), the subrepo for ctx2 was returned amongst all of the ctx1 based
subrepos, since no subrepo exists in ctx1 to replace it in the 'subpaths' dict.
The two callers of this, basectx.status() and cmdutil.diffordiffstat(), both
compare the yielded subrepo against ctx2, and thus saw no changes when ctx2's
subrepo was returned.  The tests here previously didn't mention 's/a' for the
'p1()' case.

This appears to have been a known issue, because some diffordiffstat() comments
mention that the subpath disappeared, and "the best we can do is ignore it".  I
originally ran into the issue with some custom convert code to flatten a tree of
subrepos causing hg.putcommit() to abort, but this new behavior seems like the
correct status and diff behavior regardless.  (The abort in convert isn't
something users will see, because convert doesn't currently support subrepos in
the official repo.)
2015-06-03 14:21:15 -04:00
Yuya Nishihara
d0b6a92234 revrange: build spanset from x:y range
This slightly improves the performance in the optimal case:

% hg log -R mozilla-central -r0:tip -l1 --time
(before)
time: real 0.050 secs (user 0.040+0.000 sys 0.010+0.000)
(after)
time: real 0.020 secs (user 0.000+0.000 sys 0.010+0.000)
2015-05-24 18:30:27 +09:00
Yuya Nishihara
6bf5f80705 revrange: build balanced tree of addsets from revisions (issue4565)
This reduces the stack depth from O(n) to O(log(n)). Therefore, repeated
-rREV options will never exceed the Python stack limit.

Currently it depends on private revset._combinesets() function. But at some
point, we'll be able to drop the old-style parser, and revrange() can be
completely rewritten without using _combinesets():

  trees = [parse(s) for s in revs]
  optimize(('or',) + trees)  # combine trees and optimize at once
  ...

Blockers that prevent eliminating old-style parser:

 - nullary ":" operator
 - revrange(repo, [intrev, ...]), can be mapped to 'rev(%d)' ?
 - revrange(repo, [binnode, ...]), should be banned ?
2015-05-24 18:11:33 +09:00
Yuya Nishihara
b37964ca55 revrange: clean up meaningless reconstruction of sets
They just exist for deduplication that was removed by the previous patch.
2015-05-24 17:59:55 +09:00
Yuya Nishihara
8807625c4d revrange: drop unnecessary deduplication of revisions
Because "l" is a smartset, duplicated entries are omitted by addsets.
2015-05-24 17:53:22 +09:00
Matt Harbison
9311abf92a match: resolve filesets in subrepos for commands given the '-S' argument
This will work for any command that creates its matcher via scmutil.match(), but
only the files command is tested here (both workingctx and basectx based tests).
The previous behavior was to completely ignore the files in the subrepo, even
though -S was given.

My first attempt was to teach context.walk() to optionally recurse, but once
that was in place and the complete file list was built up, the predicate test
would fail with 'path in nested repo' when a file in a subrepo was accessed
through the parent context.

There are two slightly surprising behaviors with this functionality.  First, any
path provided inside the fileset isn't narrowed when it is passed to the
subrepo.  I dont see any clean way to do that in the matcher.  Fortunately, the
'subrepo()' fileset is the only one to take a path.

The second surprise is that status predicates are resolved against the subrepo,
not the parent like 'hg status -S' is.  I don't see any way to fix that either,
given the path auditor error mentioned above.
2015-05-16 00:36:35 -04:00
Drew Gottlieb
ffaf3d5a36 requires: move requires file writing func from localrepo to scmutil
The logic to read a requires file resides in scmutil, so it's only logical that
the logic to write the file should be there too.

And now I've typed logic too many times it no longer looks like a word.
Logically.
2015-04-13 18:11:47 -04:00
Pierre-Yves David
3e542e8c99 devel-warn: add a prefix to all messages ("devel-warn: ")
We want to make the origin and importance of the message clear to developers.
2015-04-15 01:18:09 -04:00
Pierre-Yves David
23f376ba5d develwarn: include call site in the simple message version
Just displaying the warning makes it quite hard to recognise the guilty code
quickly and using --traceback for all calls is not very convenient. So we
include the call site with all simple message to help developer to recognise
errors sources.
2015-04-12 14:27:42 -04:00
Pierre-Yves David
ac5bf7b3e8 develwarn: handle the end of line inside the function itself
The traceback version should not have a end of line at all. The non-traceback
version will requires the same things soon.
2015-04-12 14:26:11 -04:00
Pierre-Yves David
d3e735bffe develwarn: refactor the developer warning logic
The logic is currently duplicated and we plan to make it a bit smarter. So we
move it into a function first to make the update more robust and simple.
2015-04-12 14:24:28 -04:00
FUJIWARA Katsunori
57690add3e vfs: add walk
To eliminate "path prefix" (= "the root of vfs") part from "dirpath"
yielded by "os.walk()" correctly, "path prefix" should have "os.sep"
at the end of own string, but it isn't easy to ensure it, because:

  - examination by "path.endswith(os.sep)" isn't portable

    Some problematic encodings use 0x5c (= "os.sep" on Windows) as the
    tail byte of some multi-byte characters.

  - "os.path.join(path, '')" isn't portable

    With Python 2.7.9, this invocation doesn't add "os.sep" at the end
    of UNC path (see issue4557 for detail).

Python 2.7.9 changed also behavior of "os.path.normpath()" (see *) and
"os.path.splitdrive()" for UNC path.

    vfs root        normpath       splitdrive          os.sep required
    =============== ============== =================== ============
    z:\             z:\            z: + \              no
    z:\foo          z:\foo         z: + \foo           yes
    z:\foo\         z:\foo         z: + \foo           yes

    [before Python 2.7.9]
    \\foo\bar       \\foo\bar      '' + \\foo\bar      yes
    \\foo\bar\      \\foo\bar  (*) '' + \\foo\bar      yes
    \\foo\bar\baz   \\foo\bar\baz  '' + \\foo\bar\baz  yes
    \\foo\bar\baz\  \\foo\bar\baz  '' + \\foo\bar\baz  yes

    [Python 2.7.9]
    \\foo\bar       \\foo\bar      \\foo\bar + ''      yes
    \\foo\bar\      \\foo\bar\ (*) \\foo\bar + \       no
    \\foo\bar\baz   \\foo\bar\baz  \\foo\bar + \baz    yes
    \\foo\bar\baz\  \\foo\bar\baz  \\foo\bar + \baz    yes

If it is ensured that "normpath()"-ed vfs root is passed to
"splitdrive()", adding "os.sep" is required only when "path" part of
"splitdrive()" result isn't "os.sep" itself. This is just what
"pathutil.nameasprefix()" examines.

This patch applies "os.path.normpath()" on "self.join(None)"
explicitly, because it isn't ensured that vfs root is already
normalized: vfs itself is constructed with "realpath=False" (= avoid
normalizing in "vfs.__init__()") in many code paths.

This normalization should be much cheaper than subsequent file I/O for
directory traversal.
2015-04-11 23:00:04 +09:00
Gregory Szorc
5b06fcaa29 repoview: move function for computing filtered hash
An upcoming patch will establish per-filter tags caches. We'll want
to use the same cache validation logic as the branch cache. Prepare
for that by moving the logic for computing a filtered view hash
to somewhere central.
2015-04-01 18:43:29 -07:00
FUJIWARA Katsunori
798e1be41f vfs: add removedirs 2015-04-11 00:47:09 +09:00
FUJIWARA Katsunori
51fdbd9c2a vfs: add rmtree
This duplicates "onerror()" function from "svnsubrepo.remove()" for
equivalence of replacing in subsequent patch.

This "onerror()" function for "shutil.rmtree()" was introduced by
094a056562e7, which avoids failure of removing svn repository on
Windows.
2015-04-11 00:47:09 +09:00
Drew Gottlieb
901ac5e726 util: move dirs() and finddirs() from scmutil to util
An upcoming commit requires that match.py be able to call scmutil.dirs(), but
when match.py imports scmutil, a dependency cycle is created. This commit
avoids the cycle by moving dirs() and its related finddirs() function from
scmutil to util, which match.py already depends on.
2015-04-06 14:36:08 -07:00
Matt Harbison
34c91242f1 vfs: make it possible to pass multiple path elements to join
os.path.join(), localrepo.join() and localrepo.wjoin() allow passing multiple
path elements; vfs.join() should be as convenient.
2015-04-04 17:19:16 -04:00
Yuya Nishihara
2d0b41ce60 scmutil: add function to help handling workingctx in arithmetic operation
It's unfortunate that workingctx revision is None, which doesn't work well in
arithmetic operation or comparison. This function is trivial but will be used
in several places.
2015-03-14 19:38:59 +09:00
Martin von Zweigbergk
ca1a27676b matcher: make e.g. 'relpath:.' lead to fast paths
Several commands take the fast path when match.always() is
true. However, when the user passes "." on the command line, that
results in a matcher for which match.always() == False. Let's make it
so such matchers return True, and have an empty list of .files(). This
makes e.g. "hg log ." as fast as "hg log" and "hg revert ." as fast as
"hg revert --all" (when run from repo root).
2014-11-19 15:56:58 -08:00
Matt Harbison
978de44356 scmutil: replace 'ctx._repo' with 'ctx.repo()' 2015-03-12 23:16:26 -04:00
Jordi Gutiérrez Hermoso
ed917f2095 revrange: don't parse revset aliases as hash prefixes (issue4553)
If a user has a revsetalias defined, it is their explicit wish for
this alias to be parsed as a revset and nothing else. Although the
case of the alias being short enough and only contain the letters a-f
is probably kind of rare, it may still happen.
2015-02-25 18:12:01 -05:00
Yuya Nishihara
25fac1a15b revset: make match function initiate query from full set by default
This change is intended to avoid exposing the implementation detail to
callers. I'm going to extend fullreposet to support "null" revision, so
these mfunc calls will have to use fullreposet() instead of spanset().
2015-02-02 22:21:07 +09:00
Matt Harbison
21ca967140 narrowmatcher: propagate the rel() method
The full path is propagated to the original match object since this is often
used directly for printing a file name to the user.  This is cleaner than
requiring each caller to join the prefix with the file name prior to calling it,
and will lead to not having to pass the prefix around separately.  It is also
consistent with the bad() and abs() methods in terms of the required input.  The
uipath() method now inherits this path building property.

There is no visible change in path style for rel() because it ultimately calls
util.pathto(), which returns an os.sep based path.  (The previous os.path.join()
was violating the documented usage of util.pathto(), that its third parameter be
'/' separated.)  The doctest needed to be normalized to '/' separators to avoid
test differences on Windows, now that a full path is returned for a short
filename.

The test changes are to drop globs that are no longer necessary when printing an
absolute file in a subrepo, as returned from match.uipath().  Previously when
os.path.join() was used to add the prefix, the absolute path to a file in a
subrepo was printed with a mix of '/' and '\'.  The absolute path for a file not
in a subrepo, as returned from match.uipath(), is still purely '/' based.
2014-11-27 10:16:56 -05:00
Pierre-Yves David
8985258968 vfs: add a 'split' method
This method has the same behavior as the 'os.path.split' function, but having
it in vfs will allow handling of tricky encoding situations in the future.

In the same patch, we replace the use of 'os.path.split' in the transaction code.
2014-12-15 13:32:34 -08:00
Pierre-Yves David
329429e77c vfs: add a 'reljoin' function for joining relative paths
The vfs.join method only works for absolute paths. We need something
that works for relative paths too when transforming filenames. Since
os.path.join may misbehave in tricky encoding situations, encapsulate
the new join method in our vfs abstraction. The default implementation
remains os.path.join, but this opens the door to other VFSes doing
something more intelligent based on their needs.

In the same go, we replace the usage of 'os.path.join' in transaction code.
2014-12-15 13:27:46 -08:00
Matt Harbison
a7a84e8adc addremove: support addremove with explicit paths in subrepos
Git and svn subrepos are currently not supported.
2014-11-09 23:46:25 -05:00
Matt Harbison
3c47e94de7 commit: propagate --addremove to subrepos if -S is specified (issue3759)
The recursive addremove operation occurs completely before the first subrepo is
committed.  Only hg subrepos support the addremove operation at the moment- svn
and git subrepos will warn and abort the commit.
2014-11-24 22:27:49 -05:00
Matt Harbison
d639c093a5 addremove: warn when addremove fails to operate on a named path
It looks like a bad path is the only mode of failure for addremove.  This
warning is probably useful for the standalone command, but more important for
'commit -A'.  That command doesn't currently abort if the addremove fails, but
it will be made to do so prior to adding subrepo support, since not all subrepos
will support addremove.  We could just abort here, but it looks like addremove
has always silently ignored bad paths, except for the exit code.
2014-11-26 14:27:36 -05:00
Matt Harbison
9e4d7cc2d3 scmutil: pass a matcher to scmutil.addremove() instead of a list of patterns
This will make it easier to support subrepository operations.
2014-11-09 19:57:02 -05:00
Matt Harbison
e5bd4011a8 addremove: restore the relative path printing when files are named
This fixes the previously mentioned issue with 7d5fcea60c78, and undoes its
corresponding test change.

The test change demonstrates the correctness when a file is specified (i.e. the
glob is required on Windows because relative paths use '\' and absolute paths
use '/').  It is admittedly very subtle, but there will be a more robust test in
the addremove -S v3 series.
2014-12-04 23:08:27 -05:00
Martin von Zweigbergk
242bbe216d addremove: print relative paths when called with -I/-X (BC)
For "hg addremove 'glob:*.py'", we print any paths added or removed as
relative to the current directory, but when "hg addremove -I
'glob:*.py'" is used, we use the absolute path (relative from the repo
root). It seems like they should be the same, so change it so we use
relative paths in both cases. Continue to use absolute paths when no
patterns are given.
2014-12-01 21:48:32 -08:00
FUJIWARA Katsunori
86bc73ffa9 vfs: add "writelines"
This patch allows "writelines" to take "mode" and "notindexed"
arguments, because subsequent patch for subrepo requires both.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
f60bafa1b3 vfs: add "notindexed" argument to invoke "ensuredir" with it in write mode
This patch uses "False" as default value of "notindexed" argument,
even though "vfs.makedir()" uses "True" for it, because "os.mkdir()"
doesn't set "_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED" attribute to newly
created directories.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
b1ff97d24c vfs: add "readlines" and "tryreadlines"
This patch allows "readlines" and "tryreadlines" to take "mode"
argument, because "subrepo" requires to read files not in "rb"
(binary, default for vfs) but in "r" (text) mode in subsequent patch.
2014-11-19 18:35:14 +09:00
Martin von Zweigbergk
98fbfc44f9 addremove: add back forgotten files (BC)
After running "hg forget README && hg addremove", README will still be
reported as removed, while "hg forget README && hg add README" adds it
back so it gets reported as clean. It seems like they should behave
the same. Furthermore, it seems like no files should remain untracked
after 'hg addremove && hg commit' (or 'hg commit -A'). For these
reasons, change the behavior of addremove so it does add forgotten
files back.

The problem is with scmutil._interestingfiles(), which reports the
file as removed, so scmutil.addremove() does not add it. Fix by
teaching _interestingfiles() to report forgotten files separately from
removed files and make addremove() add forgotten files back. However,
do not treat forgotten files as sources for rename detection. Note
that since removed and forgotten files are treated the same before
this change, forgotten files were considered sources for rename
detection.

Also update the other caller, marktouched(), in the same way as
addremove().
2014-11-08 23:13:39 -08:00
Mads Kiilerich
7f5af5ba4c config: introduce "built-in" default configuration settings in default.d
This helps providing a more consistent user experience on all platforms and
with all packaging.

The exact location of default.d depends on how Mercurial is installed and
whether it is 'frozen'. The exact location should never be relevant to users
and is intentionally not explained in details in the documentation. It will
however always be next to the help and templates files.

Note that setting HGRCPATH also disables these defaults. I don't know if that
should be considered a bug or a feature.
2014-09-04 21:36:35 +02:00
Martin von Zweigbergk
8b968ecfe2 status: update and move documentation of status types to status class
The various status types are currently documented on the
dirstate.status() method. Now that we have a class for the status
types, it makese sense to document the status types there
instead. Only leave the bits related to lookup/unsure in the status()
method documentation.
2014-10-10 10:14:35 -07:00
Martin von Zweigbergk
41a4138ec7 status: create class for status lists
Callers of various status() methods (on dirstate, context, repo) get a
tuple of 7 elements, where each element is a list of files. This
results in lots of uses of indexes where names would be much more
readable. For example, "status.ignored" seems clearer than "status[4]"
[1]. So, let's introduce a simple named tuple containing the 7 status
fields: modified, added, removed, deleted, unknown, ignored, clean.

This patch introduces the class and updates the status methods to
return instances of it. Later patches will update the callers.

 [1] Did you even notice that it should have been "status[5]"?

(tweaked by mpm to introduce the class in scmutil and only change one user)
2014-10-10 14:32:36 -07:00
Pierre-Yves David
c05e6afd86 revpair: use first and last instead of direct indexing
This makes it compatible with all smarsets classes.
2014-10-06 23:37:39 -07:00
Pierre-Yves David
d6d95b6b1f revsingle: use last instead of direct indexing
This makes it compatible with all smarsets classes.
2014-10-06 23:37:08 -07:00
Pierre-Yves David
e2d1bcc06d revset-limit: use boolean testing instead of len(revs) < 1
I'm not sure why we wrote it that way. But smartsets have faster/lazier non-zero
testing than length computation.
2014-10-06 11:43:32 -07:00
Chinmay Joshi
0db86c64a5 vfs: add listdir for os.listdir in vfs
This patch adds listdir() in vfs to use os.listdir().
2014-06-20 21:18:14 +05:30
Chinmay Joshi
ecc3ce679c vfs: add unlinkpath to vfs
This patch adds unlinkpath() function in vfs to replace util.unlinkpath().
2014-06-05 15:16:44 +05:30
Chinmay Joshi
46bebd3c8d vfs: add lexists() in current api
lexists is added in current API of vfs.
2014-05-27 23:02:05 +05:30
Mads Kiilerich
df98b5168a match: improve documentation - docstrings and more descriptive variable naming
No real changes.

pattern: 'kind:pat' as specified on the command line
patterns, pats: list of patterns
kind: 'path', 'glob' or 're' or ...
pat: string in the corresponding 'kind' format
kindpats: list of (kind, pat) tuples
2013-10-03 18:01:21 +02:00
FUJIWARA Katsunori
4956966646 vfs: add "mkstemp()" 2014-03-09 01:03:28 +09:00
Pierre-Yves David
ce5b702bdf revpair: smartset compatibility
Since recent revset changes, revrange now return a smartset. This smart set
probably does not support indexing (_addset does not). This led to crash.
Instead when the smartset is ordered we use the `min` and `max` method of
smart set. Otherwise we turn is into a list and use indexing on it.

The tests have been updated to catch such regression.
2014-03-20 18:44:25 -07:00
Mads Kiilerich
914cc822c9 repo: rephrase the "missing requirement" error message
Unknown requirements will now be reported as:
  abort: repository requires features unknown to this Mercurial: largefiles!
  (see http://mercurial.selenic.com/wiki/MissingRequirement for more information)

Some features of this phrasing:
* avoid double ':' in abort message
* make it more clear who requires and knows what
* don't quote the requirement names - it is not something the user entered or
  need the exact spelling of ... and it is "identifiers" that are unambiguous
  anyway
* remove double hint by removing "(upgrade Mercurial)" comment
* don't mention upgrading Mercurial without mentioning enabling the feature -
  instead, just refer to wiki page for both
* don't just talk about "details", talk about "more information"
2014-03-19 00:18:30 +01:00
Pierre-Yves David
c515a37f0e revpair: drop useless conditional
The `if not revs:` case is tested at the beginning of the function.
2014-03-20 17:34:02 -07:00
Durham Goode
c173245d83 scmutil: fix revrange when multiple revs are specified
revrange was trying to add a list to a revset class, but revset classes only
support adding with other revset classes. So wrap the lists in basesets.
2014-03-20 09:55:44 -07:00
Matt Mackall
2dfc464098 revrange: pass repo to revset parser
This allows handling of hyphenated symbols for command-line revsets.
2014-03-18 17:56:27 -05:00
Pierre-Yves David
4b1a4196e2 require: provide a link to a wiki page in addition of suggesting upgrade
The wiki page is intended to describe several solution to the requirement issue.
Some of those solutions does not involve upgrading mercurial. That is very
useful for people that can't easily upgrade they Mercurial in some place.
2011-06-25 02:46:23 +02:00
Matt Mackall
b93e6d4112 merge with stable 2014-03-13 12:05:08 -05:00
Cristian Zamfir
c85ed151ff hg log: solves bug regarding hg log -r 0:null (issue4039)
'hg log -r 0:null' was showing only one changeset(the '-1' one) instead of the first two changesets.
2014-03-12 10:26:48 +02:00
Lucas Moscovicz
5e0ec4bc97 scmutil: changed revrange code not to use append
Removed one call to the append method
2014-02-24 09:27:32 -08:00
Lucas Moscovicz
ec3c3a2803 scmutil: changed revrange to return lazysets for new style revsets
When there is an old style revset or both it will still return a baseset. This
may be changed in later patches.
2014-02-12 15:30:27 -08:00
Lucas Moscovicz
ba7cfe4ed4 revset: changed revsets to use spanset
Performance Benchmarking:

$ hg perfrevset "first(all())"
! wall 0.304936 comb 0.300000 user 0.280000 sys 0.020000 (best of 33)

$ ./hg perfrevset "first(all())"
! wall 0.175640 comb 0.180000 user 0.160000 sys 0.020000 (best of 56)
2014-02-03 10:15:15 -08:00
Augie Fackler
8bfe6ea1ed itersubrepos: move to scmutil to break a direct import cycle 2014-02-03 18:36:00 -05:00
Lucas Moscovicz
ef8bd69f5f revset: added baseset class (still empty) to improve revset performance
This class is going to be used to cache the set that is created from this list
in many cases while evaluating a revset.
2014-01-21 11:39:26 -08:00
FUJIWARA Katsunori
f2d55c7c7d vfs: add "makelock()" and "readlock()" 2013-11-12 16:23:52 +09:00
FUJIWARA Katsunori
f39330457a vfs: add "chmod()" 2013-11-12 16:23:52 +09:00
FUJIWARA Katsunori
d6fa8a9bfa vfs: add "isfile()" 2013-11-12 16:23:52 +09:00
Siddharth Agarwal
25418f3155 scmutil.filecache: support watching over multiple files 2013-11-16 13:29:39 -08:00
Siddharth Agarwal
fceaf0623e scmutil: introduce a filecacheentry that can watch multiple paths 2013-11-16 13:24:26 -08:00
Siddharth Agarwal
3585a23345 scmutil: rename filecacheentry to filecachesubentry
Upcoming patches will allow the file cache to watch over multiple files, and
call the decorated function again if any of the files change.

The particular use case for this is the bookmark store, which needs to be
invalidated if either .hg/bookmarks or .hg/bookmarks.current changes. (This
doesn't currently happen, which is a bug. This bug will also be fixed in
upcoming patches.)
2013-11-16 13:19:06 -08:00
Siddharth Agarwal
cb19f2bbbe scmutil.filecacheentry: make stat argument to constructor mandatory
There's no real upside to making stat optional -- this constructor has just two
callers.
2013-11-16 13:33:33 -08:00
Augie Fackler
213fff305a pathutil: tease out a new library to break an import cycle from canonpath use 2013-11-06 18:19:04 -05:00
FUJIWARA Katsunori
d759404236 scmutil: skip checks in "casecollisionauditor" if filename is already checked
Before this patch, almost all of check code in
"casecollisionauditor.__call__()" is executed, even if specified
filename is already checked, because "f in self._newfiles" is examined
lastly.

In addition to it, adding "fl" to "self._loweredfiles" and "f" to
"self._newfiles" are also redundant in such case.

This patch checks "f in self._newfiles" first, and returns immediately
to avoid execution of check code for efficiency.
2013-11-12 00:07:23 +09:00
FUJIWARA Katsunori
770590e67f context: use "vfs.lstat()" instead of "os.lstat()"
This patch also changes paths added to "rejected" list from full path
(referred by "p") to relative one (referred by "f"), when type of
target path is neither file nor symlink.

This change should be reasonable, because the path added to "rejected"
list is relative one, when "OSError" is raised at "lstat()".
2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
61a538d89f changelog: use "vfs.fstat()" instead of "util.fstat()"
Just invoking "os.fstat()" with "file.fileno()" doesn't require non
ANSI file API, because filename is not used for invocation of
"os.fstat()".

But "util.fstat()" should invoke "os.stat()" with "fp.name", if file
object doesn't have "fileno()" method for portability, and "fp.name"
may cause invocation of non ANSI file API.

So, this patch makes the constructor of appender class invoke
"util.fstat()" via vfs, to encapsulate filename handling.
2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
49c8ebb7ec vfs: add "open()" for newly added code paths which open files via vfs
This patch replaces "open()" by own "__call__()" defined in derived
classes at the first invocation, for efficiency of succeeding
invocations.
2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
23a7a98972 bookmarks: use "vfs.utime()" instead of "os.utime()" 2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
33e3348b3e bookmarks: use "vfs.unlink()" instead of "util.unlink()" 2013-10-15 00:51:04 +09:00
Siddharth Agarwal
4f7171d11d addremove: don't do full walks
Full walks are only necessary when the caller needs the list of clean files.
addremove by definition doesn't need them.

With this patch and an extension that produces a subset of results for
dirstate.walk when full is False, on a repository with over 200,000 files, hg
addremove drops from 2.8 seconds to 0.5.
2013-09-04 18:42:55 -07:00
Matt Mackall
fac649fcb2 revsingle: fix silly API issue (issue2992) 2013-07-26 15:42:10 -05:00
Siddharth Agarwal
c944ae0c27 scmutil: add a function to mark that files have been operated on
Several places use scmutil.addremove as a means to declare that certain files
have been operated on. This is ugly because:
- addremove takes patterns relative to the cwd, not paths relative to the root,
  which means extra contortions for callers.
- addremove doesn't make clear what happens to files whose status hasn't
  changed.

This new method accepts filenames relative to the repo root, and has a much
clearer contract. It also allows future modifications that do more with files
whose status hasn't changed.
2013-04-04 13:38:28 -07:00
Siddharth Agarwal
9ad5c8f0a6 scmutil.addremove: factor out code to mark added/removed/renames
An upcoming patch will reuse this code in another function.
2013-04-03 15:53:59 -07:00
Siddharth Agarwal
c89587db25 scmutil.addremove: factor out code to find renames
This code will be used in a different context in upcoming patches.
2013-04-03 16:32:41 -07:00
Siddharth Agarwal
76d8b6d164 scmutil.addremove: rename local 'copies' to 'renames'
An upcoming patch will refactor some code out into a method called
_findrenames. Having a line saying "copies = _findrenames..." is confusing.
Besides, 'renames' is a more precise name for this local anyway.
2013-04-03 15:32:15 -07:00
Siddharth Agarwal
5839ae6e69 scmutil.addremove: factor out dirstate walk into another function
Upcoming patches will reuse and expand on this function for other purposes.
2013-04-02 17:19:36 -07:00
Durham Goode
1b7b932cfc translations: change label integer error to not specify the kind of label
The current error message used the kind (bookmark, branch, tag) in the message.
Unfortunately this isn't easily translatable since some languages give different
genders to these words. The fix is to not specify it at all, since it should be
implicit based on the command the user just ran.

Relevant discussions around this area:
http://selenic.com/pipermail/mercurial-devel/2012-October/045567.html
http://selenic.com/pipermail/mercurial-devel/2012-October/045600.html
2013-04-19 10:55:11 -07:00
FUJIWARA Katsunori
2dcdc7d9fa localrepo: use "vfs.setflags()" instead of "util.setflags()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
721696db5d localrepo: use "vfs.readlink()" instead of "os.readlink()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
bc43776a26 localrepo: use "vfs.islink()" instead of "os.path.islink()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
8e88b218bd localrepo: use "vfs.rename()" instead of "util.rename()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
0860626b09 vfs: split "expand" into "realpath"/"expandpath" to apply each separately
Before this patch, vfs constructor applies both "util.expandpath()"
and "os.path.realpath()" on "base" path, if "expand" is True.

This patch splits it into "realpath" and "expandpath", to apply each
functions separately: this splitting can allow to use vfs also where
one of each is not needed.
2013-04-15 01:22:15 +09:00
Bryan O'Sullivan
8f78d582d5 scmutil: rewrite dirs in C, use if available
This is over twice as fast as the Python dirs code. Upcoming changes
will nearly double its speed again.

perfdirs results for a working dir with 170,000 files:
  Python     638 msec
  C          244
2013-04-10 15:08:27 -07:00
Bryan O'Sullivan
c1db508ee8 scmutil: add a dirs class
This encapsulates the "multiset of directories" structures that are
currently open-coded (and duplicated) in both the dirstate and
context modules.

This will be used, and optionally replaced by a C implementation,
in upcoming changes.
2013-04-10 15:08:26 -07:00
Bryan O'Sullivan
00ff38c9c3 scmutil: migrate finddirs from dirstate 2013-04-10 15:08:25 -07:00
Siddharth Agarwal
070b188489 scmutil.addremove: use iteritems on walk results
Now that we no longer sort all the walk results, using iteritems becomes
possible.

This is a relatively minor speedup: on a large repository with 170,000 files,
perfaddremove goes from 2.13 seconds to 2.10.
2013-04-02 14:50:50 -07:00
Siddharth Agarwal
cf3792485f scmutil.addremove: stop sorting all walk results
The only place where the order matters is in printing out added or removed
files. We already sort that set.

On a large repository with 170,000 files, this speeds up perfaddremove from
2.34 seconds to 2.13.
2013-04-02 14:50:31 -07:00
Siddharth Agarwal
eff1b30357 scmutil.addremove: pull ui.status printing out of the loop
This will let us stop sorting all the results in an upcoming patch.

This also permits future refactorings where the same code consumes
dirstate.walk results but doesn't print anything out.

An argument could be made that printing out results as we go along is more
responsive UI-wise. However, at this point iterating through walk results is
actually faster than sorting them, so once we stop sorting all the results the
argument ceases to be valid.
2013-04-02 10:56:24 -07:00
Siddharth Agarwal
c4b1cf0480 scmutil.addremove: remove redundant directory and symlink checks
dirstate.walk only does lstats and never returns stat objects for directories.

On a large repository with 170,000 files, this speeds perfaddremove up from
2.40 seconds to 2.34.
2013-04-02 14:49:34 -07:00
Siddharth Agarwal
392b6d1872 scmutil.addremove: pull repo.dirstate fetch out of the loop
On a large repository with 170,000 files, this speeds up perfaddremove from
2.78 seconds to 2.40.
2013-04-02 14:46:55 -07:00
Siddharth Agarwal
64922bc1af scmutil: remove dead updatedir code
This code has not been used in a long while.
2013-04-01 20:38:37 -07:00