Mercurial > hg-stable
changeset 43205:dfaa477e37a8
eol: fix update - don't use and apply removed .hgeol patterns
'hg up -C' to revisions with different .hgeol patterns could leave dirty
changes in the working directory. That could make deployment of new .hgeol
filters tricky: they would "occasionally" apply also in branches where they
shouldn't.
Fixed by dropping all old patterns before applying new ones.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sun, 13 Oct 2019 02:15:07 +0200 |
parents | fd8c3f59b544 |
children | 7699d9237a67 |
files | hgext/eol.py tests/test-eol-update.t |
diffstat | 2 files changed, 13 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/eol.py Sun Oct 13 02:11:33 2019 +0200 +++ b/hgext/eol.py Sun Oct 13 02:15:07 2019 +0200 @@ -221,6 +221,12 @@ self.match = match.match(root, b'', [], include, exclude) def copytoui(self, ui): + newpatterns = set(pattern for pattern, key, m in self.patterns) + for section in (b'decode', b'encode'): + for oldpattern, _filter in ui.configitems(section): + if oldpattern not in newpatterns: + if ui.configsource(section, oldpattern) == b'eol': + ui.setconfig(section, oldpattern, b'!', b'eol') for pattern, key, m in self.patterns: try: ui.setconfig(b'decode', pattern, self._decode[key], b'eol')
--- a/tests/test-eol-update.t Sun Oct 13 02:11:33 2019 +0200 +++ b/tests/test-eol-update.t Sun Oct 13 02:15:07 2019 +0200 @@ -120,12 +120,6 @@ first -second third - diff --git a/f b/f - --- a/f - +++ b/f - @@ -1,1 +1,1 @@ - -f\r (esc) - +f $ dotest CRLF % hg clone repo repo-CRLF @@ -159,12 +153,6 @@ first -second third - diff --git a/f b/f - --- a/f - +++ b/f - @@ -1,1 +1,1 @@ - -f\r (esc) - +f Test in repo using eol extension, while keeping an eye on how filters are applied: @@ -177,8 +165,8 @@ > eol = > EOF -Update to revision 0 which has no .hgeol . Unfortunately, it uses the filter -from tip ... which evidently is wrong: +Update to revision 0 which has no .hgeol, shouldn't use any filters, and +obviously should leave things as tidy as they were before the clean update. $ hg up -c -r 0 -v --debug resolving manifests @@ -193,22 +181,8 @@ filtering a.txt through tolf f: remote created -> g getting f - filtering f through tolf 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg st - M f - $ touch .hgeol * # ensure consistent dirtyness checks ignoring dirstate - $ hg up -C -r 0 -v --debug - eol: detected change in .hgeol - filtering .hgeol through isbinary - filtering a.txt through tolf - resolving manifests - branchmerge: False, force: True, partial: False - ancestor: 15cbdf8ca3db+, local: 15cbdf8ca3db+, remote: 15cbdf8ca3db - calling hook preupdate.eol: hgext.eol.preupdate - f: remote is newer -> g - getting f - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg branch b marked working directory as branch b @@ -250,9 +224,9 @@ -f\r (esc) +f -Abort the merge with up -C to revision 0 ... but notice how .hgeol changes are -not detected correctly: f is filtered with tolf even though there is no filter -for f in revision 0, and it thus ends up with working directory changes. +Abort the merge with up -C to revision 0. +Note that files are filtered correctly for revision 0: f is not filtered, a.txt +is filtered with tolf, and everything is left tidy. $ touch .hgeol * # ensure consistent dirtyness checks ignoring dirstate $ hg up -C -r 0 -v --debug @@ -269,7 +243,6 @@ filtering a.txt through tolf f: remote is newer -> g getting f - filtering f through tolf 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ touch .hgeol * @@ -277,16 +250,9 @@ eol: detected change in .hgeol filtering .hgeol through isbinary filtering a.txt through tolf - M f $ hg diff - diff --git a/f b/f - --- a/f - +++ b/f - @@ -1,1 +1,1 @@ - -f\r (esc) - +f -Workaround: Update again - this will read the right .hgeol: +Things were clean, and updating again will not change anything: $ touch .hgeol * $ hg up -C -r 0 -v --debug @@ -297,9 +263,7 @@ branchmerge: False, force: True, partial: False ancestor: 15cbdf8ca3db+, local: 15cbdf8ca3db+, remote: 15cbdf8ca3db calling hook preupdate.eol: hgext.eol.preupdate - f: remote is newer -> g - getting f - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ touch .hgeol * $ hg st --debug