Commit Graph

13 Commits

Author SHA1 Message Date
Jun Wu
e1e3cc79e7 filecommit: add a fast path to reuse raw revision data
Summary:
This is a resend of https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097693.html,
with Yuya's comments addressed and some additional comments.

The original commit message is:

> The high-level idea is similar to metadataonlyctx.
> If filelog parents and metadata match, then raw revision data (rawtext,
> rawflags, hash) could be reused. This saves time calculating hash or going
> through flag processors.

Note in the original patch, the amend operation is not using the fast path.
But it uses the fast path today. That's because singhsrb's D636 change
(cmdutil: remove the redundant commit during amend):

```
                    # If the file being considered is not amongst the files
                    # to be amended, we should return the file context from the
                    # old changeset. This avoids issues when only some files in
                    # the working copy are being amended but there are also
                    # changes to other files from the old changeset.
                    if path not in filestoamend:
                        return old.filectx(path)
```

Reviewed By: DurhamG

Differential Revision: D8986780

fbshipit-source-id: 7d18957a713f90eafb786446972020f7939c3671
2018-07-27 20:06:07 -07:00
Jun Wu
f7e72658ec context: do not cache manifestctx
This will make sure when ctx.repo.manifestlog changes, a correct new
manifestctx is returned. repo.manifestlog takes care of caching so the
manifestctx won't be reconstructed every time.
2017-05-25 17:20:43 -07:00
Jun Wu
716a09c254 test-context: add a case demonstrating manifest caching problem
This issue was discovered when testing absorb on Windows. What happens are:

  1. ctx.p1().manifestctx gets cached.
     let's call ctx.p1().manifestctx._revlog() "mrevlog1"
  2. repo.manifestlog gets invalidated.
     let's call repo.manifestlog._revlog "mrevlog2"
  3. repo.commitctx(ctx)
     commitctx uses ctx.p1().manifestctx and writes to "mrevlog1"
  4. repo[n].manifest()
     cannot find the manifest node in "mrevlog2"

This patch adds a test case to reproduce the issue.
2017-05-25 17:06:32 -07:00
Denis Laxalde
e8f2a25582 test: end printed diff "hunks" with an empty string in test-context.py
So that the resulting diff is correct and does not include a spurious empty
line between lines "diff --git a/foo b/foo" and "--- a/foo".
2017-03-03 16:17:17 +01:00
FUJIWARA Katsunori
851e75b58e context: override _dirstatestatus in workingcommitctx for correct matching
Before this patch, the result of "status()" on "workingcommitctx" may
incorrectly contain files other than ones to be committed, because
"workingctx._dirstatestatus()" returns the result of
"dirstate.status()" directly.

For correct matching, this patch overrides "_dirstatestatus" in
"workingcommitctx" and makes it return matched files only in
"self._status".

This patch uses empty list for "deleted", "unknown" and "ignored" of
status, because status between "changectx"s also makes them empty.
2014-12-31 17:55:43 +09:00
FUJIWARA Katsunori
7b31cd3a28 context: avoid breaking already fixed self._status at ctx.status()
Before this patch, "status()" on "workingcommitctx" with "always
match" object causes breaking "self._status" in
"workingctx._buildstatus()", because "workingctx._buildstatus()"
caches the result of "dirstate.status()" into "self._status" for
efficiency, even though it should be fixed at construction for
committing.

For example, template function "diff()" without any patterns in
"committemplate" implies "status()" on "workingcommitctx" with "always
match" object, via "basectx.diff()" and "patch.diff()".

Then, broken "self._status" causes committing unexpected files.

To avoid breaking already fixed "self._status" at "ctx.status()", this
patch overrides "_buildstatus" in "workingcommitctx".

This patch doesn't write out the result of template function "diff()"
in "committemplate" in "test-commit.t", because matching against files
to be committed still has an issue fixed in subsequent patch.
2014-12-31 17:55:43 +09:00
FUJIWARA Katsunori
c2e92a32b4 context: make unknown/ignored/clean of cached status empty for equivalence
Before this patch, "workingctx.status" caches the result of
"dirstate.status" directly into "self._status".

But "dirstate.status" is invoked with False "list*" arguments in
normal "self._status" accessing route, and this makes
"unknown"/"ignored"/"clean" of status empty.

This may cause unexpected result of code paths internally accessing to
them (accessors for external usage are already removed by previous patch).

This patch makes "unknown"/"ignored"/"clean" of cached status empty
for equivalence. Making them empty is executed only when at least one
of "unknown", "ignored" or "clean" has files, for efficiency.
2014-12-31 17:55:43 +09:00
FUJIWARA Katsunori
797fef3e65 context: cache self._status correctly at workingctx.status
Before this patch, "workingctx.status" always replaces "self._status"
by the recent result, even though:

  - status isn't calculated against the parent of the working directory, or

  - specified "match" isn't "always" one
    (status is only visible partially)

If "workingctx" object is shared between some procedures indirectly
referring "ctx._status", this incorrect caching may cause unexpected
result: for example, "ctx._status" is used via "manifest()", "files()"
and so on.

To cache "self._status" correctly at "workingctx.status", this patch
overwrites "self._status" in "workingctx._buildstatus" only when:

  - status is calculated against the parent of the working directory, and
  - specified "match" is "always" one

This patch can be applied (and effective) only on default branch,
because procedure around "basectx.status" is much different between
stable and default: for example, overwriting "self._status" itself is
executed not in "workingctx._buildstatus" but in
"workingctx._poststatus", on stable branch.
2014-12-31 17:55:43 +09:00
Martin von Zweigbergk
8961a5a15c status: update various other methods to return new class 2014-10-14 00:52:27 -05:00
Sean Farley
e5137b4545 test-context: add test for performing a diff on a memctx
We now see the first result of all that refactoring of memctx: we can now diff
against a memctx.
2014-06-13 15:59:18 -07:00
Sean Farley
49ecf5d144 test-context: add test for memctx status 2014-06-13 15:56:11 -07:00
Martin Geisler
ff9aae8a76 changelog: convert user and desc from local encoding early
Failing to do so makes it impossible to use the memctx API to create a
changeset with a commit message or username outside of the current
encoding.encoding setting.
2011-05-19 18:09:25 +02:00
Thomas Arendsen Hein
c20f16ea94 Fixed workingfilectx.date() (found by Thomas Waldmann) with test. 2007-02-23 17:31:00 +01:00