##// END OF EJS Templates
demandimport: delay loading for "from a import b" with absolute_import...
demandimport: delay loading for "from a import b" with absolute_import Before this patch, "from a import b" doesn't delay loading module "b", if absolute_import is enabled, even though "from . import b" does. For example: - it is assumed that extension X has "from P import M" for module M under package P with absolute_import feature - if importing module M is already delayed before loading extension X, loading module M in extension X is delayed until actually referring util, cmdutil, scmutil or so of Mercurial itself should be imported by "from . import M" style before loading extension X - otherwise, module M is loaded immediately at loading extension X, even if extension X itself isn't used at that "hg" command invocation Some minor modules (e.g. filemerge or so) of Mercurial itself aren't imported by "from . import M" style before loading extension X. And of course, external libraries aren't, too. This might cause startup performance problem of hg command, because many bundled extensions already enable absolute_import feature. To delay loading module for "from a import b" with absolute_import feature, this patch does below in "from a (or .a) import b" with absolute_import case: 1. import root module of "name" by system built-in __import__ (referred as _origimport) 2. recurse down the module chain for hierarchical "name" This logic can be shared with non absolute_import case. Therefore, this patch also centralizes it into chainmodules(). 3. and fall through to process elements in "fromlist" for the leaf module of "name" Processing elements in "fromlist" is executed in the code path after "if _pypy: .... else: ..." clause. Therefore, this patch replaces "if _pypy:" with "elif _pypy:" to share it. At 4f1144c3c72b introducing original "work around" for "from a import b" case, elements in "fromlist" were imported with "level=level". But "level" might be grater than 1 (e.g. level=2 in "from .. import b" case) at demandimport() invocation, and importing direct sub-module in "fromlist" with level grater than 1 causes unexpected result. IMHO, this seems main reason of "errors for unknown reason" described in 4f1144c3c72b, and we don't have to worry about it, because this issue was already fixed by 78d05778907b. This is reason why this patch removes "errors for unknown reasons" comment.

File last commit:

r28709:94494031 default
r29375:fcaf2017 default
Show More
map
184 lines | 4.7 KiB | text/plain | TextLexer
Gregory Szorc
templates: add a stub template for json...
r24544 mimetype = 'application/json'
filerevision = '"not yet implemented"'
search = '"not yet implemented"'
Gregory Szorc
json: implement {shortlog} and {changelog} templates...
r24588 # changelog and shortlog are the same web API but with different
# number of entries.
changelog = changelist.tmpl
shortlog = changelist.tmpl
changelistentry = '\{
"node": {node|json},
"date": {date|json},
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "desc": {desc|utf8|json},
Gregory Szorc
json: implement {shortlog} and {changelog} templates...
r24588 "bookmarks": [{join(bookmarks%changelistentryname, ", ")}],
"tags": [{join(tags%changelistentryname, ", ")}],
av6
hgweb: add parents to json-log (issue5074)...
r28709 "user": {author|utf8|json},
"parents": [{join(allparents%changesetparent, ", ")}]
Gregory Szorc
json: implement {shortlog} and {changelog} templates...
r24588 }'
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 changelistentryname = '{name|utf8|json}'
Gregory Szorc
json: implement {changeset} template...
r24563 changeset = '\{
"node": {node|json},
"date": {date|json},
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "desc": {desc|utf8|json},
Gregory Szorc
json: implement {changeset} template...
r24563 "branch": {if(branch, branch%changesetbranch, "default"|json)},
"bookmarks": [{join(changesetbookmark, ", ")}],
"tags": [{join(changesettag, ", ")}],
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "user": {author|utf8|json},
Gregory Szorc
hgweb: add phase to {changeset} template...
r24564 "parents": [{join(parent%changesetparent, ", ")}],
"phase": {phase|json}
Gregory Szorc
json: implement {changeset} template...
r24563 }'
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 changesetbranch = '{name|utf8|json}'
changesetbookmark = '{bookmark|utf8|json}'
changesettag = '{tag|utf8|json}'
Gregory Szorc
json: implement {changeset} template...
r24563 changesetparent = '{node|json}'
Gregory Szorc
json: implement {manifest} template...
r24589 manifest = '\{
"node": {node|json},
"abspath": {path|json},
"directories": [{join(dentries%direntry, ", ")}],
"files": [{join(fentries%fileentry, ", ")}],
"bookmarks": [{join(bookmarks%name, ", ")}],
"tags": [{join(tags%name, ", ")}]
}'
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 name = '{name|utf8|json}'
Gregory Szorc
json: implement {manifest} template...
r24589 direntry = '\{
"abspath": {path|json},
"basename": {basename|json},
"emptydirs": {emptydirs|json}
}'
fileentry = '\{
"abspath": {file|json},
"basename": {basename|json},
"date": {date|json},
"size": {size|json},
"flags": {permissions|json}
}'
Gregory Szorc
json: implement {tags} template...
r24545 tags = '\{
"node": {node|json},
"tags": [{join(entriesnotip%tagentry, ", ")}]
}'
tagentry = '\{
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "tag": {tag|utf8|json},
Gregory Szorc
json: implement {tags} template...
r24545 "node": {node|json},
"date": {date|json}
}'
Gregory Szorc
json: implement {bookmarks} template
r24546 bookmarks = '\{
"node": {node|json},
"bookmarks": [{join(entries%bookmarkentry, ", ")}]
}'
bookmarkentry = '\{
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "bookmark": {bookmark|utf8|json},
Gregory Szorc
json: implement {bookmarks} template
r24546 "node": {node|json},
"date": {date|json}
}'
Gregory Szorc
json: implement {branches} template
r24547 branches = '\{
"branches": [{join(entries%branchentry, ", ")}]
}'
branchentry = '\{
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "branch": {branch|utf8|json},
Gregory Szorc
json: implement {branches} template
r24547 "node": {node|json},
"date": {date|json},
"status": {status|json}
}'
Gregory Szorc
templates: add a stub template for json...
r24544 summary = '"not yet implemented"'
Gregory Szorc
json: implement {filediff} template...
r24713 filediff = '\{
"path": {file|json},
"node": {node|json},
"date": {date|json},
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "desc": {desc|utf8|json},
"author": {author|utf8|json},
Gregory Szorc
json: implement {filediff} template...
r24713 "parents": [{join(parent%changesetparent, ", ")}],
"children": [{join(child%changesetparent, ", ")}],
"diff": [{join(diff%diffblock, ", ")}]
}'
diffblock = '\{
"blockno": {blockno|json},
"lines": [{join(lines, ", ")}]
}'
difflineplus = '\{
"t": "+",
"n": {lineno|json},
"l": {line|json}
}'
difflineminus = '\{
"t": "-",
"n": {lineno|json},
"l": {line|json}
}'
difflineat = '\{
"t": "@",
"n": {lineno|json},
"l": {line|json}
}'
diffline = '\{
"t": "",
"n": {lineno|json},
"l": {line|json}
}'
Gregory Szorc
json: implement {comparison} template...
r24714 filecomparison = '\{
"path": {file|json},
"node": {node|json},
"date": {date|json},
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "desc": {desc|utf8|json},
"author": {author|utf8|json},
Gregory Szorc
json: implement {comparison} template...
r24714 "parents": [{join(parent%changesetparent, ", ")}],
"children": [{join(child%changesetparent, ", ")}],
"leftnode": {leftnode|json},
"rightnode": {rightnode|json},
"comparison": [{join(comparison, ", ")}]
}'
comparisonblock = '\{
"lines": [{join(lines, ", ")}]
}'
comparisonline = '\{
"t": {type|json},
"ln": {leftlineno|json},
"ll": {leftline|json},
"rn": {rightlineno|json},
"rl": {rightline|json}
}'
Gregory Szorc
json: implement {fileannotate} template
r24715 fileannotate = '\{
"abspath": {file|json},
"node": {node|json},
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "author": {author|utf8|json},
Gregory Szorc
json: implement {fileannotate} template
r24715 "date": {date|json},
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "desc": {desc|utf8|json},
Gregory Szorc
json: implement {fileannotate} template
r24715 "parents": [{join(parent%changesetparent, ", ")}],
"children": [{join(child%changesetparent, ", ")}],
"permissions": {permissions|json},
"annotate": [{join(annotate%fileannotation, ", ")}]
}'
fileannotation = '\{
"node": {node|json},
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "author": {author|utf8|json},
"desc": {desc|utf8|json},
Gregory Szorc
json: implement {fileannotate} template
r24715 "abspath": {file|json},
"targetline": {targetline|json},
"line": {line|json},
"lineno": {lineno|json},
"revdate": {revdate|json}
}'
Gregory Szorc
templates: add a stub template for json...
r24544 filelog = '"not yet implemented"'
graph = '"not yet implemented"'
Gregory Szorc
json: implement {helptopics} template
r24590 helptopics = '\{
"topics": [{join(topics%helptopicentry, ", ")}],
"earlycommands": [{join(earlycommands%helptopicentry, ", ")}],
"othercommands": [{join(othercommands%helptopicentry, ", ")}]
}'
helptopicentry = '\{
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "topic": {topic|utf8|json},
"summary": {summary|utf8|json}
Gregory Szorc
json: implement {helptopics} template
r24590 }'
Gregory Szorc
json: implement {help} template...
r24591 help = '\{
Yuya Nishihara
templatefilters: make json filter be byte-transparent (BC) (issue4926)...
r28212 "topic": {topic|utf8|json},
"rawdoc": {doc|utf8|json}
Gregory Szorc
json: implement {help} template...
r24591 }'
Gregory Szorc
templates: add a stub template for json...
r24544 filenodelink = ''
filenolink = ''
av6
hgweb: add index template to json/map...
r28268 index = '\{
"entries": [{join(entries%indexentry, ", ")}]
}'
indexentry = '\{
"name": {name|utf8|json},
"description": {description|utf8|json},
"contact": {contact|utf8|json},
"lastchange": {lastchange|json}
}'