Commit Graph

684 Commits

Author SHA1 Message Date
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
FUJIWARA Katsunori
f8ea001372 context: add "descendant()" to changectx for efficient descendant examination
This patch adds "descendant()", which uses "revlog.descendant()" for
descendant examination, to changectx.

This implementation is more efficient than "new in old.descendants()"
expression, because:

  - "changectx.descendants()" creates temporary "changectx" objects,
    but "revlog.descendant()" doesn't

    "revlog.descendant()" checks only revision numbers of descendants.

  - "revlog.descendant()" stops scanning, when scanning of all
    revisions less than one of examination target is finished

    this can avoid useless scanning in "not descendant" case.
2012-09-18 21:39:12 +09:00
Pierre-Yves David
785d90eba0 obsolete: introduce caches for all meaningful sets
This changeset introduces caches on the `obsstore` that keeps track of sets of
revisions meaningful for obsolescence related logics. For now they are:

- obsolete: changesets used as precursors (and not public),
- extinct:  obsolete changesets with osbolete descendants only,
- unstable: non obsolete changesets with obsolete ancestors.

The cache is accessed using the `getobscache(repo, '<set-name>')` function which
builds the cache on demand. The `clearobscaches(repo)` function takes care of
clearing the caches if any.

Caches are cleared when one of these events happens:

- a new marker is added,
- a new changeset is added,
- some changesets are made public,
- some public changesets are demoted to draft or secret.

Declaration of more sets is made easy because we will have to handle at least
two other "troubles" (latecomer and conflicting).

Caches are now used by revset and changectx. It is usually not much more
expensive to compute the whole set than to check the property of a few elements.
The performance boost is welcome in case we apply obsolescence logic on a lot of
revisions. This makes the feature usable!
2012-08-28 20:52:04 +02:00
Mads Kiilerich
e973af65d0 improve some comments and docstrings, fixing issues found when spell checking 2012-08-21 02:41:20 +02:00
Mads Kiilerich
2372d51b68 fix wording and not-completely-trivial spelling errors and bad docstrings 2012-08-15 22:39:18 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Patrick Mezard
5d1bd7fadf context: simplify workingctx._parents 2012-08-02 17:48:58 +02:00
Pierre-Yves David
edc2b520d9 hidden: move hiddenrevs set on the repository
This set is always accessed through the repo for now. Having this set
carried by the changelog make it complicated to:

- initialize it, computing hidden set may involve revset call
- lazy compute it, (1) only the changelog can detect someone access it,
                   (2) only the repo have enought knowledge to compute it.

In later version I expect he changelog to apply filtering itself and the set to
be carried by changelog again.
2012-07-16 17:44:46 +02:00
Pierre-Yves David
9e13d2931c obsolete: compute extinct changesets
`extinct` changesets are obsolete changesets with obsolete descendants only. They
are of no interest anymore and can be:

- exclude from exchange
- hidden to the user in most situation
- safely garbage collected

This changeset just allows mercurial to detect them.

The implementation is a bit naive, as for unstable changesets. We better use a
simple revset query and a cache, but simple version comes first.
2012-07-06 19:34:09 +02:00
Pierre-Yves David
2444c95546 obsolete: compute unstable changeset
An unstable changeset is a changeset *not* obsolete but with some obsolete
ancestors.

The current logic to decide if a changeset is unstable is naive and very
inefficient. A better solution is to compute the set of unstable changeset with
a simple revset and to cache the result. But this require cache invalidation
logic. Simpler version goes first.
2012-07-06 00:18:09 +02:00
Pierre-Yves David
5793a07f30 obsolete: fix context.obsolete() method
- obsstore attribut name changed.
- public changeset can't be obsolete
2012-07-04 17:26:51 +02:00
Pierre-Yves.David@ens-lyon.org
3c02b8eab1 obsolete: function and method to access some obsolete data
An `obsolete` boolean property is added to changeset context. Function to get
obsolete marker object from a changeset context are added to the obsolete
module.
2012-06-06 01:56:58 +02:00
Matt Mackall
cbbdbdd866 copies: re-include root directory in directory rename detection (issue3511) 2012-06-27 13:41:04 -05:00
Bryan O'Sullivan
141bd09daa revlog: descendants(*revs) becomes descendants(revs) (API)
Once again making the API more rational, as with ancestors.
2012-06-01 12:45:16 -07:00
Bryan O'Sullivan
6ba97b40c1 revlog: ancestors(*revs) becomes ancestors(revs) (API)
Accepting a variable number of arguments as the old API did is
deeply ugly, particularly as it means the API can't be extended
with new arguments.  Partly as a result, we have at least three
different implementations of the same ancestors algorithm (!?).

Most callers were forced to call ancestors(*somelist), adding to
both inefficiency and ugliness.
2012-06-01 12:37:18 -07:00
Matt Mackall
d53510c6a2 merge with stable 2012-05-21 16:35:27 -05:00
Matt Mackall
ca006af287 context: grudging accept longs in constructor 2012-05-21 16:32:50 -05:00
Brodie Rao
ab32f1721d context: add changectx.closesbranch() method
This removes the duplicated code for inspecting the 'close' extra field in
a changeset.
2012-05-13 14:04:06 +02:00
Brodie Rao
d36ae7f264 localrepo: add branchtip() method for faster single-branch lookups
For the PyPy repo with 744 branches and 843 branch heads, this brings
hg log -r default over NFS from:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
        3249            0      1.3222      1.3222   <open>
        3244            0      0.6211      0.6211   <method 'close' of 'file' objects>
        3243            0      0.0800      0.0800   <method 'read' of 'file' objects>
        3241            0      0.0660      0.0660   <method 'seek' of 'file' objects>
        3905            0      0.0476      0.0476   <zlib.decompress>
        3281            0      2.6756      0.0472   mercurial.changelog:182(read)
       +3281            0      2.5256      0.0453   +mercurial.revlog:881(revision)
       +3276            0      0.0389      0.0196   +mercurial.changelog:28(decodeextra)
       +6562            0      0.0123      0.0123   +<method 'split' of 'str' objects>
       +6562            0      0.0408      0.0073   +mercurial.encoding:61(tolocal)
       +3281            0      0.0054      0.0054   +<method 'index' of 'str' objects>
        3241            0      2.2464      0.0456   mercurial.revlog:818(_loadchunk)
       +3241            0      0.6205      0.6205   +<method 'close' of 'file' objects>
       +3241            0      0.0765      0.0765   +<method 'read' of 'file' objects>
       +3241            0      0.0660      0.0660   +<method 'seek' of 'file' objects>
       +3241            0      1.4209      0.0135   +mercurial.store:374(__call__)
       +3241            0      0.0122      0.0107   +mercurial.revlog:810(_addchunk)
        3281            0      2.5256      0.0453   mercurial.revlog:881(revision)
       +3280            0      0.0175      0.0175   +mercurial.revlog:305(rev)
       +3281            0      2.2819      0.0119   +mercurial.revlog:847(_chunkraw)
       +3281            0      0.0603      0.0083   +mercurial.revlog:945(_checkhash)
       +3281            0      0.0051      0.0051   +mercurial.revlog:349(flags)
       +3281            0      0.0040      0.0040   +<mercurial.mpatch.patches>
       13682            0      0.0479      0.0248   <method 'decode' of 'str' objects>
       +7418            0      0.0228      0.0076   +encodings.utf_8:15(decode)
          +1            0      0.0003      0.0000   +encodings:71(search_function)
        3248            0      1.3995      0.0246   mercurial.scmutil:218(__call__)
       +3248            0      1.3222      1.3222   +<open>
       +3248            0      0.0235      0.0184   +os.path:80(split)
       +3248            0      0.0084      0.0068   +mercurial.scmutil:92(__call__)
Time: real 2.750 secs (user 0.680+0.000 sys 0.360+0.000)

down to:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
          55           31      0.0197      0.0163   <__import__>
          +1            0      0.0006      0.0002   +mercurial.context:8(<module>)
          +1            0      0.0042      0.0001   +mercurial.revlog:12(<module>)
          +1            0      0.0002      0.0001   +mercurial.match:8(<module>)
          +1            0      0.0003      0.0001   +mercurial.dirstate:7(<module>)
          +1            0      0.0057      0.0001   +mercurial.changelog:8(<module>)
           1            0      0.0117      0.0032   mercurial.localrepo:525(_readbranchcache)
        +844            0      0.0015      0.0015   +<binascii.unhexlify>
        +845            0      0.0010      0.0010   +<method 'split' of 'str' objects>
        +843            0      0.0045      0.0009   +mercurial.encoding:61(tolocal)
        +843            0      0.0004      0.0004   +<method 'setdefault' of 'dict' objects>
          +1            0      0.0003      0.0003   +<method 'close' of 'file' objects>
           3            0      0.0029      0.0029   <method 'read' of 'file' objects>
           9            0      0.0018      0.0018   <open>
         990            0      0.0017      0.0017   <binascii.unhexlify>
          53            0      0.0016      0.0016   mercurial.demandimport:43(__init__)
         862            0      0.0015      0.0015   <_codecs.utf_8_decode>
         862            0      0.0037      0.0014   <method 'decode' of 'str' objects>
        +862            0      0.0023      0.0008   +encodings.utf_8:15(decode)
         981            0      0.0011      0.0011   <method 'split' of 'str' objects>
         861            0      0.0046      0.0009   mercurial.encoding:61(tolocal)
        +861            0      0.0037      0.0014   +<method 'decode' of 'str' objects>
         862            0      0.0023      0.0008   encodings.utf_8:15(decode)
        +862            0      0.0015      0.0015   +<_codecs.utf_8_decode>
           4            0      0.0008      0.0008   <method 'close' of 'file' objects>
         179          154      0.0202      0.0004   mercurial.demandimport:83(__getattribute__)
         +36           11      0.0199      0.0003   +mercurial.demandimport:55(_load)
         +72            0      0.0001      0.0001   +mercurial.demandimport:83(__getattribute__)
         +36            0      0.0000      0.0000   +<getattr>
           1            0      0.0015      0.0004   mercurial.tags:148(_readtagcache)
Time: real 0.060 secs (user 0.030+0.000 sys 0.010+0.000)
2012-05-13 14:04:04 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Patrick Mezard
641ee7d3ba phases: introduce phasecache
The original motivation was changectx.phase() had special logic to
correctly lookup in repo._phaserev, including invalidating it when
necessary. And at other places, repo._phaserev was accessed directly.

This led to the discovery that phases state including _phaseroots,
_phaserev and _dirtyphase was manipulated in localrepository.py,
phases.py, repair.py, etc. phasecache helps encapsulating that.

This patch replaces all phase state in localrepo with phasecache and
adjust related code except for advance/retractboundary() in phases.
These still access to phasecache internals directly. This will be
addressed in a followup.
2012-05-12 00:24:07 +02:00
Idan Kamara
6360e96576 context: fix call to util.safehasattr 2012-05-09 02:46:58 +03:00
Matt Mackall
4d062ed81e context: add copies method with caching 2012-05-06 14:37:51 -05:00
Matt Mackall
e38c9f282e filectx: handle some other simple cases for finding merge ancestor 2012-05-06 14:20:53 -05:00
Matt Mackall
da4217097f filectx: make ancestor require actx
When grafting or rebasing, we need to know the target ancestor.
2012-05-04 17:27:14 -05:00
Patrick Mezard
036643538d update: make --check abort with dirty subrepos
Aka "we could use dirty() but... yeah let's use it"
2012-04-23 12:12:04 +02:00
Patrick Mezard
82044cab98 context: revert workingctx.ancestors() followfirst option
It was introduced by mistake in df40a7c0d6aa.
2012-04-11 11:29:12 +02:00
Matt Mackall
35b009e3d3 context: use rev for changelog lookup
Faster when we're doing numeric scanning
2012-04-08 12:38:08 -05:00
Matt Mackall
3a03c51f0d context: internalize lookup logic
This allows us to avoid doing rev->node->rev lookups on silly
instances like "0", which end up caching the whole nodemap.
2012-04-08 12:38:07 -05:00
Matt Mackall
560dd93d34 merge with stable 2012-04-06 15:18:14 -05:00
Patrick Mezard
f535cae825 context: make changectx.mutable() benefit from .phase() logic
This fixes "hg qimport -r null". Previous versions used to:
- Traceback because null revision mutability was not defined
- Add an empty -1.diff patch to the series

The error message:

  abort: revision -1 is not mutable

is symptomatic of a deeper problem in phase command revision handling. It could
be fixed easily in the command itself but I feel a better fix must be done in
phase API which raises the issue of phase updates atomicity: aborting in
phases.advanceboundary/retractboundary requires a better rollback behaviour to
avoid partial changes.
2012-04-05 19:15:23 +02:00
Patrick Mezard
57671f9108 context: add followfirst arg to filectx and workingfilectx
When _followfirst() revset was introduced it seemed to be the sole user of such
an argument, so filectx.ancestors() was duplicated and modified instead. It now
appears this argument could be used when computing the set of files to be
considered when --patch or --stat are passed along with --follow FILE.
2012-02-26 17:10:57 +01:00
Matt Mackall
72210502d5 merge with stable 2012-02-22 17:36:33 -06:00
FUJIWARA Katsunori
4a78e2a3a1 context: use 'changectx.dirs()' in 'walk()' for directory patterns
this patch uses 'changectx.dirs()' instead of nested loop, to examine
whether specified pattern is related to the context as a directory or not.
2012-02-23 00:07:54 +09:00
FUJIWARA Katsunori
a4ea09aa29 context: add 'dirs()' to changectx/workingctx for directory patterns
this patch adds 'dirs()' to changectx/workingctx, which returns map of
all directories deduced from manifest, to examine whether specified
pattern is related to the context as directory or not quickly.

'workingctx.dirs()' uses 'dirstate.dirs()' rather than building
another copy of it.
2012-02-23 00:07:54 +09:00
Patrick Mezard
48bbc97548 context: make workingctx.forget() really warn about untracked files 2012-02-16 12:56:48 +01:00
Matt Mackall
ee1d294b90 merge with stable 2012-02-16 16:40:29 -06:00
Matt Mackall
e3a172f2f0 merge: don't use unknown()
This removes use of unknown files for building the synthetic working
directory manifest used by manifestmerge. Instead, we adopt the
strategy used by _checkunknown.

Side-effect: unknown files are no longer moved by remote directory
renames, and now are left alone like ignored files.
2012-02-09 17:04:17 -06:00
David M. Carr
560a2fff89 forget: fix subrepo recursion for explicit path handling
When support for handling explicit paths in subrepos was added to the forget
command (155b89136ae7), subrepo recursion wasn't taken into account.  This
change fixes that by pulling the majority of the logic of commands.forget into
cmdutil.forget, which can then be called from both there and subrepo.forget.
2012-01-17 19:10:59 -05:00
Matt Mackall
8985b466e0 merge with stable 2012-01-15 18:00:01 -06:00
Christian Ebert
4fcf579deb filectx: typo in comment 2012-01-15 13:39:09 +01:00
Yuya Nishihara
0bf3f9f6fd filectx: fix cmp() of file starting with '\1\n'
If file data starts with '\1\n', it will be escaped in the revlog to
create an empty metadata block, thus adding four bytes to the size in
the revlog size index. There's no way to detect that this has happened
in filelog.size() faster than decompressing each revision [1].

For filectx.cmp(), we have the size of the file in the working directory
available. If it differs by exactly four bytes, it may be this case, so
do a full comparison.

 [1]: http://markmail.org/message/5akdbmmqx7vq2fsg
2012-01-12 00:49:45 +09:00
Matt Mackall
e0479875b3 merge with stable 2012-01-13 11:29:53 -06:00
Pierre-Yves David
8cf1ba5eea phases: add a phasestr method on context 2011-12-29 04:40:09 +01:00
Pierre-Yves David
5262f88500 phases: store phase values in constant instead of using raw integer
Phases constant are named after the phase name. Usage of integer have been
replaced by proper constant.
2012-01-06 09:51:35 +01:00
Laurens Holst
8daae4999d context: add isbinary function 2011-12-21 18:20:15 +01:00
Matt Mackall
3044265f69 windows: recompute flags when committing a merge (issue1802)
Before this patch, Windows always did the wrong thing with exec bits
when committing a merge: consult the flags in first parent.

Now we manually recompute the result of merging flags at commit time,
which almost always does the right thing (except when there are
conflicts between symlink and exec flags).

To do this, we:

- pull flag synthesis out into its own function
- delay building this function unless it's needed
- add a merge case that compares flags in local and other against the ancestor

This has been tested in multiple ways on Linux:

- running the whole test suite with both old and new code in place,
  checking for differences in each flags() result
- running the whole test suite while comparing real on-disk flags
  against synthetic ones for merges
- test-issue1802 (from Martin Geisler) which disables exec bit
  checking on Unix
2011-10-22 16:12:33 -05:00
Pierre-Yves David
051b2da122 phases: implement `phase() and hidden()` method for workingctx
Working ctx don't have revision number and need a dedicated implementation.
2011-12-21 23:56:15 +01:00
Pierre-Yves David
164efe3ee5 phases: add a mutable boolean property on context 2011-12-19 23:31:38 +01:00
Patrick Mezard
cc3315778f annotate: support diff whitespace filtering flags (issue3030)
splitblock() was added to handle blocks returned by bdiff.blocks() which differ
only by blank lines but are not made only of blank lines. I do not know exactly
how it could happen but mdiff.blocks() threshold behaviour makes me think it
can if those blocks are made of very popular lines mixed with popular blank
lines. If it is proven to be wrong, the function can be dropped.

The first implementation made annotate share diff configuration entries. But it
looks like users will user -w/b for annotate but not for diff, on both the
command line and hgweb. Since the latter cannot use command line entries, we
introduce a new [annotate] section duplicating the diff whitespace options.
2011-11-18 12:04:31 +01:00
Pierre-Yves David
aa9ca9ca1c phases: improve context.phase()
* force recompute of outdated cache
* handle nullrev case
2011-11-07 18:37:58 +01:00
Pierre-Yves David
cbc7e13374 phases: add a phase method to context 2011-10-18 18:25:53 +02:00