Mercurial > hg
annotate contrib/casesmash.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 | 42a7301fb4d5 |
children | 2372284d9457 |
rev | line source |
---|---|
28351
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
1 from __future__ import absolute_import |
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
2 import __builtin__ |
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
3 import os |
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
4 from mercurial import ( |
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
5 util, |
42a7301fb4d5
casesmash: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
19378
diff
changeset
|
6 ) |
14730 | 7 |
8 def lowerwrap(scope, funcname): | |
9 f = getattr(scope, funcname) | |
10 def wrap(fname, *args, **kwargs): | |
11 d, base = os.path.split(fname) | |
12 try: | |
13 files = os.listdir(d or '.') | |
19378
9de689d20230
cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents:
19322
diff
changeset
|
14 except OSError: |
14730 | 15 files = [] |
16 if base in files: | |
17 return f(fname, *args, **kwargs) | |
18 for fn in files: | |
19 if fn.lower() == base.lower(): | |
20 return f(os.path.join(d, fn), *args, **kwargs) | |
21 return f(fname, *args, **kwargs) | |
22 scope.__dict__[funcname] = wrap | |
23 | |
24 def normcase(path): | |
25 return path.lower() | |
26 | |
27 os.path.normcase = normcase | |
28 | |
29 for f in 'file open'.split(): | |
30 lowerwrap(__builtin__, f) | |
31 | |
32 for f in "chmod chown open lstat stat remove unlink".split(): | |
33 lowerwrap(os, f) | |
34 | |
35 for f in "exists lexists".split(): | |
36 lowerwrap(os.path, f) | |
37 | |
38 lowerwrap(util, 'posixfile') |