Gregory Szorc <gregory.szorc@gmail.com> [Tue, 24 Nov 2015 22:53:55 -0800] rev 27221
check-seclevel: set module load policy to Python only
If we don't change this, the upcoming change to make the module
loading policy only load C modules will cause this script to fail if
run with CPython against an unbuilt source checkout.
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 03 Dec 2015 21:37:01 -0800] rev 27220
mercurial: implement import hook for handling C/Python modules
There are a handful of modules that have both pure Python and C
extension implementations. Currently, setup.py copies files from
mercurial/pure/*.py to mercurial/ during the install process if C
extensions are not available. This way, "import mercurial.X" will
work whether C extensions are available or not.
This approach has a few drawbacks. First, there aren't run-time checks
verifying the C extensions are loaded when they should be. This could
lead to accidental use of the slower pure Python modules. Second, the
C extensions aren't compatible with PyPy and running Mercurial with
PyPy requires installing Mercurial - you can't run ./hg from a source
checkout. This makes developing while running PyPy somewhat difficult.
This patch implements a PEP-302 import hook for finding and loading the
modules with both C and Python implementations. When a module with dual
implementations is requested for import, its import is handled by our
import hook.
The importer has a mechanism that controls what types of modules we
allow to load. We call this loading behavior the "module load policy."
There are 3 settings:
* Only load C extensions
* Only load pure Python
* Try to load C and fall back to Python
An environment variable allows overriding this policy at run time. This
is mainly useful for developers and for performing actions against the
source checkout (such as installing), which require overriding the
default (strict) policy about requiring C extensions.
The default mode for now is to allow both. This isn't proper and is
technically backwards incompatible. However, it is necessary to
implement a sane patch series that doesn't break the world during
future bisections. The behavior will be corrected in future patch.
We choose the main mercurial/__init__.py module for this code out of
necessity: in a future world, if the custom module importer isn't
registered, we'll fail to find/import certain modules when running
from a pure installation. Without the magical import-time side-effects,
*any* importer of mercurial.* modules would be required to call a
function to register our importer. I'm not a fan of import time side
effects and I initially attempted to do this. However, I was foiled by
our own test harness, which has numerous `python` invoked scripts that
"import mercurial" and fail because the importer isn't registered.
Realizing this problem is probably present in random Python scripts
that have been written over the years, I decided that sacrificing
purity for backwards compatibility is necessary. Plus, if you are
programming Python, "import" should probably "just work."
It's worth noting that now that we have a custom module loader, it
would be possible to hook up demand module proxies at this level
instead of replacing __import__. We leave this work for another time,
if it's even desired.
This patch breaks importing in environments where Mercurial modules
are loaded from a zip file (such as py2exe distributions). This will
be addressed in a subsequent patch.
Augie Fackler <augie@google.com> [Thu, 03 Dec 2015 10:56:05 -0500] rev 27219
changegroup: document manifest linkrev callback some more
Martin and I just got super-confused reading some code here, so I
think it's time for some more documentation.
Augie Fackler <augie@google.com> [Wed, 02 Dec 2015 14:32:17 -0500] rev 27218
changegroup: note during bundle apply if the repo was empty
An upcoming change for exchanging treemanifest data will need to
update the repository capabilities, which we should only do if the
repository was empty before we started applying this changegroup. In
the future we will probably need a strategy for upgrading to
treemanifest in requires during a pull (I'm assuming at some point
we'll make it possible to have a flag day to enable treemanifests on
an existing history.)
timeless <timeless@mozdev.org> [Wed, 02 Dec 2015 07:41:35 +0000] rev 27217
histedit: improve missing rule suggestion
include actual suggested text
Yuya Nishihara <yuya@tcha.org> [Sat, 14 Nov 2015 17:25:43 +0900] rev 27216
graphlog: make node symbol templatable by ui.graphnodetemplate option
New ui.graphnodetemplate option allows us to colorize a node symbol by phase
or branch,
[ui]
graphnodetemplate = {label('graphnode.{phase}', graphnode)}
[color]
graphnode.draft = yellow bold
or use a variety of unicode emoji characters, and so on. (You'll need less-481
to display non-BMP unicode character.)
[ui]
graphnodetemplate = {ifeq(obsolete, 'stable', graphnode, '\xf0\x9f\x92\xa9')}
Yuya Nishihara <yuya@tcha.org> [Sat, 14 Nov 2015 17:02:57 +0900] rev 27215
templatekw: avoid slow creation of changectx objects in showgraphnode()
This mitigates the minor perf regression introduced by the previous patch.
% hg log -G -R mozilla-central -l10000 --time > /dev/null
(original) real 2.200 secs
(previous) real 2.590 secs
(this) real 2.280 secs
Yuya Nishihara <yuya@tcha.org> [Sat, 14 Nov 2015 16:58:18 +0900] rev 27214
graphlog: extract "graphnode" template keyword that represents node symbol
This provides a default node symbol. Tests will be added later.
"showparents" variable is renamed to "wpnodes" to avoid confusion with the
existing showparents() function.
Yuya Nishihara <yuya@tcha.org> [Sat, 14 Nov 2015 16:45:15 +0900] rev 27213
graphlog: move creation of workingdir-parent nodes to displaygraph()
Future patches will make a node symbol templatable. Because arguments of a
templatekw function are repo and ctx, "showparents" list will have to be
built from a repo object by that function.
Anton Shestakov <av6@dwimlabs.net> [Wed, 25 Nov 2015 18:07:33 +0800] rev 27212
builddeb: read default distribution and codename from lsb_release
This makes `make deb` place packages into a more appropriately named directory
instead of just "debian-unknown".
Anton Shestakov <av6@dwimlabs.net> [Wed, 25 Nov 2015 15:26:03 +0800] rev 27211
builddeb: remove unused --debbuilddir option
Looks like it was never used and after 7f49efcaa9b4 it can be removed.
Anton Shestakov <av6@dwimlabs.net> [Wed, 25 Nov 2015 15:15:03 +0800] rev 27210
builddeb: add --distid option to specify Distributor ID
This allows builddeb to handle distributions that are not Debian.
Distributor ID is reported by lsb_release --id, and in case of builddeb it's
usually Debian or Ubuntu.
Anton Shestakov <av6@dwimlabs.net> [Wed, 25 Nov 2015 14:59:43 +0800] rev 27209
builddeb: rename --release option to --codename
Debian and Ubuntu releases have both codenames and traditional version numbers.
An entire "branch" of releases is referred to by its codename, and version
numbers (e.g. 8.2, 14.04.3) are used to address individual releases.
Since we use codenames for building .deb packages, let's call the option and
the variable appropriately.
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27208
histedit: get rid of state.rules
Now we are using state.actions instead of state.rules everywhere.
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27207
histedit: change state.rules uses to state.actions
This change is replacing most of state.rules uses with state.actions
uses. The next change will change histeditstate class to actually
uses state actions.
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27206
histedit: add tostate method to histedit action
the format of rules that we store in state file format is different from the rule
format that we present to users. We need a way of dumping action to state file.
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27205
histedit: remove makedesc
It's a dead code now.
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27204
histedit: use torule instead of makedesc in ruleeditor
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27203
histedit: add torule method to histedit action objects
To make histedit action objects responsible for understanding
the format of their action lines we are adding a torule method
which for a histedit action will return a string which can be
saved in histedit state or shown in text editor when editing the
plan.
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27202
histedit: add verify() to histeditaction
This commits splits the parsing of the histedit rule from its semantic analysis.
It's necessary because sometimes we want to do first without doing the former (reading the
histedit state).
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27201
histedit: add addhisteditaction decorator
This decorator will is allowing us to move the registering the action
in actiontable closer to the action code. Also it is storing the
verb inside histedit action so the action is aware of the verb
needed to trigger it.
Mateusz Kwapich <mitrandir@fb.com> [Wed, 02 Dec 2015 12:19:01 -0800] rev 27200
histedit: add actions property to histedit state
I want to refactor histedit to use action objects instead of (verb, rest)
pairs whenever possible. At the end of this series I want the rules to
be translated into action objects when reading state and translated back
when writing state. All histedit internals should use action objects instead
of state rules.
To migrate histedti internals sequentially I'm introducing the state.actions
property to translate rules on the fly so we can use both state.actions and
state.rules until refactoring is done.
Pierre-Yves David <pierre-yves.david@fb.com> [Fri, 06 Nov 2015 17:27:42 -0500] rev 27199
check-commit: remove confusion between summary line and other headers
The pull url header can easily grow over 80 chars. The check-commit script was
confusing this with a too long summary line. We update the regular expression to
not match other header.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> [Wed, 02 Dec 2015 03:12:08 +0900] rev 27198
shelve: execute checkunfinished inside wlock scope
Before this patch, "hg shelve" of shelve extension executes
'cmdutil.checkunfinished()' before acquisition of wlock.
It may cause unintentional result, if another command runs parallelly
(see also issue4368).
To avoid this issue, this patch executes 'cmdutil.checkunfinished()'
inside wlock scope of "hg shelve".
This also fixes issue4957, because now 'cmdutil.checkunfinished()'
isn't invoked at "hg shelve" with options below:
--cleanup
--delete
--list
--patch
--stat
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> [Wed, 02 Dec 2015 03:12:08 +0900] rev 27197
shelve: widen wlock scope of shelve for consistency while processing
Before this patch, "hg shelve" of shelve extension executes/refers
below before acquisition of wlock:
- 'repo.dirstate.parents()' via 'repo[None].parents()'
- 'repo._activebookmark'
It may cause unintentional result, if another command runs parallelly
(see also issue4368).
This patch widens wlock scope of "hg shelve" of shelve extension for
consistency while processing.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> [Wed, 02 Dec 2015 03:12:08 +0900] rev 27196
gpg: make sign acquire wlock before processing
Before this patch, "hg sign" of gpg extension executes/evaluates below
without acquisition of wlock.
- repo.dirstate.parents()
- '.hgsigs' not in repo.dirstate
It may cause unintentional result, if another command runs parallelly
(see also issue4368).
To avoid this issue, this patch makes "hg sign" of gpg extension
acquire wlock before processing.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> [Wed, 02 Dec 2015 03:12:08 +0900] rev 27195
commands: execute checkunfinished and bailifchanged inside wlock scope
Before this patch, "hg import" executes below before acquisition of
wlock:
- cmdutil.checkunfinished()
- cmdutil.bailifchanged()
It may cause unintentional result, if another command runs parallelly
(see also issue4368).
To avoid this issue, this patch executes 'cmdutil.checkunfinished()'
and 'cmdutil.bailifchanged()' inside wlock scope of "hg import".
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> [Wed, 02 Dec 2015 03:12:07 +0900] rev 27194
commands: widen wlock scope of graft for consitency while processing
Before this patch, "hg graft" executes below before acquisition of
wlock.
- cmdutil.checkunfinished()
- cmdutil.bailifchanged()
- repo.dirstate.parents() via 'repo["."]'
- unlinking '.hg/graftstate'
It may cause unintentional result, if another command runs parallelly
(see also issue4368).
This patch widens wlock scope of "hg graft" for consitency while
processing.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> [Wed, 02 Dec 2015 03:12:07 +0900] rev 27193
commands: make backout acquire locks before processing
Before this patch, "hg backout" executes below before acquisition of
wlock.
- cmdutil.checkunfinished()
- cmdutil.bailifchanged()
- repo.dirstate.parents()
It may cause unintentional result, if another command runs parallelly
(see also issue4368).
In addition to it, "hg backout" refers changelog for purposes below
without acquisition of store lock (slock), and it may cause
unintentional result, if store is updated parallelly.
- show and update to the revision by 'repo.changelog.tip()'
- examine for "created new head" by 'repo.branchheads()' and
'cmdutil.commitstatus()'
To avoid this issue, this patch makes "hg backout" acquire wlock and
slock before processing.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> [Wed, 02 Dec 2015 03:12:07 +0900] rev 27192
commands: make commit acquire locks before processing (issue4368)
Before this patch, "hg commit" (process A) executes steps below:
1. get current branch heads via 'repo.branchheads()'
- cache 'repo.changelog'
2. invoke 'repo.commit()'
3. acquire wlock
- invalidate 'repo.dirstate'
4. access 'repo.dirstate'
- re-read '.hg/dirstate'
- check validity of parent revisions with 'repo.changelog'
5. invoke 'repo.commitctx()'
6. acquire store lock (slock)
- invalidate 'repo.changelog'
7. do committing
8. release slock
9. release wlock
10. check new branch head (via 'cmdutil.commitstatus()')
If acquisition of wlock at (3) above waits for another "hg commit"
(process B) or so running parallelly to release wlock, process A
causes creating orphan revision, because:
- '.hg/dirstate' refers the revision, which is newly added by
process B, as its parent
- but already cached 'repo.changelog' doesn't contain such revision
- therefore, validating parents of '.hg/dirstate' at (4) above
replaces such revision with 'nullid'
Then, process A creates "orphan" revision, of which parent is "null"
revision.
In addition to it, "created new head" may be shown at the end of
process A unintentionally, if store is updated parallelly, because
both getting branch heads (1) and checking new branch head (10) are
executed outside slock scope.
To avoid this issue, this patch makes "hg commit" acquire wlock and
slock before processing.
This patch resolves the issue between "hg commit" processes, but not
one between "hg commit" and other commands. Subsequent patches resolve
the latter.
Even after this patch, there are still corner case problems below:
- filecache may overlook changes of '.hg/dirstate', and it causes
similar issue (see below for detail)
https://bz.mercurial-scm.org/show_bug.cgi?id=4368#c10
- 3rd party extension may cause similar issue, if it directly uses
'repo.commit()' without acquisition of wlock and slock
This can be fixed by acquisition of slock at the beginning of
'repo.commit()', but it seems suitable for "default" branch
In fact, acquisition of slock itself is already introduced at
"default" branch by 4414d500604f, but acquisition is not at the
beginning of 'repo.commit()'.
This patch also changes some tests:
- test-fncache.t needs this tricky wrapping, to release (= forced
failure of) wlock certainly
- order of "hg commit" output is changed by widening scope of locks,
because some hooks are fired after releasing wlock