[MERGE] The eol functionality now issues a warning if a rule is configured (bug 358199)

John Arbash Meinel john at arbash-meinel.com
Fri Apr 17 20:11:26 BST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian de Alwis wrote:
> Attached is a patch to bzr.dev to emit a warning when encountering an
> unknown eol setting.  This patch fixed bug 358199.
> 
> Brian.
> 

+	filter = _eol_filter_stack_map.get(key)
+	if filter == None:
+	     from bzrlib.trace import warning
+	     warning("Unknown eol filter type '%s'" % key)

^- as a 'pythonic' thing, you should always use 'is' to compare with
None, so it would be:

if filter is None:
  ...

I'm also a bit concerned about filling the screens with warnings.

Consider someone who does something like:

[name *.c]
eol = crlff

At that point when the do 'bzr co' it will give 10,000 warnings about
unknown eol filter type (I believe).

So I think we would want a 'debounce' in it with something like:

_unknown_eol = set()

def eol_lookup(key):
  ...
  if filter is None and key not in _unknown_eol:
    _unknown_eol.add(key)
    warning("Unknown eol filter type '%s'", key)

(note that 'warning' already has the right code to do % *args, so you
can just pass 'key' as another argument.)


...

+class TestEolRulesSpecifications(TestCase):
+
+    def setUp(self):
+        self.warnings = []
+        self._warning = trace.warning
+	def warning(*args):
+	    self.warnings.append(args[0] % args[1:])
+        trace.warning = warning
+	super(TestEolRulesSpecifications, self).setUp()

^- The spacing on this shows that you have some 'tab' characters mixed
with plain space characters. We only allow plain space characters in our
python source code.


I'm not 100% sure about adding a debounce to 'unknown eol', but I'm
guessing that scrolling by 1000s of messages is undesirable.

Anyway, because of tabs in the source:
BB:resubmit

for now. I think the change is otherwise reasonable.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkno1F0ACgkQJdeBCYSNAAN5rACgqUPFTeORS7v97HQhDMus9HO8
wSwAoJTW5Q3zKEsMhEs8/bFiiiXpXx5R
=H65n
-----END PGP SIGNATURE-----



More information about the bazaar mailing list