Commit Graph

18448 Commits

Author SHA1 Message Date
Jun Wu
b9b53e155e parsers: add version to help detect breaking binary changes 2017-04-25 17:43:30 -07:00
Jun Wu
a834f8300e osutil: add version to help detect breaking binary changes
See the previous patch for why.
2017-04-25 17:36:59 -07:00
Jun Wu
ccdd272d29 mpatch: add version to help detect breaking binary changes 2017-04-25 17:38:36 -07:00
Jun Wu
757c1e41e0 diffhelpers: add version to help detect breaking binary changes 2017-04-25 17:40:13 -07:00
Jun Wu
9c351a5051 base85: add version to help detect breaking binary changes 2017-04-25 17:45:48 -07:00
Jun Wu
43069dd542 bdiff: add version to help detect breaking binary changes
Previously, we have no way to detect if a compiled .so file could be used or
not, and blindly load it if it exists. Usually we carefully maintain
compatibility of .so and fallback to pure code gracefully. But if we stick
to the rules, certain nice changes will be impossible to make in a clean
way.

This patch adds a "version" constant to the module so we can detect
inconsistency and take appropriate actions (warn, abort, fallback to pure,
run make automatically) in module loader.
2017-04-25 17:34:41 -07:00
Pierre-Yves David
1d69629fff obsmarker: add an experimental flag controlling "operation" recording
It seems better to introduce the experiment behind a flag for now as there are
multiple concerns around the feature:

 * Storing operation increase the size of obsolescence markers significantly
   (+10-20%).

 * It performs poorly when exchanging markers (cannot combine command names,
   command name might be unknown remotely, etc)
2017-05-20 03:10:23 +02:00
Augie Fackler
8197ec1496 dirstate: mark {begin,end}parentchange as deprecated (API) 2017-05-18 17:13:32 -04:00
Augie Fackler
d3c24043bb merge: migrate to context manager for changing dirstate parents 2017-05-18 17:11:24 -04:00
Augie Fackler
c46d888391 localrepo: migrate to context manager for changing dirstate parents 2017-05-18 17:11:14 -04:00
Augie Fackler
f75f070546 context: migrate to context manager for changing dirstate parents 2017-05-18 17:11:07 -04:00
Augie Fackler
dae08b1747 dirstate: introduce new context manager for marking dirstate parent changes 2017-05-18 17:10:30 -04:00
Yuya Nishihara
7b77796abc extensions: show deprecation warning for the use of cmdutil.command
Since this is a fundamental API for extensions, we set 1-year period until
actually removing it.
2016-01-09 23:24:52 +09:00
Yuya Nishihara
029af11327 extensions: prohibit registration of command without using @command (API)
Detect the problem earlier for better error indication. I'm tired of teaching
users that the mq extension is not guilty but the third-party extension is.

https://bitbucket.org/tortoisehg/thg/issues?q=%27norepo%27
2017-05-13 15:41:50 +09:00
Yuya Nishihara
748641feec extensions: optionally print hint on import failure
Test will be added by the next patch.
2017-05-14 15:46:45 +09:00
Yuya Nishihara
1e7ba75af3 error: add hint to ProgrammingError
As the hint isn't shown by the default exception handler, we need to print
it manually. I've copied the "** " style from _exceptionwarning().
2017-05-14 15:41:27 +09:00
Yuya Nishihara
018a4881b3 registrar: unindent superfluous "if True" block 2017-05-08 22:14:56 +09:00
Yuya Nishihara
12a6145361 registrar: switch @command decorator to class
It overrides _funcregistrarbase._doregister() since the structure of the
command table is quite different.
2017-05-08 22:08:40 +09:00
Yuya Nishihara
3e663dde68 registrar: move cmdutil.command to registrar module (API)
cmdutil.command wasn't a member of the registrar framework only for a
historical reason. Let's make that happen. This patch keeps cmdutil.command
as an alias for extension compatibility.
2016-01-09 23:07:20 +09:00
Pierre-Yves David
457dd23894 obsolete: move the 'isenabled' function at the top of the file
That is a simple and important function so having it at the top next to the
related constant seems better.
2017-05-19 13:12:42 +02:00
Pierre-Yves David
705173411e cache: make the cache updated callback easily accessible to extension
This will help extension to benefit from this new logic. As a side effect this
clarify the 'transaction' method a little bit.
2017-05-19 13:09:23 +02:00
Pierre-Yves David
60bb5d96f7 obscheckhead: skip context creation to test phase
On repository with many many heads, this is called often enough to show an
overhead to appears in some profile. So we skip the 'changectx' creation to test
the node phases.
2017-05-19 12:35:14 +02:00
Durham Goode
77dcefda06 obsolete: add operation metadata to rebase/amend/histedit obsmarkers
By recording what operation created the obsmarker, we can show very intuitive
messages to the user in various UIs. For instance, log output could have
messages like "Amended as XXX" to show why a commit is old and has an 'x' on it.

     @  ac28e3  durham
    /   First commit
   |
   | o  d4afe7 durham
   | |  Second commit
   | |
   | x  8e9a5d (Amended as ac28e3)  durham
   |/   First commit
   |
2017-05-09 16:29:31 -07:00
Martin von Zweigbergk
64acd1e09e match: use match.prefix() in subdirmatcher
It seems like the subdirmatcher should be checking if the matcher it's
based on is matching prefixes. It was effectively doing that already
because "prefix() == not always() and not anypats() and not
isexact()", subdirmatcher was checking the first two parts of that
condition and I don't think it will ever be given an "exact" matcher
with it's directory name (because exact matchers are for matching
files, not directories). Still, let's switch to using prefix() for
clarity (and because I'm trying to remove code that reaches for
matchers internals).
2017-05-17 22:33:15 -07:00
Martin von Zweigbergk
096fa56147 match: avoid accessing match._pathrestricted from subdirmatcher
Accessing only the public API wherever possible helps us refactor
matchers later.
2017-05-12 16:31:21 -07:00
Martin von Zweigbergk
ddbf56e07e match: override visitdir() the usual way in subdirmatcher
Just override the function instead of replacing it on each instance.
2017-05-18 10:17:57 -07:00
Martin von Zweigbergk
767cd2bb63 match: make _fileroots a @propertycache and rename it to _fileset
The files in the set are not necesserily roots of anything. Making it
a @propertycache will help towards extracting a base class for
matchers.
2017-05-18 09:04:37 -07:00
Andrew Zwicky
faec617779 diffstat: properly count lines starting in '--' or '++' (issue5479)
Lines that start in '--' or '++' were previously not counted
as deletions or additions in diffstat, resulting in incorrect
addition/deletion counts.  The bug was present if the start
of the line, combined with the diff character resulted
in '---' or '+++'.

diffstatdata will now track, for each file, if it has moved
pas the header section by looking for a line beginning with
'@@'.  Once that has happened, lines beginning with '-'
or '+' will be counted for deletions and additions.  Once a
line beginning with 'diff' is found, the process starts over.
2017-05-17 20:51:17 -05:00
Martin von Zweigbergk
e4f5b2c691 config: make config.items() return a copy
config.items() was iterating over a copy of the data for the the
specified section on Python 2 by using .items(). However, on Python 3,
items() does not make a copy, so let's switch to explicitly making a
copy to make it safe on both Python 2 and Python 3.
2017-05-18 13:38:37 -07:00
Stanislau Hlebik
32f126a2e0 filemerge: store error messages in module variables
Copytracing may be disabled because it's too slow (see
experimental.disablecopytrace config option). In that case user may get errors
like 'local changed FILE which other deleted'. It would be nice to give user a
hint to rerun command with `--config experimental.disablecopytrace=False`. To
make it possible let's extract error message to variables so that extension may
overwrite them.
2017-05-19 03:47:43 -07:00
Gregory Szorc
8af088ee65 revlog: rename constants (API)
Feature flag constants don't need "NG" in the name because they will
presumably apply to non-"NG" version revlogs.

All feature flag constants should also share a similar naming
convention to identify them as such.

And, "RevlogNG" isn't a great internal name since it isn't obvious it
maps to version 1 revlogs. Plus, "NG" (next generation) is only a good
name as long as it is the latest version. Since we're talking about
version 2, now is as good a time as any to move on from that naming.
2017-05-17 19:52:18 -07:00
Gregory Szorc
0d15165c74 localrepo: reformat set literals
Putting multiple elements on the same line makes diffs harder
to read. Switch to one line per element so future changes are
easier on the eyes.
2017-05-17 20:01:29 -07:00
Martin von Zweigbergk
3bc2187d25 match: remove ispartial()
The function was added in c2498bb6d298 (match: add match.ispartial(),
2015-05-15) for use by narrowhg, but narrowhg never ended up needing
it.
2017-05-17 09:43:50 -07:00
Jun Wu
718861a5f7 changelog: make sure datafile is 00changelog.d (API)
0ad0d26ff7 makes it possible for changelog datafile to be "00changelog.i.d",
which is wrong. This patch adds an explicit datafile parameter to fix it.
2017-05-17 20:14:27 -07:00
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