Commit Graph

74 Commits

Author SHA1 Message Date
Yuya Nishihara
634500f64e templater: relax unquotestring() to fall back to bare string
This is convenient for our use case where quotes are optional except in
a map file.
2016-03-26 18:12:12 +09:00
Kostia Balytskyi
e31d7d20ae formatter: make labels work with templated output
To describe the bug this fix is addressing, one can do
   ``$ hg status -T "{label('red', path)}\n" --color=debug``
and observe that the label is not applied before my fix and applied with it.
2016-03-08 04:08:33 -08:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Yuya Nishihara
ca46de8232 formatter: use dict.update() to set arguments passed to write functions
This isn't important, but update() is better than loop in general.
2015-09-23 21:54:47 +09:00
Yuya Nishihara
78102f8d39 formatter: verify number of arguments passed to write functions
zip() takes the shortest length, which can be a source of bug.
2015-09-23 21:51:48 +09:00
Gregory Szorc
9142160136 formatter: use absolute_import 2015-08-08 19:17:40 -07:00
Matt Mackall
0e22b7683e formatter: mark developer options 2015-06-25 17:49:11 -05:00
Matt Mackall
88eb59a3ff formatter: add template support
This lets all the non-log commands that use the formatter use
templates. There are still some things that don't work, for instance:

- color (needs "repo" in map)
- shortest (needs "ctx" in map)
2015-06-10 14:33:38 -05:00
Matt Mackall
110d98d512 formatter: add a method to build a full templater from a -T option 2015-06-10 14:30:18 -05:00
Matt Mackall
8b7c4f2d3a formatter: move most of template option helper to formatter
We want to share this function between formatter and cmdutils. It
doesn't belong in templater because it imports knowledge of ui layers
that shouldn't be there. We'd prefer cmdutil to layer on the formatter
rather than vice-versa. Since the formatter is the handler for -T
options for all non-log commands, let's move the helper there. We
leave the bits specific to the old --style option behind.
2015-06-10 14:29:13 -05:00
Yuya Nishihara
410cff16c8 formatter: convert None to json null
It will be used by "annotate" command to represent the workingctx revision.
2014-09-17 22:34:34 +09:00
Yuya Nishihara
f7d73883e0 formatter: add general way to switch hex/short functions
This seems a bit awkward, but it can avoid duplicates in annotate, tags,
branches and bookmarks.

I guess fm.hexfunc can eventually be removed (or redesigned) when it gets
template backend.
2014-10-03 22:20:02 +09:00
Yuya Nishihara
f8be8539d4 formatter: convert booleans to json
It will be used in branches output.
2014-10-02 23:20:59 +09:00
Yuya Nishihara
9678578b10 formatter: convert float value to json
It will be used to encode ctx.date().
2014-09-17 22:21:01 +09:00
Yuya Nishihara
a0e25a7bf4 formatter: have jsonformatter accept tuple as value
This is necessary for "annotate" to encode ctx.date() in the same manner
as jsonchangeset printer.

It doesn't support list object because keeping mutable object in _item could
be a source of hidden bugs.  Also, I can't think of the use case.
2014-09-17 21:30:22 +09:00
Yuya Nishihara
c8c3f2cd83 formatter: extract function that encode values to json string
This is the stub for tuple support, which will be used to encode ctx.date()
in the same manner as jsonchangeset printer.
2014-09-17 21:15:43 +09:00
Yuya Nishihara
e91eea1470 formatter: correct bool testing which should be __nonzero__ in Python 2 2014-09-17 00:31:03 +09:00
Matt Mackall
8a32bb8140 formatter: add pickle format
This gives convenient Python2 output. Python 3 users will need encoding=bytes.
2014-09-12 18:36:38 -05:00
Matt Mackall
949498b27d formatter: add json formatter 2014-09-12 18:29:29 -05:00
Matt Mackall
be3bc4f866 formatter: make debug style match Python syntax 2014-09-12 19:06:11 -05:00
Matt Mackall
8d7146d630 formatter: add condwrite method
This makes handling conditional output tidier
2012-11-03 14:37:50 -05:00
David M. Carr
9e830e5477 formatter: improve implementation of data method
This alternate syntax was proposed by Bryan O'Sullivan in a review of
441ebe37ceb5.  I haven't been able to measure any particular performance
difference, but the new syntax is more concise and easier to read.
2012-09-20 23:30:59 -04:00
David M. Carr
9b004d69e6 formatter: add base implementation of data method
Previously, nothing was done with the passed in values, which clearly wasn't
the intention.
2012-09-15 22:50:34 -04:00
Matt Mackall
0acc5a5ce3 formatter: add basic formatters 2012-02-20 16:42:47 -06:00