Commit Graph

15248 Commits

Author SHA1 Message Date
Gregory Szorc
2afb6aff3e extensions: refuse to load extensions if minimum hg version not met
As the author of several 3rd party extensions, I frequently see bug
reports from users attempting to run my extension with an old version
of Mercurial that I no longer support in my extension. Oftentimes, the
extension will import just fine. But as soon as we run extsetup(),
reposetup(), or get into the guts of a wrapped function, we encounter
an exception and abort. Today, Mercurial will print a message about
extensions that don't have a "testedwith" declaring explicit
compatibility with the current version.

The existing mechanism is a good start. But it isn't as robust as I
would like. Specifically, Mercurial assumes compatibility by default.
This means extension authors must perform compatibility checking in
their extsetup() or we wait and see if we encounter an abort at
runtime. And, compatibility checking can involve a lot of code and
lots of error checking. It's a lot of effort for extension authors.

Oftentimes, extension authors know which versions of Mercurial there
extension works on and more importantly where it is broken.

This patch introduces a magic "minimumhgversion" attribute in
extensions. When found, the extension loading mechanism will compare
the declared version against the current Mercurial version. If the
extension explicitly states we require a newer Mercurial version, a
warning is printed and the extension isn't loaded beyond importing
the Python module. This causes a graceful failure while alerting
the user of the compatibility issue.

I would be receptive to the idea of making the failure more fatal.
However, care would need to be taken to not criple every hg command.
e.g. the user may use `hg config` to fix the hgrc and if we aborted
trying to run that, the user would effectively be locked out of `hg`!

A potential future improvement to this functionality would be to catch
ImportError for the extension/module and parse the source code for
"minimumhgversion = 'XXX'" and do similar checking. This way we could
give more information about why the extension failed to load.
2015-11-24 15:16:25 -08:00
Yuya Nishihara
8b17e38d89 serve: unify cmdutil.service() calls of commandserver and hgweb 2015-10-31 22:17:05 +09:00
Yuya Nishihara
c64bc024c8 hgweb: extract factory function of httpservice object
The next patch will merge the cmdutil.service() calls of both commandserver
and hgweb. Before doing it, this patch wipes out the code specific to hgweb
from commands.serve().
2015-10-31 22:15:16 +09:00
Yuya Nishihara
4fb8995ece hgweb: move httpservice object from commands module
This avoids the deep import of hgweb.server at the commands module.
2015-10-31 21:57:45 +09:00
Siddharth Agarwal
106338a190 merge: move almost all change/delete conflicts to resolve phase (BC) (API)
We have finally laid all the groundwork to make this happen.

The only change/delete conflicts that haven't been moved are .hgsubstate
conflicts. Those are trickier to deal with and well outside the scope of this
series.

We add comprehensive testing not just for the initial selections but also for
re-resolves and all possible dirstate transitions caused by merge tools. That
testing managed to shake out several bugs in the way we were handling dirstate
transitions.

The other test changes are because we now treat change/delete conflicts as
proper merges, and increment the 'merged' counter rather than the 'updated'
counter. I believe this is the right approach here.

For third-party extensions, if they're interacting with filemerge code they
might have to deal with an absentfilectx rather than a regular filectx.

Still to come:
- add a 'leave unresolved' option to merges
- change the default for non-interactive change/delete conflicts to be 'leave
  unresolved'
- add debug output to go alongside debug outputs for binary and symlink file
  merges
2015-11-25 14:25:33 -08:00
Siddharth Agarwal
298e8f0bd3 debugmergestate: also recognize change/delete conflicts in the merge state
We're going to use this for tests in upcoming patches.
2015-11-24 18:26:21 -08:00
Siddharth Agarwal
6bdb690f9a debugmergestate: print out null nodes as 'null'
This is so much easier to read than a long string of zeroes, and we're going to
have a lot more of these nodes once change/delete conflicts are part of the
merge state.
2015-11-30 10:26:37 -08:00
Siddharth Agarwal
ed64d46a37 merge.recordupdates: mark 'a' files as added unconditionally
See the previous patch for why we do this.
2015-11-24 15:26:51 -08:00
Siddharth Agarwal
3a27c524dc merge: add a new action type representing files to add/mark as modified
This is somewhat different from the currently existing 'a' action, for the
following case:

- dirty working copy, with file 'fa' added and 'fm' modified
- hg merge --force with a rev that neither has 'fa' nor 'fm'
- for the change/delete conflicts we pick 'changed' for both 'fa' and 'fm'.

In this case 'branchmerge' is true, but we need to distinguish between 'fa',
which should ultimately be marked added, and 'fm', which should be marked
modified.

Our current strategy is to just not touch the dirstate at all. That works for
now, but won't work once we move change/delete conflicts to the resolve phase.
In that case we may perform repeated re-resolves, some of which might mark the
file removed or remove the file from the dirstate. We'll need to re-add the
file to the dirstate, and we need to be able to figure out whether we mark the
file added or modified. That is what the new 'am' action lets us do.
2015-11-30 10:19:39 -08:00
Siddharth Agarwal
ae700a3344 mergestate: add a cached property accessor for the local context
This is going to be useful in an upcoming patch. We make this a public accessor
because this is also going to be useful for custom merge drivers.
2015-11-30 10:03:21 -08:00
Siddharth Agarwal
71a05a4daf mergestate: raise exception if otherctx is accessed but _other isn't set
We don't want to inadvertently return the workingctx (self._repo[None]).
2015-11-30 10:05:09 -08:00
Siddharth Agarwal
6775160009 filemerge: in ':prompt', use ':fail' tool rather than returning directly
The ':fail' tool now knows to write out the changed side for change/delete
conflicts.

This has no impact right now but will make things better when we move
change/delete conflicts in here.
2015-11-24 10:58:35 -08:00
Siddharth Agarwal
1fc099f7ba filemerge: in ':fail' tool, write out other side if local side is deleted
We do this because we don't want to modify the dirstate for failures, and don't
just want to leave the file missing from disk. Plus it's more useful for the
user if the changed side is written out -- it is easier to delete a file than
to get it back via hg revert.
2015-11-24 10:57:01 -08:00
Siddharth Agarwal
c40efd7aa0 mergestate: explicitly forget 'dc' conflicts where the deleted side is picked
Once we move change/delete conflicts into the resolve phase, a 'dc' file might
first be resolved by picking the other side, then later be resolved by picking
the local side. For this transition we want to make sure that the file goes
back to not being in the dirstate.

This has no impact on conflicts during the initial merge.
2015-11-23 18:03:25 -08:00
Siddharth Agarwal
c655a316e8 merge.applyupdates: add all actions returned from merge state
At the moment this is a no-op (the only actions defined are 'r', 'a' and 'g'),
but soon we're going to add other sorts of actions to the dictionary returned
from mergestate.actions().
2015-11-23 19:06:15 -08:00
Mathias De Maré
b4c9b11d12 identify: refer to log to be able to view full hashes 2015-11-27 20:23:23 +01:00
Mathias De Maré
2bc22a2b60 log: add 'hg log' example for full hashes 2015-11-27 20:23:02 +01:00
Mathias De Maré
f15b803069 backout: add examples to clarify basic usage 2015-10-02 07:48:23 +02:00
Augie Fackler
dafe189e47 extensions: properly mark progress as part of core
This should have been done as part of or as an immediate follow-up to
01b01d59e33f, but presumably this feature of extensions.py was
forgotten at that time.
2015-11-24 18:40:16 -05:00
Gregory Szorc
f29561137a dispatch: use versiontuple()
We have a new generic function for this. Use it.
2015-11-24 14:23:46 -08:00
Gregory Szorc
11a7cac430 util: add versiontuple() for returning parsed version information
We have similar code in dispatch.py. Another consumer is about to be
created, so establish a generic function in an accessible location.
2015-11-24 14:23:51 -08:00
Bryan O'Sullivan
94365b400e extensions: rename _ignore to _builtin, add descriptive comment
It was previously not at all obvious what this was for.

We also change it to a set to avoid iterating over an admittedly
small list repeatedly at startup time.
2015-11-24 16:38:54 -08:00
Gregory Szorc
d84af347c4 ui: avoid needless casting to a str
In many cases, we don't need to cast to a str because the object will
be cast when it is eventually written.

As part of testing this, I added some code to raise exceptions when a
non-str was passed in and wasn't able to trigger it. i.e. we're already
passing str into this function everywhere, so the casting isn't
necessary.
2015-11-22 14:44:55 -08:00
Gregory Szorc
b184853d7f ui: remove labeled argument from popbuffer
It was moved to pushbuffer and currently does nothing.
2015-11-24 11:23:10 -08:00
Gregory Szorc
9a0cab7d0b cmdutil: pass labeled=True to pushbuffer()
This doesn't yet change behavior because labeling is still performed
at popbuffer time.

Surprisingly, this is the only in-tree consumer that passes
labeled=True.
2015-11-22 14:13:25 -08:00
Gregory Szorc
b338644768 ui: track label expansion when creating buffers
As part of profiling `hg log` performance, I noticed a lot of time
is spent in buffered writes to ui instances. This patch starts a series
that refactors buffered writes with the eventual intent to improve
performance.

Currently, labels are expanded when buffers are popped. This means
we have to preserve the original text and the label until we render
the final output. This is avoidable overhead and adds complexity
since we're retaining state.

This patch adds functionality to ui.pushbuffer() to declare whether
label expansion should be active for the buffer. Labels are still
evaluated during buffer pop. This will change in a subsequent
patch.

Since we'll need to access the "expand labels" flag on future write()
operations, we prematurely optimize how the current value is stored
to optimize for rapid retrieval.
2015-11-22 14:10:48 -08:00
Pierre-Yves David
5dc648f5ae format: create new repository as 'generaldelta' by default
Since we have pushed back the performance issue related to general delta behind
another configuration (Still off by default), we can safely create new
repository with general delta support. As client are compatible with it since
Mercurial 1.9 (4.5 years ago) I do no expect any significant compatibility
issues.
2015-11-02 17:33:18 +00:00
Siddharth Agarwal
06ed2cbe50 merge.applyupdates: create absentfilectxes for change/delete conflicts
At the moment no change/delete conflicts get to this point -- we're going to
make that happen in an upcoming patch.
2015-11-22 21:58:28 -08:00
Siddharth Agarwal
5b40330cf9 mergestate: add methods to queue files to remove, add or get
These are meant for use by custom merge drivers that might want to modify the
dirstate. Dirstate internal consistency rules require that all removes happen
before any adds -- this means that custom merge drivers shouldn't be modifying
the dirstate directly.
2015-11-22 21:59:52 -08:00
Siddharth Agarwal
2071a98a25 resolve: record dirstate actions after performing resolutions
Some resolutions might lead to pending actions we need to perform in the
dirstate -- so perform them.
2015-11-15 21:27:22 -08:00
Siddharth Agarwal
be9444426c mergestate: add a way to record pending dirstate actions
We're going to use this in resolve in the next patch.
2015-11-20 16:55:01 -08:00
Siddharth Agarwal
76ecd9e872 merge.recordupdates: don't require action keys to be present in dict
We're going to use this function for a much smaller set of actions in the next
patch. It's easier to do this than to backfill the dict we pass in.
2015-11-15 21:55:46 -08:00
Anton Shestakov
5c74a8a582 paper: show current revision on file log page
Most of the pages in paper (and coal) style show the current revision and its
branch, tags and bookmarks. Let's also show all this on file log page.
2015-11-13 18:31:58 +08:00
Siddharth Agarwal
d2620ef53f merge.applyupdates: extend action queues with ones returned from mergestate
These queues will always be empty at the moment -- we're going to fill them up
in upcoming patches.
2015-11-20 11:26:31 -08:00
Siddharth Agarwal
1e4024e0f1 mergestate: add a method to compute actions to perform on dirstate
We're going to use this to extend the action lists in merge.applyupdates.

The somewhat funky return value is to make passing this dict directly into
recordactions easier. We're going to exploit that in an upcoming patch.
2015-11-20 16:43:25 -08:00
Siddharth Agarwal
b86e19fd45 merge.applyupdates: use counters from mergestate
This eliminates a whole bunch of duplicate code and allows us to update the
removed count for change/delete conflicts where the delete action was chosen.
2015-11-20 16:37:39 -08:00
Siddharth Agarwal
f919bd4f7b mergestate: add a function to return the number of unresolved files
Note that unlike the other functions, this is based on the persistent
mergestate.
2015-11-20 16:18:51 -08:00
Siddharth Agarwal
8dd9d0304c mergestate: add a method to return updated/merged/removed counts
This will not only allow us to remove a bunch of duplicate code in applyupdates
in an upcoming patch, it will also allow the resolve interface to be a lot
simpler: it doesn't need to return the dirstate action to applyupdates.
2015-11-20 16:17:54 -08:00
Siddharth Agarwal
dd58f25087 mergestate._resolve: don't return the action any more
This is a partial backout of an earlier diff -- now that we're storing the
results in a dict, we don't actually need this any more.
2015-11-20 16:32:47 -08:00
Siddharth Agarwal
aaac3ed514 mergestate._resolve: store return code and action for each file
We're going to need this to compute (a) updated/merged/unresolved counts, and
(b) actions to perform on the dirstate.
2015-11-20 16:08:22 -08:00
Gregory Szorc
b8f3c3b570 localrepo: improve docstring for revset methods
revs() doesn't return a list. Also document what its arguments do.

Also clarify that set() is just a convenience wrapper around revs().
2015-11-21 11:07:30 -08:00
Gregory Szorc
09f64f3e3e revlog: improve documentation
There are a lot of functions and variables doing similar things.
Document the role and functionality of each to make it easier to
grok.
2015-11-22 16:23:20 -08:00
Gregory Szorc
9180aefb82 demandimport: don't enable when running under PyPy
On demand importing doesn't work with PyPy for some reason. Don't honor
requests to enable demand importing when running under PyPy.
2015-11-21 22:28:01 -08:00
Gregory Szorc
de3b37d77c ui.write: don't clear progress bar when writing to a buffer
ui.write() has 2 modes: buffered and unbuffered. In buffered mode, we
capture output before writing it. This is how changeset printing works,
for example.

Previously, we were potentially clearing the progress bar for every
call to ui.write(). In buffered mode, this clearing was useless because
the clearing function would be called again before actually writing
the buffered data.

This patch stops the useless calling of _progclear() unless we are
actually writing data. During changeset printing with the default
template, this removes ~6 function calls per changeset, making
changeset printing slightly faster.

before: 23.76s
after:  23.35s
delta:  -0.41s (98.3% of original)
2015-11-14 17:14:14 -08:00
Gregory Szorc
5f5da12c81 util.datestr: use divmod()
We were computing the quotient and remainder of a division operation
separately. The built-in divmod() function allows us to do this with
a single function call. Do that.
2015-11-14 17:30:10 -08:00
Gregory Szorc
dbea71eee2 cmdutil.changeset_printer: pass context into showpatch()
Before, we passed the node then subsequently performed a lookup on
repo.changelog. We already has the context available, so just pass it
in.

This does result in a small performance win. But I doubt it will show
up anywhere because diff[stat] calculation will dwarf the time spent
to create a changectx. Still, we should be creating fewer changectx
out of principle.
2015-11-14 17:44:01 -08:00
Gregory Szorc
79473d891d context: avoid extra parents lookups
Resolving parents requires reading from the changelog, which is a few
attributes and function calls away. Parents lookup occurs surprisingly
often. Micro optimizing the code to avoid redundant lookups of parents
appears to make `hg log` on my Firefox repo a little faster:

before: 24.91s
after:  23.76s
delta:  -1.15s (95.4% of original)
2015-11-21 19:21:01 -08:00
Gregory Szorc
b65e310257 context: optimize _parents()
This patch avoids some extra attribute lookups and list mutations.

This micro-optimization seems to result in a minor speedup for `hg log`
on my Firefox repo:

before: 25.35s
after:  24.91s
delta:  -0.44s (98% of original)

Not the biggest gain. But every little bit helps.
2015-11-21 19:04:12 -08:00
Gregory Szorc
be59b3aff6 lsprof: support PyPy (issue4573)
PyPy's _lsprof module doesn't export a "profiler_entry" symbol. This
patch treats the symbol as optional and falls back to verifying the
attribute is present on the first entry in the collected data as
part of validation.

There is a chance not every entry will contain the requested sort
attribute. But, this patch does unbust lsprof on PyPy for the hg
commands I've tested, so I assume it is sufficient. It's certainly
better than the ImportError we encountered before.

As part of the import refactor, I snuck in the addition of
absolute_import.
2015-11-21 23:26:22 -08:00
Augie Fackler
72f70c2998 base85: clean up function definition style
Cleanup performed with clang-format.
2015-11-11 19:10:45 -05:00