Commit Graph

18414 Commits

Author SHA1 Message Date
Yuya Nishihara
012b052e98 util: drop unneeded override, sortdict.copy()
OrderedDict.copy() returns self.__class__(self).
2017-05-17 23:01:56 +09:00
Martin von Zweigbergk
7d0d4cab28 util: rewrite sortdict using Python 2.7's OrderedDict
Pattern copied from
https://docs.python.org/dev/library/collections.html#ordereddict-examples-and-recipes.
2017-05-16 23:40:29 -07:00
Yuya Nishihara
34b243ac82 encoding: use i.startswith() instead of i[0] to eliminate py2/3 divergence 2017-05-16 23:36:38 +09:00
Durham Goode
8712c20680 hg: backout optimizing for treemanifests
It turns out that the files list is not sufficient to identify with revlogs have
changed. In a merge commit, no files could've changed but directories would
have. For now let's just backout this optimization.
2017-05-15 18:55:58 -07:00
Gregory Szorc
ae8cb885e7 changelog: load pending file directly
When changelogs are written, a copy of the index (or inline revlog)
may be written to an 00changelog.i.a file to facilitate hooks and
other processes having access to the pending data before it is
finalized.

The way it works today, the localrepo class loads the changelog
like normal. Then, if it detects a pending transaction, it asks
the changelog class to load a pending changelog. The changelog
class looks for a 00changelog.i.a file. If it exists, it is
loaded and internal data structures on the new revlog class are
copied to the original instance.

The existing mechanism is inefficient because it loads 2 revlog
files. The index, node map, and chunk cache for 00changelog.i
are thrown away and replaced by those for 00changelog.i.a.

The existing mechanism is also brittle because it is a layering
violation to access the data structures being accessed. For example,
the code copies the "chunk cache" because for inline revlogs
this cache contains the raw revision chunks and allows the original
changelog/revlog instance to access revision data for these pending
revisions. This whole behavior of course relies on the revlog
constructor reading the entirety of an inline revlog into memory
and caching it. That's why it is brittle. (I discovered all this
as part of modifying behavior of the chunk cache.)

This patch streamlines the loading of a pending 00changelog.i.a
revlog by doing it directly in the changelog constructor if told
to do so. When this code path is active, we no longer load the
00changelog.i file at all.

The only negative outcome I see from this change is if loading
00changelog.i was somehow facilitating a role. But I can't imagine
what that would be because we throw away its data (the index data
structures are replaced and inline revision data is replaced via
the chunk cache) and since 00changelog.i.a is a copy of
00changelog.i, file content should be identical, so there should
be no meaninful file integrity checking at play. I think this was
all just sub-optimal code.
2017-05-13 16:26:43 -07:00
Martin von Zweigbergk
c3406ac3db cleanup: use set literals
We no longer support Python 2.6, so we can now use set literals.
2017-02-10 16:56:29 -08:00
Pulkit Goyal
4e8e473e5e py3: convert date and format arguments str before passing in time.strptime
time.strptime() raises ValueError if the arguments are not str.
Source Code: https://hg.python.org/cpython/file/3.5/Lib/_strptime.py#l307
2017-05-06 04:51:25 +05:30
Pulkit Goyal
edb3048605 py3: convert kwargs' keys to str using pycompat.strkwargs 2017-05-04 00:24:21 +05:30
Jun Wu
ac08ec9cb1 verify: add a config option to skip certain flag processors
Previously, "hg verify" verifies everything, which could be undesirable when
there are expensive flag processor contents.

This patch adds a "verify.skipflags" developer config. A flag processor will
be skipped if (flag & verify.skipflags) == 0.

In the LFS usecase, that means "hg verify --config verify.skipflags=8192"
will not download all LFS blobs, which could be too large to be stored
locally.

Note: "renamed" is also skipped since its default implementation may call
filelog.data() which will trigger the flag processor.
2017-05-14 09:38:06 -07:00
Durham Goode
a73dbb6c8d changegroup: add bundlecaps back
Commit 9233182ea547d0aa removed the unused bundlecaps argument from the
changegroup code. While it is unused in core Mercurial, it was an important
feature for the remotefilelog extension because it allowed the exchange layer to
communicate to the changegroup packer that this was a shallow repo and that
filelogs should not be included. Without bundlecaps, there is currently no other
way to pass that information along without a more extensive refactor of
exchange, bundle, and changegroup code.

This patch backs out the original removal, and merges it with some recent
changes to changegroup apis.
2017-05-15 09:35:27 -07:00
Jun Wu
4656f56bb3 flagprocessor: add a fast path when flags is 0
When flags is 0, _processflags could be a no-op instead of iterating through
the flag bits.
2017-05-10 16:17:58 -07:00
Gregory Szorc
4d36274575 branchmap: remove use of buffer() to support Python 2.6
The use of buffer() was added in 455069d62fec to support Python 2.6,
which we no longer support.
2017-05-13 11:58:08 -07:00
Gregory Szorc
d8b8a2301d obsolete: use 2 argument form of enumerate()
The 2 argument form of enumerate was added in Python 2.6. This
change effectively reverts 00a7214a4f0d.
2017-05-13 11:42:42 -07:00
Gregory Szorc
4c11e54e6e encoding: remove workaround for locale.getpreferredencoding()
locale.getpreferredencoding() was buggy in OS X for Python <2.7.
Since we no longer support Python <2.7, we no longer need this
workaround.

This essentially reverts 4a8b821a69fb.
2017-05-13 11:20:51 -07:00
Gregory Szorc
b26df9d04b mail: remove code to support < Python 2.7
This code was added in 025d0ea4305a. Since we no longer support
Python <2.7, it can be removed.
2017-05-13 11:12:44 -07:00
Gregory Szorc
304ebe38d7 help: clarify that colons are allowed in fingerprints values
This was suggested by Lars Rohwedder in issue5559.
2017-05-11 00:02:32 -07:00
Gregory Szorc
4cbe1b2aa1 sslutil: tweak the legacy [hostfingerprints] warning message
Lars Rohwedder noted in issue5559 that the previous wording was
confusing. I agree.
2017-05-10 23:49:37 -07:00
Jun Wu
dcb05ed412 chgserver: more explicit about sensitive environ variables
Environment variables like HGUSER, HGEDITOR, HGEDITFROM should not trigger
a new chgserver. This patch uses a whitelist for environ variables starting
with "HG" to reduce the number of servers.

I have went through `grep -o "[\"']HG[A-Z_0-9]*['\"]" -hR . | sort -u` so
the list should be up-to-date.
2017-05-10 11:55:22 -07:00
Kostia Balytskyi
ff9a0dc5da scmutil: make simplekeyvaluefile able to have a non-key-value first line
To ease migration from files with version numbers in their first lines,
we want simplekeyvaluefile to support a non-key-value first line. In this
way, old versions of Mercurial will read such files, discover a newer version
than the one they know how to handle and fail gracefully, rather than with
exception. Shelve's shelvestate file is an example.
2017-05-11 08:49:33 -07:00
Kostia Balytskyi
e4f8ca5106 scmutil: add simplekeyvaluefile reading test
Before this patch, mockvfs did not emulate readlines correctly
and there was no test for simplekeyvaluefile reading.
2017-05-11 08:39:44 -07:00
Pierre-Yves David
dc1e05ed68 caches: stop warming the cache after changegroup application
Now that we garantee that branchmap cache is updated at the end of the
transaction we can drop this update. This removes a problematic case with
nested transaction where the new cache could be written on disk before the
transaction is finished (and even roll-backed)

Such premature cache write was visible in the following test:

* tests/test-acl.t
* tests/test-rebase-conflicts.t

In addition, running the cache update later means having more date about the
state of the repository (in particular: phases). So we can generate caches with
more information. This creates harmless changes to the following tests:

* tests/test-hardlinks-whitelisted.t
* tests/test-hardlinks.t
* tests/test-phases.t
* tests/test-tags.t
* tests/test-inherit-mode.t
2017-05-02 18:57:52 +02:00
Pierre-Yves David
9c635f53f5 caches: move the 'updating the branch cache' message in 'updatecaches'
We are about to remove the branchmap cache update in changegroup application.
There is a debug message alongside this update that we do not want to loose. We
move the message beforehand to simplify the test update in the next changeset.
The message move is quite noisy and isolating that noise is useful.

Most tests update are just line reordering since the message is issued at a
later point during the transaction.

After this changes, the message is displayed in more case since local commit
creation also issue it.
2017-05-02 22:27:44 +02:00
Pierre-Yves David
781ab337a0 caches: stop warming the cache after 'localrepo.commitctx'
Now that we garantee that branchmap cache are updated at the end of the
transaction we can drop that one. This removes a problematic case with nested
transaction where the new cache could be written on disk before the transaction
is finished.

The test change is harmless, since we update the cache at a later point, the
dirstate have been updated in between.
2017-05-02 18:56:07 +02:00
Pierre-Yves David
383c4352b9 caches: introduce a 'debugupdatecaches' command
That command make sure caches are updated. This is based on
'localrepo.updatecaches' so when we move support for new cache in that function this
command will benefit from it.
2017-05-02 21:35:06 +02:00
Pierre-Yves David
6b3c96d7ef caches: call 'repo.updatecache()' in 'repo.destroyed()'
Regenerating the cache after a 'strip' or a 'rollback' is useful. So we call the
generic cache warming function as other caches than just branchmap will be
updated there in the future.

To do so, we have to make 'repo.updatecache()' able to take no arguments. In
such cases, we reload all caches.
2017-05-02 19:05:58 +02:00
Pierre-Yves David
87c7f6f271 caches: introduce a function to warm cache
We have multiple caches that gain from being kept up to date. For example in a
server setup, we want to make sure the branchcache cache is hot for other
read-only clients.

Right now each cache tries to update themself in place where new data have been
added. However the approach is error prone (we might miss some spot) and
fragile. When nested transaction are involved, such cache updates might happen
before a top level transaction is committed. Writing caches for uncommitted
data on disk.

Having a single entry point, run at the end of each successful transaction,
helps to ensure the cache is up to date and refreshed at the right time.

We start with updating the branchmap cache but other will come.
2017-05-02 21:39:43 +02:00
Pierre-Yves David
a1a70e3fbc transaction: track newly introduced revisions
Tracking revisions is not the data that will unlock the most new capability.
However, they are the simplest thing to track and still unlock some nice
improvements in regard with caching.

We plug ourself at the changelog level to make sure we do not miss any revision
additions.

The 'revs' set is configured at the repository level because the transaction
itself does not needs to know that much about the business logic.
2017-05-02 18:45:51 +02:00
Pierre-Yves David
f6cb69a5f6 transaction: introduce "changes" dictionary to precisely track updates
The transaction is already tracking some data intended for hooks (in
'hookargs'). However, that information is minimal as we optimise for
passing data to other processes through environment variables. There are
multiple places were we could use more complete and lower level
information locally (eg: cache update, better report of changes to
hooks, etc...).

For this purpose we introduces a 'changes' dictionary on the
transaction.  It is intended to track every changes happening to the
repository (eg: new revs, bookmarks move, phases move, obs-markers,
etc).

For now we just adds the 'changes' dictionary. We'll adds more tracking
and usages over time.
2017-05-02 18:31:18 +02:00
Siddharth Agarwal
0c7305054f clone: add a server-side option to disable full getbundles (pull-based clones)
For large enough repositories, pull-based clones take too long, and an attempt
to use them indicates some sort of configuration or other issue or maybe an
outdated Mercurial. Add a config option to disable them.
2017-05-11 10:50:05 -07:00
Siddharth Agarwal
3bf516869d clone: warn when streaming was requested but couldn't be performed
This helps both users and the people who support them figure out why
a stream clone couldn't be performed.

In an upcoming patch we're going to add a way for servers to hard
abort on a full getbundle. In those cases servers might expect
clients to perform a stream clone, so it's important to communicate
why one couldn't be done.
2017-05-08 20:01:06 -07:00
Siddharth Agarwal
ade0695cf9 bundle2: don't check for whether we can do stream clones
At the moment this isn't used and all stream clones use the legacy protocol.

In an upcoming diff, canperformstreamclone will print out a message if a stream
clone was requested but couldn't happen for some reason. Removing this call
ensures the message isn't printed twice.
2017-05-08 17:30:51 -07:00
FUJIWARA Katsunori
0dd849cb04 debugcommands: add debugpickmergetool to examine which merge tool is chosen
Before this patch, there is no convenient way to know which merge tool
is chosen for each managed files without actual merging.
2017-05-13 03:37:50 +09:00
FUJIWARA Katsunori
aa0e47b129 filemerge: add internal merge tool to dump files forcibly
Internal merge tool :dump implies premerge. Therefore, files aren't
dumped, if premerge runs successfully.

This undocumented behavior might confuse users, if they want to always
dump files. But just making :dump omit premerge might cause backward
compatibility issue for existing automation.

This patch adds new internal merge tool :forcedump, which works as
same as :dump, but omits premerge always.

Internal tools annotated with "nomerge" should merge "change and
delete" correctly, but _forcedump() can't. Therefore, it is annotated
with "mergeonly" to always omit premerge, even though it doesn't merge
files actually.

This patch also adds explanation about premerge to :dump, to clarify
how :dump actually works.

BTW, this patch specifies internal tools with "internal:" prefix in
newly added test scenario in test-merge-tools.t, even though this
prefix is already deprecated. This is only for similarity to other
tests in test-merge-tools.t.
2017-05-13 03:31:42 +09:00
FUJIWARA Katsunori
40936d94b1 filemerge: make warning message more i18n friendly
Before this patch, " specified for " part of warning messages
(e.g. "couldn't find merge tool TOOL specified for PAT") isn't
translatable.
2017-05-13 03:28:36 +09:00
FUJIWARA Katsunori
3018e1b77b filemerge: show warning about choice of :prompt only at an actual fallback
Before this patch, internal merge tool :prompt shows "no tool found to
merge FILE" line, even if :prompt is explicitly specified as a tool to
be used.

This patch shows warning message about choice of :prompt only at an
actual fallback, in which case any tool is rejected by capability for
binary or symlink.

It is for backward compatibility to omit warning message in
"changedelete" case.
2017-05-13 03:28:36 +09:00
Durham Goode
941307e87c treemanifest: allow manifestrevlog to take an explicit treemanifest arg
Previously we relied on the opener options to tell the revlog to be a tree
manifest. This makes it complicated for extensions to create treemanifests and
normal manifests at the same time. Let's add a construtor argument to create a
treemanifest revlog as well.

I considered removing the options['treemanifest'] logic from manifestrevlog
entirely, but doing so shifts the responsibility to the caller which ends up
requiring changes in localrepo, bundlerepo, and unionrepo. I figured having the
dual mechanism was better than polluting other parts of the code base with
treemanifest knowledge.
2017-05-09 13:56:46 -07:00
Yuya Nishihara
2fe12e4917 policy: relax the default for in-place build
We're going to make the 'c' policy more strict, where no missing attribute
will be allowed. Since we want to run 'hg bisect' without rebuilding the C
extension modules, we'll need a looser policy for development environment.

The default for system installation isn't changed.

Note that the current 'c' policy is practically 'allow'-ish as we have lots
of adhoc fallbacks to pure functions.
2017-04-26 23:02:43 +09:00
Jun Wu
319c497b3a verify: always check rawsize
Previously, verify only checks "rawsize == len(rawtext)", if
"len(fl.read()) != fl.size()".

With flag processor, "len(fl.read()) != fl.size()" does not necessarily mean
"rawsize == len(rawtext)". So we may miss a useful check.

This patch removes the "if len(fl.read()) != fl.size()" condition so the
rawsize check is always performed.

With the condition removed, "fl.read(n)" looks unnecessary so a comment was
added to explain the side effect is wanted.
2017-05-11 14:52:02 -07:00
Gregory Szorc
4044fde425 sslutil: remove conditional cipher code needed for Python 2.6
We dropped support for Python 2.6. So this code to work around a
missing feature on 2.6 is no longer necessary.
2017-05-10 23:32:00 -07:00
Phil Cohen
f313a0b236 merge: use repo.wvfs.setflags() instead of util.setflags()
Most merge.py code goes through the vfs instead of maniulating
files directly, so let's do the same here.
2017-05-11 18:38:43 -07:00
Martin von Zweigbergk
09d53c160b merge with stable 2017-05-12 11:20:25 -07:00
Jun Wu
2c11c92a85 revlog: move part of "addrevision" to "addrawrevision"
"addrawrevision" will be the public API to reuse revision rawdata elsewhere.
It will be used by a future patch.
2017-05-09 21:27:06 -07:00
Jun Wu
384e554e79 filectx: add an overlayfilectx class
The end goal is to make it possible to avoid potential expensive fctx.data()
when unnecessary.

While memctx is useful for creating new file contexts, there are many cases
where we could reuse an existing raw file revision (amend, histedit, rebase,
process a revision constructed by a remote peer, etc). The overlayfilectx
class is made to support such reuse cases. Together with a later patch, hash
calculation and expensive flag processor could be avoided.
2017-05-09 20:23:21 -07:00
Jun Wu
eeacfd5a3b filectx: remove __new__
It does not seem to be used anywhere, and breaks a later patch.
2017-05-09 19:16:48 -07:00
Jun Wu
832b866521 filectx: add a rawflags method
The new method returns the low-level revlog flag. We already have "rawdata"
so a "rawflags" makes sense.

Both "rawflags" and "rawdata" will be used in a later patch.
2017-05-09 16:34:12 -07:00
Jun Wu
f131743929 filectx: move size to basefilectx
See previous patch for context - avoid code duplication.
2017-05-09 19:53:31 -07:00
Jun Wu
a24f7109e4 filectx: make renamed a property cache
See previous patch for context - mainly to avoid code duplication.
2017-05-09 19:48:57 -07:00
Jun Wu
fbe796f9ab filectx: make flags a property cache
Make basefilectx._flags a property cache, so basefilectx.flags() could be
reasonably reused. This avoids code duplication between memfilectx and a
class added in a later patch.
2017-05-09 19:23:28 -07:00
Mads Kiilerich
d682210796 graft: fix graft across merges of duplicates of grafted changes
Graft used findmissingrevs to find the candidates for graft duplicates in the
destination. That function operates with the constraint:

  1. N is an ancestor of some node in 'heads'
  2. N is not an ancestor of any node in 'common'

For our purpose, we do however have to work correctly in cases where the graft
set has multiple roots or where merges between graft ranges are skipped. The
only changesets we can be sure doesn't have ancestors that are grafts of any
changeset in the graftset, are the ones that are common ancestors of *all*
changesets in the graftset. We thus need:

  2. N is not an ancestor of all nodes in 'common'

This change will graft more correctly, but it will also in some cases make
graft slower by making it search through a bigger and unnecessary large sets of
changes to find duplicates. In the general case of grafting individual or
linear sets, we do the same amount of work as before.
2017-05-11 17:18:40 +02:00
Gregory Szorc
3ffdc76e66 sslutil: reference fingerprints config option properly (issue5559)
The config option is "host:fingerprints" not "host.fingerprints".

This warning message is bad and misleads users.
2017-05-08 09:30:26 -07:00