Commit Graph

197 Commits

Author SHA1 Message Date
Gregory Szorc
ef80cfae6c webcommands: define web commands using a decorator
Other parts of Mercurial have evolved to use decorators to declare
commands or handlers. This patch gives the same treatment to web
commands.
2015-02-06 19:06:17 -08:00
Yuya Nishihara
b17cf752d2 hgweb: use revset.spanset where appropriate
It is remainder of 8c5f695903af where spanset was introduced.
2015-02-02 22:28:52 +09:00
Gregory Szorc
2eb1a12cad hgweb: extract changelist entry generation into own function
I want to supplement changelist entries (used by shortlog and changelog
endpoints) with custom metadata from an extension. i.e. I have extra
per-changeset metadata that I wish to make available to templates so it
can be rendered on hgweb.

To facilitate this, I've extracted the logic for creating a changeset
data structure into its own function, where it can be wrapped by
extensions.

Ideally, hgweb would use the same templater as the command line and have
full access to templatekw.keywords. But that's a lot of work. This patch
gets us some of the benefit without all the work.

Many other hgweb commands could benefit from similar refactorings. I'm
going to wait to see how this patch is received before I go crazy on
extracting inline functions.
2015-01-06 20:14:52 -08:00
Anton Shestakov
fa59efaa89 hgweb: allow viewing diffs against p1 or p2 for merge commits (issue3904)
This adds UI portion of the feature that has resided in mercurial since 2012.
Back then the interface was added together with the code, but was shortly
backed out because it was deemed "not ready". Code, however, stayed.

For the original feature and its implementation, see issue2810 and
3ff83729b63f.

In short, the backed-out interface had two outstanding issues:
1. it was introducing an entirely new term (baseline) and
2. it was present on every changeset's page, even for changesets with 1 parent
   (or no parents), which didn't make sense

This patch implements a hopefully better interface because:
1. it uses the usual terms (diff) and
2. it only shows up when there actually are 2 parents.
2015-01-03 17:50:21 +08:00
Siddharth Agarwal
ed470d2b63 webcommands.annotate: explicitly only honor whitespace diffopts
The whitespace ones are the only ones the annotate logic cares about anyway, so
there's no visible impact.
2014-11-21 16:16:03 -08:00
Matt Harbison
eae366b6a1 hgweb: fix a crash when using web.archivesubrepos
A matcher is required when enabling the subrepo option on archival.archive(),
because that calls match.narrowmatcher(), which accesses fields on the object.
It's therefore probably a bad idea to default the matcher to None on archive(),
but that's a fix for default.
2014-11-05 21:33:45 -05:00
Mads Kiilerich
374f35aab5 templater: introduce templatepaths for getting paths searched for templates
Avoid function with different return types depending on parameters.
2014-09-28 16:57:37 +02:00
Mads Kiilerich
23da6c1d98 cleanup: avoid _ for local unused tmp variables - that is reserved for i18n
_ is usually used for i18n markup but we also used it for I-don't-care
variables.

Instead, name don't-care variables in a slightly descriptive way but use the _
prefix to designate unused variable.

This will mute some pyflakes "import '_' ... shadowed by loop variable"
warnings.
2014-08-15 16:20:47 +02:00
FUJIWARA Katsunori
350af37dc3 hgweb: show revisions and hashes gotten from changelog in "comparison" page
Before this patch, revision numbers and hash values in "comparison"
page are gotten from not changelog but filelog.

Such filelog information is useful only for hgweb debugging, and may
confuse users.

This patch shows revision numbers and hash values gotten from
changelog in "comparison" page.
2014-04-17 09:36:09 +09:00
FUJIWARA Katsunori
fc4364cead hgweb: make "comparison" get parent from not filelog but changelog
Before this patch, "comparison" shows unexpected result, when the
specified file is not modified in the specified revision, even though
"diff" shows empty result.

When REV doesn't change specified FILE, "diff" shows:

  "hg diff -c REV FILE"

but "comparison" shows:

  "hg diff -c `hg parents -r REV FILE` FILE"

In other words, the former gets parent from changelog, but the latter
gets one from filelog.

This may confuse users browsing (and switching "diff" and
"comparison" of) files in the specified revision.

This patch makes "comparison" get parent from not filelog but
changelog, to show "hg diff -c REV FILE" in both "diff" and
"comparison" pages.
2014-04-17 09:36:08 +09:00
Lucas Moscovicz
441a4355fa webcommands: changed code to use lazy classes when calling dagwalker
This needs to be changed to use a baseset since dagwalker now expects to
receive a smartset. This is basically wrapping revs into a baseset to be
compatible with smartset implementations.
2014-03-14 08:47:57 -07:00
Augie Fackler
0e4f8ed27f webcommands: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
2014-03-12 13:29:07 -04:00
Lucas Moscovicz
ef8bd69f5f revset: added baseset class (still empty) to improve revset performance
This class is going to be used to cache the set that is created from this list
in many cases while evaluating a revset.
2014-01-21 11:39:26 -08:00
Brodie Rao
7dec608ff1 hgweb: simplify branches with repo.branchmap().iterbranches() 2013-09-16 01:08:29 -07:00
Brodie Rao
adc7ea02cb hgweb: simplify summary with repo.branchmap().iterbranches() 2013-09-16 01:08:29 -07:00
Matt Mackall
40d3e4ba4e merge with stable 2013-11-22 17:26:58 -06:00
Isaac Jurado
b5e7be1139 hgweb: ignore non numeric "revcount" parameter values (issue4091) 2013-11-08 09:48:01 +01:00
Wagner Bruna
b966a63297 hgweb, i18n: do not translate search mode description
The search mode description can't be translated by itself, since
it's displayed as part of a template phrase (the "Assuming ..."
/ "Use ... instead" bits). Just drop the translation markers for
now, since the templates themselves currently do not support
translations.
2013-11-13 16:46:46 -02:00
Alexander Plavin
91879c1d15 hgweb: use semantically suitable filelog.revs in filelog
The functions are equivalent in behaviour, so no behavior change.
2013-11-10 18:23:29 +04:00
Alexander Plavin
1fa7978d6b hgweb: always compute all entries and latestentry in filelog
This is the same thing which was done for changelog earlier, and it doesn't
affect performance at all. This change will make it possible to get the first
entry of the next page easily without computing the list twice.
2013-11-10 18:07:56 +04:00
Alexander Plavin
6a6391cdb6 hgweb: remove unused argument of entries function in filelog
This doesn't change the behavior as the argument wasn't used anyway.
2013-11-10 18:05:53 +04:00
Mads Kiilerich
eabc047878 spelling: random spell checker fixes 2013-10-24 01:49:56 +08:00
Matt Mackall
397a3b5d72 merge with stable 2013-10-09 14:15:34 -07:00
Matt Mackall
e1cd16976f hgweb: add escaping of tags and bookmarks in graph view 2013-10-09 12:02:32 -07:00
Matt Mackall
1b8efe2652 hgweb: escape branch names in graph view 2013-10-07 15:21:17 -07:00
Mads Kiilerich
1e900bb145 check-code: check for spaces around = for named parameters 2013-10-03 14:50:47 +02:00
Alexander Plavin
f7a860d1a8 hgweb: replace next(revs) to revs.next() to fix compatibility with Python 2.5- 2013-07-25 15:27:41 +04:00
Alexander Plavin
953f96e356 hgweb: fix duplication for some search queries
Given that N is maximum revision number in a repo, than if a revision with
number N-100n or N-100n+1 (for any integer n) is found with a hgweb search,
this revision is duplicated in search results.
2013-07-21 01:38:04 +04:00
Alexander Plavin
e2c135afa3 hgweb: add link to force literal keyword search
This makes it possible to make keyword search in case the search query also
specifies an exact revision (like '1234' or 'abcdef'), or a revset expression.
2013-09-06 13:30:56 +04:00
Alexander Plavin
ce8859ee70 hgweb: pass variable with current search mode name to the search template 2013-09-06 13:30:56 +04:00
Alexander Plavin
eee67f7bda hgweb: add nextentry variable for easy pagination in changelog
nextentry always contains the first entry not shown on current page (if there is
such entry)
2013-09-06 13:30:57 +04:00
Alexander Plavin
be32ad07fd hgweb: always compute all entries and latestentry in changelog
Get the whole list of entries before rendering instead of using lazy evaluation.
This doesn't affect the performance for usual case when the entries are shown
anyway. When both entries and latestentry are used, this performs unnoticeably
faster, and for pages which use only latestentry (quite uncommon case) it
would be a bit slower.
This change will make it possible to get the first entry of the next page easily
without computing the list twice.
2013-09-06 13:30:57 +04:00
Alexander Plavin
3f021369d6 hgweb: remove unused argument of changelist function in changelog
This doesn't change the behavior as the argument isn't used anyway, and
it's a preparation to the next patches,
2013-09-06 13:30:57 +04:00
Alexander Plavin
e1392e4ce2 hgweb: add revset syntax support to search
This mode is used when all the conditions are met:
- 'reverse(%s)' % query string can be parsed to a revset tree
- this tree has depth more than two, i.e. the query has some part of
revset syntax used
- the repo can be actually matched against this tree, i.e. it has only existent
function/operators and revisions/tags/bookmarks specified are correct
- no revset regexes are used in the query (strings which start with 're:')
- only functions explicitly marked as safe in revset.py are used in the query

Add several new tests for different parsing conditions and exception handling.
2013-09-06 13:30:56 +04:00
Alexander Plavin
279ad45b7d hgweb: import the whole util module in webcommands instead of just one function
This is to allow using other functions from this module easily.
2013-09-03 20:02:53 +04:00
Alexander Plavin
0aac0cdac8 hgweb: add string constants for search mode names
It helps detecting mistakes in the mode names.
2013-09-04 19:40:04 +04:00
Alexander Plavin
eac9cb37ca hgweb: always run search when a query is entered (bc)
This changes the behavior for queries which point at a revision directly,
now the output is consistent to other cases: it results in only this matched
revision shown, not the log starting with it.
A new test checks this behaviour and fails for the old one.
2013-07-19 02:09:13 +04:00
Alexander Plavin
ea40ee8f63 hgweb: search() function supports direct pointing to revision
This doesn't change the behavior, as queries directly pointing to revisions
are not delegated to the search() function now.
2013-07-19 02:41:11 +04:00
Alexander Plavin
d2cc03584c hgweb: pass arguments which a function depends on explicitly in search
This changes makes clearer which arguments can a function depend on. Now all
the modified functions depend on the 'query' argument only, but future additions
will change it.
2013-08-22 16:42:10 +04:00
Alexander Plavin
44f0fb3b4e hgweb: add dynamic search function selection, depending on the query
This allows adding other specific search functions, in addition to current
keyword search.
2013-08-22 16:45:23 +04:00
Alexander Plavin
1a5c5a0196 hgweb: cleaner if conditions in changelog() function
This removes unneeded extra nesting level and extra variable, which makes
the code easier to understand.
2013-07-19 02:08:19 +04:00
Alexander Plavin
888e02c499 hgweb: separate search itself and template generation
This will make it simpler to add other search modes.
2013-07-15 01:10:22 +04:00
Alexander Plavin
0b5af3690c hgweb: fix incorrect revisions count in graph (issue3977)
Actual amount of revisions is used now instead of their numbers in the repo
before to deal with skipped numbers correctly.
2013-07-25 02:41:22 +04:00
Alexander Plavin
553f7e5d2b hgweb: fix incorrect way to count revisions in log (issue3977)
Actual amount of revisions is used now instead of their numbers in the repo
before to deal with skipped numbers correctly.
This iterates starting from the newest revision (which is shown on top)
yielding up to the specified count, instead of the reversed order used before.
Effect of this change on efficiency is negligible, when the same changesets are
returned.
2013-07-25 02:22:39 +04:00
Alexander Plavin
f8894d94ab hgweb: always start graph with the revision in url
It is the same fix for graph command, as was recently for log. This makes the
specified revision be always on top of the graph view.
Before the patch, for example with repo having revisions 0, 1, 2, 3 and revision
in url being '2', all revisions were shown and the specified one wasn't
the first.
2013-07-25 02:48:21 +04:00
Alexander Plavin
39b918d7ca hgweb: always start log with searched revision
This makes the specified revision be always on top of the list.
Before the patch, for example with repo having revisions 0, 1, 2, 3 and user
searching for '2', all revisions were shown and the specified one wasn't
the first.
2013-07-13 02:36:29 +04:00
Alexander Plavin
f36cebc920 hgweb: run search instead of showing wrong error for ambigious identifier
Before this when multiple changesets hashes in the repos started with the
search query string, error was given that the revision isn't found, and it
was misleading. Now a simple keyword search runs in this case.
2013-07-12 01:58:48 +04:00
Alexander Plavin
79f178845b hgweb: move local changelist function to the beginning of the parent one 2013-07-15 01:05:42 +04:00
Alexander Plavin
b84ced8343 hgweb: show current search query in the input field 2013-07-11 17:01:54 +04:00
Angel Ezquerra
21863e23e9 hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files 2013-03-21 23:27:37 +01:00