sapling/mercurial
Yuya Nishihara a0741d6e1d formatter: add fm.nested(field) to either write or build sub items
We sometimes need to build nested items by formatter, but there was no
convenient way other than building and putting them manually by fm.data():

  exts = []
  for n, v in extensions:
      fm.plain('%s %s\n' % (n, v))
      exts.append({'name': n, 'ver': v})
  fm.data(extensions=exts)

This should work for simple cases, but doing this would make it harder to
change the underlying data type for better templating support.

So this patch provides fm.nested(field), which returns new nested formatter
(or self if items aren't structured and just written to ui.) A nested formatter
stores items which will later be rendered by the parent formatter.

  fn = fm.nested('extensions')
  for n, v in extensions:
      fn.startitem()
      fn.write('name ver', '%s %s\n', n, v)
  fn.end()

Nested items are directly exported to a template for now:

  {extensions % "{name} {ver}\n"}

There's no {extensions} nor {join(extensions, sep)} yet. I have a plan for
them by extending fm.nested() API, but I want to revisit it after trying
out this API in the real world.
2016-03-13 19:59:39 +09:00
..
default.d mergetools.rc: find OSX FileMerge in the new location inside Xcode 4.3 2015-10-16 11:37:34 +02:00
help profiling: add a context manager that no-ops if profiling isn't enabled 2016-08-14 17:51:12 -07:00
hgweb hgweb: tweak zlib chunking behavior 2016-08-14 21:29:46 -07:00
httpclient httpclient: update to 54868ef054d2 of httpplus 2016-06-27 11:53:50 -04:00
pure bdiff: implement cffi version of bdiff 2016-08-20 23:06:01 +02:00
templates coal: use inheritance to derive from paper 2016-08-17 13:43:13 -05:00
__init__.py py3: import builtin wrappers automagically by code transformer 2016-08-16 12:35:15 +09:00
ancestor.py py3: convert to next() function 2016-05-16 21:30:53 +00:00
archival.py pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
base85.c base85: fix comparison of an int and a long 2015-08-21 14:29:42 -04:00
bdiff_module.c bdiff: split bdiff into cpy-aware and cpy-agnostic part 2016-07-13 10:46:26 +02:00
bdiff.c bdiff: split bdiff into cpy-aware and cpy-agnostic part 2016-07-13 10:46:26 +02:00
bdiff.h bdiff: split bdiff into cpy-aware and cpy-agnostic part 2016-07-13 10:46:26 +02:00
bitmanipulation.h internals: move the bitmanipulation routines into its own file 2016-06-06 13:08:13 +02:00
bookmarks.py bookmarks: abort 'push -B .' when no active bookmark 2016-06-13 23:50:26 +02:00
branchmap.py branchmap: remove extra indent 2016-08-05 15:01:16 +02:00
bundle2.py py3: conditionalize the raise statement 2016-08-08 23:51:11 +05:30
bundlerepo.py manifest: break mancache into two caches 2016-08-17 13:25:13 -07:00
byterange.py pycompat: switch to util.urlreq/util.urlerr for py3 compat 2016-04-06 23:22:12 +00:00
changegroup.py computeoutgoing: move the function from 'changegroup' to 'exchange' 2016-08-09 17:06:35 +02:00
changelog.py py3: use unicode literals in changelog.py 2016-08-04 00:15:39 +05:30
cmdutil.py cmdutil: extract samefile function from amend() 2016-08-21 08:00:18 +00:00
commands.py getchangegroup: take an 'outgoing' object as argument (API) 2016-08-09 17:00:38 +02:00
commandserver.py commandserver: update comment about setpgid 2016-07-18 15:59:08 +01:00
compat.h compat: define ssize_t as int on 32bit Windows, silences C4142 warning 2016-07-15 23:54:56 +09:00
config.py config: add hasconfig method and supporting plumbing 2016-01-07 19:45:03 -08:00
context.py manifest: change changectx to access manifest via manifestlog 2016-08-17 13:25:13 -07:00
copies.py py3: convert to next() function 2016-05-16 21:30:53 +00:00
crecord.py crecord: restore SIGWINCH handler before return 2016-08-24 11:24:07 +01:00
dagparser.py error: get Abort from 'error' instead of 'util' 2015-10-08 12:55:45 -07:00
dagutil.py dagutil: use absolute_import 2015-08-08 19:04:09 -07:00
demandimport.py demandimport: omit default value of "level" at construction of _demandmod 2016-08-06 22:24:33 +09:00
destutil.py destutil: add the ability to specify a search space for rebase destination 2016-04-30 18:41:08 +02:00
diffhelpers.c diffhelpers: fix botched return statement from e48d70075d8a 2015-01-28 13:34:20 -05:00
dirs.c dirs._addpath: reinstate use of Py_CLEAR 2015-04-07 20:43:04 -07:00
dirstate.py dirstate: add callback to notify extensions about wd parent change 2016-08-11 08:00:41 -07:00
discovery.py outgoing: add a 'missingroots' argument 2016-08-09 22:31:38 +02:00
dispatch.py dispatch: explicitly pass fancyopts optional arg as a keyword 2016-08-18 11:32:02 -04:00
dummycert.pem ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs 2014-09-26 02:19:48 +02:00
encoding.py encoding: use range() instead of xrange() 2016-03-11 21:27:26 -08:00
error.py shelve: make unshelve be able to abort in any case 2016-07-13 16:16:18 +01:00
exchange.py computeoutgoing: move the function from 'changegroup' to 'exchange' 2016-08-09 17:06:35 +02:00
exewrapper.c exewrapper: add .dll to LoadLibrary() argument 2016-04-27 09:23:39 -07:00
extensions.py extensions: add unwrapfunction to undo wrapfunction 2016-08-10 16:27:33 +01:00
fancyopts.py error: get Abort from 'error' instead of 'util' 2015-10-08 12:55:45 -07:00
filelog.py filelog: use absolute_import 2015-08-08 19:11:42 -07:00
filemerge.py merge: always use other, not remote, in user prompts 2016-08-12 05:56:40 -07:00
fileset.py fileset: fix copy/paste in eol() error message 2016-02-18 22:32:18 -05:00
formatter.py formatter: add fm.nested(field) to either write or build sub items 2016-03-13 19:59:39 +09:00
graphmod.py revset: add new topographical sort 2016-06-13 18:20:00 +01:00
hbisect.py with: use context manager in bisect save_state 2016-01-15 13:14:49 -08:00
help.py help: don't try to render a section on sub-topics 2016-08-06 17:04:22 -07:00
hg.py shared: take wlock for writting the 'shared' file 2016-08-07 17:10:47 +02:00
hook.py hook: split config reading further 2016-04-14 17:03:49 -07:00
httpconnection.py httpconnection: remove use of sslkwargs 2016-05-25 19:54:06 -07:00
httppeer.py py3: conditionalize httplib import 2016-06-28 16:01:53 +05:30
i18n.py i18n: use unicode literal 2016-06-25 17:40:53 -07:00
keepalive.py keepalive: switch from thread to threading module 2016-07-01 19:17:16 +05:30
localrepo.py manifest: use property instead of field for manifest revlog storage 2016-08-17 13:25:13 -07:00
lock.py lock: clear postrelease hooks list after usage 2016-04-16 09:00:15 -07:00
lsprof.py lsprof: use print function 2016-01-02 11:40:53 -08:00
lsprofcalltree.py lsprofcalltree: use print function 2016-01-02 11:45:29 -08:00
mail.py mail: unsupport smtp.verifycert (BC) 2016-06-04 11:13:28 -07:00
manifest.c lazymanifest: fix typo s/typles/tuples/ 2016-05-27 21:24:05 +02:00
manifest.py manifest: use property instead of field for manifest revlog storage 2016-08-17 13:25:13 -07:00
match.py match: remove matchessubrepo method (API) 2016-08-16 08:21:16 +00:00
mdiff.py mdiff: remove use of __slots__ 2016-06-25 13:52:46 -07:00
merge.py merge: remove files with extra actions from merge action list 2016-08-23 17:58:53 -07:00
minirst.py help: search section of help topic by translated section name correctly 2016-05-13 07:19:59 +09:00
mpatch_module.c mpatch: raise MemoryError instead of mpatchError if lalloc() failed 2016-08-07 10:06:56 +09:00
mpatch.c mpatch: raise MemoryError instead of mpatchError if lalloc() failed 2016-08-07 10:06:56 +09:00
mpatch.h mpatch: raise MemoryError instead of mpatchError if lalloc() failed 2016-08-07 10:06:56 +09:00
namespaces.py namespaces: fix name/node confusion 2016-03-16 23:12:43 +00:00
node.py node: use byte literals to construct nullid and wdirid 2016-03-12 14:04:57 -08:00
obsolete.py i18n: translate abort messages 2016-06-14 11:53:55 +02:00
osutil.c osutil: stop using strcpy 2016-03-19 20:02:19 -04:00
parser.py parser: shorten prefix of alias parsing errors 2016-04-17 12:31:06 +09:00
parsers.c internals: move the bitmanipulation routines into its own file 2016-06-06 13:08:13 +02:00
patch.py patch: use iter(callable, sentinel) instead of while True 2016-08-05 14:00:14 -04:00
pathencode.c pathencode: use hashlib.sha1 directly instead of indirecting through util 2016-06-10 00:25:07 -04:00
pathutil.py error: get Abort from 'error' instead of 'util' 2015-10-08 12:55:45 -07:00
peer.py py3: convert to next() function 2016-05-16 21:30:53 +00:00
phases.py phases: make writing phaseroots file out avoid ambiguity of file stat 2016-06-03 00:44:20 +09:00
policy.py policy: add cffi policy for PyPy 2016-06-07 15:35:58 +02:00
posix.py chgserver: extract utility to bind unix domain socket to long path 2016-05-21 16:52:04 +09:00
profiling.py profiling: don't error with statprof when profiling has already started 2016-08-14 18:28:43 -07:00
progress.py progress: stop excessive clearing (issue4801) 2016-05-06 17:53:06 -05:00
pushkey.py pushkey: use absolute_import 2015-08-08 19:57:27 -07:00
pvec.py pvec: use absolute_import 2015-12-21 21:32:58 -08:00
py3kcompat.py py3compat: use absolute_import 2015-12-21 21:31:57 -08:00
pycompat.py py3: import builtin wrappers automagically by code transformer 2016-08-16 12:35:15 +09:00
registrar.py registrar: add templatefunc to mark a function as template function (API) 2016-03-30 02:10:44 +09:00
repair.py repair: build dirlogs using manifest, rather than repo shortcut method 2016-08-05 13:01:01 -04:00
repoview.py cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1 2016-06-10 00:12:33 -04:00
revlog.py revlog: use an LRU cache for delta chain bases 2016-08-22 21:48:50 -07:00
revset.py revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334) 2016-08-18 17:25:10 +02:00
scmposix.py scmposix: use absolute_import 2015-12-21 21:24:49 -08:00
scmutil.py subrepo: cleanup of subrepo filematcher logic 2016-08-16 08:15:12 +00:00
scmwindows.py py3: conditionalize _winreg import 2016-08-10 04:35:44 +05:30
setdiscovery.py setdiscovery: use iterbatch interface instead of batch 2016-03-01 17:44:41 -05:00
similar.py cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1 2016-06-10 00:12:33 -04:00
simplemerge.py simplemerge: move conflict warning message to filemerge 2015-10-09 13:54:52 -07:00
sshpeer.py wireproto: consolidate code for obtaining "cmds" argument value 2016-08-06 13:46:28 -07:00
sshserver.py sshserver: use iter(callable, sentinel) instead of while True 2016-08-05 14:00:30 -04:00
sslutil.py sslutil: work around SSLContext.get_ca_certs bug on Windows (issue5313) 2016-07-25 12:00:55 -07:00
statichttprepo.py statichttprepo: do not try to write caches 2016-08-05 15:48:09 +02:00
store.py store: use hashlib.sha1 directly instead of through util 2016-06-10 00:10:06 -04:00
streamclone.py streamclone: fix error when store files grow while stream cloning 2016-03-13 02:29:11 +01:00
strutil.py strutil: use absolute_import 2015-08-08 20:01:40 -07:00
subrepo.py error: make hintable exceptions reject unknown keyword arguments (API) 2016-07-11 21:40:02 +09:00
tagmerge.py tagmerge: use absolute_import 2015-08-08 20:10:46 -07:00
tags.py tags: silence hgtagsfnodes reading failures 2016-04-28 15:40:43 -05:00
templatefilters.py pycompat: switch to util.urlreq/util.urlerr for py3 compat 2016-04-06 23:22:12 +00:00
templatekw.py templatekw: fix join format of parents keyword (issue5292) 2016-07-22 22:12:12 +09:00
templater.py templater: rename "right" argument of pad() function 2016-04-22 21:32:30 +09:00
transaction.py transaction: avoid ambiguity of file stat at restoring from backup 2016-06-13 05:11:56 +09:00
treediscovery.py error: get Abort from 'error' instead of 'util' 2015-10-08 12:55:45 -07:00
ui.py ui: drop values returned by inspect.*frame*() to avoid cycles 2016-08-10 15:05:20 +01:00
unionrepo.py unionrepo: properly handle hidden linkrev in revlog (issue5070) 2016-02-22 23:36:04 +01:00
url.py url: use iter(callable, sentinel) instead of while True 2016-08-05 14:00:39 -04:00
util.h internals: move the bitmanipulation routines into its own file 2016-06-06 13:08:13 +02:00
util.py util: checknlink should remove file it creates if an exception occurs 2016-08-19 13:30:40 -07:00
verify.py verify: specify unit for ui.progress when checking files 2016-03-11 20:18:41 +08:00
win32.py win32: use absolute_import 2015-08-08 18:52:59 -07:00
windows.py py3: conditionalize _winreg import 2016-08-10 04:35:44 +05:30
wireproto.py wireproto: remove gboptslist (API) 2016-08-06 15:00:34 -07:00
worker.py error: get Abort from 'error' instead of 'util' 2015-10-08 12:55:45 -07:00