Commit Graph

18527 Commits

Author SHA1 Message Date
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
Augie Fackler
c84213bcdd cmdutil: use a generator expression instead of a list comprehension 2017-05-22 13:35:22 -04:00
Augie Fackler
414ee4894d cmdutil: rename template param to export to fntemplate
It's actually a template for the filename, not a formatter template.
2017-05-20 20:15:05 -04:00
Augie Fackler
47d21819fe cmdutil: comprehensively document the interface of export
I want to make some improvements here, but in order to make future
patches easier to review I want to document the current state of the
world.
2017-05-20 17:58:04 -04:00
Jun Wu
714cce3396 policy: define C module versions individually
This allows us to bump the version for a single module without changing all
of them.
2017-05-22 22:59:40 -07:00
Pierre-Yves David
b02205e9d6 repoview: rename '_getdynamicblockers' to 'revealedrevs' (API)
Recent mailing list discussion made me realised we could clarify these. We make
the function "public" to encourage extensions to wrap it and we use a more
explicit name that mirror "hideablerevs".
2017-05-20 19:43:58 +02:00
Pierre-Yves David
2795351073 repoview: move '_getdynamicblock' next to 'hideablerevs'
There are the two functions that extensions should use to augment the hidding
logic. It seem better to have them together at the top of the file.
2017-05-20 19:43:29 +02:00
Siddharth Agarwal
dae5a54ac2 python3: allow hgloader to work with lazy loaders
Don't clobber the loader returned from find_spec.

This brings `hg version` down from 0.27 seconds to 0.17.
2017-05-21 13:26:17 -07:00
Siddharth Agarwal
a41c665cd6 demandimport: move to separate package
In Python 3, demand loading is per-package. Keeping demandimport in the
mercurial package would disable demand loading for any modules in
mercurial.
2017-05-21 12:10:53 -07:00
Jun Wu
610c5f87a9 profiling: allow loading profiling extension before everything else
459366b580cf makes profiler start early without loading extensions. That
makes it impossible for an extension to add customized profilers.

This patch adds a special case: if a profiler is not found but an extension
with the same name could be loaded, load that extension first, and expect it
to have a "profile" contextmanager method. This allows customized profilers
and extension setup time is still profiled.
2017-05-22 01:17:49 -07:00
Jun Wu
1e83688564 extensions: allow loading a whitelisted subset of extensions
This feature will be used by the next patch.
2017-05-22 00:51:56 -07:00
Martin von Zweigbergk
243fda7165 match: catch attempts to create case-insenstive exact matchers
Exact matchers are only created internally (as opposed to from user
input) based on a set of files that the caller collected before, so
they should always match the list exactly (i.e. case-sensitively).
2017-05-22 08:49:34 -07:00
Boris Feld
527b4d3011 devel: use default-date config field when creating obsmarkers
Also use the default-date when creating obsmarkers. Currently they are created
with the current date and without any option to force their value.

To test the feature, we remove some of the many 'glob' used to match obsmarker
date in the tests.
2017-05-19 12:08:47 +02:00
Boris Feld
b66380af61 devel: add a config field to force dates to timestamp 0
Add a new config field named default-date under the devel section to force all
implicits date to a specific value. If a explicit date is passed, it will
override the default.

This patch only affect changesets. Other usages (blackbox, obsmarkers) are
updated in later patchs.

The test runner is setting a bunch of alias to force the '--date' argument. We
will replace theses aliases in a later patch.
2017-05-19 12:18:25 +02:00
Boris Feld
04a3cbe923 ui: add the possiblity to get a date config field
Add the method configdate to read a date from configuration. It uses the
util.rawparsedate refactored earlier to support all standard date formats.
2017-05-19 12:07:41 +02:00
Boris Feld
db6502431a util: refactor util.parsedate to raises ValueError
Split most of util.parsedate in util.rawparsedate and make it raises ValueError instead
of error.Abort.

The util.parsedate function is now just a shell function converting ValueError
to error.Abort for existing users.

I need to parse a date from config in a later patch and use util.rawparsedate
with ui.configwith which expect a convert that raises ValueError.
2017-05-19 12:07:23 +02:00
Martin von Zweigbergk
ee3be3c6ea match: implement __repr__() and update users (API)
fsmonitor and debugignore currently access matcher fields that I would
consider implementation details, namely patternspat, includepat, and
excludepat. Let' instead implement __repr__() and have the few users
use that instead.

Marked (API) because the fields can now be None.
2017-05-22 11:08:18 -07:00
Pulkit Goyal
6b98477968 revset: make hg log -r 'wdir()^' work (issue4905)
This patch catches the WdirUnsupported exception to support wdir()^.
2017-05-19 20:06:45 +05:30
Pulkit Goyal
26a5b62b59 revlog: raise WdirUnsupported when wdirrev is passed
revlog.parentrevs() is called while evaluating ^ operator in revsets. When wdir
is passed, it raises IndexError. This patch raises WdirUnsupported if wdir is
passed in the function. The error will be caugth in future patches.
2017-05-19 19:12:06 +05:30
Pulkit Goyal
8c8779ddbb error: add a new exception named WdirUnsupported
This series intents to support wdir() predicate with different operators
like ~, ^.

Currently the storage class don't support wdir(). This exception is introduced
so that it can be raised from places where wdir() is passed and is not
supported and we can catch this where we want to support the predicate.
Also throwing an error at low level and catching at some higher level is better
than using if-else especially for perf.
2017-05-19 19:10:37 +05:30
Martin von Zweigbergk
722dff8abb match: replace icasefsmatch() function by flag to regular match()
match() will soon gain more logic and we don't want to duplicate that
in icasefsmatch(), so merge the two functions instead and use a flag
to get case-insensitive behavior.
2017-05-18 22:20:59 -07:00
Martin von Zweigbergk
8daa488d75 match: delete icasefsmatcher now that it's same as matcher 2017-05-18 16:48:02 -07:00
Martin von Zweigbergk
a7219ec491 match: pass in normalize() function to matchers
This will let us delete icasefsmatcher.
2017-05-18 15:45:50 -07:00
Martin von Zweigbergk
04a6ac40df match: don't print explicitly listed files with wrong case (BC)
On case-insensitive file systems, if file A exists and you try to
remove it (or add, etc.) by specifying a different case, you will see
something like this:

  $ hg rm a
  removing file A

I honestly found this surprising because it seems to me like it was
explicitly listed by the user. Still, there is a comment in the code
describing it, so it is very clearly intentional. The code was added
in d70aa474bd84 (match: add a subclass for dirstate normalizing of the
matched patterns, 2015-04-12).

I'm going to do a lot of refactoring to matchers and the feature
mentioned above is going to get in my way. I'm therefore removing it
for the time being and we can hopefully add it back when I'm done.
2017-05-18 16:05:46 -07:00
Martin von Zweigbergk
6b512ea877 match: move body of _normalize() to a static function
matcher._normalize() no longer depends on any of the matcher's state,
and making it static will enable further refactoring. Note that the
subdirmatcher subclass calls _normalize(), so we can't remove it
completely.
2017-05-18 15:25:16 -07:00