Commit Graph

23934 Commits

Author SHA1 Message Date
Ryan McElroy
54e6a6adbc extensions: allow extending command synopsis and docstring
Mercurial uses a synopsis string and the docstring of a command for the
command's help output. Today  there is no way for an extension that adds
functionality to a command to extend either of these help strings.

This patch enables appending to both the doctring and the synopsis, and adds
a test for this functionality. Example usage is shown in the test and is also
described in the docstring of extensions.wrapcommand().
2015-02-09 11:02:45 -08:00
Mike Edgar
3562a06261 revlog: _addrevision creates full-replace deltas based on censored revisions
A delta against a censored revision is either received through exchange and
written blindly to a revlog, or it is created by the revlog itself. This
change ensures the latter process creates deltas which fully replace all
data in a censored base using a single patch operation.

Recipients of a delta against a censored base will verify that the delta is in
this full-replace format. Other recipients will use the delta as normal.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-01-21 17:11:37 -05:00
Mike Edgar
0a639adee5 revlog: special case expanding full-replacement deltas received by exchange
When a delta received through exchange is added to a revlog, it will very
often be expanded to a full text by applying the delta to its base. If
that delta is of a particular form, we can avoid decoding the base revision.
This avoids an exception if the base revision is censored.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-02-06 01:38:16 +00:00
Martin von Zweigbergk
1568f5ba1d test-merge-tools: fix flaky test by avoiding debugsetparents
debugsetparents is a debug command and does not provide the same
guarantees as non-debug commands do. In particular, when the user sets
a different parent, any clean files will remain clean in the dirstate
even though the new parent might have a different version of the file
(so it should appear modified compared to the new parent). Let's
instead achieve the same effect by updating to the new parent and
reverting the contents back to what they were.

This fix can be tested by passing '--config
debug.dirstate.delaywrite=2' to the 'hg update' command in the
beforemerge().
2015-02-10 16:17:15 -08:00
Mike Edgar
9635f8c5b0 revlog: in addgroup, reject ill-formed deltas based on censored nodes
To ensure interoperability when clones disagree about which file nodes are
censored, a restriction is made on deltas based on censored nodes. Any such
delta must replace the full text of the base in a single patch.

If the recipient of a delta considers the base to be censored and the delta
is not in the expected form, the recipient must reject it, as it can't know
if the source has also censored the base.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-02-06 00:55:29 +00:00
Mike Edgar
af0ba8e839 mdiff: add helper for making deltas which replace the full text of a revision
This helper will be used initially for censor-aware delta generation. Deltas
which replace the full contents of the base revision are guaranteed to apply
correctly regardless of whether the delta recipient has censored the base.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-01-21 16:35:09 -05:00
Mike Edgar
c736894d9c revlog: add "iscensored()" to revlog public API
The iscensored method will be used by the exchange layer to reject
nonconforming deltas involving censored revisions (and to produce
conforming deltas).

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-01-23 17:01:39 -05:00
Mike Edgar
fcc0e5645e filelog: allow censored files to contain padding data
To ensure delta compatibility, when a revision is censored, it is
padded to match the original data in size. The previous check does
not allow for padding because it was added before padding was found
to be a requirement.

For more background and design of the censorship feature, see:
mercurial.selenic.com/wiki/CensorPlan
2015-02-06 01:44:24 +00:00
Yuya Nishihara
4c1f7f24d7 revset: drop factory that promotes spanset to fullreposet
All callers use fullreposet where appropriate.

Backed out changeset 6c2c046ac382
2015-01-08 23:43:15 +09:00
Yuya Nishihara
878c8b67df revset: specify fullreposet without using spanset factory
The factory function will be removed because the subsequent patches will
make fullreposet(repo) not fully compatible with spanset(repo).
2015-01-08 23:46:54 +09:00
Yuya Nishihara
25fac1a15b revset: make match function initiate query from full set by default
This change is intended to avoid exposing the implementation detail to
callers. I'm going to extend fullreposet to support "null" revision, so
these mfunc calls will have to use fullreposet() instead of spanset().
2015-02-02 22:21:07 +09:00
Matt Harbison
179f83c3ed localrepo: don't reintroduce pruned tag entries when tagging
If a commit and a followup tag commit are pruned, there are no references to it
in any non obsolete version of .hgtags.  Without this change however, the next
time a tag is added to another branch, the obsolete references are appended in
.hgtags before the new entries for the current tag command.

The annotation to unfilter localrepo._tag() has been around since 3da49fd631fb.
The log message for it mentions computing the tag cache though, so I'm not sure
if this was misplaced?  It looks like branchmap was aware of filtering then, and
now tracks a cache per view.
2014-10-01 20:26:33 -04:00
Mateusz Kwapich
d8c405977d histedit: switch state to store node instead of ctx
Currently, if the node no longer exists, the state object fails to load
and pukes with an exception. Changing the state object to only store the
node allows callers to handle these cases.  For instance, in
bootstrapcontinue we can now detect that the node doesn't exist and exit
gracefully.

The alternative is to have the state object store something like None
when the node doesn't exist, but then outside callers won't be able to
access the old node for recovery (unless we store both the node and the
ctx, but why bother).

More importantly it allows us to detect this case when doing hg histedit
--abort.  Currently this situation results in both --continue and
--abort being broken and the user has to rm .hg/histedit-state to unwedge
their repo.
(description by Durham Goode)
2015-02-05 13:10:07 -08:00
Mateusz Kwapich
aa07ec44a0 histedit: don't allow to strip nodes which are necessary to continue histedit
During histedit we don't want user to do any operation resulting in
stripping nodes needed to continue history editing. This patch
wraps the strip function to detect such situations.
2015-01-30 16:47:35 -08:00
Martin von Zweigbergk
c2aa9ed527 trydiff: transpose 'if opts.git or losedatafn' with 'if f[12]'
Perhaps it's more readable this way...
2015-02-06 16:09:43 -08:00
Martin von Zweigbergk
f2001609be trydiff: extract function that generates filename pairs
The code that identifies copies/renames, as well as the filenames
before and after, is now isolated and we can extract it to a function
so it can be overridden by extensions (in particular the narrow clone
extension).
2015-01-22 23:29:00 -08:00
Martin von Zweigbergk
8e7eeafaf5 trydiff: read file data in only one place
This moves getfilectx() out of the initial block in the loop, leaving
that block to be only about finding pairs of filenames in ctx1 and
ctx2 to diff.
2015-01-22 23:18:43 -08:00
Martin von Zweigbergk
c5d80876e7 trydiff: set filename variables to None even when not opts.git or losedatafn
There is not much left of the first block "if opts.git or losedatafn"
block now. The next patch will move the call to getfilectx() out of
that block. We will then be using the defined-ness of 'f1' to tell
whether the file existed in ctx1 (and under what name). We will need
this information whether or not opts.git or losedatafn was set, so
just remove that guard. The only operation in the block that is not
cheap is the call to getfilectx(), but that has an extra 'if opts.git'
guard already.

--ignore-space-change proves that only 'if opts.git or losedatafn:'
  was removed.
2015-01-22 23:13:48 -08:00
Martin von Zweigbergk
ff03ae13d3 trydiff: read flags in one place
Now that we can trust f1/f2 to indicate whether that side of the diff
exists, we can move the calls to ctx.flag() to a single place.
2015-01-22 23:01:00 -08:00
Martin von Zweigbergk
5cac0e0289 trydiff: break 'if opts.git or losedatafn' into two
This moves the initialization 'binary' closer to its other assignment,
but exists mostly to simplify future patches.
2015-02-06 15:21:56 -08:00
Martin von Zweigbergk
03828692db trydiff: make filenames None when they don't exist
f1 and f2 are currently set always set to some filename, even for
added or deleted files. Let's instead set them to None to indicate
that one side of the diff doesn't exist. This lets us use the filename
variables instead of the content variables and simplify a bit since
the empty string is not a valid filename. More importantly, it paves
the way for further simplifications.
2015-01-22 22:42:35 -08:00
Augie Fackler
56de6b9a2a test-help: add test to demonstrate that 'hg help merge-tools' is sane 2015-02-10 10:57:58 -05:00
Gregory Szorc
bfb9e38893 help.merge-tools: do not double document merge tools
Merge tools were being double documented in help system output due
to functions being defined under multiple names in the merge tools
dictionary.

Establish a new dictionary for just the tools to document and
use it from the help system so we don't get double output.

Double documentation likely plagues other auto-documented items
as well. It might be a good idea to eventually compare function
instances to filter out duplicate entries from dictionaries
passed to ``makeitemsdoc``. However, without an easy way to break
ties, this may result in some functions being advertised over
their modern equivalents. This would be a noble patch series.
But it isn't one this author is willing to tackle at this time.
2015-02-09 23:07:39 -08:00
Gregory Szorc
2a9673b3df help: teach topic symbols how to dedent
When using docstrings for documenting symbols such as revsets,
templates, or hgweb commands, documentation likely has leading
whitespace corresponding to the indentation from the Python source
file.

Up until this point, the help system stripped all leading and
trailing whitespace and replaced it with 2 spaces of leading
whitespace. There were a few bad side-effects. First, sections
could not be used in docstrings because they would be indented
and the rst parser would fail to parse them as sections. Also,
any rst elements that required indentation would lose their
indentation, again causing them to be parsed and rendered
incorrectly.

In this patch, we teach the topic symbols system how to dedent
text properly. I argue this mode should be enabled by default.
However, I stopped short of changing that because it would cause
a lot of documentation reformatting to occur. I'm not sure if
people are relying on or wanting indentation. So, dedenting has
only been turned on for hgweb symbols. This decision should be
scrutinized.
2015-02-09 14:59:04 -08:00
Gregory Szorc
19908c11f2 webcommands: document "graph" web command 2015-02-06 22:25:40 -08:00
Gregory Szorc
84c9e68503 webcommands: document "archive" web command 2015-02-06 22:19:59 -08:00
Gregory Szorc
7a4c38aedb webcommands: document "filelog" web command 2015-02-06 22:11:54 -08:00
Gregory Szorc
164751c7a0 webcommands: document "annotate" web command 2015-02-06 22:08:30 -08:00
Gregory Szorc
46063b9658 webcommands: document "comparison" web command 2015-02-06 22:06:44 -08:00
Gregory Szorc
4543e0b0be webcommands: document "filediff" web command 2015-02-06 22:02:14 -08:00
Gregory Szorc
d8699a97c0 webcommands: document "summary" web command 2015-02-06 21:51:52 -08:00
Gregory Szorc
060baa099d webcommands: document "manifest" web command 2015-02-06 21:48:01 -08:00
Gregory Szorc
2d9a7685cf webcommands: document "changelog" web command 2015-02-06 21:39:15 -08:00
Gregory Szorc
bb7094c895 webcommands: document "file" web command 2015-02-06 21:26:53 -08:00
Gregory Szorc
e4e6ba61d1 webcommands: document "log" web command 2015-02-06 21:13:03 -08:00
Gregory Szorc
7c907b0b4b webcommands: document "shortlog" web command 2015-02-06 20:50:17 -08:00
Gregory Szorc
22d62d80ec webcommands: document "changeset" web command 2015-02-06 20:48:22 -08:00
Gregory Szorc
8ce448377a webcommands: document "tags" web command 2015-02-06 20:44:46 -08:00
Gregory Szorc
2885cfee5f webcommands: document "bookmarks" web command 2015-02-06 20:43:54 -08:00
Gregory Szorc
ece2021397 webcommands: document "branches" web command 2015-02-06 20:44:10 -08:00
Gregory Szorc
896713a026 webcommands: document "help" web command 2015-02-06 20:41:08 -08:00
Gregory Szorc
c26c3581a4 help: add web commands to help documentation
The capabilities and URL endpoints of the hgweb server can currently
only be inferred by looking at links in `hg serve` output or by reading
the source code. I've frequently found myself wanting to quickly see
what URLs and capabilities are available.

This patch teaches the help system how to display information about
web commands and their URLs. Using a mechanism similar to revsets,
templates, etc, we can now iterate over the docstrings of registered
web command functions and display them in the help output.

Unfortunately, web commands don't currently have docstrings, so the
output is currently empty. This will be addressed in the following
patches. I apologize for the patch bomb.
2015-02-06 20:27:56 -08:00
Gregory Szorc
d2d0fbc4d0 help.hgweb: add a section describing URLs and common parameters
The behavior of hgweb's URLs isn't documented anywhere inside Mercurial.
Let's start to change that.
2015-02-06 23:08:47 -08:00
Gregory Szorc
4498c4489d webcommands: move help import into help command handler
A subsequent patch will introduce an import cycle between mercurial.help
and mercurial.hgweb.webcommands. Break the cycle by moving the import of
mercurial.help into the web command that actually needs it.
2015-02-06 22:47:48 -08:00
Gregory Szorc
11ed5adff7 webcommands: define a dict of available commands
This will be used to hook web commands up to the help system. It also
makes web commands work similarly as CLI commands.
2015-02-06 22:52:40 -08:00
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
Gregory Szorc
7975de696c run-tests: ensure install directories exist
As part of the transition to setuptools, it was discovered that
setuptools doesn't create install directories for you where distutils
apparently did. This was causing run-tests.py to fail when creating the
temporary hg install.

We work around this problem by creating the install directories before
running setup.py.
2015-02-06 16:33:05 -08:00
Gregory Szorc
3a2a31e038 run-tests: avoid printing extra newlines from install log
If an installation error occurs, we print the install log. Before,
output had extra newlines because we were using "print" on data that was
already newline terminated.
2015-02-06 16:15:02 -08:00
Eric Sumner
598db3e9f3 bundlerepo: basic bundle2 support
For bundlerepo to work with bundle2 files, we need to find the part that
contains the bundle's changegroup data and work with that instead of the
entire bundle.  Future work can add separate processing for other bundle2
parts.
2015-02-06 11:27:25 -08:00
Eric Sumner
caef80410d bundlerepo: keep track of the original bundle object
Bundlerepo should always close() the object that it receives from
exchange.readbundle().  When bundle2 support is added in a later diff,
self.bundle will be overwritten to be the changegroup part instead of the
entire bundle unpacker.
2015-02-05 16:03:26 -08:00