Commit Graph

735 Commits

Author SHA1 Message Date
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
Sean Farley
6e02ef72e6 basefilectx: move ancestor from filectx 2013-08-11 23:05:08 -05:00
Sean Farley
9b77633abf basefilectx: move annotate from filectx 2013-08-11 23:03:33 -05:00
Sean Farley
d165e8257b basefilectx: move p2 from filectx 2013-08-11 23:00:11 -05:00
Sean Farley
98aa1d5037 basefilectx: move p1 from filectx 2013-08-11 22:59:10 -05:00
Sean Farley
7a7821cc2f basefilectx: move parents from filectx 2013-08-11 22:57:21 -05:00
Sean Farley
b4bfc8c2dc basefilectx: move cmp from filectx 2013-08-11 22:56:53 -05:00
Sean Farley
29424e6c91 basefilectx: move isbinary from filectx 2013-08-11 22:56:30 -05:00
Sean Farley
6173fa01da basefilectx: move path from filectx 2013-08-11 22:56:18 -05:00
Sean Farley
615c354555 basefilectx: move changectx from filectx 2013-08-11 22:56:02 -05:00
Sean Farley
7f9c8225f5 basefilectx: move manifest from filectx 2013-08-11 22:55:09 -05:00
Sean Farley
3d1241011d basefilectx: move phasestr from filectx 2013-08-11 22:54:58 -05:00
Sean Farley
5fc34c58af basefilectx: move phase from filectx 2013-08-11 22:54:48 -05:00
Sean Farley
14863e5b77 basefilectx: move extra from filectx 2013-08-11 22:54:39 -05:00
Sean Farley
f6e15b5aa3 basefilectx: move branch from filectx 2013-08-11 22:54:31 -05:00
Sean Farley
0e2bdf70f7 basefilectx: move description from filectx 2013-08-11 22:54:22 -05:00
Sean Farley
7b079fe631 basefilectx: move files from filectx 2013-08-11 22:54:12 -05:00
Sean Farley
aa95db8a42 basefilectx: move date from filectx 2013-08-11 22:53:56 -05:00
Sean Farley
75c2c801b7 basefilectx: move user from filectx 2013-08-11 22:53:47 -05:00
Sean Farley
0ce35dca8c basefilectx: move hex from filectx
We also change the function call to use the hex method of its change context
so that it mirrors other such method calls.
2013-08-11 22:53:23 -05:00
Sean Farley
c0467a47e6 basefilectx: move node from filectx 2013-08-11 22:51:53 -05:00
Sean Farley
d6ce710e1b basefilectx: move linkrev from filectx 2013-08-11 22:51:41 -05:00
Sean Farley
6e99ebd143 basefilectx: move rev from filectx 2013-08-11 22:51:30 -05:00
Sean Farley
edc03d3f42 basefilectx: move filelog from filectx 2013-08-11 22:51:18 -05:00
Sean Farley
02848fc120 basefilectx: move flags from filectx 2013-08-11 22:51:04 -05:00
Sean Farley
f9fa7c5178 basefilectx: move filenode from filectx 2013-08-11 22:50:37 -05:00
Sean Farley
148e8ae6f6 basefilectx: move filerev from filectx 2013-08-11 22:50:15 -05:00
Sean Farley
ed823527a5 basefilectx: move __ne__ from filectx 2013-08-11 22:49:40 -05:00
Sean Farley
56f8d7a94b basefilectx: move __eq__ from filectx
We also add type checking for extra protection.
2013-08-11 22:49:03 -05:00
Sean Farley
cb1cda0d9a basefilectx: move __hash__ from filectx 2013-08-11 22:47:39 -05:00
Sean Farley
79dc9a8663 basefilectx: move __repr__ from filectx
We change the hardcoded 'filectx' to instead use type(self).__name__ so that objects that
inherit from basefilectx in the future will be able to use the same representation.
2013-08-11 22:46:54 -05:00
Sean Farley
6d40b2e84f basefilectx: move __str__ from filectx 2013-08-11 22:45:30 -05:00
Sean Farley
7d4c1da38f basefilectx: move __nonzero__ from filectx 2013-08-11 22:45:13 -05:00
Sean Farley
1b8c804677 basefilectx: move _repopath from filectx 2013-08-11 22:44:51 -05:00
Sean Farley
39c010ae44 basefilectx: move _filerev from filectx 2013-08-11 22:44:36 -05:00
Sean Farley
07765a7f23 basefilectx: move _filenode from filectx 2013-08-11 22:44:19 -05:00
Sean Farley
4e0ed076f1 basefilectx: move _changeid from filectx 2013-08-11 22:44:06 -05:00
Sean Farley
f3b2912cb9 basefilectx: move _filelog from filectx 2013-08-11 22:40:59 -05:00
Sean Farley
d011e7fbd2 basefilectx: add an empty class that will be used as a parent of file contexts
Similar to the refactoring of context, we split common logic from filectx to a
parent class called basefilectx that will be inherited by filectx,
workingfilectx, and memfilectx. This will allow a clear disinction of all the
file contexts:

- filectx: read-only access to a filerevision that is already present in the repo,
- workingfilectx: a filecontext that represents files from the working directory,
- memfilectx: a filecontext that represents files in-memory
2013-08-10 15:10:26 -05:00
Sean Farley
a4d6a7d01f workingctx: inherit from basectx instead of changectx 2013-08-05 18:44:18 -05:00
Sean Farley
580a78aa17 basectx: remove unnecessary check of instance
The refactoring of all the context objects allows us to simply pass a basectx
to the __new__ constructor and have it return the same object without
allocating new memory.
2013-08-06 15:11:31 -05:00
Sean Farley
be56583a99 basectx: move dirty from changectx 2013-08-05 18:42:41 -05:00
Sean Farley
88b0e436e0 basectx: move dirs from changectx 2013-08-05 18:41:56 -05:00
Sean Farley
dca5c7f7f2 basectx: move _dirs from changectx 2013-08-05 18:41:43 -05:00
Sean Farley
91c4597fc7 basectx: move diff from changectx 2013-08-05 18:41:12 -05:00
Sean Farley
bba5397f5e basectx: move match from changectx 2013-08-05 18:41:00 -05:00
Sean Farley
6f4798a10d basectx: move sub from changectx 2013-08-05 18:40:36 -05:00
Sean Farley
e090a5106f basectx: move flags from changectx 2013-08-05 18:28:54 -05:00
Sean Farley
2cd511aaf5 basectx: move filenode from changectx 2013-08-05 18:28:40 -05:00
Sean Farley
7d373f2849 basectx: move _fileinfo from changectx 2013-08-05 18:28:23 -05:00
Sean Farley
6af5ffc183 basectx: move p2 from changectx 2013-08-05 18:26:54 -05:00
Sean Farley
5d4918976c basectx: move p1 from changectx 2013-08-05 18:26:15 -05:00
Sean Farley
4d440ce0c1 basectx: move parents from changectx 2013-08-05 18:19:38 -05:00
Sean Farley
0767e83eed basectx: move mutable from changectx 2013-08-05 18:19:19 -05:00
Sean Farley
cfa3733573 basectx: move phasestr from changectx 2013-08-05 18:19:04 -05:00
Sean Farley
9944871a46 basectx: move manifest from changectx 2013-08-05 17:22:49 -05:00
Sean Farley
11dddf4758 basectx: move __iter__ from changectx 2013-08-05 17:22:18 -05:00
Sean Farley
61511fb277 basectx: move __getitem__ from changectx 2013-08-05 17:22:05 -05:00
Sean Farley
8e476c8cae basectx: move __contains__ from changectx 2013-08-05 17:21:38 -05:00
Sean Farley
647fcb2041 basectx: move substate from changectx 2013-08-05 17:21:23 -05:00
Sean Farley
023d601420 basectx: move __ne__ from changectx 2013-08-05 17:00:32 -05:00
Sean Farley
22e31d9ce0 basectx: move __eq__ from changectx
We also add type checking for extra protection.
2013-08-05 17:00:09 -05:00
Sean Farley
c271e20c45 basectx: move __repr__ from changectx
We change the hardcoded 'changectx' to instead use type(self).__name__ so that
objects that inherit from basectx in the future will be able to use the same
representation.
2013-08-02 18:24:08 -05:00
Sean Farley
a6645dbc9c basectx: move __int__ from changectx 2013-08-02 16:52:13 -05:00
Sean Farley
818788f1ff basectx: change _node to node() in hex
This allows a child class to overload the node() function and still share the
same code for hex().
2013-08-02 16:50:13 -05:00
Sean Farley
3113ec1337 basectx: move hex from changectx 2013-08-02 16:49:01 -05:00
Sean Farley
3531329b72 basectx: move node from changectx 2013-08-02 16:48:19 -05:00
Sean Farley
57662a823e basectx: move rev from changectx 2013-08-02 19:09:06 -05:00
Sean Farley
71b2479bed basectx: move __str__ from changectx 2013-08-02 16:46:23 -05:00
Sean Farley
576828ddf4 changectx: if passing a basectx then exit __init__ immediately 2013-08-06 16:42:41 -05:00
Sean Farley
7c95c6b91c basectx: return a copied context if changeid is already a basectx
This implements a copy constructor so that we can pass a basectx-derived object
in future refactorings.
2013-08-06 15:50:28 -05:00
Sean Farley
8bfc82b32e basectx: add an empty class that will be used as a parent of all contexts
At the moment, there is no simple way to check if an object is a context
because there is no common parent class. If there were, we could use
'isinstance' everywhere. Simply having memctx inherit from workingctx or
changectx would allow the use of 'isinstance' but that could lead to some
confusing situations of reading the code since we have three distinct concepts
of a context:

- changectx represents a changeset *already* in the repo, and is therefore immutable
- workingctx represents changes on disk in the working directory
- memctx represents changes solely in memory which may or may not be on disk

Therefore, I propose refactoring context.py to have all three contexts inherit
from a parent class 'basectx'.
2013-07-13 19:59:21 -05:00
Durham Goode
539b1f606b filectx: remove dependencies on filerev
Removing dependencies on filectx.filerev() makes it easier to create a filelog
implementation that doesn't have rev numbers.
2013-05-30 19:29:21 -07:00
Durham Goode
94d98a2fbb annotate: simplify annotate parent function
The annotate algorithm used a custom parents() function to try to reuse
filectx and filelogs. I simplified it a bit to rely more heavily on the
self.parents() which makes it work well with alternative filectx
implementations. I tested performance on a file with 5000+ revisions
but no renames, and on a file with 500 revisions repeating a series of
4 edits+renames and saw zero performance hit.  In fact, it was reliably a
couple milliseconds faster now.

Added the perfannotate command to contrib/perf.py for future use.
2013-05-30 19:29:03 -07:00
Durham Goode
bbcab6cdef filectx: refactor filectx.rev() to use filectx._changeid
The code in filectx.rev() was identical to filectx._changeid. Fixing this
allows alternative filectx implementations to only override _changeid.
2013-05-30 17:49:37 -07:00
Durham Goode
41d830bbb8 filecontext: use 'is not None' to check for filelog existence
Previously we used 'if filelog:' to check if the filelog existed. If the
instance did exist, this pattern then calls len() on the filelog to see
if it is empty. I'm developing a filelog replacement that doesn't have
len() implemented, so it's better to do an explicit 'is not None' check
here instead.

Also change _changeid() to return the _changeid attribute if it has it.
Previously it would try to obtain it from the _changectx(), and if that
did not exist it would construct the _changectx() using the linkrev. In
the extension I'm working on, filectx's don't have easy access to linkrevs
so avoiding this when possible is better.
2013-05-01 10:42:03 -07:00
FUJIWARA Katsunori
387c38ed85 annotate: discard refcount of discarded annotation for memory efficiency
Before this patch, refcount (managed in "needed") of the annotation
result is kept as 1, even if corresponding annotation result is
discarded from "hist", because it isn't decreased and discarded.

In the history tree including merging revision, the most recent common
ancestor of merged revisions is scanned twice. Refcount of such
ancestor never becomes 0, because refcount is started from 1 at the
second scanning.

This prevents annotation results of merging revision in "hist" from
being discarded, and decreases memory efficiency.

This patch discards refcount of the annotation result, when the
corresponding annotation is discarded from "hist".
2013-04-18 19:50:04 +09:00
FUJIWARA Katsunori
3a71637352 annotate: increase refcount of each revisions correctly (issue3841)
Before this patch, refcount (managed in "needed") of parents of each
revisions in "visit" is increased, only when parent is not annotated
yet (examined by "p not in hist").

But this causes less refcount of the revision like "A" in the tree
below ("A" is assumed as the second parent of "C"):

    A --- B --- C
      \       /
       \-----/

Steps of annotation for "C" in this case are shown below:

  1. for "C"
    1.1 increase refcount of "B"
    1.2 increase refcount of "A" (=> 1)
    1.3 defer annotation for "C"

  2. for "A"
    2.1 annotate for "A" (=> put result into "hist[A]")
    2.2 clear "pcache[A]" ("pcache[A] = []")

  3. for "B"
    3.1 not increase refcount of "A", because "A not in hist" is False
    3.2 annotate for "B"
    3.3 decrease refcount of "A" (=> 0)
    3.4 delete "hist[A]", even though "A" is still needed by "C"
    3.5 clear "pcache[B]"

  4. for "C", again
    4.1 not increase refcount of "B", because "B not in hist" is False
    4.2 increase refcount of "A" (=> 1)
    4.3 defer annotation for "C"

  5. for "A", again
    5.1 annotate for "A" (=> put result into "hist[A]", again)
    5.2 clear "pcache[A]"

  6. for "C", once again
    6.1 not increase refcount of "B", because "B not in hist" is False
    6.2 not increase refcount of "A", because "A not in hist" is False
    6.3 annotate for "C"
    6.4 decrease refcount of "A", and delete "hist[A]"
    6.5 decrease refcount of "B", and delete "hist[B]"
    6.6 clear "pcache[C]"

At step (5.1), annotation for "A" mis-recognizes that all lines are
created at "A", because "pcache[A]" already cleared at step (2.2)
prevents from scanning ancestors of "A".

So, annotation for "C" or its descendants loses information about "A"
or its ancestors.

The root cause of this problem is that refcount of "A" is decreased at
step (3.3), even though it isn't increased at step (3.1).

To increase refcount correctly, this patch increases refcount of each
parents of each revisions:

  - regardless of "p not in hist" or not, and
  - only once for each revisions in "visit" (by "not pcached")

In fact, this problem should occur only on legacy repositories in
which a filelog includes the merging between the revision and its
ancestor (as the second parent), because:

  - tree is scanned in depth-first

    without such merging, revisions in "visit" refer different
    revisions as parent each other

  - recent Mercurial doesn't allow such merging

    changelog and manifest can include such merging someway, but
    filelogs can't, because "localrepository._filecommit()" converts
    such merging request to linear history.

This patch tests merging cases below: these cases are from filelog of
"mercurial/commands.py" in the repository of Mercurial itself.

  - both parents are same

        10 --- 11 --- 12
                  \_/

        filelogrev: changesetid:
          10          526aca6bcb38
          11          05098100ff44
          12          2d4f4cfa81d6

  - the second parent is also ancestor of the first one

        37 --- 38 --- 39 --- 40
                  \________/

        filelogrev: changesetid:
          37          033dc4170fe6
          38          5ff1a23ce38c
          39          661a47367859
          40          a2ba99fd026f
2013-03-29 22:57:16 +09:00
FUJIWARA Katsunori
8355d1b7f6 annotate: reuse already calculated annotation
Before this patch, annotation is re-calculated even if it is already
calculated. This may cause unexpected annotation, because already
cleared "pcache" ("pcache[f] = []") prevents from scanning ancestors.

This patch reuses already calculated annotation if it is available.

In fact, "reusable" situation should be seen only on legacy
repositories in which a filelog include the merging between the
revision and its ancestor, because:

  - tree is scanned in depth-first

    without such merging, annotation result should be released soon

  - recent Mercurial doesn't allow such merging

    changelog and manifest can include such merging someway, but
    filelogs can't, because "localrepository._filecommit()" converts
    such merging request to linear history.
2013-03-29 22:57:15 +09:00
Bryan O'Sullivan
4a3a46aff6 ancestor: a new algorithm that is faster for nodes near tip
Instead of walking all the way to the root of the DAG, we generate
a set of candidate GCA revs, then figure out which ones will win
the race to the root (usually without needing to traverse all the
way to the root).

In the common case of nodes that are close to each other in both
revision number and topology, this is usually a big win: it makes
"hg --time debugancestors" up to 9 times faster than the more general
ancestor function when measured on heads of the linux-2.6 hg repo.

Victory is not assured, however. The older function can still win
by a large margin if one node is much closer to the root than the
other, or by a much smaller amount if one is an ancestor of the
other.

For now, we've also got a small paranoid harness function that calls
both ancestor functions on every input and ensures that they give
equivalent answers.

Even without the checker function, the old ancestor function needs
to stay alive for the time being, as its generality is used by
context.filectx.merge.
2013-04-16 10:08:18 -07:00
Mads Kiilerich
a8db98ea05 spelling: fix typos and spelling errors 2013-04-15 01:37:23 +02: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
82ca6ed101 merge with mpm 2013-04-02 08:58:42 -07:00
Takumi IINO
94c0d6fcb6 hgweb: show correct error message for i18n environment
If exception is error.LookupError and running in i18n environment,
below condition is always true.
Because msg is translated and dosen't contain 'manifest'.

    if util.safehasattr(err, 'name') and 'manifest' not in msg:

This patch creates a new exception class and uses it instead of
string match.
2013-02-15 18:07:14 +09:00
Pierre-Yves David
093fc83eab changectx: fix the handling of tip
We can not use `len(repo,changelog)`, it may be a filtered revision. We now use
`repo,changelog.tip()` to fetch this information.

The `tip` command is also fixed and tested

Thanks goes to Idan Kamara for the initial report.
2013-01-22 11:39:14 +01:00
David Schleimer
1dc36ff74c commit: factor out post-commit cleanup into workingctx
This pulls some of the logic for the cleanup that needs to happen
after a commit has been made otu of localrepo.commit and into
workingctx.  This is part of a larger refactoring effort that will
eventually allow us to perform some types of merges in-memory.
2013-02-08 05:36:08 -08:00
Mads Kiilerich
5787baee50 spelling: fix some minor issues found by spell checker 2013-02-10 18:24:29 +01:00
Pierre-Yves David
6c68029a60 clfilter: stronger detection of filtered changeset in changectx.__init__
We previously let some IndexError spill out of this function.

A new tests is added to check the command that spotted the error.
2013-01-16 05:21:11 +01:00
Kevin Bullock
93f9cb7f25 filtering: rename filters to their antonyms
Now that changelog filtering is in place, it's become evident that
naming the filters according to the set of revs _not_ included in the
filtered changelog is confusing. This is especially evident in the
collaborative branch cache scheme.

This changes the names of the filters to reflect the revs that _are_
included:

  hidden -> visible
  unserved -> served
  mutable -> immutable
  impactable -> base

repoview.filteredrevs is renamed to filterrevs, so that callers read a
bit more sensibly, e.g.:

  filterrevs('visible') # filter revs according to what's visible
2013-01-13 01:39:16 -06:00
Mads Kiilerich
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Pierre-Yves David
b7230b8249 context: retrieve hidden from filteredrevs
This prepare the dropping of the repo.hiddenrevs property
2013-01-03 18:51:16 +01:00
Pierre-Yves David
704a17970c clfilter: fallback to unfiltered version when linkrev point to filtered history
On `filectx`, linkrev may point to any revision in the repository. When the
repository is filtered this may lead to `filectx` trying to build `changectx`
for filtered revision. In such case we fallback to creating `changectx` on the
unfiltered version of the reposition. This fallback should not be an issue
because `changectx` from `filectx` are not used in complex operation that
care about filtering. It is complicated to work around the issue in a
clearer way as code raising such `filectx` rarely have access to the
repository directly.

Linkrevs create a lot of issue with filtering. It is stored in revlog entry at
creation time and never changed. Nothing prevent the changeset revision pointed
to become filtered. Several bogus behavior emerge from such situation. Those
bugs are complex to solve and not part of the current effort to install
filtering. This changeset is simple hack that prevent plain crash in favor on
minor misbehavior without visible effect.

This "hack" is longly documented in to code itself to help people that would
look at it in the future.
2012-12-29 00:40:18 +01:00
Pierre-Yves David
0571efafd8 obsolete: introduce a troubles method on context
A troubled changeset may be affected by multiple trouble at the same time. This
new method returns a list of all troubles affecting a changes.
2012-12-17 15:17:54 +01:00
Pierre-Yves David
c1a745d834 obsolete: introduce a troubled method on context
Allows to quickly check if a changeset is affected by any troubles.
(troubles are: unstable, bumped and divergent)
2012-12-17 15:06:15 +01:00
Pierre-Yves David
985f5be6c5 clfilter: ensure context raise RepoLookupError when the revision is filtered
Currently the code path of `changectx(filteredrepo, rev)` call
`filteredrepo.changelog.node(rev)`. When `rev` is filtered this raise an
unhandled `IndexError`. This case now raise a `RepoLookupError` as other
error case do.
2012-12-17 18:09:41 +01:00
Pierre-Yves David
38afff41e0 obsolete: add a divergent method on context
The same we have `unstable` and `bumped`. Convenient method to access troubles
information in general may land later.

This get actual use and testing in the next changesets.
2012-12-12 03:20:49 +01:00
David Schleimer
3dbabdb2fc merge: support calculating merge actions against non-working contexts
This is not currently used.  It is instead a pre-requisite to
performing non-conflicting grafts in memory, which a subsequent patch
will do.
2012-12-04 12:54:18 -08:00
Pierre-Yves David
c2a31b5437 clfilter: prevent unwanted warning about filtered parents as unknown
During changectx __init__ the dirstate's parents MAY be checked. If
the repo is filtered, this check will complain "working directory has
unknown parents" even if the parents are perfectly known.

This may happen when the repo is used for serving and the dirstate has
parents that are secret, as those secret changesets will be filtered.
2012-10-08 17:15:08 +02:00
Pierre-Yves David
b3f5aa66c1 context: add a bumped method to changectx
Same as `unstable()`, returns true if the changeset is bumped.
2012-10-19 00:43:44 +02:00
Pierre-Yves David
bc08c6dbf1 obsolete: rename getobscache into getrevs
The old name was not very good for two reasons:
- caller does not care about "cache",
- set of revision returned may not be obsolete at all.

The new name was suggested by Kevin Bullock.
2012-10-19 00:28:13 +02:00
Sean Farley
26d22253ab phases: add a phase and phasestr method to file context 2012-10-16 17:09:50 -05:00