Commit Graph

735 Commits

Author SHA1 Message Date
Pierre-Yves David
1512377552 filectx.parents: filter nullrev parent sooner
We are going to introduce a linkrev-correction phases  when computing parents.
It will be more convenient to have the nullid parent filtered out earlier. I
had to make a minimal adjustment to the rename handling logic to keep it
functional.  That logic have been documented in the process since it took me
some time to check all the cases out.
2014-12-23 18:29:03 -08:00
Pierre-Yves David
a0aa329ab1 context: catch FilteredRepoLookupError instead of RepoLookupError
Now that we have a more specialised exception, lets use it when we meant to
catch the more specialised case.
2014-12-23 17:13:51 -08:00
Durham Goode
42321923c9 context: return dirstate parents in workingctx.ancestors()
workingctx.ancestors() was not returning the dirstate parents as part of the
result set. The only place this function is used is for copy detection when
committing a file, and that code already checks the parents manually, so this
change has no affect at the moment.

I found it while playing around with changing how copy detection works.
2014-12-18 09:37:14 -08:00
FUJIWARA Katsunori
14f33673ea memctx: calculate manifest more efficiently
Before this patch, "memctx._manifest" updates all entries in the
(parent) manifest. But this is inefficiency, because almost all files
may be clean in that context.

On the other hand, just updating entries for changed "files" specified
at construction causes unexpected abortion, when there is at least one
newly removed file (see issue4470 for detail).

To calculate manifest more efficiently, this patch replaces
"pman.iteritems()" for the loop by "self._status.modified" to avoid
updating entries for clean or removed files

Examination of removal is also omitted, because removed files aren't
treated in this loop (= "self[f]" returns not None always).
2014-12-19 00:11:56 +09:00
Matt Mackall
0826b8e884 merge with stable 2014-12-18 16:41:59 -06:00
FUJIWARA Katsunori
aeafaa296e memctx: calculate manifest correctly with newly-removed files (issue4470)
Before this patch, "memctx._manifest" tries to get (and use normally)
filectx also for newly-removed files, even though "memctx.filectx()"
returns None for such files.

To calculate manifest correctly even with newly-removed files, this
patch does:

  - replace "man.iteritems()" for the loop by "self._status.modified"
    to avoid accessing itself to newly removed files

    this also reduces loop cost for large manifest.

  - remove files in "self._status.removed" from the manifest

In this patch, amending is confirmed twice to examine both (1) newly
removed files and (2) ones already removed in amended revision.
2014-12-17 15:09:43 +09:00
FUJIWARA Katsunori
bcd06fbc9b memctx: calculate manifest including newly added files correctly
Before this patch, "memctx._manifest" calculates the manifest
according to the 1st parent. This causes the disappearance
of newly added files from the manifest.

For example, if newly added files aren't listed up in manifest of
memctx, they aren't listed up in "added" field of "status" returned by
"ctx.status()", and "{diff()}" (= "patch.diff") in "committemplate"
shows nothing for them.

To calculate manifest including newly added files correctly, this
patch puts newly added files (= ones in "self._status.added") into the
manifest.

Some details of changes for "test-commit-amend.t" in this patch:

  - "touch foo" is replaced by "echo foo > foo", because newly added
    empty file can't be shown in "diff()" output without "diff.git"
    configuration

  - amending is confirmed twice to examine both (1) newly added files
    and (2) ones already added in amended revision
2014-12-17 15:09:43 +09:00
FUJIWARA Katsunori
855293b5eb memctx: calculate exact status being committed from specified files
Before this patch, "memctx._status" is initialized by "(files, [], [],
[], [], [], [])" and this causes "memctx.modified" to include not
only modified files but also added and removed ones incorrectly.

This patch adds "_status" method to calculate exact status being
committed according to "files" specified at construction time.

Exact "_status" is useful to share/reuse logic of committablectx.

This patch is also preparation for issues fixed by subsequent patches.

Some details of changes for tests in this patch:

  - some filename lines are omitted in "test-convert-svn-encoding.t",
    because they are correctly listed up as "removed" files

    those lines are written out in "localrepository.commitctx" for
    "modified" and "added" files by "ui.note".

  - "| fixbundle" filterring in "test-histedit-fold.t" is omitted to
    check lines including "added" correctly

    "fixbundle" discards all lines including "added".
2014-12-17 15:09:38 +09:00
Augie Fackler
a029bf7fdb memctx: fix manifest for removed files (issue4470)
filectxfn returns None for removed files, so we have to check for None
before computing the new file content hash for the manifest.

Includes a test that proves this works, by demonstrating that we can
show the diff of an amended commit in the committemplate.
2014-12-15 15:00:54 -05:00
Augie Fackler
dbb0b3f2fe context: stop setting None for modified or added nodes
Instead use a magic value, so that we can identify modified or added
nodes correctly when using manifest.diff().

Thanks to Martin von Zweigbergk for catching that we have to update
_buildstatus as well. That part eluded my debugging for some time.
2014-12-12 15:29:54 -05:00
Pierre-Yves David
8db67ed78a rename: properly report removed and added file as modified (issue4458)
The result of 'hg rm' + 'hg rename' disagreed with the one from
'hg rename --force'. We align them on 'hg move --force' because it agrees with
what 'hg status' says after the commit.

Stopping reporting a modified file as added puts an end to the hg revert confusion in this
situation (issue4458).

However, reporting the file as modified also prevents revert from restoring the copy
source. We fix this in a later changeset.

Git diff also stop reporting the add in the middle of the chain as add. Not
sure how important (and even wrong) it is.
2014-11-24 18:42:56 -08:00
Pierre-Yves David
bb7457d4d7 manifest: fix a bug where working copy file 'add' mark was buggy
Because the same dictionary was used to (1) get node from parent and (2) store
annotated version, we could end up with buggy values. For example with a chain
of renames:

  $ hg mv b c
  $ hg mv a b

The value from 'b' would be updated as "<old-a>a", then the value of c would be
updated as "<old-b>a'. With the current dictionary sharing this ends up with:

    '<new-c>' == '<old-a>aa'

This value is double-wrong as we should use '<old-b>' and a single 'a'.

We now use a read-only value for lookup. The 'test-rename.t' test is impacted
because such a chained added file is suddenly detected as such.
2014-11-26 14:54:16 -08:00
Sean Farley
a106407d01 namespaces: add branches
Note that the exception-catching from the previous branchtip check is moved up
to catch exceptions from the try block surrounding the namespace lookup.
2014-10-17 15:27:12 -07:00
Sean Farley
066d5cf84a namespaces: add tags 2014-10-17 15:27:33 -07:00
Ryan McElroy
28a1fb3f8a namespaces: remove weakref; always pass in repo
It turns out that maintaining a reference of any sort (even weak!) to the repo
when constructed doesn't work because we may at some point pass in a repoview
filtered by something other than what the initial repo was.
2014-12-14 19:11:44 -08:00
Sean Farley
11ae771651 changectx: use names api to simplify and extend node lookup
Previously, changectx had to know about each type of name (bookmark, tag, etc.)
to look up. Now, we use repo.namenodes to simplify (and extend) this.
2014-10-16 23:27:54 -07:00
Mads Kiilerich
b420dd92b1 spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Laurent Charignon
859ae355fa context: make warning message for hidden revision extensible
Extensions might want to create new filternames and change what revisions
are considered hidden or shown. This is the case for inhibit that enables
direct access to hidden hashes with the visible-directaccess-nowarn filtername.
By using startswith instead of a direct comparison with 'visible' we
allow extensions to do that and not work directly on the 'visible' filtername
used by core.
2015-05-04 10:38:45 -07:00
Pierre-Yves David
c52ad3f03b manifest: document the extra letter in working copy manifest node
As the second developer to get confused by this in November, I'm adding some
documentation for the next poor soul.
2014-11-26 15:37:01 -08:00
Matt Mackall
4abfc94f18 merge with stable 2014-11-27 12:25:01 -06:00
Martin von Zweigbergk
455810026c manifest: add matches() method
Move the code in context._manifestmatches() into a new
manifest.matches(). It's a natural place for the code to live and it
allows other callers to easily use it. It should also make it easier
to optimize the new method in alternative implementations of the
manifest (same reasoning as with manifest.diff()).
2014-10-22 21:38:30 -07:00
Martin von Zweigbergk
cfd2a961bd context.status: pass status tuple into _buildstatus
By passing a status tuple (instead of the current list), we can access
the status fields by name and make it a little more readable.
2014-11-12 22:20:36 -08:00
Martin von Zweigbergk
f2e6b819eb context.status: avoid de- and reconstructing status tuple
We can just modify the status tuple we got from dirstate.status()
instead of deconstructing it and constructing a new instance, thereby
simplifying the code a little.
2014-11-12 22:07:31 -08:00
Martin von Zweigbergk
7de43e79f4 context.status: make _dirstatestatus() return an status tuple
Letting _dirstatestatus() return an scmutil.status instance also means
that _buildstatus() will always return such an instance, so we can
remove the conversion from the call sites.
2014-11-12 16:51:11 -08:00
Martin von Zweigbergk
38e47fc778 context.status: wipe deleted/unknown/ignored fields when reversed
It makes no sense to request reverse status (i.e. changes from the
working copy to its parent) and then look at the deleted, unknown or
ignored fields. If you do, you would get the result from the forward
status (changes from parent to the working copy). Instead of giving a
nonsensical answer to a nonsensical question, it seems a little saner
to return empty lists. It might be best if we could prevent the caller
accessing these lists, but it's doubtful it's worth the trouble.
2014-11-12 21:19:07 -08:00
Martin von Zweigbergk
abccb5c328 context.status: explain "caching reasons" more fully
Where we "load earliest manifest first for caching reasons", elaborate
on what "caching reasons" refers to. Text provided by Matt in
http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/73235/focus=73578.
2014-11-11 10:16:54 -08:00
Martin von Zweigbergk
f07d2059f7 context.status: only filter suspect symlinks in the dirstate status
We don't care about filtering out symlinks that have already been
committed with full content, only those that have been accidentally
resolved in the working directory.
2014-10-23 17:00:38 -07:00
Martin von Zweigbergk
e1831ee6df context.status: inline _poststatus()
By inlining _poststatus() into _buildstatus(), it becomes clearer that
it is only called for the workingctx.
2014-10-23 16:19:56 -07:00
Martin von Zweigbergk
9901573e36 context.status: remove now-empty _prestatus() 2014-10-12 00:06:40 -07:00
Martin von Zweigbergk
22a4f35851 context.status: call _dirstatestatus() from within _buildstatus()
By making the call to _dirstatestatus() within _buildstatus(), it
becomes clearer that it's called only for the workingctx.
2014-10-11 23:30:08 -07:00
Martin von Zweigbergk
f41e08e268 context.status: move manifest caching trick to _buildstatus()
In basectx._buildstatus(), we read the manifests for the two revisions
being compared. For "caching reasons" unknown to me, it is better to
read the earlier manifest first, which basectx._prestatus() takes care
of. However, if the 'self' context is a committablectx and the 'other'
context is the parent of the working directory (as in the very common
case of plain "hg status"), there is no need to read any manifests at
all -- all that's needed is the dirstate status. To avoid reading the
manifests, _prestatus() is overridden in committablectx and avoids
calling its super method, and _buildstatus() calls its super method
only if the 'other' context is not the parent of the working
directory.

It seems easier to follow what's happening if we move the pre-fetching
to _buildstatus() just before the place where the manifests are
fetched. We just need to add an extra check that the revision is not
None to handle the case that was previously handled by subclass
overriding. That also makes it safe for committablectx._prestatus() to
call its parent, although the latter now becomes empty, so we won't
bother.
2014-10-12 00:00:13 -07:00
Martin von Zweigbergk
7d724075bb context.status: remove unused arguments from _matchstatus() 2014-10-11 23:18:53 -07:00
Martin von Zweigbergk
3e01ff74de context.status: remove overriding in workingctx
The workingctx method simply calls the super method. The only effect
it has is that it uses a different default argument for the 'other'
argument. The only in-tree caller is patch.diff, which always passes
an argument to the method, so it should be safe to remove the
overriding. Having the default argument depend on the type seems
rather dangerous anyway.
2014-10-23 13:43:20 -07:00
Mads Kiilerich
523c87c1fe spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
FUJIWARA Katsunori
bf44489048 i18n: make hint message of exception translatable 2014-11-01 02:43:08 +09:00
Martin von Zweigbergk
a97f944a97 status: make 'hg status --rev' faster when there are deleted files
In order not to avoid listing files as both added and deleted, for
example, we check for every file in the manifest if it is in the
_list_ of deleted files. This can get quite slow when there are many
deleted files. Change it to a set to make the containment check
faster. On a somewhat contrived example of the Mozilla repo with the
entire testing/ directory deleted (~14k files), this makes
'hg status --rev .^' go from 26s to 2s.
2014-10-24 14:24:28 -07:00
Martin von Zweigbergk
061743c247 context.status: remove incorrect swapping of added/removed in workingctx
The comment in workingctx.status() says that "calling 'super' subtly
reveresed the contexts", but that is simply not true, so we should not
be swapping added and removed fields.
2014-10-24 15:52:20 -05:00
Pierre-Yves David
2658f42db0 repoview: issue a special message when filtering hidden changesets
Hidden changesets are by far the most common error case and is the only one[1]
that can reach the user. We move to a friendlier message with a hint about how
to access the data anyway. We should probably point to a help topic instead but
we do not have such a topic yet.

Example of the new output

  abort: hidden revision '4'!
  (use --hidden to access hidden revisions)


[1] Actually, filtering from "served" can also reach the user during certain
exchange operations.
2014-10-17 15:25:32 -07:00
Pierre-Yves David
1dd313bfc1 repoview: include the filter name in filtered revision error messages
This will help user to debug. A more precise message will be issued
for the most common case ("visible" filter) in the next changesets.

example output:

  -  abort: filtered revision '4'!
  +  abort: filtered revision '4' (not in 'visible' subset)!
2014-10-17 15:54:43 -07:00
Pierre-Yves David
7fc829de42 changectx: issue a FilteredRepoLookupError when applicable
We capture FilteredxxxError and issue a FilteredRepoLookupError instead with a
sightly different messsge. The message will likely get more improvement in the
future.

    error: filtered revision '4'
2014-10-15 20:37:44 -07:00
Pierre-Yves David
de4a821442 changectx: move IndexError handling in the top level try except
This one can be handled by the top level catching.
2014-10-15 16:14:50 -07:00
Pierre-Yves David
4b3ae249b1 changectx: wrap the changeid processing in a try/except
We are going to introduce more precise exception classes for filtered nodes. So
we will have to upgrade them to the `RepoLookupError` level here. We wrap the
whole thing into a try/except to ease this future catching. Some of the current
exception catching will be moved in this one. But the current changeset focuses
on code movement only.
2014-10-15 16:05:24 -07:00
Augie Fackler
9afa9a909c manifest: rename ambiguously-named set to setflag
Just makes it a little clearer what this method does.
2014-10-10 14:09:37 -04:00
Mike Edgar
7403ba126b context: handle censored data in an on-disk file context based on config
Two possible behaviors are defined for handling censored data: abort, and
ignore. When we ignore censored data we return an empty file to callers
requesting the file data.
2014-10-14 15:46:16 -04:00
Martin von Zweigbergk
011cf39cde context: store status class instead of plain tuple in self._status
This improves readability a bit by allowing us to refer to statuses by
name rather than index.
2014-10-04 21:05:41 -07:00
Martin von Zweigbergk
8961a5a15c status: update various other methods to return new class 2014-10-14 00:52:27 -05:00
Martin von Zweigbergk
1a4e0a3d51 dirstate: separate 'lookup' status field from others
The status tuple returned from dirstate.status() has an additional
field compared to the other status tuples: lookup/unsure. This field
is just an optimization and not something most callers care about
(they want the resolved value of 'modified' or 'clean'). To prepare
for a single future status type, let's separate out the 'lookup' field
from the rest by having dirstate.status() return a pair: (lookup,
status).
2014-10-03 21:44:10 -07:00
Mads Kiilerich
b4b06de04d changectx: skip all invalid merge.preferancestor values
A better fix for 0e1533a3ded2 that will ignore other kinds of "invalid"
revisions.
2014-10-01 03:40:51 +02:00
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
Sean Farley
24ca8e9461 memctx: remove user since it is now inherited 2013-08-15 15:07:01 -05:00
Sean Farley
ef4723d1a0 memctx: remove p2 since it is now inherited 2013-08-15 15:06:39 -05:00
Sean Farley
ee101eac61 memctx: remove p1 since it is now inherited 2013-08-15 15:06:10 -05:00
Sean Farley
9609b1d01c memctx: remove __getitem__ since it is now inherited 2013-08-15 15:05:32 -05:00
Sean Farley
f9b7d78d04 memctx: remove __nonzero__ since it is now inherited 2013-08-15 15:04:55 -05:00
Sean Farley
4a1f5fc163 memctx: remove __int__ since it is now inherited 2013-08-15 15:04:36 -05:00
Sean Farley
a6facf0d7d memctx: remove __str__ since it is now inherited 2013-08-15 15:03:52 -05:00
Sean Farley
f37d45d609 memctx: call super.__init__ instead of duplicating code 2013-08-15 15:03:03 -05:00
Sean Farley
2b69f12f63 memctx: inherit from committablectx
This patch marks the start of having memctx inherit from committablectx,
thereby making it a full-fledged context that will eventually grow the ability
to perform diffing and also merging.
2013-08-15 15:00:03 -05:00
Sean Farley
f1efbc42f4 committablectx: fix _manifest doc string 2014-04-29 16:49:27 -05:00
Sean Farley
91eeee166f context: fix wrong indentation from renaming method 2014-05-29 16:09:16 -05:00
Sean Farley
3692a2672f context: explicitly return a tuple
In the refactoring of removing localrepo.status, e283486177bd, we accidentally
changed the return type from a tuple to a list. Philosophically, this is
incorrect so we explicitly return a tuple again.
2014-05-27 17:04:48 -05:00
Sean Farley
927e6572f4 workingctx: have status method call super instead of customized code.
The old code is unneeded now that basectx has the ability to calculate the
status between two context objects.

Now, we use the objected oriented pattern called 'super'.
2014-05-27 15:55:35 -07:00
Sean Farley
7d4925ec2b basectx: copy localrepo.status method
Now that all the pieces are in place, we copy the status method from
localrepo. In the next few patches, we will remove the old implementation.
2014-04-24 18:07:42 -05:00
Sean Farley
6a40a50483 committablectx: cache _status in _poststatus
A future patch will remove the old workingctx.status which caches the status of
the working directory, therefore we now cache this status in the poststatus
hook of committablectx.
2014-04-24 17:42:53 -05:00
Sean Farley
da54d7ddc4 committablectx: simplify caching the status
Previously, workingctx had custom variables for the unknown, ignored, and clean
list of files of status. These then got moved to committablectx and, after the
refactoring of localrepo.status, are no longer needed. We, therefore, simplify
the whole mess.

As a bonus, we are able to remove the need for having 'assert'.
2014-04-24 17:31:20 -05:00
Sean Farley
c4a16ba6c8 workingctx: add note about super._prestatus calling manifest 2014-04-23 16:06:42 -05:00
Sean Farley
ff42938c33 basectx: preserve loading the cached manifest in _prestatus
This is just a copy from localrepo.status and is a small step to removing that
method entirely. The prestatus hook is only called for changectx's, thereby
ensuring that the same behavior is guaranteed.
2014-04-23 16:06:23 -05:00
Sean Farley
9882a9e5a4 committablectx: add subrev method to return None
This allows a future patch to use object oriented style to remove an if
statement in the status method.
2013-09-20 22:07:58 -05:00
Sean Farley
ede9f80137 basectx: add subrev method to return the rev of a subrepo given a subpath
This will be used in an upcoming patch to simplify the status method by
eliminating an if block.
2013-09-20 21:55:42 -05:00
Sean Farley
42ad19b6f3 workingctx: override _matchstatus for parentworking case
This patch encapsulate the logic for changing the match.bad function when
comparing against the working directory's parent. Future patches will remove
more of the 'if ... else' blocks in localrepo.status that test for this working
directory parent case.
2014-04-24 08:32:28 -05:00
Sean Farley
7c49d1c079 basectx: add _matchstatus method for factoring out last of parentworking logic
This patch paves the way to allow a workingctx to override the match object
with a custom 'bad' method for cases where status is sent a directory pattern.
2014-04-23 15:39:30 -05:00
Sean Farley
884625aaa0 workingctx: use inheritance for _buildstatus while keeping the fastpath
This patch maintains the fast path for workingctx which is to not build a
manifest if the working directory is being compared to its parent since, in
this case, we can just copy the parent manifest.
2014-04-24 08:34:44 -05:00
Sean Farley
463e9b93cd workingctx: add _poststatus method to call _filtersuspectsymlink
With this patch, we are one step closer to removing 'if ... else' logic in
localrepo.status for testing if the context is the working directory or
not. Future patches will replace those blocks of code with a call to the
context's _poststatus hook so that each context object will do the right thing
depending on the situation.
2014-04-22 12:59:22 -05:00
Sean Farley
8c39c57c3f context: add a no-op _poststatus method
This patch adds a private _poststatus method so that certain contexts, such as
workingctx, can add custom post-processing to status.
2014-04-22 12:51:58 -05:00
Sean Farley
6d43da865f workingctx: add _prestatus method to call _dirstatestatus
With this patch, we are one step closer to removing 'if ... else' logic in
localrepo.status for testing if the context is the working directory or
not. Future patches will replace those blocks of code with a call to the
context's _prestatus hook so that each context object will do the right thing
depending on the situation.
2014-04-21 22:12:59 -05:00
Sean Farley
950833cded context: add a no-op _prestatus method
This patch adds a private _prestatus method so that certain contexts, such as
workingctx, can add custom pre-processing to status.
2014-04-21 21:39:10 -05:00
Sean Farley
276fa81238 context: add _buildstatus method
This method is a copy of localstatus.status's core logic. Later patches will
clean up some of the dense coditionals in the for loop.
2014-04-21 21:35:36 -05:00
Sean Farley
bc8fd01f30 localrepo: factor out _manifestmatch logic for workingctx 2014-04-15 15:43:30 -05:00
Sean Farley
9f299940b4 basectx: add _manifestmatches method
This method is a duplicate of localrepo.mfmatches and sets the stage for
factoring localrepo.status into a context method that will be customizable
based on inheritance and object type.
2014-04-23 20:52:10 -05:00
Sean Farley
c7e1cc99b7 workingctx: call _dirstatestatus in status
Rip out the call from workingctx.status to localrepo.status.
2014-04-22 13:20:30 -05:00
Sean Farley
84708b1841 context: add private _dirstatestatus method
This patch is a step forward in getting rid of needing to check 'parentworking'
throughout the status method. Eventually, we will use the power of inheritance
to do the correct thing when comparing the working directory with its parent.

This method is mostly a copy from localrepo.status. The custom status method of
workingctx will eventually be absorbed by the refactoring of localrepo.status
to context.status but unfortunately we can't do it in one step.
2014-04-22 13:14:51 -05:00
Sean Farley
cdafec8fc5 committablectx: move status to workingctx
This method was accidentally placed into the committablectx class. It contains
logic for querying the dirstate so we move it to the correct class.
2014-03-11 18:28:09 -05:00
Sean Farley
df1d7f2500 localrepo: factor out parentworking logic for comparing files
We will temporarily call a private method of the context class while we are in
the process of removing the need of having localrepo.status.
2014-03-11 18:10:00 -05:00
Sean Farley
0df8cdd414 localrepo: move symlink logic to workingctx 2014-03-07 13:32:37 -08:00
FUJIWARA Katsunori
a569398722 context: move editor invocation from "makememctx()" to "memctx.__init__()"
This patch introduces "editor" argument to "memctx.__init__()", and
moves editor invocation from "makememctx()" to "memctx.__init__()", to
centralize editor invocation into "memctx" object creation.

This relocation is needed, because "makememctx()" requires the "store"
object providing "getfile()" to create "memfilectx" object, and this
prevents some code paths from using "makememctx()" instead of
"memctx.__init__()".

This patch also invokes "localrepository.savecommitmessage()", when
"editor" is specified explicitly, to centralize saving commit message
into "memctx" object creation: passing "cmdutil.commiteditor" as
"editor" can achieve both suppressing editor invocation and saving
into ".hg/last-message.txt" for non empty commit messages.
2014-05-05 21:26:40 +09:00
Matt Mackall
8ba0348c31 ancestor: silence multiple ancestor warning outside of merge (issue4234)
The current situation is a bit of a layering violation as
merge-specific knowledge is pushed down to lower layers and leaks
merge assumptions into other code paths.

Here, we simply silence the warning with a hack. Both the warning and
the hack will probably go away in the near future when bid merge is
made the default.
2014-04-30 14:19:01 -05:00
Mads Kiilerich
cdb11ac02d context: introduce merge.preferancestor for controlling which ancestor to pick
Multiple revisions can be specified in merge.preferancestor, separated by
whitespace. First match wins.

This makes it possible to overrule the default of picking the common ancestor
with the lowest hash value among the "best" (introduced in f19507e1bcf2).

This can for instance help with some merges where the 'wrong' ancestor is used.
There will thus be some overlap between this and the problems that can be
solved with a future 'consensus merge'.

Mercurial will show a note like
  note: using 40663881a6dd as ancestor of 3b08d01b0ab5 and adfe50279922
        alternatively, use --config merge.preferancestor=0f6b37dbe527
when the option is available, listing all the alternative ancestors.
2014-02-24 22:42:14 +01:00
Mads Kiilerich
81feeb72af context: tell when .ancestor picks one of multiple common ancestors heads
Show a message like
  note: using 0f6b37dbe527 as ancestor of adfe50279922 and cf89f02107e5

So far this is just a warning - there is nothing the user can do to select
another ancestor.
2014-04-17 17:32:04 +02:00
Mads Kiilerich
c608411f0d context: remove redundant handling of match.bad return value
The 'bad' function is for reporting - it never returns anything.
2013-10-03 18:01:21 +02:00
Mads Kiilerich
c951e7f8b6 context: remove unused filectx.ancestor 2014-04-07 23:17:48 +02:00
Augie Fackler
550a17aab3 context: add a getfileset() method so fewer things need fileset directly
Allows me to break an import cycle in a subsequent change.
2014-02-04 15:27:49 -05:00
Durham Goode
ffaaebd787 changectx: increase perf of walk function
When running 'hg cat -r . <file>' it was doing an expensive ctx.walk(m) which
applied the regex to every file in the manifest.

This changes changectx.walk to iterate over just the files in the regex, if no
other patterns are specified. This cuts hg cat time by 50% in our repo and
probably benefits a few other commands as well.
2014-01-14 13:49:19 -08:00
Mads Kiilerich
48b69add79 context: drop caching 'copies' method
The 'copies' method has no test coverage and calls copies.pathcopies with an
incorrect number of parameters and is thus (fortunately) not used. Kill it.
2013-11-16 15:46:29 -05:00
Augie Fackler
fb91efd733 makememctx: move from patch to context to break import cycle 2013-11-06 22:09:15 -05:00
Mads Kiilerich
eabc047878 spelling: random spell checker fixes 2013-10-24 01:49:56 +08:00
FUJIWARA Katsunori
52c2363e13 context: use "vfs.lstat()" to examine target path instead of "os.path.*"
This patch gets stat object of target path by "vfs.lstat()", and
examines stat object to know the type of it. This follows the way in
"workingctx.add()".

This should be cheaper than original implementation invoking
"lexists()", "isfile()" and "islink()".
2013-10-15 00:51:05 +09:00
FUJIWARA Katsunori
269961e114 context: use "vfs.lstat()" instead of "os.lstat()" 2013-10-15 00:51:04 +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
Sean Farley
89ec93306f context: move evolution functions from changectx to basectx
This is just a code move and corrects an overlook from my previous patch series
that assumed only a changectx would want this functionality.
2013-09-17 23:34:57 -05:00
Sean Farley
58d5c3fd06 context: use correct spelling of committable 2013-09-17 18:34:45 -05:00
Sean Farley
f65ef721e4 commitablefilectx: move children from workingfilectx 2013-08-15 13:42:56 -05:00
Sean Farley
f415142833 commitablefilectx: move parents from workingfilectx 2013-08-15 13:42:33 -05:00
Sean Farley
f31ebd758d commitablefilectx: move __nonzero__ from workingfilectx 2013-08-15 13:23:06 -05:00
Sean Farley
f38f187cbc commitablefilectx: move __init__ from workingfilectx 2013-08-15 13:12:50 -05:00
Sean Farley
608e9a1f09 commitablefilectx: add a class that will be used for mutable file contexts
Just like commitablectx, this will serve as a common place for code that will
be shared between workingfilectx and memfilectx.
2013-08-15 13:11:51 -05:00
Sean Farley
be4c3801e7 commitablectx: move dirs from workingctx 2013-08-14 16:40:34 -05:00
Sean Farley
e88dd1aaed commitablectx: move markcommitted from workingctx 2013-08-14 16:40:27 -05:00
Sean Farley
63bb66d577 commitablectx: move ancestors from workingctx 2013-08-14 16:37:59 -05:00
Sean Farley
402e7ea991 commitablectx: move walk from workingctx 2013-08-14 16:37:11 -05:00
Sean Farley
a895d35a4d commitablectx: move ancestor from workingctx 2013-08-14 16:37:01 -05:00
Sean Farley
72513aefb7 commitablectx: move flags from workingctx 2013-08-14 16:25:43 -05:00
Sean Farley
279f4b1ae7 commitablectx: move children from workingctx 2013-08-14 16:25:26 -05:00
Sean Farley
612da7c6bb commitablectx: move hidden from workingctx 2013-08-14 16:25:17 -05:00
Sean Farley
185f3bd11b commitablectx: move phase from workingctx 2013-08-14 16:24:59 -05:00
Sean Farley
03cb1762ec commitablectx: move bookmarks from workingctx 2013-08-14 16:24:33 -05:00
Sean Farley
286aebb4f4 commitablectx: move tags from workingctx 2013-08-14 16:24:16 -05:00
Sean Farley
2d15415c23 commitablectx: move extra from workingctx 2013-08-14 16:23:28 -05:00
Sean Farley
801497cf22 commitablectx: move closesbranch from workingctx 2013-08-14 16:23:16 -05:00
Sean Farley
a72a4edc59 commitablectx: move branch from workingctx 2013-08-14 16:23:02 -05:00
Sean Farley
8853002f4d commitablectx: move clean from workingctx 2013-08-14 16:22:42 -05:00
Sean Farley
c314be2c39 commitablectx: move ignored from workingctx 2013-08-14 16:22:32 -05:00
Sean Farley
32b922e204 commitablectx: move unknown from workingctx 2013-08-14 16:22:20 -05:00
Sean Farley
93bdfe006a commitablectx: move deleted from workingctx 2013-08-14 16:21:55 -05:00
Sean Farley
fe6d82e931 commitablectx: move removed from workingctx 2013-08-14 16:15:29 -05:00
Sean Farley
eba15bc142 commitablectx: move added from workingctx 2013-08-14 16:15:18 -05:00
Sean Farley
ecee868f25 commitablectx: move modified from workingctx 2013-08-14 16:14:58 -05:00
Sean Farley
cc0f5b38da commitablectx: move files from workingctx 2013-08-14 16:09:45 -05:00
Sean Farley
a8af5db123 commitablectx: move description from workingctx 2013-08-14 16:09:30 -05:00
Sean Farley
d3e48b9c15 commitablectx: move date from workingctx 2013-08-14 16:03:32 -05:00
Sean Farley
e01ebdbeaa commitablectx: move _date from workingctx 2013-08-15 10:57:43 -05:00
Sean Farley
ee2b1a6d19 commitablectx: move user from workingctx 2013-08-14 15:57:24 -05:00
Sean Farley
befd1a7b66 commitablectx: move _user from workingctx 2013-08-15 10:51:53 -05:00
Sean Farley
b9cfaf5912 commitablectx: move status from workingctx 2013-08-14 15:55:56 -05:00
Sean Farley
e5affa49cb commitablectx: move _status from workingctx 2013-08-14 15:41:22 -05:00
Sean Farley
ec4dfee71f commitablectx: move _manifest from workingctx 2013-08-14 15:34:18 -05:00
Sean Farley
99dae9c3c7 commitablectx: move _flagfunc from workingctx 2013-08-14 15:30:17 -05:00
Sean Farley
b14aec7508 commitablectx: move _buildflagfunc from workingctx 2013-08-14 15:29:48 -05:00
Sean Farley
55ce00c298 commitablectx: move __contains__ from workingctx 2013-08-14 15:29:09 -05:00
Sean Farley
c0f8038aa8 commitablectx: move __nonzero__ from workingctx 2013-08-14 15:28:43 -05:00
Sean Farley
15cba08e2b commitablectx: move __str__ from workingctx 2013-08-14 15:25:14 -05:00
Sean Farley
cbd1bba7bc commitablectx: move __init__ from workingctx 2013-08-14 15:24:58 -05:00
Sean Farley
3eacb95a31 commitablectx: add a class that will be used as a parent of mutable contexts
Currently, we have basectx that serves as a common ancestor of all contexts. We
will now add a new class commitablectx that will inherit from basectx and will
serve as a common place for code that will be shared between mutable contexts,
e.g. workingctx and memctx.
2013-08-14 15:02:08 -05:00
Sean Farley
18c9d5ae45 workingfilectx: remove unneeded __repr__ since it is now inherited 2013-08-14 13:32:56 -05:00
Sean Farley
f9c1629d6e workingfilectx: remove bogus comment 2013-08-15 13:09:34 -05:00
Sean Farley
e44c746203 workingfilectx: remove __str__ manifest since it is now inherited 2013-08-15 13:32:07 -05:00
Sean Farley
a1f0e066e5 basefilectx: use basectx __str__ instead of duplicating logic
This change allows us to only rely on one place to convert a context to a
string which will help eliminate duplicate code in context.py
2013-08-15 13:31:17 -05:00
Sean Farley
6ed862f6fd workingctx: remove unneeded manifest since it is now inherited 2013-08-14 13:41:09 -05:00
Sean Farley
1e8645944c workingctx: remove unneeded __repr__ since it is now inherited 2013-08-14 13:32:44 -05:00
Sean Farley
2f686aa464 workingfilectx: inherit from basefilectx instead of filectx 2013-08-11 23:50:32 -05:00
Sean Farley
726ffb7462 basefilectx: move copies from filectx 2013-08-11 23:06:10 -05:00
Sean Farley
4ff2bdaf91 basefilectx: move ancestors from filectx 2013-08-11 23:05:50 -05:00