Commit Graph

18823 Commits

Author SHA1 Message Date
Yuya Nishihara
c1736d34f9 revset: add support of keyword arguments to ancestors() and descendants()
Prepares for adding depth parameter.
2017-06-18 12:06:22 +09:00
Yuya Nishihara
d1abf1770e revsetlang: check arguments passed to ancestors() before optimizing to only()
Future patches will add depth parameter to ancestors(), which isn't compatible
with only().
2017-06-18 11:57:28 +09:00
Yuya Nishihara
fbc6f41a27 revsetlang: factor out helper to match ancestors() in parsed tree
More checks will be added.
2017-06-18 11:39:03 +09:00
Yuya Nishihara
2db9374d13 templatekw: use common "rev:node" format as the default of predecessors
I'm not sure if this is better. If we're planning to add a template keyword
that returns obsoleted nodes unavailable in the repo (i.e. they have no valid
revision numbers), we might want to use the current "node"-only format
everywhere.
2017-06-17 13:34:18 +09:00
Yuya Nishihara
c3de10454c templatekw: populate all keywords depending on predecessor in map operation
This is what showparents() does. repo[precnode] should never fail since its
validity is tested by closestpredecessors().
2017-06-17 13:23:55 +09:00
Yuya Nishihara
5e5cff46c2 templatekw: reference predecessor node id as {node} in map operation
More predecessor-depending values will be populated by the next patch.
2017-06-17 13:18:03 +09:00
Yuya Nishihara
d2a35c3c21 help: clarify ancestors() and descendants() include given set (issue5594)
Also unified "a changeset" to "changesets".
2017-06-18 22:46:56 +09:00
Yuya Nishihara
e75a42ecc9 dagop: move blockancestors() and blockdescendants() from context
context.py seems not a good place to host these functions.

  % wc -l mercurial/context.py mercurial/dagop.py
    2306 mercurial/context.py
     424 mercurial/dagop.py
    2730 total
2017-02-19 19:37:14 +09:00
Yuya Nishihara
54b39af2a1 dagop: split module hosting DAG-related algorithms from revset
This module hosts the following functions. They are somewhat similar (e.g.
scanning revisions using heap queue or stack) and seem non-trivial in
algorithmic point of view.

 - _revancestors()
 - _revdescendants()
 - reachableroots()
 - _toposort()

I was thinking of adding revset._fileancestors() generator for better follow()
implementation, but it would be called from context.py as well. So I decided
to create new module.

Naming is hard. I couldn't come up with any better module name, so it's called
"dag operation" now. I rejected the following candidates:

 - ancestor.py - existing, revlog-level DAG algorithm
 - ancestorset.py - doesn't always return a set
 - dagalgorithm.py - hard to type
 - dagutil.py - existing
 - revancestor.py - I want to add fileancestors()

  % wc -l mercurial/dagop.py mercurial/revset.py
    339 mercurial/dagop.py
   2020 mercurial/revset.py
   2359 total
2016-10-16 18:03:24 +09:00
Pulkit Goyal
43464e00e4 py3: convert keys of kwargs back to bytes using pycompat.byteskwargs() 2017-06-17 15:29:26 +05:30
Pulkit Goyal
591b6e9fb9 py3: use pycompat.strkwargs() to convert kwargs keys to str before passing 2017-06-17 15:05:11 +05:30
Pulkit Goyal
d1e9e38065 py3: use '%d' instead of '%s' for integers
Python 3 does not let you use '%s' for integers.
2017-06-17 14:53:25 +05:30
Pierre-Yves David
92f804bd36 check-concurrency: expose the feature as 'concurrent-push-mode'
We move the feature to a proper configuration and document it. The config goes
in the 'server' section because it feels like something the server owner would
want to decide. We pick and open field because it seems likely that other
checking levels will emerge in the future. (eg: server like the mozilla-try
server will likely wants a "none" value)

The option name contains 'push' since this affects 'push' only. The option value
'check-related' is preferred over one explicitly containing 'allow' or 'deny'
because the client still have a strong decision power here. Here, the server is
just advising the client on the check mode to use.
2017-05-28 00:12:38 +02:00
Martin von Zweigbergk
ad7cafdd66 exchange: switch to usual way of testing for bundle2-ness
We used safehasattr() in one place, but we use isinstance() for this
everywhere else, so switch to the latter.
2017-06-16 22:57:31 -07:00
Matt Harbison
fcd2a4509b plan9: drop py26 hacks 2017-06-16 18:42:03 -04:00
Yuya Nishihara
9be9c72a7a revset: fix negative ancestor spec to not return changectx objects
The order was unstable because of this.
2017-06-18 12:25:23 +09:00
Pierre-Yves David
f9505c66f4 obsolete: use ProgrammingError over assert for volatile set registration
We have ProgrammingError now.
2017-05-01 05:57:36 +02:00
Martin von Zweigbergk
7059c57ed3 strip: remove a redundant setting of hookargs
bundle2.applybundle() will set both 'source' and 'url'.
2017-06-16 10:13:44 -07:00
Martin von Zweigbergk
7cf43e8a10 unbundle: move streamclone error case away from bundle[12] cases
The bundle1 and bundle2 cases are more similar, and having the
streamclone case in between is distracting.
2017-06-16 10:38:14 -07:00
Martin von Zweigbergk
dc0d2c3515 wireproto: update reference to deleted addchangegroup()
Thanks to Yuya for catching this.
2017-06-16 09:37:22 -07:00
Boris Feld
6b02ddc020 template: add predecessors template
Add a 'predecessors' template that returns the list of all closest known
predecessors for a changectx. The elements of the list are row changectx node id
formatted by default as short nodes.

The "closest predecessors" are the first locally known revisions encountered
while, walking predecessors markers. For example:

  1) If a (A, (B)) markers exists and both A and B are locally known A is a
  closest predecessors of B.

  2) If a (A, (B)) and (B, (C)) markers exists and only A and C are known
  locally, A will be the closest precursors of C.

This logic respect repository filtering. So hidden revision will be skipped by
this logic unless --hidden is specified. Since we only display the visible
predecessors, this template will not display anything in most case. It makes a
good candidate for inclusion in the default log output.

I added a new test-file for testing the precursors in various scenarios. This
test file will also be used for the successors template.

A new "obsutil" module has been added to start gathering utility function
outside of the large obsolete.py module.
2017-06-15 13:02:58 +02:00
Yuya Nishihara
1e4e9f46f4 commit: select template by spec.ref name
And load all templates defined in [committemplate] since the selected
template is no longer be named as 'changeset'.
2017-04-22 20:29:45 +09:00
Yuya Nishihara
762b9db3ef commit: do not look up committemplate in template paths (BC)
From 0b3f9fe7a730 and 5b9e4c6dd140, I don't think the current behavior is
intended. Commit templates should be processed as literal templates.
2017-04-22 15:28:29 +09:00
Yuya Nishihara
de79d3261a formatter: always store a literal template unnamed
Now spec.ref should be '' if spec.tmpl is specified. Since spec.ref is the
option to select the initial template to be rendered, it doesn't make sense
to store the given literal template as spec.ref.
2017-05-06 17:03:59 +09:00
Yuya Nishihara
75bcdb63fb formatter: load templates section like a map file
Since a map file has another level to select a template (spec -> mapfile
-> topic), this isn't exactly the same as how a map file works. But I believe
most users would expect the new behavior.

A literal template is stored as an unnamed template so that it will never
conflict with the templates defined in [templates] section.
2017-04-22 20:14:55 +09:00
Yuya Nishihara
41654e97a9 templater: add simple interface for unnamed template (API)
This provides a simpler API for callers which don't need full templating
stack. Instead of storing the given template as the name specified by topic,
use '' as the default template to be rendered.
2017-04-22 19:56:47 +09:00
Augie Fackler
708044618a ui: add support for a tweakdefaults knob
We've been talking for years about a one-stop config knob to opt in to
better behavior. There have been a lot of ideas thrown around, but
they all seem to be too complicated to get anyone to actually do the
work.. As such, this patch is the stupidest thing that can possibly
work in the name of getting a good feature to users.

Right now it's just three config settings that I think are generally
uncontroversial, but I expect to add more soon. That will likely
include adding new config knobs for the express purpose of adding them
to tweakdefaults.
2017-06-14 20:56:34 -04:00
Martin von Zweigbergk
d75cb87451 localrepo: remove unused addchangegroup() (API)
This completes the cleanup started in f1b3c9ce0ce7 (localrepo: move
the addchangegroup method in changegroup module, 2014-04-01).
2017-06-15 15:13:18 -07:00
Martin von Zweigbergk
02b210363d changegroup: rename "dh" to the clearer "deltaheads"
We have a lot of frequently used abbreviations, but this is not one of
them.
2017-06-15 13:47:54 -07:00
Martin von Zweigbergk
f2408d8030 changegroup: rename "srccontent" to "cgnodes"
It's the list of nodes in the incoming changegroup, so "cgnodes" made
more sense to me.
2017-06-15 13:42:41 -07:00
Martin von Zweigbergk
daced3540c revlog: rename list of nodes from "content" to "nodes"
It seems like the reason for "content" is that the variable contains
the nodes that the changegroup "contains", see c2901cddb53f (revlog:
make addgroup returns a list of node contained in the added source,
2012-01-13), but "nodes" seems much clearer.
2017-06-15 13:42:35 -07:00
Martin von Zweigbergk
12dbf027df revlog: delete obsolete comment
The comment seems to refer to code that was deleted in a46638c640d8
(revlog.addgroup(): always use _addrevision() to add new revlog
entries, 2010-10-08).
2017-06-15 13:25:41 -07:00
Martin von Zweigbergk
f0c7377259 revlog: delete dead assignment in addgroup() 2017-06-15 13:23:21 -07:00
Pulkit Goyal
bbb31d83e6 pycompat: move the queue related definitions below queue import
This helps in understanding why empty and queue are there.
2017-06-16 03:01:22 +05:30
Pulkit Goyal
925f55059d pycompat: move multiline comments above a function to function doc
pycompat.py is unorganized and looks ugly. Next few patches will try to make it
look more cleaner so that adding more code is easy and reading code also.

This patch moves the multiline comments above functions to function docs. While
moving, I improved the comments and make them better suitable for func doc.

While I was here I drop a unrequired and misplaced comment.
2017-06-16 02:48:17 +05:30
Pulkit Goyal
de83c26a54 py3: replace dict.iterkeys() with iter(dict)
dict.iterkeys() does not exists on Python 3.
2017-06-16 01:46:47 +05:30
Pulkit Goyal
dee99e29f8 py3: explicitly convert dict.values() to a list on py3
dict.values() returns a dict_values() object, so we need to pass it into
list() explicitly to get one.
2017-06-16 01:28:23 +05:30
Pulkit Goyal
fc04ed5c12 py3: add a new bytesurl() to convert a str url into bytes 2017-06-16 00:36:17 +05:30
Pulkit Goyal
6554e26b45 py3: add a new strurl() which will convert a bytes url to str 2017-06-16 00:32:52 +05:30
Gregory Szorc
768455e422 profiling: allow configuring minimum display threshold for hotpath
statprof.display_hotpath() accepts a "limit" function to choose the
minimum threshold for samples to display. The default is 0.05, which
means you don't need individual items contributing less than 5%.

I had a need to adjust this threshold. We already have a config
option for it. So let's reuse it.

check-config.py doesn't like having multiple defaults for the
ui.configwith() calls. The behavior is obviously correct. I'm
not sure if it is worth teaching check-config.py how to ignore
this. So I've just accepted the new output.
2017-06-15 11:10:51 -07:00
Gregory Szorc
a71e4d026c config: document profiling.show{min,max} 2017-06-15 11:04:46 -07:00
Martin von Zweigbergk
76831e82ba exchange: use context manager for bundle1 unbundling
The lazy locking is not used for bundle1, so using a regular context
manager is clearer.
2017-06-15 22:57:20 -07:00
Martin von Zweigbergk
911516dae8 unbundle: use context manager for transaction 2017-06-15 14:47:18 -07:00
Martin von Zweigbergk
c8f8b266e4 clonebundle: use context managers for lock and transaction 2017-06-15 17:00:32 -07:00
Yuya Nishihara
10f4660637 changeset_templater: render template specified by templatespec tuple 2017-04-11 21:38:24 +09:00
Yuya Nishihara
2aef40eb43 formatter: render template specified by templatespec tuple 2017-04-22 19:29:41 +09:00
Yuya Nishihara
4fc90a661f formatter: put topic in templatespec tuple
This will allow us to change the initial template reference depending on how
the template is looked up. For example,

  -Tdefault => (ref='changeset', tmpl=None, mapfile='map-cmdline.default')
  -T'{rev}' => (ref='', tmpl='{rev}', mapfile=None)

A literal template given by -T option will be stored as an unnamed template,
which will free up the template namespace so that we can load named templates
from [templates] section of user config.
2017-04-22 19:07:00 +09:00
Yuya Nishihara
5249aa5b36 cmdutil: pass templatespec tuple directly to changeset_templater (API)
A fewer number of arguments should be better.
2017-04-22 19:02:47 +09:00
Yuya Nishihara
7242ce7327 formatter: wrap (tmpl, mapfile) by named tuple
I'm going to add more options to the templatespec tuple.

cmdutil.logtemplatespec() is just an alias now, but it will be changed to
a factory function later.
2017-04-22 18:48:38 +09:00
Yuya Nishihara
ca018ac743 cmdutil: factor out helper to create changeset_templater with literal template
changeset_templater has lots of arguments, but most callers only need to
specify a literal template 'tmpl'.

"hg debugtemplate" has no diff option, which means 'opts' were effectively {},
so dropped opts.
2017-04-22 18:42:03 +09:00