Commit Graph

29644 Commits

Author SHA1 Message Date
Yuya Nishihara
e42d0fb100 formatter: add context manager interface for convenience
And port "hg files" to test it.

As you can see, extra indent is necessary to port to this API. I don't think
we should switch every fm.formatter() call to "with" statement.
2016-08-29 00:00:05 +09:00
Pierre-Yves David
b9ebcea85e histedit: remove now unused 'constraints' related code
Now that the one action that need different logic handle that using inheritance
and overriding, we can remove that code.
2016-08-26 21:06:31 +02:00
Pierre-Yves David
d2bccef0ce histedt: use inheritance to override the constraints in 'base'
All actions but one actually have the same constraints when it comes to validate
the 'action.node' value. So we actually just add this code to a method that can
be overwritten in the one action where it matters.

The now unused 'contraints' related enum and class attribute will be cleaned up
in the next changeset.
2016-08-26 21:00:33 +02:00
Pierre-Yves David
e83d8435c9 histedit: move constraint verification to the 'action.verify' method
Action has a method dedicated to verifying its validity. So we move code
related to constrains into that method. This requires a bit more context to the
'verify' method in the same fashion we were passing the 'prev' argument.

This is an extra step before we can simplify the constraint handling code
further.
2016-08-26 20:54:52 +02:00
Pierre-Yves David
c056fb41dc histedit: directly use node in 'verifyactions'
It does not seem useful to convert to hex: it is an extra step and they are
longer strings. So we stick to node for the logic. We only convert to short hex
for error when needed. As a nice side effect this remove the explicit constant
usage in'[12:]'. This will also help moving the code around later as we just
have to access action.node.
2016-08-26 20:54:32 +02:00
Pierre-Yves David
58fa162d21 histedit: temporarily shorten name of 'constraints' variable
An upcoming changeset will make the line where this variable is used
slightly too long. Other later changesets will clean that up further and makes
the variable unnecessary, so this is only temporary and it does seems useful to
put anything more complicate in place.
2016-08-26 20:42:18 +02:00
Pierre-Yves David
5dfe266b33 histedit: drop the 'nodetoverify' local variable
We can just use 'action.node'.
2016-08-26 20:38:37 +02:00
Pierre-Yves David
f113c210a5 histedit: make 'constraints' a class attribute instead of a method
There does not seem to be a reason for this to be a method. So we initialise
the class attribute once and for all at creation time and drop the instance
method.
2016-08-26 20:34:58 +02:00
Pierre-Yves David
d390c8d401 histedit: drop the 'nodetoverify' method
That method is just returning self.node and is never overridden. We just use
the attribute directly instead and get rid of the method.

This is the beginning of series to simplify and unify verification of constraints
for actions.
2016-08-26 20:31:33 +02:00
Yuya Nishihara
64a2940225 test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
Danek Duvall found that gpg-connect-agent of GnuPG 2.0 never starts gpg-agent
daemon. The 2.1 way is documented as "gpg-coonect-agent /bye" [1], which
appears to be different from the 2.0 way [2].

 [1]: https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html
 [2]: https://www.gnupg.org/documentation/manuals/gnupg-2.0/Invoking-GPG_002dAGENT.html

Since "gpg-agent --daemon" of GnuPG 2.1 never prints environment variables,
"eval $(gpg-agent --daemon)" would be valid only for GnuPG < 2.1, and we'll
need a different workaround for 2.0. I have no 2.0 environment, I won't
implement it.
2016-08-29 22:59:39 +09:00
timeless
faab59b629 rebase: properly calculate total commits to rebase (issue5347)
Before this, predecessor commits were being included in the count
2016-08-26 00:16:51 +00:00
Maciej Fijalkowski
b115657a10 mpatch: add setup_mpatch_cffi.py
This file got dropped when the corresponding setup.py changes were
made.
2016-08-28 17:51:32 -07:00
Pierre-Yves David
816a66763b journal: rename on disk files to 'namejournal'
The 'journal' naming is already used by the transaction journal. Having an
unrelated group of file with such a close naming is confusing and error prone.
We rename the file used by the 'journal' extension to use 'namejournal' as the
extension track the location of various 'names'.
2016-08-24 03:59:19 +02:00
timeless
1ad349cf3d tests: guard demandimport segment of test-extension.t 2016-08-25 23:13:36 +00:00
timeless
5e52f93083 tests: skip demandimport if disabled
demandimport and setuptools and decorator (from ironpython) and
pygments leads to lots of fail.

If demandimport is disabled we should skip testing it...
2016-08-25 22:03:51 +00:00
timeless
eab7889a37 hghave: add demandimport checking 2016-08-25 22:30:35 +00:00
timeless
1e21e7a9f5 hghave: make bzr checks stricter
My bzr does not have bzrlib.revisionspec.RevisionSpec,
and thus tests were failing because convert refused to believe in bzr,
but hghave without this change thought it was available.
2016-08-25 22:51:39 +00:00
Gregory Szorc
57934ad4c1 help: document wire protocol commands 2016-08-22 19:50:21 -07:00
Gregory Szorc
a167c55bc7 help: document wire protocol "handshake" protocol
There isn't a formal handshake protocol in the wire protocol. But
clients almost certainly need to perform particular actions before they
can communicate with a server optimally. So document what that is
so people understand what's going on at connection establishment time.
2016-08-22 19:49:59 -07:00
Gregory Szorc
378142967e help: document wire protocol capabilities
All capabilities from the history of the project are now documented.
2016-08-22 19:48:31 -07:00
Gregory Szorc
b21abff69d help: document wire protocol transport protocols
The HTTP and SSH transport protocols are documented. This
includes how commands and arguments are serialized as well as
response types.
2016-08-22 19:47:34 -07:00
Gregory Szorc
5c136c2209 help: internals topic for wire protocol
The Mercurial wire protocol is under-documented. This includes a lack
of source docstrings and comments as well as pages on the official
wiki.

This patch adds the beginnings of "internals" documentation on the
wire protocol.

The documentation should have nearly complete coverage on the
lower-level parts of the protocol, such as the different transport
mechanims, how commands and arguments are sent, capabilities, and,
of course, the commands themselves.

As part of writing this documentation, I discovered a number of
deficiencies in the protocol and bugs in the implementation. I've
started sending patches for some of the issues. I hope to send a lot
more.

This patch starts with the scaffolding for a new internals page.
2016-08-22 19:46:39 -07:00
Yuya Nishihara
23829625a1 grep: add formatter support
Several fields are renamed to be consistent with the annotate command, which
doesn't mean the last call for the name unification [1]. Actually, I'd rather
rename line_number to linenumber, linenum, lineno or line, but I want to
port the grep command to formatter first.

 [1]: https://www.mercurial-scm.org/wiki/GenericTemplatingPlan#Dictionary

I don't have any better name for the list of matched/unmatched texts, so
they are just called as "texts".
2016-08-18 15:13:56 +09:00
Yuya Nishihara
bc268d1d3a grep: build list of all columns regardless of display options
These columns should always be available in JSON or template outputs. The
"change" column is excluded because it has no useful data unless --all is
specified.
2016-08-18 14:52:06 +09:00
Yuya Nishihara
69e3fa3cab grep: build list of columns without "grep." label prefix
Prepares for formatter support. We need field names without "grep.".
2016-08-18 14:23:29 +09:00
Yuya Nishihara
18d54828a3 grep: factor out function that prints matched line with labels
Prepares for formatter support.
2016-08-18 14:09:49 +09:00
Yuya Nishihara
1e04cbab83 grep: refactor loop that yields matched text with label
As preparation for formatter support, this and the next patch split
linestate.__iter__() into two functions, line scanner and displayer.

New code uses regexp.search(str, pos) in place of regexp.search(substr),
which appears to fix a bug of highlighting.
2016-08-18 14:03:25 +09:00
liscju
6bdf778d3e files: change documentation to match its behaviour (issue5276)
Documentation gave the usage pattern as '[OPTION]... [PATTERN]...'
when the command match given files as relpaths by default.
2016-07-05 09:37:07 +02:00
Matt Mackall
6041ad2e9e templater: add template path to __base__ search
This does a fall-back check for style files or directories that are
in Mercurial's template path for user convenience.

We intentionally don't use this for the built-in coal style because we don't
want the style to mysteriously break if the working directory just
happens to have a file named "paper".
2016-08-24 17:43:45 -07:00
Augie Fackler
82bc5f196f blackbox: also log alias expansions
This should be extremely useful for helping users debug without having
to see their complete configuration.

Shell aliases do not get their expansion logged, because we don't look
and see if we're in a repo before we dive into the execution of a
shell alias. As a result, the ui object doesn't know where to log.
2016-08-23 16:40:08 -04:00
Augie Fackler
d368fe9648 test-clonebundles: accept another error string here
This is what happens if you run the test in a FreeBSD Jail, rather
than "connection refused".
2016-08-25 01:06:32 -04:00
Augie Fackler
f20b54b5ab tests: guard test-archive-symlink with unziplinks check
This fixes the test on FreeBSD, where the stock unzip doesn't
understand symlinks.
2016-08-25 01:26:39 -04:00
Augie Fackler
51a50cbe97 hghave: add a check for unzip(1) that understands symlinks
unzip(1) from the FreeBSD base system does not understand symlinks, so
test-archive-symlinks is busted.
2016-08-25 01:25:52 -04:00
Augie Fackler
1a37c09b9f test-https: drop two spurious --traceback flags
These make test failures scarier than they are.
2016-08-25 01:00:54 -04:00
Augie Fackler
4e1c384d0a extensions: change magic "shipped with hg" string
I've caught multiple extensions in the wild lying about being
'internal', so it's time to move the goalposts on people. Goalpost
moving will continue until third party extensions stop trying to
defeat the system.
2016-08-23 11:26:08 -04:00
Yuya Nishihara
3e1f2a73cd version: add formatter support
The license message isn't exported, which I don't think is useful and I
couldn't find a way to restructure it for JSON or template outputs.
2016-08-25 01:00:26 -04:00
Yuya Nishihara
161bc66818 version: factor out mapping of internal/external labels
Prepares for formatter support, where translation should be disabled
conditionally.
2016-08-16 16:09:12 +09:00
Yuya Nishihara
e723a6d369 version: always build list of extension versions
This patch just moves "if ui.verbose:" to the inner loop, as preparation
for formatter support.
2016-08-16 16:03:09 +09:00
Yuya Nishihara
a0741d6e1d formatter: add fm.nested(field) to either write or build sub items
We sometimes need to build nested items by formatter, but there was no
convenient way other than building and putting them manually by fm.data():

  exts = []
  for n, v in extensions:
      fm.plain('%s %s\n' % (n, v))
      exts.append({'name': n, 'ver': v})
  fm.data(extensions=exts)

This should work for simple cases, but doing this would make it harder to
change the underlying data type for better templating support.

So this patch provides fm.nested(field), which returns new nested formatter
(or self if items aren't structured and just written to ui.) A nested formatter
stores items which will later be rendered by the parent formatter.

  fn = fm.nested('extensions')
  for n, v in extensions:
      fn.startitem()
      fn.write('name ver', '%s %s\n', n, v)
  fn.end()

Nested items are directly exported to a template for now:

  {extensions % "{name} {ver}\n"}

There's no {extensions} nor {join(extensions, sep)} yet. I have a plan for
them by extending fm.nested() API, but I want to revisit it after trying
out this API in the real world.
2016-03-13 19:59:39 +09:00
Yuya Nishihara
2c363af9f2 formatter: factor out format*() functions to separate classes
New converter classes will be reused by a nested formatter. See the next
patch for details.

This change is also good in that the default values are defined uniquely
by the baseformatter.
2016-08-15 13:51:14 +09:00
Jun Wu
7957528e61 crecord: restore SIGWINCH handler before return
Previously, the SIGWINCH handler does not get cleared and if the commit
message editor also needs SIGWINCH handling (like vim), the two SIGWINCH
handlers (the editor's, ours) will have a race. And we may erase the
editor's screen content.

This patch restores SIGWINCH handler to address the above issue.
2016-08-24 11:24:07 +01:00
Maciej Fijalkowski
9fdc692e77 bdiff: implement cffi version of bdiff 2016-08-20 23:06:01 +02:00
Maciej Fijalkowski
a33764dd71 bdiff: implement cffi version of blocks 2016-07-28 14:17:08 +02:00
Tony Tung
b79d52dab0 util: checknlink should remove file it creates if an exception occurs
There's no reason to leave the file behind.
2016-08-19 13:30:40 -07:00
Siddharth Agarwal
52c9a999c5 merge: remove files with extra actions from merge action list
See the comment for a detailed explanation why.

Even though this is a bug, I've sent it to 'default' rather than 'stable'
because it isn't triggered in any code paths in stock Mercurial, just with the
merge driver included. For the same reason I haven't included any tests here --
the merge driver is getting a new test.
2016-08-23 17:58:53 -07:00
Gregory Szorc
e339efbb5b revlog: use an LRU cache for delta chain bases
Profiling using statprof revealed a hotspot during changegroup
application calculating delta chain bases on generaldelta repos.
Essentially, revlog._addrevision() was performing a lot of redundant
work tracing the delta chain as part of determining when the chain
distance was acceptable. This was most pronounced when adding
revisions to manifests, which can have delta chains thousands of
revisions long.

There was a delta chain base cache on revlogs before, but it only
captured a single revision. This was acceptable before generaldelta,
when _addrevision would build deltas from the previous revision and
thus we'd pretty much guarantee a cache hit when resolving the delta
chain base on a subsequent _addrevision call. However, it isn't
suitable for generaldelta because parent revisions aren't necessarily
the last processed revision.

This patch converts the delta chain base cache to an LRU dict cache.
The cache can hold multiple entries, so generaldelta repos have a
higher chance of getting a cache hit.

The impact of this change when processing changegroup additions is
significant. On a generaldelta conversion of the "mozilla-unified"
repo (which contains heads of the main Firefox repositories in
chronological order - this means there are lots of transitions between
heads in revlog order), this change has the following impact when
performing an `hg unbundle` of an uncompressed bundle of the repo:

before: 5:42 CPU time
after:  4:34 CPU time

Most of this time is saved when applying the changelog and manifest
revlogs:

before: 2:30 CPU time
after:  1:17 CPU time

That nearly a 50% reduction in CPU time applying changesets and
manifests!

Applying a gzipped bundle of the same repo (effectively simulating a
`hg clone` over HTTP) showed a similar speedup:

before: 5:53 CPU time
after:  4:46 CPU time

Wall time improvements were basically the same as CPU time.

I didn't measure explicitly, but it feels like most of the time
is saved when processing manifests. This makes sense, as large
manifests tend to have very long delta chains and thus benefit the
most from this cache.

So, this change effectively makes changegroup application (which is
used by `hg unbundle`, `hg clone`, `hg pull`, `hg unshelve`, and
various other commands) significantly faster when delta chains are
long (which can happen on repos with large numbers of files and thus
large manifests).

In theory, this change can result in more memory utilization. However,
we're caching a dict of ints. At most we have 200 ints + Python object
overhead per revlog. And, the cache is really only populated when
performing read-heavy operations, such as adding changegroups or
scanning an individual revlog. For memory bloat to be an issue, we'd
need to scan/read several revisions from several revlogs all while
having active references to several revlogs. I don't think there are
many operations that do this, so I don't think memory bloat from the
cache will be an issue.
2016-08-22 21:48:50 -07:00
Gregory Szorc
60ecfeec38 revlog: remove unused variables 2016-08-22 20:17:36 -07:00
Gregory Szorc
06b69e4299 util: properly implement lrucachedict.get()
Before, it was returning the raw _lrucachenode instance instead of its
value.
2016-08-22 20:30:37 -07:00
Durham Goode
3f8e8b7f90 manifest: change changectx to access manifest via manifestlog
This is the first place where we'll start using manifestctx instances instead of
manifestdict. This will facilitate using different manifestctx implementations
in the future.
2016-08-17 13:25:13 -07:00
Durham Goode
f38741166f manifest: use property instead of field for manifest revlog storage
The file caches we're using to avoid reloading the manifest from disk everytime
has an annoying bug that causes the in memory structure to not be reloaded if
the mtime and the size haven't changed. This causes a breakage in the tests
because the manifestlog is not being reloaded after a commit+strip operation in
mq (the mtime is the same because it all happens in the same second, and the
resulting size is the same because we add 1 and remove 1). The only reason this
doesn't affect the manifest itself is because we touch it so often that we
had already reloaded it after the commit, but before the strip.

Once the entire manifest has migrated to manifestlog, we can get rid of these
properties, since then the manifestlog will be touched after the commit, but
before the strip, as well.
2016-08-17 13:25:13 -07:00