Commit Graph

62 Commits

Author SHA1 Message Date
Ryan McElroy
c8de25429e templatekw: introduce activebookmark keyword
Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
2015-04-15 08:12:04 -07:00
Ryan McElroy
ecf5daf629 templatekw: rename variable current to active
Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
2015-04-15 08:26:01 -07:00
Ryan McElroy
be754988cc bookmarks: simplify iscurrent to isactivewdirparent (API)
Previously this function accepted two optional parameters that were unused by
any callers and complicated the function.

Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
2015-04-14 12:45:15 -07:00
Ryan McElroy
7a091e748f bookmarks: rename bookmarkcurrent to activebookmark (API)
Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
2015-04-14 13:17:33 -07:00
Yuya Nishihara
e4b8aeed9f templatekw: have {manifest} use ctx.manifestnode() for consistency
changeset_printer was updated at dbba1dc6a539 to not access changeset by
index.
2015-04-08 21:04:06 +09:00
Matt Harbison
229d34fc55 templater: replace 'ctx._repo' with 'ctx.repo()' 2015-03-12 23:11:15 -04:00
Yuya Nishihara
f407d33cc5 templatekw: forward _hybrid.get to raw values so that get(extras, key) works
fffa7616be9d implies that the primary goal is to allow "{get(extras, key)}",
but it didn't work.

I'm not sure if _hybrid should forward all unknown attributes to values, so
only "get" is forwarded for now.
2015-02-18 23:17:52 +09:00
Yuya Nishihara
3a37788d5b templater: implement _hybrid.__contains__ so that ifcontains can accept dict
7678263f920c is fine for "{revset()}", but "i.values()[0]" does not work if
each item has more than one values such as "{bookmarks}".

This fixes the problem by using list.__contains__ or dict.__contains__
appropriately.
2015-02-18 23:01:33 +09:00
Yuya Nishihara
5614b9665b templatekw: keep raw list or dict in _hybrid object
This will allow us to handle bookmarks, extras and copies properly in
"ifcontains()" and "get()".
2015-03-08 14:46:42 +09:00
Yuya Nishihara
a861e28d3d templatekw: give name to lambda that constructs variables map of templater
The constructed list is useless for "ifcontains()" and "get()". Instead,
makemap() and raw dict will be passed to _hybrid object.
2015-03-08 14:38:50 +09:00
Yuya Nishihara
e4dfa9d6a0 templatekw: convert list of key/value pairs to sortdict
These sortdict objects will be passed to _hybrid later, which will allow
us to handle them by "ifcontains()" and "get()" as expected.
2015-03-08 14:17:35 +09:00
Yuya Nishihara
4c5195bbaa templatekw: fix {join(bookmarks, sep)} to always show associated bookmarks
The default joinfmt, "x.values()[0]", can't be used here because it picks
either 'bookmark' or 'current' randomly.

I got wrong result with PYTHONHASHSEED=1 on my amd64 machine.
2015-02-18 22:17:35 +09:00
Yuya Nishihara
80c7f8aa9b templatekw: inline showlist() into showbookmarks()
showlist() is the helper to build _hybrid object from a trivial list. It can't
be applied if each value has more than one items, 'bookmark' and 'current' in
this case.

This change is necessary to fix random failure of "{join(bookmarks, sep)}".
2015-02-18 22:10:17 +09:00
FUJIWARA Katsunori
beb57d53bc templatekw: re-add showtags() to list tags keyword up in online help
Changeset 427a0ac924e4 removed "showtags()" definition for "tags"
template keyword from "templatekw.py", because "namespaces" puts a
helper function for it into template keyword map automatically. This
works correctly from the point of view of templating functionality.

But on the other hand, it removed "tags" template keyword from "hg
help templates" unexpectedly, because online help text is built before
"namespaces" puts a helper function for "tags" into template keyword
map.

This patch is a kind of backing 427a0ac924e4 out, but this implements
"showtags()" with newly introduced "shownames()" instead of originally
used "showlist()".
2015-02-01 09:36:47 +09:00
Sean Farley
2ab14b992b templatekw: update namespace calls
Previous patches changed the namespace api to be more of an object-oriented
approach. This patch updates the template function to use said api changes.
2014-12-21 14:01:52 -08:00
Sean Farley
cc2595a676 templatekw: remove unneeded showtags
Now that we have the machinery of namespaces in-place, we use that instead of
hand-rolling our own template function.

Note, this can only be used for tags because both branches and bookmarks have
special case logic for 'default' and the current bookmark (which is something
outside the namespace api for now).
2014-12-15 09:40:02 -08:00
Sean Farley
bb554af3db templatekw: add helper method to generate a template keyword for a namespace
This marks our second feature of the namespace api: automatic template keyword.
This patch adds a method that takes in a namespace and uses the node-to-name
map to output the list of names.
2014-12-14 19:15:37 -08:00
Anton Shestakov
c4f325bd82 templater: implement __len__ for _hybrid
Objects of class _hybrid are returned by such template keywords as children,
bookmarks, tags and others, and also by revset() template function. They are
representing "list of strings" (as hg help template says) for use in templates.
So it would be logical to implement a handy way to count the number of strings
in such list, and that's what __len__ method does.
2014-09-08 20:12:58 +09:00
FUJIWARA Katsunori
f09e7bc4c8 templatekw: add 'subrepos' keyword to show updated subrepositories
'subrepos' template keyword newly added by this patch shows updated
subrepositories.

For the compatibility with the list of subrepositories shown in the
editor at commit:

  - 'subrepos' is empty, at revisions removing '.hgsub' itself

  - 'subrepos' is calculated between the revision and the first parent
    of it, at merge revisions

To avoid silent regression, this patch also confirms "hg diff" of
".hgsubstate" and parents for each target revisions in the test.
2014-07-15 23:34:13 +09:00
FUJIWARA Katsunori
843d08c987 templatekw: add 'currentbookmark' keyword to show current bookmark easily
Before this patch, complicated template expression below is required
to show current active bookmark if it is associated with the
changeset.

    "{bookmarks % '{ifeq(bookmark, current, \"{bookmark}\")}'}"

This patch add 'currentbookmark' keyword to show current bookmark
easily.
2014-07-15 23:34:13 +09:00
Augie Fackler
f8666738b4 templatekw: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
2014-03-12 13:20:42 -04:00
Durham Goode
2d869e6a8e template: add 'current' to scope during {bookmarks % ...}
This adds the keyword 'current' to the template scope when processing a
bookmark list. The 'current' keyword resolves to the name of the currently
active bookmark in the repo. This allows us to apply special labels to the
current bookmark to distinguish it (especially in the case where there are
multiple bookmarks on the same commit).

Example: "{bookmarks % '{bookmark}{ifeq(bookmark, current, \"*\")} '}"

Results in a space separated list of bookmarks where the current bookmark has
an asterix.
2014-02-11 21:40:33 -08:00
Andrew Shadura
88eaae271b templatekw: allow tagtypes other than global in getlatesttags
hg-git uses tagtype 'git', for example, so it's better
to check for tagtype != 'local', not strictly for 'global'
2013-12-23 14:14:31 +01:00
Matthew Turk
c0982bbb31 template: modify showextras to return a hybrid
This modifies slightly the behavior introduced in fcc482469a3c to allow
showextras to return a hybrid, rather than showlist.  The example in the
template help file now executes and returns meaningful results.
2013-11-21 15:46:49 -05:00
Matt Mackall
df890e8b8a merge with stable 2013-11-21 15:08:30 -06:00
Matt Mackall
1b2df1cd91 help: drop help for branches template keyword
The {branches} keyword dates to pre-1.0 Mercurial's tag-like branch
scheme which allowed changesets to be on multiple branches. This is
the last visible vestige of that scheme, users should instead be using
{branch}, possibly with if().
2013-11-21 11:49:31 -06:00
Matt Mackall
fb22d26dbd templater: makes branches work correctly with stringify (issue4108) 2013-11-21 11:30:52 -06:00
Matthew Turk
5493f40b2a template: change extras to use showlist rather than manual templ call.
This enables start_extras and end_extras in template maps.
2013-11-15 18:08:50 -05:00
Matthew Turk
3fa07ee864 help: document about {extras} template keyword
This adds text about the "extras" template keyword, similar to that proposed by
Yuya Nishihara previously.
2013-11-15 16:53:54 -05:00
Matt Mackall
7f909e9c22 templatekw: add default styles for hybrid types (issue3887)
This allows elements like file_copies to be printed as 'name (source)'
when used with join.
2013-04-16 09:44:29 -05:00
Matt Mackall
b88b659df4 templater: properly handle file_copies with % 2013-02-22 13:45:46 -06:00
Matt Mackall
0dd30183db templating: make new-style templating features work with command line lists 2012-09-21 18:54:00 -05:00
epriestley
0e72c6b3d0 templatekw: add p1rev, p1node, p2rev, p2node keywords
The {parents} template is cumbersome for some uses, as it does not show
anything if there's only one "natural" parent and you can't use it to get the
full 40 digit node hashes for parents unless you rely on the behavior of
the --debug flag.

Introduce four new template keywords: {p1rev}, {p2rev}, {p1node} and
{p2node}. The "node" flavors of these always show full 40 digit hashes,
but users can get the short version with a filter construction like
'{p1node|short}'.
2012-07-10 08:43:32 -07:00
epriestley
182772cb75 templatekw/help: document the {parents} keyword
The {parents} keyword does not appear in the generated documentation for
templates because it is added by `changeset_templater` (and this is because
its behavior depends on `ui`, so it can't be defined as a normal template
keyword; see comments in `changeset_templater._show()`).

Add it to the documentation synthetically by creating a stub documentation
function.

Test plan: built the docs and examined the man page to verify that this
keyword is now documented. I'm not sure how to test the i18n extraction part,
but assume it will just work given that this patch doesn't do anything too
crazy.
2012-07-10 09:11:53 -07:00
Wagner Bruna
ec5d06f3b6 templatekw: fix phase keywords 2012-01-20 13:10:01 -02:00
Pierre-Yves David
47a0f8f964 phases: `{phase}` template keyword display the phase name
``{phaseidx}`` is providing the phase index as integer. This integer
 representation is useful when people need to use the fact that phase are
 ordered.

Test keep using the number version for readability purpose.
2012-01-06 11:20:49 +01:00
Pierre-Yves David
ef7ba6c6d0 phases: add a phase template keyword 2011-10-09 14:25:04 +02:00
Yann E. MORIN
ad9ca506f5 templates: add 'bisect' keyword to return a cset's bisect status
This new 'bisect' template expands to a cset's bisection status (good,
bad and so on...). There is also a new 'shortbisect' filter that yields
a single char representing the cset's bisection status.

It uses the two recently-added hbisect.label() and .shortlabel() functions.

Example output using the repository in test-bisect2.t, and some made-up
state of the 'end at merge' test (with graphlog, it's so explicit):

  $ hg glog --template '{rev}:{node|short} {bisect}\n'  \
            -r 'bisect(range)|bisect(ignored)'
  o  17:228c06deef46: bad
  |
  o  16:609d82a7ebae: bad (implicit)
  |
  o    15:857b178a7cf3: bad
  |\
  | o  13:b0a32c86eb31: good
  | |
  | o  12:9f259202bbe7: good (implicit)
  | |
  | o  11:82ca6f06eccd: good
  | |
  @ |    10:429fcd26f52d: untested
  |\ \
  | o |  9:3c77083deb4a: skipped
  | |/
  | o  8:dab8161ac8fc: good
  | |
  o |    6:a214d5d3811a: ignored
  |\ \
  | o |  5:385a529b6670: ignored
  | | |
  o | |  4:5c668c22234f: ignored
  | | |
  o | |  3:0950834f0a9c: ignored
  |/ /
  o /  2:051e12f87bf1: ignored
  |/

And now the same with the short label:

  $ hg log --template '{bisect|shortbisect} {rev}:{node|short}\n'
    18:d42e18c7bc9b
  B 17:228c06deef46
  B 16:609d82a7ebae
  B 15:857b178a7cf3
    14:faa450606157
  G 13:b0a32c86eb31
  G 12:9f259202bbe7
  G 11:82ca6f06eccd
  U 10:429fcd26f52d
  S 9:3c77083deb4a
  G 8:dab8161ac8fc
    7:50c76098bbf2
  I 6:a214d5d3811a
  I 5:385a529b6670
  I 4:5c668c22234f
  I 3:0950834f0a9c
  I 2:051e12f87bf1
    1:4ca5088da217
    0:33b1f9bc8bc5

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
2011-09-22 01:36:01 +02:00
Steven Brown
b13eee65a4 patch: restore the previous output of 'diff --stat'
Restore the previous diffstat behaviour of scaling by the maximum number of
changes to a single file. Changeset 7bb0e22a7988 modified the diffstat to be
scaled by the total number of changes. This seems to have been unintentional.
2011-05-26 22:51:02 +08:00
Matt Mackall
0842cf2d1e templatekw: use diffstatsum in diffstat keyword 2011-05-21 15:09:15 -05:00
Matt Mackall
1d5abac148 help: consolidate topic hooks in help.py
This removes loops like cmdutil->revset->help->extensions->cmdutil and
simplifies the code.
2011-05-13 12:57:27 -05:00
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Matt Mackall
a8dd64dcb0 misc: replace .parents()[0] with p1() 2011-04-04 16:21:59 -05:00
Patrick Mezard
d297dd65c7 help: extract items doc generation function 2011-03-12 12:46:31 +01:00
Patrick Mezard
3a56f6a3b1 templates: document missing keywords or filters
Keywords keywords are not documented yet but are turned into function
definitions to avoid lambda docstring weirdness.
2011-03-12 12:46:31 +01:00
Patrick Mezard
77482b30d5 templates: generate keyword help dynamically 2011-03-12 12:46:31 +01:00
David Soria Parra
60c47bdb07 templater: add bookmarks to templates and default output
as bookmarks are not dispalyed as tags anymore, we add a bookmark label
to the changeset printer.
2011-02-11 19:47:39 +01:00
Eric Eisner
8113ebb989 template: add showbranch template for {branch}
Like showbranches, but always yields exactly one branch. Replaces the less
correct {branches|nonempty}.
2010-12-13 10:30:15 -05:00
Alexander Solovyov
b7f3f7f2f4 templatekw.showdiffstat: use ctx.diff() instead of calling patch 2010-12-07 15:50:28 +01:00
Matt Mackall
8b31da4540 branch: operate on branch names in local string space where possible
Previously, branch names were ideally manipulated as UTF-8 strings,
because they were stored as UTF-8 in the dirstate and the changelog
and could not be safely converted to the local encoding and back.

However, only about 80% of branch name code was actually using the
right encoding conventions. This patch uses the localstr addition to
allow working on branch names as local strings, which simplifies
handling so that the previously incorrect code becomes correct.
2010-11-24 15:56:32 -06:00