Commit Graph

67 Commits

Author SHA1 Message Date
Pierre-Yves David
1b59e168fe eol: fix 'error' parameter name in the commitctx wrapper
Since its introduction in c7ec460797a9, the parameter has always been name
"error". Yet the eol extension have been using 'haserror' as the argument name,
breaking extensions with subclass passing 'error' as a keyword argument.
2017-06-23 13:22:04 +02:00
Pierre-Yves David
f83c410836 eol: import 'error' as 'errormod'
We need the 'error' name available to fix another bug, so we rename the imported
module.
2017-06-23 13:24:45 +02:00
Yuya Nishihara
1163409660 util: extract pure tolf/tocrlf() functions from eol extension
This can be used for EOL conversion of text files.
2017-03-29 21:28:54 +09:00
Yuya Nishihara
2f682a6206 pycompat: provide bytes os.linesep 2017-03-29 21:23:28 +09:00
Pierre-Yves David
c8ef80badf eol: use 'wvfs' instead of 'wfile'
Method is about to be deprecated and the modern form is shorter.
2017-03-15 00:31:59 -07:00
Pierre-Yves David
d781ee1c04 eol: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:51:36 -08:00
Pierre-Yves David
8f6b267699 eol: make sure we always release the wlock when writing cache
If any exception were to happen after we acquired the wlock, we could leave it
unreleased. We move the wlock release in a 'finally:' close as it should be.
2016-10-13 13:47:47 +02:00
Mads Kiilerich
cb6727b739 eol: on update, only re-check files if filtering changed
Before, update would mark all files as 'normallookup' in dirstate if .hgeol
changed so all files would get the new filtering applied. That takes some time
... and is pointless if the filtering for that file didn't change.

Instead, keep track of the old filtering and only check files where the
filtering is changed.

To keep the old filtering, change to write the applied .hgeol content to
.hg/eol.cache instead of just touching it. That change is backwards/forwards
compatible.

In a real world test, this takes an update that is changing .hgeol and 30000
files from 12s to 4s - where the remaining eol overhead is 1-2s.
2016-10-09 15:54:49 +02:00
Mads Kiilerich
7fc89d4630 eol: store and reuse pattern matchers instead of creating in tight loop
More "right" and more efficient.
2016-10-09 15:54:42 +02:00
Mads Kiilerich
e84c500b99 eol: fix variable naming - call it _eolmatch instead of _eolfile
It is not the file but a match object based on it.
2016-10-09 15:42:42 +02:00
Augie Fackler
4e1c384d0a extensions: change magic "shipped with hg" string
I've caught multiple extensions in the wild lying about being
'internal', so it's time to move the goalposts on people. Goalpost
moving will continue until third party extensions stop trying to
defeat the system.
2016-08-23 11:26:08 -04:00
Pulkit Goyal
e8c7dbca1d py3: make eol use absolute_import 2016-04-17 02:10:55 +05:30
Bryan O'Sullivan
cf9489897c eol: make output stable
This eliminates a divergence in behaviour between PyPy and Python.
2015-12-27 23:55:54 +09:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Pierre-Yves David
7e69ac5da6 eol: rename 'error' to 'haserror'
The variable 'error' conflict with the module name that we would like to import
and use in a coming changeset.
2015-10-05 22:49:24 -07:00
timeless@mozdev.org
52eae47139 spelling: behaviour -> behavior 2015-08-28 10:53:55 -04:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Augie Fackler
f95a6caba1 extensions: document that testedwith = 'internal' is special
Extension authors (notably at companies using hg) have been
cargo-culting the `testedwith = 'internal'` bit from hg's own
extensions, which then defeats our "file bugs over here" logic in
dispatch. Let's be more aggressive about trying to give extension
authors a hint about what testedwith should say.
2015-04-28 16:44:37 -04:00
Yuya Nishihara
efaf86bce6 eol: replace "working copy" with "working directory" in extension help 2015-03-17 20:41:52 +09:00
Angel Ezquerra
88cbab7845 localrepo: remove all external users of localrepo.opener
This change touches every module in which repository.opener was being used, and
changes it for the equivalent repository.vfs. This is meant to make it easier
to split the repository.vfs into several separate vfs.

It should now be possible to remove localrepo.opener.
2015-01-15 23:17:12 +01:00
Mads Kiilerich
a195867192 eol: fix crash when handling removed files
ci --amend would in some cases fail after 2eef89bfd70d failed to refactor the
eol extension too.
2014-10-22 16:10:23 +02:00
Matt Mackall
c9eb4517fa merge with stable 2014-04-01 15:11:19 -05:00
FUJIWARA Katsunori
0eed53de6c i18n: fix "% inside _()" problems
Before this patch, "contrib/check-code.py" can't detect these
problems, because the regexp pattern to detect "% inside _()" doesn't
suppose the case that format string consists of multiple string
components concatenated implicitly or explicitly,

This patch does below for that regexp pattern to detect "% inside _()"
problems in such case.

  - put "+" into separator part ("[ \t\n]") for explicit concatenation
    ("...." + "...." style)

  - enclose "component and separator" part by "(?:....)+" for
    concatenation itself ("...." "...." or "...." + "....")
2014-04-01 02:46:03 +09:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
Simon Heimberg
25ae76fc48 documentation: add an extra newline after note directive
Like this no docutils version interprets any line in the following text as
argument of note.
2013-11-05 08:59:55 +01:00
Bryan O'Sullivan
ffb0e7fc5d eol: don't refer to a random name-captured ui object
Previously, we used a ui object captured at the time of monkeypatching.
2012-11-20 14:21:56 -08:00
timeless@mozdev.org
8d25b9561a spelling: Macintosh 2012-08-17 13:58:18 -07:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Martin Geisler
83e80ac544 eol: remove left-over print statements 2012-03-15 16:57:19 +01:00
Martin Geisler
d25c6987fd eol: document why os.utime doesn't work here
I wanted to use

  os.utime(self.join("eol.cache"), None)

as a cleaner way of touching the cache file -- but this fails when the
cache doesn't exist.
2012-03-15 16:52:22 +01:00
Matt Mackall
4773ae257d merge with stable 2011-07-13 16:29:28 -05:00
Matt Mackall
db0ee5fbeb eol: fix silly test-gendoc breakage by escaping control characters 2011-07-12 16:22:36 -05:00
Nicholas Riley
8b7c28a23b eol: ignore IOError from deleted files in commitctx
A Mercurial repo signals a file is deleted by raising IOError when the
file's data is requested.  This IOError is normally caught by
localrepository.commitctx.  With the eol extension enabled and EOL
mappings in place, the eolrepo subclass should ignore IOError because
a deleted file has no line endings to process.

This issue exhibited itself when performing an incremental hg convert
of a revision with deleted files to a repo with an existing .hgeol
file.
2011-07-12 12:06:11 -04:00
Martin Geisler
caafeeda38 eol: document new eol.fix-trailing-newline setting 2011-07-07 12:13:07 +02:00
Stepan Koltsov
a47a7047c8 eol: fix missing trailing newlines in comitted files
Some text editors (Eclipse, for example) do not add trailing newlines,
so diffs often contain annoying "\ No newline at the end of file".
This patch to eol extension simply adds trailing newline on commit.
2011-07-01 23:12:52 +04:00
Stepan Koltsov
8ad66e155c eol: eol.only-consistent can now be specified in .hgeol 2011-07-01 22:53:58 +04:00
Patrick Mezard
5f254d281f eol: no need to accumulate files when checking all changesets
Just check the files touched by the changesets.
2011-03-14 21:31:54 +01:00
Patrick Mezard
99858baa84 eol: improve hook failure output
Before, only the first failure was reported:

  abort: b.txt should not have CRLF line endings

while now all of them are listed:

  abort: end-of-line check failed:
    d.txt in a7040e68714f should not have CRLF line endings
    b.txt in fbcf9b1025f5 should not have CRLF line endings

As first suggested by Antoine Pitrou <solipsis@pitrou.net>
2011-03-14 21:08:18 +01:00
Steve Borho
af5b09475e merge with stable 2011-03-13 10:09:30 -05:00
Steve Borho
f61b2a6d58 eol: do not abort when win32text is found, only warn
The win32text extension does not break eol or vice-versa, so it is not a fatal
error to have both of them enabled.  It's just folly.  So spewing warnings in
this condition is preferrable to aborting.  When both extensions are enabled,
the user now sees:

% hg st
the eol extension is incompatible with the win32text extension
win32text is deprecated: http://mercurial.selenic.com/wiki/Win32TextExtension
M hgext/eol.py
2011-03-13 10:03:06 -05:00
Patrick Mezard
d52fb5d6ab eol: rename hook into checkheadshook, add checkallhook (issue2665)
"hook" is still an alias for "checkheadshook".
2011-03-13 15:07:44 +01:00
Patrick Mezard
25db85f436 eol: make the hook check all new heads, not only tip (issue2666)
Report and test by Antoine Pitrou <solipsis@pitrou.net>
2011-03-13 15:07:44 +01:00
Patrick Mezard
31042d7b6f eol: the hook no longer requires the extension to be loaded
Reading rules in the hook means we no longer need ui to be filled and do not
need reposetup() to be run anymore.
2011-03-13 15:07:44 +01:00
Patrick Mezard
df3e99aabe eol: extract parsing error handling in parseeol() 2011-03-13 15:07:44 +01:00
Patrick Mezard
6138329fcd eol: separate .hgeol parsing from merge in ui
This will help refactoring the hook.
2011-03-13 15:07:44 +01:00
Patrick Mezard
bd3e6eac01 eol: remove unused argument in readhgeol() 2011-03-13 15:07:44 +01:00
Patrick Mezard
683492a8b0 eol: explain why reading .hgeol from the working dir is special 2011-03-13 15:07:44 +01:00
Martin Geisler
27aa536556 eol: use dirstate methods to clear dirstate
This fixes a race that was observed when status was called before and
after clearing the dirstate.
2011-03-12 12:11:09 +01:00
Martin Geisler
8ccb77ff7e eol: do not abort on parse error
Handle parse errors in the .hgeol similarly to how parse errors in the
.hgtags file are handled: by issuing a warning. This allows the user
to revert the file using 'hg revert' or 'hg update -C'.
2011-02-28 15:46:48 +01:00