Commit Graph

26911 Commits

Author SHA1 Message Date
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
Matt Harbison
ea3de44e49 test-resolve: fix '--tool f' invocation for Windows
Windows can't invoke a python script directly, so invoke sh.exe instead.

According to sid0, the output changes are due to the fact that 'f' is no longer
being passed all of the args that it was, but these changes aren't essential to
the test [1].

[1] https://selenic.com/pipermail/mercurial-devel/2015-November/075768.html
2015-11-22 21:20:08 -05: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
Matt Harbison
2c0c2470a4 test-histedit: $TESTTMP quoting fixes for Windows
Without this, C:\path\to\test is converted into C:pathtotest.

Since $TESTTMP appears in output, seems to work in some places without quotes,
and is also used within a larger quote block (see test-rebase-collapse.t, ~line
160), I'm not sure what a check-code rule would look like (or even if it is
feasible).
2015-11-22 13:05:21 -05: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
Laurent Charignon
b6a3739c99 rebase: use bookmarks.recordchange instead of bookmarks.write
Before this patch we were using the old api bookmarks.write instead of
bookmarks.recordchange at the end of rebase operations.
We move clearstatus within the transaction to make it easier for extensions
that wrap transactions operations.
2015-11-20 14:06:31 -08:00
Laurent Charignon
bd889a16a7 rebase: indentation change to make the next patch more legible
We put the code to be indented in the next patch in a "if True:" block to make
it easier to review.
2015-11-20 11:36:05 -08:00
Matt Harbison
bf40666b90 test-run-tests: conditionalize the $TESTDIR check for Windows separator
The variable uniformly uses '\' separators, so the straight equality check with
'/' separating the last component fails.  It also doesn't like having the quote
appear in the middle of the string when testing.
2015-11-16 16:56:00 -05:00
Matt Harbison
8637ab634c test-context: conditionalize the workingfilectx date printing for Windows
Starting with 8102a3981272, the output changed on Windows:

  --- e:/Projects/hg/tests/test-context.py.out
  +++ e:/Projects/hg/tests/test-context.py.err
  @@ -1,4 +1,4 @@
  -workingfilectx.date = (1000, 0)
  +workingfilectx.date = (1000L, 0)
   ASCII   : Gr?ezi!
   Latin-1 : Grⁿezi!
   UTF-8   : Gr├╝ezi!

Since int and long are both 32 bit on Windows, this seems harmless in practice
other than the previous test failure.
2015-11-09 17:15:36 -05:00
Matt Harbison
89239f0372 test-mq-qrefresh: drop single quoting of HGEDITOR value for Windows
This was failing with:

    sh: $TESTTMP/checkvisibility.sh: No such file or directory
2015-11-16 14:37:03 -05:00
Matt Harbison
446c297580 test-import: don't use printf to append an extension to $HGRCPATH
The extension was failing to load on Windows because $TESTTMP contains a path
component 'test', prefixed by a path separator '\'.  That combination ends up
converted to "...<tab>est...".
2015-11-16 14:12:27 -05:00
Matt Harbison
66fa6febb4 test-ssh: stop quoting dummyssh invocation for Windows
The other invocations aren't quoted, and Windows doesn't like the single quotes:

  diff --git a/tests/test-ssh.t b/tests/test-ssh.t
  --- a/tests/test-ssh.t
  +++ b/tests/test-ssh.t
  @@ -520,20 +520,8 @@ remote hook failure is attributed to rem
     $ echo "pretxnchangegroup.fail = python:$TESTTMP/failhook:hook" >> remote/.hg/hgrc

     $ hg -q --config ui.ssh="python '$TESTDIR/dummyssh'" clone ssh://user@dummy/remote hookout
  +  abort: no suitable response from remote hg!
  +  [255]
     $ cd hookout
  +  $TESTTMP.sh: line 264: cd: hookout: No such file or directory
     $ touch hookfailure
  -  $ hg -q commit -A -m 'remote hook failure'
  ....
2015-11-16 13:44:27 -05:00
Laurent Charignon
d3b83d4e8c strip: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Before this patch, strip was using repo._bookmarks.write.
This patch replaces this code with the recommended way of saving bookmarks
changes: repo._bookmarks.recordchange.
2015-11-20 13:46:36 -08:00
Laurent Charignon
8ace80e21d histedit: make use of bookmarks.recordchange instead of bookmarks.write
Before this patch we were using the old api bookmarks.write, this patches
replaces its usage by bookmarks.recordchange, the new api to record bookmark
changes.
2015-11-20 13:23:47 -08:00
Siddharth Agarwal
f5d6c8e713 largefiles: fall back to the original for change/delete conflicts
The largefiles merge code (currently) does not handle change/delete conflicts.
So fall back to regular filemerge in that case.

Making this code handle change/delete conflicts is left as an exercise for the
future.
2015-11-18 17:40:13 -08:00
Siddharth Agarwal
5d6cb7e78f mergestate.add: store absentfilectxes as nullhex
This is the most natural way to represent these files. We also need to make
sure we don't try to store these files in the merge store.
2015-11-14 00:07:11 -08:00
Siddharth Agarwal
328287680c mergestate._resolve: handle change/delete conflicts
We will represent a deleted file as 'nullhex' in the in-memory and on-disk
merge states. We need to be able to create absentfilectxes in that case, and
delete the file from disk rather than try to write it out.
2015-11-20 01:14:15 -08:00
Siddharth Agarwal
2264cfb327 filemerge: don't try to copy files known to be absent
We set 'back' to None in this case, so we need to handle that as well.
2015-11-14 00:00:46 -08:00
Yuya Nishihara
47690f822c hgweb: use absolute_import 2015-10-31 22:07:40 +09:00
Yuya Nishihara
6f91677786 hgweb: import wsgicgi at top level
There should be no practical reason to delay the import of wsgicgi.
2015-11-01 15:09:35 +09:00
Yuya Nishihara
3a2ca88d5a hgweb: import BaseHTTPServer as module at top level
This will avoid future warning spotted by the import checker.
2015-11-01 15:07:08 +09:00
Yuya Nishihara
e142543972 hgweb: do not import hgweb_mod.hgweb and .makebreadcrumb as symbol
It will be enforced by the import checker.
2015-11-01 14:23:23 +09:00
Siddharth Agarwal
830ec886fc filemerge: don't try using external tools on change/delete conflicts
This is mostly for completeness' sake -- the current code shouldn't get to this
point.
2015-11-13 23:57:43 -08:00
Siddharth Agarwal
5222eee8d6 filemerge: don't attempt to premerge change/delete conflicts
This is mostly for completeness' sake -- at the moment we don't support any
tools for change/delete conflicts that would do a premerge.
2015-11-13 23:56:00 -08:00
Siddharth Agarwal
a5600d30a6 filemerge._mergecheck: add check for change/delete conflicts
Merge tools that perform an actual 3-way merge can't handle change/delete
conflicts. This adds a check for that.
2015-11-13 23:58:05 -08:00
Siddharth Agarwal
1154e3eab0 filemerge._picktool: only pick from nomerge tools for change/delete conflicts
For --tool or HGMERGE, we could have either:
(a) proceeded with the particular tool, then failed the merge.
(b) chosen to prompt regardless.

We're explicitly choosing (b) here, because it's effectively what we've been
doing so far and helps maintain an easier-to-use interface.

However, in future patches we're going to change the default selection from
'pick changed version' to 'leave unresolved'. That fixes most of the brokenness
involved with choice (b).
2015-11-15 21:40:15 -08:00
Siddharth Agarwal
dfb75ef0b1 filemerge: add support for change/delete conflicts to the ':prompt' tool
We haven't added the 'leave unresolved' option yet -- that will come in a
future patch.
2015-11-13 23:52:26 -08:00
Siddharth Agarwal
1b647216ac filemerge: add support for change/delete conflicts to the ':other' merge tool
This, along with the previous patch to the :local merge tool, covers the full
matrix of change/delete conflicts.
2015-11-18 15:41:50 -08:00
Siddharth Agarwal
b3c05df6b2 filemerge: add support for change/delete conflicts to the ':local' merge tool
This covers two of the four cases of change/delete conflicts -- in an upcoming
patch we'll make :other cover the other two.
2015-11-18 15:40:28 -08:00
Siddharth Agarwal
f5fc173bec merge.mergestate: compute dirstate action
In upcoming patches we're going to queue these actions up to be applied to the
dirstate at the end.
2015-11-19 10:50:02 -08:00
Siddharth Agarwal
4904ded295 filemerge: return whether the file was deleted
This is required for change/delete conflict resolution -- see previous patches
for more details.
2015-11-18 14:22:52 -08:00
Siddharth Agarwal
c33d958db2 filemerge: return whether the file is deleted from all other merge tools
This is required for change/delete conflicts -- see the previous patch for more
information.
2015-11-18 13:55:31 -08:00
Siddharth Agarwal
4155f9cde2 filemerge: return whether the file is deleted for nomerge internal tools
We're going to support the filemerge code resolving change/delete conflicts in
upcoming patches. Some of these resolutions require that the dirstate be
modified. Modifying the dirstate directly from in here would be (a) a pretty
bad layering violation and (b) wrong because all dirstate removals should
happen before adds. So in this and upcoming patches we're instead going to pass
whether the file is deleted up to merge.mergestate, then in there figure out
what dirstate action needs to be taken.
2015-11-18 13:52:28 -08:00
Siddharth Agarwal
c5b488f2d2 mergestate: allow storing and retrieving change/delete conflicts
We introduce a new record type, 'C', to indicate change/delete conflicts. This
is a separate record type because older versions of Mercurial will not be able
to handle these conflicts.

We aren't actually storing any change/delete conflicts yet -- that will come in
future patches.
2015-11-18 15:46:45 -08:00
Shubhanshu Agrawal
caf17cd48e strip: changing bookmark argument to be a list
Currently strip works with a single bookmark,
the changes in this patch modifies the strip
extension to accept a list of bookmarks
2015-11-19 12:50:10 +05:30
Shubhanshu Agrawal
64e100e7aa strip: strip a list of bookmarks
Currently strip works with a single bookmark,
the changes in this patch modifies the strip module
to work with a list of bookmarks

Building on this we can take a list of bookmarks as input
and remove all of them in a single go
2015-11-15 21:03:44 +05:30
Pierre-Yves David
5269ce9dff revset: speed up '_matchfiles'
File matching is done by applying the matcher to all elements in the 'file'
field of all changesets in the repository. This requires to read/parse all
changesets in the repository and do a lot of matching. However about 1/3 of the
time of the function is used to create 'changectx' object and retrieve their
'file' field.

This is far too much overhead so we are skipping the changectx layer and
directly access the data from the changelog. This provide use significant speed
up:

repository: mozilla central 252524 revisions
command: hg perfrevset '_matchfiles("p:browser")'
Before: 15.899687s
After:  10.011705s

Slowdown is even more significant if you have a lot of namespace that slowdown
lookup.

The time is now spent with this approximate repartition:

  Matcher: 20%
    regexp matching: 10%
  changelog.read: 80%
    reading revision: 60%
      checking hash: 15%
      decompression: 15%
      reading chunk: 30%
    changelog parsing: 20%
      decoding to local: 10%

The next easy win is probably to have more of the changelog stack implemented
using the CPython api.
2015-11-18 23:23:03 -08:00
Siddharth Agarwal
4a78a436f9 mergestate: handle additional record types specially
This works around a bug in older Mercurial versions' handling of the v2 merge
state.

We also add a bunch of tests that make sure that
(1) we correctly abort when the merge state has an unsupported record type
(2) aborting the merge, rebase or histedit continues to work and clears out the
    merge state.
2015-11-18 15:46:45 -08:00
Siddharth Agarwal
d523c7a52e test-resolve.t: remove completely unnecessary line
I have no idea what I was thinking when I wrote this.
2015-11-18 23:42:32 -08:00
Siddharth Agarwal
5380ac35da resolve: fix incorrect merge
The merge from stable into default was semantically incomplete -- a couple of
changes in preceding code had to be rewritten here.

This code only triggers for change/delete conflicts, so we can't test it yet.
We will soon be able to do it, though.
2015-11-18 23:43:18 -08:00
liscju
616740cead fileset: add missing() predicate (issue4925)
Help of status cmd defines status file of 'missing', what is
called in fileset 'deleted'. To stay consistent this patch
introduces missing() predicate which in fact is alias to
'deleted'.
2015-11-18 20:55:32 +01:00
Anton Shestakov
53412195f4 webutil: make _siblings into an object with __iter__ and __len__
_siblings is a helper that is used for displaying changeset parents and
children in hgweb. Before, when it was a simple generator, it couldn't tell its
length without being consumed, and that required a special case when preparing
data for changeset template (see 3468fd599ef4).

Let's make it into a class (similar to templatekw._hybrid) that allows len(...)
without side-effects.
2015-11-10 17:22:40 +08:00
Siddharth Agarwal
a19a04c7f9 mergestate: move binary format documentation into _readrecordsv2
This is too low-level to be the top-level documentation for mergestate. We're
restricting the top-level documentation to only be about what consumers of the
mergestate and anyone extending it need to care about.
2015-11-18 16:39:30 -08:00
Siddharth Agarwal
ad963d1bec unshelve: add support for custom merge tools
For parity with merge --tool, rebase --tool etc.

rebase.rebase overwrites the tool in repo.ui, so we need to explicitly pass it
down there too.
2015-11-18 15:11:23 -08:00