Commit Graph

537 Commits

Author SHA1 Message Date
Durham Goode
a5a69f0001 dirstate: wrap setparent calls with begin/endparentchange (issue4353)
This wraps all the locations of dirstate.setparent with the appropriate
begin/endparentchange calls. This will prevent exceptions during those calls
from causing incoherent dirstates (issue4353).
2014-09-05 11:36:20 -07:00
Mads Kiilerich
fae32dd0a3 comments: describe ancestor consistently - avoid 'least common ancestor'
"best" is as defined by mercurial.ancestor.ancestors: furthest from a root (as
measured by longest path).
2014-08-19 01:13:10 +02:00
Siddharth Agarwal
65cbe9daf5 memctx: allow extensions to determine what filectxfn should do
Rev 2eef89bfd70d switched the contract for filectxfn from "raise IOError if
file is missing" to "return None if file is missing". Out of tree extensions
need to be updated for that, but for extensions interested in compatibility
with both Mercurial <= 3.1 and default, it is next to impossible to introspect
core Mercurial to figure out what to do.

This patch adds a field to memctx for extensions to use.
2014-08-30 05:29:38 -07:00
Mads Kiilerich
4dd236da3f convert: use None value for missing files instead of overloading IOError
The internal API used IOError to indicate that a file should be marked as
removed.

There is some correlation between IOError (especially with ENOENT) and files
that should be removed, but using IOErrors to represent file removal internally
required some hacks.

Instead, use the value None to indicate that the file not is present.

Before, spurious IO errors could cause commits that silently removed files.
They will now be reported like all other IO errors so the root cause can be
fixed.
2014-08-26 22:03:32 +02:00
Matt Mackall
92e0debc2b merge with stable 2014-08-15 11:48:05 -05:00
Mads Kiilerich
b778f12731 cleanup: fix some list comprehension redefinitions of existing vars
In all the remaining cases the comprehension variable is used for the same
thing as a previous loop variable.

This will mute some pyflakes "list comprehension redefines" warnings.
2014-08-15 04:37:46 +02:00
Yuya Nishihara
58cebc106d annotate: inline definition of decorate() functions 2014-08-15 14:33:19 +09:00
Yuya Nishihara
fa3165fc6e annotate: rewrite long short-circuit statement by if-elif-else 2014-08-15 14:29:30 +09:00
Mads Kiilerich
af05e75b06 changectx: ancestor should only prefer merge.preferancestor if it is a revision
The value '*' currently designates that bid merge should be used. The best
way to test bid merge is to set preferancestor=* in the configuration file ...
but then it would abort with unknown revision '*' when other code paths ended
up in changectx.ancestor .

Instead, just skip and ignore the value '*' when looking for a preferred
ancestor.
2014-08-15 02:46:44 +02:00
Siddharth Agarwal
171c903a48 context: call normal on the right object
dirstate.normal is the method that marks files as unchanged/normal.

Rev 03dc7365e275 started caching dirstate.normal in order to improve
performance. However, there was an error in the patch: taking the wlock, under
some conditions depending on platform, can cause a new dirstate object to be
created. Caching dirstate.normal before calling wlock would then cause the
fixup calls below to be on the old dirstate object, effectively disappearing
into the ether.

On Unix and Unix-like OSes, the condition under which we create a new dirstate
object is 'the dirstate file has been modified since the last time we opened
it'. This happens pretty rarely, so the object is usually the same -- there's
little impact.

On Windows, the condition is 'always'. This means files in the lookup state are
never marked normal, so the bug has a serious performance impact since all the
files in the lookup state are re-read every time hg status is run.
2014-08-01 18:30:18 -07:00
Pierre-Yves David
f28fa0f221 status: do not reverse deleted and unknown
When reversing a status, trading "added" and "removed" make sense.
Reversing "deleted" and "unknown" does not. We stop doing it.

The reversing is documented in place for the poor soul not even able to remember
the index of all status elements by heart.
2014-08-01 13:01:35 -07:00
Pierre-Yves David
6b79b1a061 status: don't drop unknown and ignored information (issue4321)
By the magic of code movement, we ended up dropping unknown and ignored
information when comparing the working directory with a non-parent revision.

Let's stop doing it and add a test.
2014-08-01 12:49:00 -07:00
Pierre-Yves David
634525fb9a status: explicitly exclude removed file from unknown and ignored
Changeset 83ad0e76acc0 introduced a test to validate that file were not reported
twice when both unknown and removed. This behavior change was introduced by
64d05ea3a10f alongside a bug that dropped ignored and unknown completely
(issue4321). As we are going to fix the bug, we need a proper implementation of
the behavior tested in 83ad0e76acc0.
2014-08-01 13:13:24 -07:00
Sean Farley
f571686ac2 memctx: substate needs to be {} instead of None
Setting substate to None was an oversight in 5b3c9729fe09 and this patch
corrects it by setting substate to an empty dictionary which matches what
subrepo code expects.
2014-07-16 13:07:39 -05:00
Sean Farley
2c7a940b62 memctx: add note about p2 2014-06-17 20:55:06 -07:00
Sean Farley
f810468c76 memfilectx: add remove and write methods
Similar to the previous patch for workingfilectx, this patch will allow
abstracting localrepo.remove / write method to refactor working directory code
but instead operate on files in memory.
2014-07-25 20:20:26 -05:00
Sean Farley
a94ef7041a workingfilectx: add remove and write methods
This patch will allow abstracting localrepo.remove / write method to refactor
working directory code.
2014-07-02 14:01:01 -05:00
Sean Farley
2909941bb0 memctx: create a filectxfn if it is not callable
This will allow future patches to construct a memctx based on another context
or any other store-type object.
2014-07-25 19:36:01 -05:00
Sean Farley
a9b7ae9555 basectx: add missing, merge, and branch args to dirty method
This fixes a discrepency for basectx and classes that inherit from it. Now
callers can pass these arguments to any context without an exception being
raised.
2014-06-17 20:26:51 -07:00
Sean Farley
760faddb4c basefilectx: move isexec and islink from memfilectx
This will be used in the future for creating memctx objects from other
store-type objects, such as a patch store or even another context.
2014-07-25 20:11:47 -05:00
Matt Mackall
fbb6a8c166 merge with stable 2014-08-04 14:32:34 -05:00
Siddharth Agarwal
8d983aad7b context: add a method to efficiently filter by match if possible
For non-working contexts, walk and matches do the same thing. For working
contexts, walk stats all the files and looks for unknown files, while matches
just filters the dirstate by match.
2014-08-01 22:07:29 -07:00
Siddharth Agarwal
869ee24c8b context: extend efficient manifest filtering to when all paths are files
On a repository with over 250,000 files and 700,000 commits, this improves
cases like

hg status --rev <rev> -- <file>  # rev is not .

from 2.1 seconds to 1.4 seconds.

There is further scope for improvement here: for a single file or a small set
of files, it is probably more efficient to use filelog linkrevs when possible.
However there will always be cases where that will fail (multiple commits
pointing to the same file revision, removed files...), so this is independently
useful.
2014-07-16 14:53:03 -07:00
Siddharth Agarwal
b89cfab942 context: generate filtered manifest efficiently for exact matchers
When the matcher is exact, there's no reason to iterate over the entire
manifest. It's much more efficient to iterate over the list of files instead.

For a repository with approximately 300,000 files, this speeds up
hg log -l10 --patch --follow for a frequently modified file from 16.5 seconds
to 10.5 seconds.
2014-07-12 17:59:03 -07:00
Sean Farley
6fe5bc8cca committablectx: move __contains__ into workingctx
This was mistakenly moved from workingctx to committablectx in
edbbc56a5e4f. Since the method is querying the dirstate, the only logical place
is for it to reside is in workingctx.
2014-07-03 23:01:37 -05:00
Sean Farley
274d2d46cf memctx: explicitly set substate to None
In 4c8873aad79a, memctx was changed to inherit from committablectx, this in
turn added the 'substate' property to memctx. It turns out that the
newcommitphase method tested for this property:

  def newcommitphase(ui, ctx):
      commitphase = phases.newcommitphase(ui)
      substate = getattr(ctx, "substate", None)
      if not substate:
          return commitphase

Currently, memctx isn't ready to handle substates, nor removed files, so we
explicitly must set substate=None to get the old behavior back. In the future,
we can decide how memctx should play with substate. For now, this fixes
third-party extensions and some internal code dealing with subrepos.
2014-07-02 15:24:43 -05:00
Sean Farley
5b08d55f04 memctx: add _manifest implementation that computes the filenode
This is an initial implementation of having a manifest for memctx that computes
the hash in the same way that filenodes are computed elsewhere.
2014-05-29 16:12:59 -05:00
Sean Farley
9f8a936835 basectx: pass raw context objects to patch.diff 2014-04-29 16:43:59 -05:00
Pierre-Yves David
52e1ca0858 status: document the content of the returned tuple in the docstring
The ``status`` function returns a lot of information. We document it.
2014-05-31 17:26:15 -07:00
Yuya Nishihara
0215b66d65 workingctx: duplicate status list received at _poststatus hook
basectx.status may reorder the list after workingctx._poststatus is called,
so workingctx must copy it.  Otherwise, wctx.deleted() would return "unknown"
files, for example.
2014-05-31 21:21:06 +09:00
Sean Farley
23ec6d1ff8 memfilectx: add a size method
This method is needed to have memfilectx behave like the other file
contexts. We can't just inherit this method because each file context has
different behavior: filectx reads from the filelog, and workingfilectx reads
from the disk. Therefore, we define memfilectx to return the size of the data
in memory.
2014-06-03 13:49:51 -07:00
Sean Farley
1757a6c91c memfilectx: remove path since it is now inherited 2013-08-15 15:47:15 -05:00
Sean Farley
48e74f2a7a memfilectx: remove __str__ since it is now inherited 2013-08-15 15:46:32 -05:00
Sean Farley
4c2ccc8f74 memfilectx: remove __nonzero__ since it is now inherited 2013-08-15 15:46:22 -05:00
Sean Farley
1002b6c612 memfilectx: call super.__init__ instead of duplicating code
This patch changes the calling signature of memfilectx's __init__ to fall in
line with the other file contexts.

Calling code and tests have been updated accordingly.
2013-08-15 16:49:27 -05:00
Sean Farley
ce51e4e299 memfilectx: inherit from committablefilectx
This patch marks the beginning of having memfilectx become a full-fledged file
contex so that we can handle diffing and merging.
2013-08-15 15:23:36 -05:00
Sean Farley
dab79b2875 memctx: remove parents since it is now inherited 2013-08-15 15:20:56 -05:00
Sean Farley
19ee0d9801 memctx: remove flags since it is now inherited
commitablectx has a much more robust implementation of flags() so we will use
that instead of just blindly calling the flags function for the given path.
2013-08-15 15:19:29 -05:00
Sean Farley
b313657e44 memctx: remove extra since it is now inherited 2013-08-15 15:17:05 -05:00
Sean Farley
c6c9260200 memctx: remove branch since it is now inherited 2013-08-15 15:14:47 -05:00
Sean Farley
5dad7e7445 memctx: remove clean since it is now inherited 2014-05-28 20:03:38 -05:00
Sean Farley
8901e63f4c memctx: remove ignored since it is now inherited 2014-05-28 20:03:29 -05:00
Sean Farley
72ed48fbf9 memctx: remove unknown since it is now inherited 2014-05-28 20:03:19 -05:00
Sean Farley
10ff60a8f2 memctx: remove deleted since it is now inherited 2013-08-15 15:13:14 -05:00
Sean Farley
06fb032978 memctx: remove removed since it is now inherited 2013-08-15 15:12:54 -05:00
Sean Farley
a5e383250e memctx: remove added since it is now inherited 2013-08-15 15:12:46 -05:00
Sean Farley
e1a50e2392 memctx: remove modified since it is now inherited 2013-08-15 15:12:31 -05:00
Sean Farley
3bb2b1b835 memctx: remove files since it is now inherited
This is a slight change in definition from memctx returning only modified() but
its parent's definition is more consistent with other contexts' behavior so we
can call this change a slight bugfix and step in the right direction.
2013-08-15 15:12:19 -05:00
Sean Farley
ff84134188 memctx: remove description since it is now inherited 2013-08-15 15:07:43 -05:00
Sean Farley
e20bb1e948 memctx: remove date since it is now inherited 2013-08-15 15:07:29 -05:00