Commit Graph

18551 Commits

Author SHA1 Message Date
Martin von Zweigbergk
66dd6b9e1c match: remove support for non-include patterns from includematcher
The includematcher will always get at least one include pattern and
will never get any non-include patterns, so we can remove most of the
code in it. This patch does mostly straight-forward deletions of
code. We will clean up further later.
2017-05-19 13:36:34 -07:00
Martin von Zweigbergk
1ba59afc49 match: split up main matcher into patternmatcher and includematcher
At this point the includematcher is an exact copy of the main matcher
class. We will specialize and simplify both classes in the following
patches. This initial unmodified copy is just to make the differences
clearer. We also rename the main matcher to "patternmatcher" for
consistency.

I may eventually merge this new includematcher back into the main
matcher, but I think doing it this way makes the intermediate steps
clearer regardless.
2017-05-19 22:36:14 -07:00
Martin von Zweigbergk
ce94f073cb match: remove support for exact matching from main matcher class
Exact matching is now handled by the exactmatcher class.

We can safely remove _files from the __repr__() implementation,
because even though the field is set, the patternspat field is enough
for the representation to be unambiguous (which was not the case when
the matcher could handle exact matches).
2017-05-18 23:39:39 -07:00
Martin von Zweigbergk
6cc2daf5d6 match: handle exact matching using new exactmatcher 2017-05-17 09:26:15 -07:00
Martin von Zweigbergk
5e8aba2103 merge: use intersectmatchers() in "m2-vs-ma optimization"
It doesn't seem like this can actually happen, but seems like cleaner
anyway.
2017-05-12 16:33:33 -07:00
Martin von Zweigbergk
7767620115 match: handle includes using new intersectionmatcher 2017-05-12 23:12:05 -07:00
Martin von Zweigbergk
8a54c0d671 match: move entire uipath() implementation to basematcher
Even though most matchers will always want to use the relative path in
uipath(), when we add support for intersecting matcher, we will want
to control which form to use for any kind of matcher without knowing
the type (see next patch), so we need the implementation on the base
class.

Also rename the attribute from "pathrestricted" to "relativeuipath"
since there actually are cases where we match everything but still use
relative paths (like when the user runs "hg files .." from inside
mercurial/).
2017-05-25 14:32:56 -07:00
Pierre-Yves David
35e577df8a local-clone: also copy tags related caches
This caches provide a large speedup for some repositories. Keeping it around is
valuable.
2017-05-25 12:09:09 +02:00
Pierre-Yves David
540a8c90f4 local-clone: also copy revs-branch-cache files
This cache provides a large speedup for some repositories. Keeping it around is
valuable.
2017-05-25 12:05:33 +02:00
Pierre-Yves David
2fbd792e60 local-clone: extract the listing of caches to copy
Right now, the clone only copies the branchmap caches. There are multiple
other valuable caches that we should copy and extensions might add their own.
So we add a function to list the cache files to copy from the repository. The
repository argument is unused but extensions will want it.
2017-05-25 11:59:07 +02:00
Pierre-Yves David
d09b0ef1ef local-clone: extract the closure copying caches
Closures often get on the way. They are not much value in having that as a
closure so I'm extracting it at the module level.
2017-05-25 11:55:00 +02:00
Pierre-Yves David
1a819b73cb obsolete: fix relevant-obsmarkers computation on pruned changeset
The markers pruning a node was not directly considered relevant for the pruned
node, only to its parents.

This went unnoticed during obsmarkers exchange because all
ancestors of the pruned node would be included in the computation.
This still affects obsmarkers exchange a bit since "inline" prune markers would
be ignored (see second test case). This went unnoticed, because in such case,
we always push another obsolescence markers for that node.

We add explicit tests covering this case.

(The set of relevant changeset is use in the obsmarkers discovery protocol used
in the evolve experimental extension, the impact will be handled on the
extension side).
2017-05-25 19:37:29 +02:00
Siddharth Agarwal
51c7d417b5 annotate: add a new experimental --skip option to skip revs
This option is most useful for mechanical code modifications, especially ones
that retain the same number of lines.
2017-05-24 19:39:33 -07:00
Siddharth Agarwal
259f128038 annotate: add core algorithm to skip a rev
The core algorithm is inspired by git hyper-blame, implemented at
https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/master/git_hyper_blame.py.

The heuristic is as documented in the comments.
2017-05-24 19:07:14 -07:00
Siddharth Agarwal
19daf128b1 annotate: make pair take all parents to pair against
In upcoming patches we'll need to be aware of all parents at the same time.

This also exposes a potential bug: if a line can be annotated with both parents
of a merge commit, it'll always be annotated with p2, not p1. I'm not sure if
that's what we want, but at least the code makes it clear now.
2017-05-24 17:40:08 -07:00
Siddharth Agarwal
136c8f6192 annotate: move pair function to top level
We'll want to make this more complicated and have unit tests for it in upcoming
patches.
2017-05-24 17:38:28 -07:00
Yuya Nishihara
6f42d09a39 bookmarks: fix check of hash-like name to not abort by ambiguous identifier
'mark in repo' may raise LookupError. I set it to not be warned since bookmark
names shorter than 4 chars aren't checked and short names are likely to be
ambiguous.
2017-05-25 23:20:00 +09:00
Yuya Nishihara
75533e6603 localrepo: document that __contains__() may raise LookupError 2017-05-25 23:18:02 +09:00
Pierre-Yves David
214b54869e hidden: drop outdated comment about "dynamic" performance
This comment is now irrelevant since we have a faster algorithm and no cache.
2017-05-21 15:56:02 +02:00
Pierre-Yves David
dc83ea2d5f hidden: unify the static and dynamic blocker logic
We no longer have cache and they both work the same way. Unifying the logic
simplify the code and reduce the amount of set copies.
2017-05-21 15:47:06 +02:00
Pierre-Yves David
74dcd06928 hidden: drop the hidden cache logic
The improvement in time complexitty and the speed-up in computation is large
enough that the has little use now. Its update time can even gets in the way. So
we drop it.

This will allow us to unify the static/dynamic blockers logic in the next
changeset.
2017-05-21 15:53:08 +02:00
Pierre-Yves David
103db3f051 hidden: simplify the computation of consistency blocker
For a couple of years, we now have precomputed set for all mutable phases. We
can use this set restrict our search and quickly detect non-hideable children of
hideable changesets.  This speeds up the hidden computation. See docstring of
the new function for details.

This new version reuses the '_domainancestors' function to keep the computation
of revealed changeset in O(len(visible))

Below are perfvolatilesets timing from two Mozilla repositories with different
contents. hidden cache is disabled while obtaining them.

1) Mozilla repository with:
 * 400667 changesets
 * 35 hidden changesets (first rev-268334)
 * 288 visible drafts
 * 1 unstable changeset

Before:
! visible
! wall 0.001744 comb 0.000000 user 0.000000 sys 0.000000 (best of 1563)

After:
! visible
! wall 0.000742 comb 0.000000 user 0.000000 sys 0.000000 (best of 3755)


The timing above include the computation of obsolete changeset:
! obsolete
! wall 0.000396 comb 0.000000 user 0.000000 sys 0.000000 (best of 6816)

So adjusted time give 1.3ms before versus 0.3ms after. A 4x speedup.

2) Mozilla repository with:
 * 405645 changesets
 * 4312 hidden changesets (first rev-326004)
 * 264 visible drafts
 * 1 unstable changeset

Before:
! visible
! wall 0.025476 comb 0.030000 user 0.030000 sys 0.000000 (best of 111)


After
! visible
! wall 0.007703 comb 0.010000 user 0.010000 sys 0.000000 (best of 358)


The timing above include the computation of obsolete changeset:
! obsolete
! wall 0.006408 comb 0.010000 user 0.010000 sys 0.000000 (best of 404)

So adjusted time give 19ms before versus 1.3ms after. A 17x speedup.
2017-05-21 16:01:20 +02:00
Pierre-Yves David
9d76dff252 hidden: use _domainancestors to compute revs revealed by dynamic blocker
The complexity of computing the revealed changesets is now 'O(revealed)'.
This massively speeds up the computation on large repository. Moving it to the
millisecond range.

Below are timing from two Mozilla repositories with different contents:

1) mozilla repository with:
 * 400667 changesets
 * 35 hidden changesets (first rev-268334)
 * 288 visible drafts
 * obsolete working copy (dynamicblockers),

Before:
! visible
! wall 0.030247 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)

After:
! visible
! wall 0.000585 comb 0.000000 user 0.000000 sys 0.000000 (best of 4221)

The timing above include the computation of obsolete changeset:
! obsolete
! wall 0.000396 comb 0.000000 user 0.000000 sys 0.000000 (best of 6816)

So adjusted time give 30ms before versus 0.2ms after. A 150x speedup.

2) mozilla repository with:
 * 405645 changesets
 * 4312 hidden changesets (first rev-326004)
 * 264 visible drafts
 * obsolete working copy (dynamicblockers),

Before:
! visible
! wall 0.168658 comb 0.170000 user 0.170000 sys 0.000000 (best of 48)

After
! visible
! wall 0.008612 comb 0.010000 user 0.010000 sys 0.000000 (best of 325)

The timing above include the computation of obsolete changeset:
! obsolete
! wall 0.006408 comb 0.010000 user 0.010000 sys 0.000000 (best of 404)

So adjusted time give 160ms before versus 2ms after. A 75x speedup.
2017-05-21 15:35:21 +02:00
Pierre-Yves David
33754edd6e hidden: add a function returning ancestors of revs within a domain
See documentation for details. This will be used to improve the hidden
computation algorithm. See new changesets for usage.
2017-05-21 15:21:46 +02:00
Pierre-Yves David
11f26a2c51 strip: use the 'writenewbundle' function to get bundle on disk
This will ensure the backup bundle use the best available logic (eg: includes
relevant caches so that we loose less of them on strip.)
2017-05-05 18:15:42 +02:00
Martin von Zweigbergk
6f7738b741 match: remove support for excludes from matcher class
The support is now provided by differencematcher() and still available
via the match() function.
2017-05-16 22:15:42 -07:00
Martin von Zweigbergk
8d0d310985 match: handle excludes using new differencematcher
As I've said on earlier patches, I'm hoping to use more composition of
simpler matchers instead of the single complex matcher we currently
have. This extracts a first new matcher that composes two other
matchers. It matches if the first matcher matches but the second does
not. As such, we can use it for excludes, which this patch also
does. We'll remove the now-unncessary code for excludes in the next
patch.
2017-05-16 16:36:48 -07:00
Martin von Zweigbergk
2724c60601 match: override matchfn() the usual way in subdirmatcher 2017-05-25 09:52:56 -07:00
Martin von Zweigbergk
cb783946fc match: make matchfn a method on the class
This makes it easier to override in subclasses, so they don't have to
assign the attribute with a lambda.
2017-05-25 09:52:49 -07:00
Boris Feld
f7e21a1d7c util: raise ParseError when parsing dates (BC)
d46a7814be5f refactored util.parsedate in order to raise ValueError instead
of Abort for using with ui.configwith. It causes several problems, putting
arbitrary bytes in ValueError can cause issues with Python 3. Moreover, we
added a function to convert ValueError exceptions back to Abort.

A better approach would be to make parsedate raises ParseError, removing
the convert function and update configwith to also catch ParseError.

The side-effect is that error message when giving an invalid date in CLI
change from:

  abort: invalid date: 'foo bar'

to:

  hg: parse error: invalid date: 'foo bar'

I'm not sure if it's an acceptable change, I found personally the error
message more clear but more verbose too.
2017-05-24 17:50:17 +02:00
Martin von Zweigbergk
de3c23309e match: fix visitdir for roots of includes
I'm hoping to rewrite the matcher so excludes are handled by
composition of one matcher with another matcher where the second
matcher has only includes. For that to work, we need to make
visitdir() to return 'all' for directory 'foo' for a '-I foo' matcher.
2017-05-16 14:31:21 -07:00
Martin von Zweigbergk
605d9dfcea match: make subdirmatcher extend basematcher
This makes the subdirmatcher not depend on the main matcher, giving us
more freedom to modify that (specifically, it will lose it _always
field in a while).
2017-05-17 23:02:42 -07:00
Martin von Zweigbergk
5e75aba9b0 match: make basematcher._files a @propertycache
This will make it easier to override in subclasses (otherwise the
function @propertycache object will be replaced by the
super-constructor call)..
2017-05-19 10:17:08 -07:00
Martin von Zweigbergk
c9664eeaa0 match: extract base class for matchers
We will soon start splitting up the current matcher class into more
specialized classes, so we'll want a base class for all the things
that don't vary much between different matchers.
2017-05-17 23:45:13 -07:00
Martin von Zweigbergk
7f477af2bf debugwalk: also print matcher representation
This will make the effect of coming patches clearer.
2017-05-22 11:08:52 -07:00
Pierre-Yves David
c1ca9ad6ee transaction: run _writejournal unfiltered
The function use the length of the repository, something affected by filtering.
It seems better to use the unfiltered length here.

Credit for finding this goes to Durham Goode.
2017-05-25 01:45:52 +02:00
Augie Fackler
5a83391bf4 bookmarks: warn about bookmark names that unambiguously resolve to a node (BC)
I just burned myself on this today because I left out the -r in my `hg
bookmark` command, which then left me confused because I didn't notice
the bookmark I created in the wrong place that was silently shadowing
the revision I was trying to check out. Let's warn the user.

This patch only enforces the check on bookmark names 4 characters long
or longer. We can tweak that if we'd like, I selected that since
that's the fewest characters shortest will use in the templater
output.

A previous version of this patch rejected such bookmarks. It was
proposed during review (and I agree) that the behavior change for a
bookmark named "cafe" or similar as history accumulated was a little
too weird, but that the warning definitely has merit.
2017-05-22 19:18:12 -04:00
Yuya Nishihara
ef50f332aa pycompat: try __bytes__() to convert object to bytestr
It should be better than using __str__() unconditionally.
2017-05-04 11:51:07 +09:00
Boris Feld
e12d51e5f8 ui: fix ui.configdate for invalid dates
d46a7814be5f introduced util._parsedate with the aim to be used in
ui.configdate but ui.configdate was using util.parsedate instead. It have the
impact of raising an AbortError in case of an invalid date instead of a
ConfigError exception. Fix ui.configdate to use the right function and add a
test for invalid dates.

Thanks to Yuya for the catch!
2017-05-23 15:44:50 +02:00
Martin von Zweigbergk
2410b10b5f match: use ProgrammingError where appropriate 2017-05-23 08:49:01 -07:00
Pulkit Goyal
dfd06a1929 revlog: raise error.WdirUnsupported from revlog.node() if wdirrev is passed
When we try to run, 'hg debugrevspec 'branch(wdir())'', it throws an index error
and blows up. Lets raise the WdirUnsupported if wdir() is passed so that we can
catch that later.
2017-05-23 01:30:36 +05:30
Pulkit Goyal
b9822a4f60 revset: add support for ancestors(wdir())
This is a part of extending support for wdir() predicate.
2017-05-23 01:22:33 +05:30
Pulkit Goyal
a1d8e291f1 revset: add support for using ~ operator on wdir() predicate
We catch the WdirUnsupported exception and handles the wdir() case here.
2017-05-23 01:08:19 +05:30
Pulkit Goyal
585fe1fa03 revset: add support for p2(wdir()) to get second parent of working directory
This adds support for finding the second parent of working directory using the
p2 predicate.
2017-05-22 02:14:22 +05:30
Pulkit Goyal
3b6d2ad7cc revset: use try-except instead of if-else because of perf
For wdir(), we now raises an exception which will be raised when wdir() will be
passed, so catching that exception is better checking for wdir() using if-else.
2017-05-22 02:03:43 +05:30
Pulkit Goyal
86c7c2d2ce revset: remove redundant condition and change to else from elif
Before going to this piece of code, we already check whether n is in [0, 1, 2],
so dropping the redundant condition.
2017-05-22 01:38:00 +05:30
Pulkit Goyal
8ed8bc3674 revset: add support for "wdir()^n"
This patch catches the WdirUnsupported exception raised, and adds support for
wdir^n which will give us the nth parent of the working directory.
2017-05-22 01:01:45 +05:30
Pulkit Goyal
ca6ae50fc1 revset: add parentheses after wdir since its a function
wdir was shown in help rather than wdir().
2017-05-22 00:54:02 +05:30
Augie Fackler
b90ae820de cmdutil: avoid redefining write() function in export if possible
Doing less work inside the loop just feels better to me.
2017-05-22 15:05:18 -04:00
Augie Fackler
cab9b6d957 cmdutil: extract closure that performs the actual export formatting
This simplifies things a little by making the actual act of turning a
revision into patch data a single function. After this, adding
formatter support to `hg export` should be much simpler.
2017-05-22 13:34:03 -04:00