Commit Graph

18834 Commits

Author SHA1 Message Date
Martin von Zweigbergk
16b7a41d93 changegroup: delete "if True" and reflow 2017-06-15 23:23:47 -07:00
Martin von Zweigbergk
560e5ce4f1 changegroup: let callers pass in transaction to apply() (API)
I think passing in the transaction makes it a little clearer and more
consistent with bundle2.
2017-06-15 22:46:38 -07:00
Martin von Zweigbergk
6700618bdb repair: create transaction for bundle1 unbundling earlier
See earlier patch for motivation.
2017-06-15 23:09:14 -07:00
Martin von Zweigbergk
e57ebfa7c2 unbundle: create transaction for bundle1 unbundling earlier
See earlier patch for motivation.
2017-06-15 22:18:21 -07:00
Martin von Zweigbergk
350d0dfe2e exchange: create transaction for bundle1 unbundling earlier
changegroup.apply() currently creates a transation if there isn't
already one. Having the callers of that method pass in an existing
transaction seems a little cleaner. To do that, we need to make sure
all callers have a transaction. Since the transaction name is used as
a hook argument (HG_TXNNAME), we need to match the name from
changegroup.apply().
2017-06-15 16:10:53 -07:00
Martin von Zweigbergk
ed4a2d83be changegroup: inline 'publishing' variable in apply() 2017-06-19 00:06:23 -07:00
Martin von Zweigbergk
28a143f25f repair: remove unnecessary locking for bookmarks
The caller has already locked the repo.
2017-06-19 11:24:49 -07:00
Martin von Zweigbergk
d8b160077a repair: move check for existing transaction earlier
Several benefits:

 * Gets close the comment describing it
 * Splits off unrelated comment about "backup" argument
 * Error checking is customarily done early
 * If we added an early return to the method, it would still
   consistently fail if there was an existing transaction (so
   we would find and fix that case quickly)

One test needs updating with for this change, because we no longer
create the backup bundle before we fail. I don't see much reason to
create that backup bundle. If some command was adding content and then
trying to strip it as well within the transaction, we would have a
backup for the user, but the risk of that not being discovered in
development seems very small.
2017-06-19 13:18:00 -07:00
Martin von Zweigbergk
64eed0f13b strip: remove unncessary "del" and inline variable 2017-06-19 13:13:28 -07:00
Martin von Zweigbergk
e070466004 repair: clarify in comment that caller must take lock, but not transaction
I have checked that all callers have already taken the lock (and if
they hadn't, we should have seen tests fail thanks to the 'transaction
requires locking' devel warning in localrepo.transaction()).
2017-06-19 11:24:21 -07:00
Martin von Zweigbergk
0016bace9c amend: use context manager for locking 2017-06-19 11:21:37 -07:00
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