[PATCH] formatter: ditch namedtuple in favor of attr
Yuya Nishihara
yuya at tcha.org
Sun May 6 02:54:46 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1525327696 -32400
# Thu May 03 15:08:16 2018 +0900
# Node ID bebe0c7559fa5015d636a73be9fba988911ff760
# Parent 9ae8a72dec358d33c96725e1f94c631e869deb80
formatter: ditch namedtuple in favor of attr
diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -107,7 +107,6 @@ baz: foo, bar
from __future__ import absolute_import, print_function
-import collections
import contextlib
import itertools
import os
@@ -117,6 +116,9 @@ from .node import (
hex,
short,
)
+from .thirdparty import (
+ attr,
+)
from . import (
error,
@@ -413,8 +415,11 @@ class templateformatter(baseformatter):
baseformatter.end(self)
self._renderitem('docfooter', {})
-templatespec = collections.namedtuple(r'templatespec',
- r'ref tmpl mapfile')
+ at attr.s(frozen=True)
+class templatespec(object):
+ ref = attr.ib()
+ tmpl = attr.ib()
+ mapfile = attr.ib()
def lookuptemplate(ui, topic, tmpl):
"""Find the template matching the given -T/--template spec 'tmpl'
More information about the Mercurial-devel
mailing list