comparison hgext/convert/p4.py @ 35036:281214150561 stable

convert: avoid wrong lfconvert defaults by moving configitems to core The `hg lfconvert --to-normal` command uses the convert extension internally to work its magic, but that produced devel-warn messages if the convert extension wasn't loaded by the user. The test in fcd2f9b06629 (modified here) wasn't showing the warnings because the convert extension was loaded via $HGRCPATH. Most of the config options default to None/False, but 'hg.usebranchnames' and 'hg.tagsbranch' are supposed to default to True and 'default' respectively. The first iteration of this was to ui.setconfig() inside lfconvert, to force the convert extension to load. But there really is no precedent for doing this, and check-config complained that 'extensions.convert' isn't documented. Yuya suggested this alternative. This partially backs out 0d5a1175d0f9.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 28 Nov 2017 23:20:08 -0500
parents 0d5a1175d0f9
children 671aba341d90
comparison
equal deleted inserted replaced
35035:96dcc78468e3 35036:281214150561
42 filename = filename.replace(k, v) 42 filename = filename.replace(k, v)
43 return filename 43 return filename
44 44
45 class p4_source(common.converter_source): 45 class p4_source(common.converter_source):
46 def __init__(self, ui, path, revs=None): 46 def __init__(self, ui, path, revs=None):
47 # avoid import cycle
48 from . import convcmd
49
47 super(p4_source, self).__init__(ui, path, revs=revs) 50 super(p4_source, self).__init__(ui, path, revs=revs)
48 51
49 if "/" in path and not path.startswith('//'): 52 if "/" in path and not path.startswith('//'):
50 raise common.NoRepo(_('%s does not look like a P4 repository') % 53 raise common.NoRepo(_('%s does not look like a P4 repository') %
51 path) 54 path)
52 55
53 common.checktool('p4', abort=False) 56 common.checktool('p4', abort=False)
54 57
55 self.revmap = {} 58 self.revmap = {}
56 self.encoding = self.ui.config('convert', 'p4.encoding') 59 self.encoding = self.ui.config('convert', 'p4.encoding',
60 convcmd.orig_encoding)
57 self.re_type = re.compile( 61 self.re_type = re.compile(
58 "([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)" 62 "([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)"
59 "(\+\w+)?$") 63 "(\+\w+)?$")
60 self.re_keywords = re.compile( 64 self.re_keywords = re.compile(
61 r"\$(Id|Header|Date|DateTime|Change|File|Revision|Author)" 65 r"\$(Id|Header|Date|DateTime|Change|File|Revision|Author)"