diff hgext/eol.py @ 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 4aa9f3a1c1df
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')