Commit Graph

364 Commits

Author SHA1 Message Date
Pierre-Yves David
b563457396 rebase: do not crash in panic when cwd disapear in the process (issue4121)
Before this patch rebase crashed badly when it happend. (not abort, crash).

Fix courtesy of Matt Mackall.
2014-01-31 15:13:15 -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
Siddharth Agarwal
7decbaaad4 dirstate.status: return explicit unknown files even when not asked
dirstate.walk will return unknown files that were explicitly requested, even
if listunknown is false. There's no point in dropping these files on the
floor in dirstate.status.

This has no effect on any current callers, because all of them assume the
unknown list is empty and ignore it. Future callers may find it useful,
though.
2013-10-14 00:25:29 -04:00
Siddharth Agarwal
d8f5823b88 dirstate.status: don't ignore symlink placeholders in the normal set
On Windows, there are two ways symlinks can manifest themselves:
1. As placeholders: text files containing the symlink's target. This is what
   usually happens with fresh clones on Windows.
2. With their dereferenced contents. This happens with clones accessed over NFS
   or Samba.

In order to handle case 2, 28af3e0c54f0 made dirstate.status ignore all symlink
placeholders on Windows. It doesn't ignore symlinks in the lookup set, though,
since those don't have the link bit set. This is problematic because it
violates the invariant that `hg status` with every file in the normal set
produces the same output as `hg status` with every file in the lookup set.

With this change, symlink placeholders in the normal set are no longer ignored.
We instead rely on code in localrepo.status that uses heuristics to look for
suspect placeholders.

An upcoming patch will test this out by no longer adding files written in the
last second of an update to the lookup set.
2013-08-31 10:20:15 -07:00
Matt Mackall
0e295e1642 merge with stable 2013-05-17 17:22:08 -05:00
Matt Mackall
870fe2303d dirstate: don't overnormalize for ui.slash
This should fix the issue exposed by debugpathcomplete on the buildbot.
2013-05-17 14:31:06 -05:00
Durham Goode
c5a04c46b0 hgignore: fix regression with hgignore directory matches (issue3921)
If a directory matched a regex in hgignore but the files inside the directory
did not match the regex, they would appear as deleted in hg status. This
change fixes them to appear normally in hg status.

Removing the ignore(nf) conditional here is ok because it just means we might
stat more files than we had before. My testing on a large repo shows this
causes no performance regression since the only additional files being stat'd
are the ones that are missing (i.e. status=!), which are generally rare.
2013-05-03 09:44:50 -07:00
FUJIWARA Katsunori
364377a413 icasefs: ignore removed files at building "dirstate._foldmap" up on icasefs
Before this patch, all files in dirstate are used to build "_foldmap"
up on case insensitive filesystem regardless of their statuses.

For example, when dirstate contains both removed file 'a' and added
file 'A', "_foldmap" may be updated finally by removed file 'a'. This
causes unexpected status information for added file 'A' at "hg status"
invocation.

This patch ignores removed files at building "_foldmap" up on case
insensitive filessytem.

This patch doesn't add any test, because this issue is difficult to
reproduce intentionally: it depends on iteration order of "dirstate._map".
2013-04-30 05:00:48 +09:00
Siddharth Agarwal
65a08dce5b dirstate.status: avoid full walks when possible 2013-04-23 14:16:33 -07:00
Siddharth Agarwal
b35c53428c dirstate.walk: add a flag to let extensions avoid full walks
Consider a hypothetical extension that implements walk in a more efficient
manner and skips some known-clean files. However, that can only be done under
some situations, such as when clean files are not being asked for and a
match.traversedir callback is not set. The full flag lets walk tell these two
cases apart.
2013-04-22 17:11:18 -07:00
Siddharth Agarwal
d9060ea694 dirstate._walkexplicit: inline dirsnotfound.append 2013-05-07 14:20:34 -07:00
Siddharth Agarwal
c1be698d70 dirstate._walkexplicit: rename work to dirsfound
Now that this code is factored out, work is too specific a name.
2013-05-07 14:19:04 -07:00
Siddharth Agarwal
819d02613a dirstate.walk: refactor explicit walk into separate function
This enables this code to be reused by extensions that implement the other,
more time-consuming bits of walk in different ways.
2013-05-07 10:02:55 -07:00
Siddharth Agarwal
b485dd87ab dirstate.walk: pull skipstep3 out of the explicit walk code
This is a move towards factoring out this code into a separate function.
2013-05-07 09:31:00 -07:00
Siddharth Agarwal
c0d29e5fe5 dirstate.walk: move dirignore filter out of explicit walk code
This is a move towards factoring this code out into a separate function.
2013-05-07 09:47:10 -07:00
Siddharth Agarwal
a143c1d00c dirstate.walk: maintain a list of dirs not found
Upcoming patches will factor out the walk over explicit files done in step 1.
This helps us get there.
2013-05-07 09:29:43 -07:00
Siddharth Agarwal
8e7066e5f2 match: make explicitdir and traversedir None by default
With this, extensions can easily tell when traversedir and/or explicitdir don't
need to be called.
2013-05-03 14:41:58 -07:00
Siddharth Agarwal
053c6e8fe3 dirstate.walk: cache match.explicitdir and traversedir locally 2013-05-03 14:39:28 -07:00
Siddharth Agarwal
cad3e8cacb dirstate.walk: call match.explicitdir or traversedir as appropriate 2013-04-28 21:25:41 -07:00
Bryan O'Sullivan
4a4a5dde94 scmutil: use new dirs class in dirstate and context
The multiset-of-directories code was open coded in each of these
modules; this change gets rid of the duplication.
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
Bryan O'Sullivan
6f6047415e dirstate: only call lstat once per flags invocation
This makes a big difference to performance in some cases.

hg --time locate 'set:symlink()'

mozilla-central (70,000 files):

  before: 2.92 sec
  after:  2.47

another repo (170,000 files):

  before: 7.87 sec
  after:  6.86
2013-04-03 11:35:27 -07:00
Siddharth Agarwal
a6bf485dee dirstate.walk: fast path none-seen + match-always case for step 3
This case is a common one -- e.g. `hg diff`.

For a repository with 170,000 files, this speeds up perfstatus from 0.95
seconds to 0.88.
2013-03-22 17:03:49 -07:00
Siddharth Agarwal
5e52c298d1 dirstate.walk: fast path match-always case during traversal
This case is a common one -- e.g. `hg status`.

For a repository with 170,000 files, this speeds up perfstatus --unknown from
2.15 seconds to 2.09.
2013-03-22 17:03:00 -07:00
Siddharth Agarwal
68d46b6a0a dirstate.walk: remove subrepo and .hg from results before step 3
An upcoming patch will speed dirstate.walk up by not querying the results dict
when it is empty. This ensures it is in some common cases.

This should be safe because subrepos and .hg aren't part of the dirstate.
2013-03-25 14:12:39 -07:00
Bryan O'Sullivan
d521a241b2 completion: add a debugpathcomplete command
The bash_completion code uses "hg status" to generate a list of
possible completions for commands that operate on files in the
working directory. In a large working directory, this can result
in a single tab-completion being very slow (several seconds) as a
result of checking the status of every file, even when there is no
need to check status or no possible matches.

The new debugpathcomplete command gains performance in a few simple
ways:

* Allow completion to operate on just a single directory. When used
  to complete the right commands, this considerably reduces the
  number of completions returned, at no loss in functionality.

* Never check the status of files. For completions that really must
  know if a file is modified, it is faster to use status:

  hg status -nm 'glob:myprefix**'

Performance:

Here are the commands used by bash_completion to complete, run in
the root of the mozilla-central working dir (~77,000 files) and
another repo (~165,000 files):

All "normal state" files (used by e.g. remove, revert):

                            mozilla    other
  status -nmcd 'glob:**'       1.77     4.10 sec
  debugpathcomplete -f -n      0.53     1.26
  debugpathcomplete -n         0.17     0.41

("-f" means "complete full paths", rather than the current directory)

Tracked files matching "a":

                            mozilla    other
  status -nmcd 'glob:a**'      0.26     0.47
  debugpathcomplete -f -n a    0.10     0.24
  debugpathcomplete -n a       0.10     0.22

We should be able to further improve completion performance once
the critbit work lands. Right now, our performance is limited by
the need to iterate over all keys in the dirstate.
2013-03-21 16:31:28 -07:00
Durham Goode
83b3faf2ec strip: make --keep option not set all dirstate times to 0
hg strip -k was using dirstate.rebuild() which reset all the dirstate
entries timestamps to 0.  This meant that the next time hg status was
run every file was considered to be 'unsure', which caused it to do
expensive read operations on every filelog. On a repo with >150,000
files it took 70 seconds when everything was in memory.  From a cold
cache it took several minutes.

The fix is to only reset files that have changed between the working
context and the destination context.

For reference, --keep means the working directory is left alone during
the strip. We have users wanting to use this operation to store their
work-in-progress as a commit on a branch while they go work on another
branch, then come back later and be able to uncommit that work and
continue working.  They currently use 'git reset HARD^' to accomplish
this in git.
2013-03-06 20:13:09 -08:00
Durham Goode
5317973684 dirstate: fix generator/list error when using python 2.7
util.statfiles returns a generator on python 2.7 with c extensions disabled.
This caused util.statfiles(...) [0] to break in tests. Since we're only
stat'ing one file, I just changed it to call lstat directly.
2013-02-10 12:23:39 -08:00
Benoit Boissinot
431f8fbd16 merge crew and main 2013-02-11 01:21:24 +01:00
Siddharth Agarwal
98fa475598 dirstate: disable gc while parsing the dirstate
This prevents a performance regression an upcoming patch would otherwise
introduce because it indirectly delays parsing the dirstate a bit.
2013-02-10 16:23:14 +00:00
Durham Goode
b4e95fed5e dirstate: walk returns None for files that have a symlink in their path
Previously dirstate.walk would return a stat object for files in the dmap
that have a symlink to a directory in their path.  Now it will return None
to indicate that they are no longer considered part of the repository. This
currently only affects walks that traverse the entire directory tree (ex:
hg status) and not walks that only list the contents of the dmap (ex: hg diff).

In a situation like this:
  mkdir foo && touch foo/a && hg commit -Am "a"
  mv foo bar
  ln -s bar foo

'hg status' will now show '! foo/a', whereas before it incorrectly considered
'foo/a' to be unchanged.

In addition to making 'hg status' report the correct information, this will
allow callers to dirstate.walk to not have to detect symlinks themselves,
which can be very expensive.
2013-02-04 14:27:15 -08:00
Siddharth Agarwal
9334236621 dirstate: move pure python dirstate packing to pure/parsers.py 2013-01-17 23:46:08 -08:00
Idan Kamara
dd240808d9 dirstate: refresh _branch cache entry after writing it 2012-12-16 20:33:00 +02:00
Kevin Bullock
aaaf5fc704 merge with crew-stable 2012-12-16 23:02:54 -06:00
Tim Henigan
31b2db1033 dirstate: remove obsolete comment from setbranch
This comment should have been removed in 9d5893d31db9, when the call
to scmutil.checknewlabel was removed.
2012-11-29 08:44:54 -05:00
Idan Kamara
26e04e85c9 dirstate: don't rename branch file if writing it failed 2012-12-15 20:19:07 +02:00
Tim Henigan
68a1fc4488 update: allow update to existing branches with invalid names (issue3710)
Starting with 049792af94d6, users are no longer able to update a
working copy to a branch named with a "bad" character (such as ':').

Prior to v2.4, it was possible to create branch names using "bad"
characters, so this breaks backwards compatibility.

Mercurial must allow users to update to existing branches with bad
names.  However, it should continue to prevent the creation of new
branches with bad names.

A test was added to confirm that 'hg update' works as expected. The
test uses a bundled repo that was created with an earlier version of
Mercurial.
2012-11-27 08:47:35 -05:00
Siddharth Agarwal
cb69b98e9b dirstate: inline more properties and methods in status
hg perfstatus -u on a working directory with 170,000 files, without this
change:
! wall 1.839561 comb 1.830000 user 1.120000 sys 0.710000 (best of 6)

With this change:
! wall 1.804222 comb 1.790000 user 1.140000 sys 0.650000 (best of 6)

hg perfstatus on the same directory, without this change:
! wall 1.016609 comb 1.020000 user 0.670000 sys 0.350000 (best of 10)

With this change:
! wall 0.985573 comb 0.980000 user 0.650000 sys 0.330000 (best of 10)
2012-12-03 14:21:45 -08:00
Siddharth Agarwal
40de7ddbeb dirstate: test normalize is truthy instead of using a no-op lambda
hg perfstatus -u on a working directory with 170,000 files, without this
change:
! wall 1.869404 comb 1.850000 user 1.170000 sys 0.680000 (best of 6)

With this change:
! wall 1.839561 comb 1.830000 user 1.120000 sys 0.710000 (best of 6)
2012-12-04 10:29:18 -08:00
Bryan O'Sullivan
09d0142d5e dirstate: avoid use of zip on big lists
In a clean working directory containing 170,000 tracked files, this
improves performance of "hg --time diff" from 1.69 seconds to 1.43.

This idea is due to Siddharth Agarwal.
2012-11-30 15:55:08 -08:00
Bryan O'Sullivan
a288702cfd dirstate: move file type filtering to its source
This prepares us to move to a much faster statfiles implementation on Unix.
2012-11-30 15:55:07 -08:00
Bryan O'Sullivan
2484b3b328 dirstate: handle dangling junctions on windows (issue2579) 2012-10-23 21:25:22 -07:00
Tim Henigan
e6d3f7258f dirstate: remove obsolete comment from setbranch
This comment should have been removed in 4d438984605c, when the call
to scmutil.checknewlabel was removed.
2012-11-29 08:44:54 -05:00
Kevin Bullock
13bf0fbbec scmutil: add bad character checking to checknewlabel
This factors out the checks from tags and bookmarks, and newly applies
the same prohibitions to branches. checknewlabel takes a new parameter,
kind, indicating the kind of label being checked.

Test coverage is added for all three types of labels.
2012-10-17 21:42:06 -05:00
Kevin Bullock
68efaf1422 dirstate: use scmutil.checknewlabel to check new branch name 2012-10-17 21:32:19 -05:00
Matt Mackall
38701c0855 dirstate: handle large dates and times with masking (issue2608)
Dates and times that are outside the 31-bit signed range are now
compared modulo 2^31. This should prevent it from behaving badly with
very large files or corrupt dates while still having a high
probability of detecting changes.
2012-10-08 17:50:42 -05:00
Matt Mackall
c49b56acb4 dirstate: drop assert 2012-07-16 16:19:53 -05:00
Adrian Buehlmann
3087eeedfb dirstate: eliminate redundant check parameter on _addpath()
state == 'a' implies check

I fail to see what the point of this check parameter is. Near as I can see,
the only _addpath call where it was set to True was in add(), but there, state
is 'a'.

This is a follow-up to 24a646d9943a.
2012-07-04 01:31:37 +02:00
Joshua Redstone
bb82354578 dirstate: factor common update code into _addpath
Factor update code common to all callers of _addpath into _addpath.
By centralizing the update code here, it provides one place to put
updates to new data structures - in a future patch.  It also removes
a few lines of duplicate code.
2012-06-18 08:06:42 -07:00
Bryan O'Sullivan
ce2a30609e parsers: add a C function to pack the dirstate
This is about 9 times faster than the Python dirstate packing code.
The relatively small speedup is due to the poor locality and memory
access patterns caused by traversing dicts and other boxed Python
values.
2012-05-30 12:55:33 -07:00