Commit Graph

10603 Commits

Author SHA1 Message Date
Gábor Stefanik
b631d16eab graft: support grafting changes to new file in renamed directory (issue5436) 2016-12-05 17:40:01 +01:00
Jun Wu
3f639e27a5 rebase: calculate ancestors for --base separately (issue5420)
Previously, the --base option only works with a single "branch" - if there
is one changeset in the "--base" revset whose branching point(s) is/are
different from another changeset in the "--base" revset, "rebase" will error
out with:

  abort: source is ancestor of destination

This happens if the user has multiple draft branches, and uses "hg rebase -b
'draft()' -d master", for example. The error message looks cryptic to users
who don't know the implementation detail.

This patch changes the logic to calculate the common ancestor for every
"base" changeset separately so we won't (incorrectly) select "source" which
is an ancestor of the destination.

This patch should not change the behavior where all changesets specified by
"--base" have the same branching point(s).

A new situation is: some of the specified changesets could be rebased, while
some couldn't (because they are descendants of the destination, or they do
not share a common ancestor with the destination). The current behavior is
to show "nothing to rebase" and exits with 1.

This patch maintains the current behavior (show "nothing to rebase") even if
part of the "--base" revset could be rebased. A clearer error message may be
"cannot find branching point for X", or "X is a descendant of destination".
The error message issue is tracked by issue5422 separately.

A test is added with all kinds of tricky cases I could think of for now.
2016-11-28 05:45:22 +00:00
Jun Wu
f9c05a235e localrepo: use ProgrammingError
This is an example usage of ProgrammingError. Let's start migrating
RuntimeError to ProgrammingError.

The code only runs when devel.all-warnings or devel.check-locks is set, so
it does not affect the end-user experience.
2016-12-06 17:06:39 +00:00
Pulkit Goyal
849c625bac py3: use pycompat.sysstr() in __import__()
__import__() on Python 3 accepts strings which are different from that of
Python 2. Used pycompat.sysstr() to get string accordingly.
2016-12-01 13:12:04 +05:30
Pulkit Goyal
4245797c62 py3: avoid use of basestring
"In this case, result is a source variable of a list to be returned, it
shouldn't be unicode. Hence we can use bytes instead of basestring here." -Yuya
2016-11-30 23:51:11 +05:30
Pulkit Goyal
bf0008abe9 py3: use unicodes in __slots__
__slots__ in Python 3 accepts only unicodes and there is no harm using
unicodes in __slots__. So just adding u'' is fine. Previous occurences of this
problem are treated the same way.
2016-11-30 23:38:50 +05:30
Gregory Szorc
6a4fd5ab05 wireproto: only advertise HTTP-specific capabilities to HTTP peers (BC)
Previously, the capabilities list was protocol agnostic and we
advertised the same capabilities list to all clients, regardless of
transport protocol.

A few capabilities are specific to HTTP. I see no good reason why we
should advertise them to SSH clients. So this patch limits their
advertisement to HTTP clients.

This patch is BC, but SSH clients shouldn't be using the removed
capabilities so there should be no impact.
2016-11-28 20:46:42 -08:00
Mads Kiilerich
ecd76cc19e bdiff: early pruning of common prefix before doing expensive computations
It seems quite common that files don't change completely. New lines are often
pretty much appended, and modifications will often only change a small section
of the file which on average will be in the middle.

There can thus be a big win by pruning a common prefix before starting the more
expensive search for longest common substrings.

Worst case, it will scan through a long sequence of similar bytes without
encountering a newline. Splitlines will then have to do the same again ...
twice for each side. If similar lines are found, splitlines will save the
double iteration and hashing of the lines ... plus there will be less lines to
find common substrings in.

This change might in some cases make the algorith pick shorter or less optimal
common substrings. We can't have the cake and eat it.

This make hg --time bundle --base null -r 4.0 go from 14.5 to 15 s - a 3%
increase.

On mozilla-unified:
perfbdiff -m 3041e4d59df2
! wall 0.053088 comb 0.060000 user 0.060000 sys 0.000000 (best of 100) to
! wall 0.024618 comb 0.020000 user 0.020000 sys 0.000000 (best of 116)
perfbdiff 0e9928989e9c --alldata --count 10
! wall 0.702075 comb 0.700000 user 0.700000 sys 0.000000 (best of 15) to
! wall 0.579235 comb 0.580000 user 0.580000 sys 0.000000 (best of 18)
2016-11-16 19:45:35 +01:00
Yuya Nishihara
0a5e04d63d formatter: add overview of API and example as doctest 2016-10-22 15:02:11 +09:00
Yuya Nishihara
1d44bd2bbb ui: factor out ui.load() to create a ui without loading configs (API)
This allows us to write doctests depending on a ui object, but not on global
configs.

ui.load() is a class method so we can do wsgiui.load(). All ui() calls but
for doctests are replaced with ui.load(). Some of them could be changed to
not load configs later.
2016-10-22 14:35:10 +09:00
Jun Wu
3ee7ba0bd8 tests: replace "cp -r" with "cp -R"
The POSIX documentation about "cp" [1] says:

  ....

  RATIONALE
    ....
    Earlier versions of this standard included support for the -r option to
    copy file hierarchies. The -r option is historical practice on BSD and
    BSD-derived systems. This option is no longer specified by POSIX.1-2008
    but may be present in some implementations. The -R option was added as a
    close synonym to the -r option, selected for consistency with all other
    options in this volume of POSIX.1-2008 that do recursive directory
    descent.

    The difference between -R and the removed -r option is in the treatment
    by cp of file types other than regular and directory. It was
    implementation-defined how the - option treated special files to allow
    both historical implementations and those that chose to support -r with
    the same abilities as -R defined by this volume of POSIX.1-2008. The
    original -r flag, for historic reasons, did not handle special files any
    differently from regular files, but always read the file and copied its
    contents. This had obvious problems in the presence of special file
    types; for example, character devices, FIFOs, and sockets.
    ....

  ....

  Issue 6
    The -r option is marked obsolescent.
    ....

  Issue 7
    ....
    The obsolescent -r option is removed.
    ....

  (No "Issue 8" yet)

Therefore it's clear that "cp -R" is strictly better than "cp -r".

The issue was discovered when running tests on OS X after 2e4d149e62aa.

[1]: pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html
2016-11-30 19:25:18 +00:00
Martijn Pieters
ca91b8fcf4 posix: give the cached symlink a real target
The NamedTemporaryFile file is cleared up so checklink ends up as a dangling
symlink, causing cp -r in tests to complain on both Solaris and OS X. Use
a permanent file instead when there is a .hg/cache directory.
2016-11-30 16:39:36 +00:00
Kostia Balytskyi
9b01b1d353 shelve: move patch extension to a string constant
We are using 'name + ".patch"' pattern throughout the shelve code to
identify the existence of a shelve with a particular name. In two
cases however we use 'name + ".hg"' instead. This commit makes
'patch' be used in all places and "emphasizes" it by moving
'patch' to live in a constant. Also, this allows to extract file
name without extension like this:
    f[:-(1 + len(patchextension))]
instead of:
    f[:-6]
which is good IMO.

This is a first patch from this initial "obsshelve" series. This
series does not include tests, although locally I have all of
test-shelve.t ported to test obs-shelve as well. I will send tests
later as a separate series.
2016-11-29 07:20:03 -08:00
Kostia Balytskyi
69bbbd3ecf shelve: fix use of unexpected working dirs in test-shelve.t
Fixing some clowniness where we created ~four levels of nested repos
and once (my test case :( ) did not even cd into a created repo.
2016-11-29 04:11:05 -08:00
Augie Fackler
f37a723203 merge with stable 2016-11-27 20:44:52 -05:00
Gregory Szorc
d5c4807106 debugcommands: sort command order
The diff is a bit large but it is straight code moving without any
logical modifications.
2016-11-25 09:59:39 -08:00
Gregory Szorc
7ab5315d89 tests: add test that @commands in debugcommands.py are sorted
I felt like inline Python in test-check-code.t was the most
appropriate place for this, as other linters in contrib/ seem to
be source file agnostic.

The test currently fails.
2016-11-25 09:55:05 -08:00
Mads Kiilerich
a31c060801 merge: use original file extension for temporary files
Some merge tools (like Araxis?) can pick merge mode based on the file
extension. That didn't work well when temporary files were given random
suffixes. It seems to work better when the random part is before the extension.

As usual, when using $output, $local will have the .orig extension. That could
perhaps be the subject of another change another day.
2016-11-23 23:47:38 +01:00
Denis Laxalde
11b3012d89 revert: prompt before removing files in interactive mode
Prior to this change, files to be removed (i.e. files added since the revision
to revert to) were unconditionally removed despite the interactive mode. Now
prompt before actually removing the files, as this is done for other actions
(e.g. forget).
2016-11-25 09:10:30 +01:00
Denis Laxalde
1dc33c0e5e revert: indicate the default choice when prompting to forget files 2016-11-25 09:09:31 +01:00
Mads Kiilerich
9c5f48e630 shelve: add missing space in help text
The change is trivial and unlikely to have been translated so we update
translation files too.
2016-11-14 22:43:25 +01:00
Nathan Goldbaum
cd41ee4190 tag: clarify warning about making a tag on a branch head
Currently the warning is ambiguous about whether the new tag (possibly specified
via --rev) is being added on a branch head or whether the working directory is
based on a branch head. Clarify the error message to eliminate this ambiguity.
2016-10-31 17:12:32 -05:00
Yuya Nishihara
26d053eede hghave: fix 'rmcwd' to ensure temporary directory is removed
On platforms where cwd can't be removed, it should try rmdir() after chdir
to the original cwd.
2016-11-01 21:14:33 +09:00
FUJIWARA Katsunori
f6a54b0fb3 tests: test preserving execbit changes at amending only on execbit platform 2016-10-30 06:15:09 +09:00
FUJIWARA Katsunori
2e91a346cc tests: put temporary file outside the working directory for test portability
test-largefiles-update.t creates temporary file exec-bit.patch inside
the working directory for no-execbit platform specific test, but
subsequent tests aren't aware of it.

On execbit platform, subsequent tests can run successfully, because
exec-bit.patch isn't created.

But on no-execbit platform, this temporary file makes subsequent tests
show "? exec-bit.patch" at each "hg status".
2016-10-30 06:15:09 +09:00
FUJIWARA Katsunori
395fcead6f tests: avoid quoting of commit messages for test portability
journal extension uses util.shellquote() to record command line, but
result of it depends on runtime platform: double quotation is used on
Windows and OpenVMS, but single quotation is used otherwise.

test-journal-share.t sometimes specifies commit messages including
white space on command line. It makes journal output depend on runtime
platform, but commit message itself isn't important in this test case.
2016-10-30 06:15:09 +09:00
FUJIWARA Katsunori
8b10b9dd7e tests: use basic format code "%Y" instead of "%s" for test portability
On Windows, strftime() doesn't support format code "%s", and it causes
"invalid format string" error.

    https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx

test-command-template.t examines not seconds value in UTC, but
arithmetic calculation. Therefore, using format code "%Y" instead of
"%s" should be reasonable.

FYI:

- Python standard library reference doesn't list "%s" up in format
  code list required for "C standard (1989 version)", even though it
  also mentions that additional format codes are required for "C
  standard (1999 version)"

  https://docs.python.org/2.7/library/datetime.html#strftime-and-strptime-behavior

- The Open Group Base Specifications Issue 7 (IEEE Std 1003.1-2008,
  2016 Edition) doesn't require strftime to support format code "%s"

  http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html

- "man strftime" of (Open/Oracle) Solaris and Mac OS X (= UNIX
  certified OSs) describes about format code "%s"
2016-10-30 06:15:07 +09:00
FUJIWARA Katsunori
feea36218b tests: add test-commit-interactive-curses.t "require tic" for test portability
Standard library of Python on Windows doesn't have curses module.
2016-10-29 03:08:08 +09:00
FUJIWARA Katsunori
85658908df tests: use "?" to glob both ":" and ";" in output for test portability
If environment variable looks like PATH or so (e.g. any of components
joined by ":" contains "/"), ":" in it is replaced with ";" by MinGW
at spawning Windows native process, to follow path concatenation style
of Windows.

Therefore, "bundle:../full.hg" is converted into "bundle;..\full.hg"
on MinGW.

Difference between "/" and "\" is automatically ignored by "(glob)",
but difference between ":" and ";" should be globed explicitly.
2016-10-29 03:04:54 +09:00
FUJIWARA Katsunori
2568974470 tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:

  - unless binding between *.py suffix and python runtime, application
    selector dialog is displayed, and running test is blocked at each
    printenv.py invocations

  - it isn't safe to assume binding between *.py suffix and python
    runtime, because application binding is easily broken

    For example, installing IDE (VisualStudio with Python Tools, or
    so) often requires binding between source files and IDE itself.

This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.

This changes were confirmed in cases below:

  - without any application binding for *.py suffix
  - with binding between *.py suffix and VisualStudio

This patch also replaces "echo + redirection" style with "heredoc"
style, because:

  - hook command line is parsed by cmd.exe as shell at first, and
  - single quotation can't quote arguments on cmd.exe, therefore,
  - "printenv.py foobar" should be quoted by double quotation, but
  - nested quoting (or tricky escaping) isn't readable
2016-10-29 02:44:45 +09:00
Yuya Nishihara
01ff276025 templater: use unfiltered changelog to calculate shortest() at constant time
cl._partialmatch() can be pretty slow if hidden revisions are involved. This
patch cancels the slowdown introduced by the previous patch by using an
unfiltered changelog, which means shortest(node) isn't always the shortest.

The result isn't perfect, but seems okay as long as shortest(node) is short
enough to type and can be used as an identifier.

  (with hidden revisions)
  % hg log -R hg-committed -r0:20000 -T '{node|shortest}\n' --time > /dev/null
  (.^^) time: real 1.530 secs (user 1.480+0.000 sys 0.040+0.000)
  (.^)  time: real 43.080 secs (user 43.060+0.000 sys 0.030+0.000)
  (.)   time: real 1.680 secs (user 1.650+0.000 sys 0.020+0.000)
2016-10-25 21:49:30 +09:00
Yuya Nishihara
35fcce9afc templater: do not use index.partialmatch() directly to calculate shortest()
cl.index.partialmatch() isn't a drop-in replacement for cl._partialmatch().
It has no knowledge about hidden revisions, and it raises ValueError if a node
shorter than 4 chars is given. Instead, use index.partialmatch() through
cl._partialmatch(), which has no such problems and gives the identical result
with/without --pure.

The test output was sampled with --pure without this patch, which shows the
most correct result. However, we'll need to switch to using an unfiltered
changelog because _partialmatch() of a filtered changelog can be an order of
magnitude slower.

  (with hidden revisions)
  % hg log -R hg-committed -r0:20000 -T '{node|shortest}\n' --time > /dev/null
  (.^)  time: real 1.530 secs (user 1.480+0.000 sys 0.040+0.000)
  (.)   time: real 43.080 secs (user 43.060+0.000 sys 0.030+0.000)
2016-10-23 14:05:23 +09:00
Yuya Nishihara
85c5af29fa tests: run "cwd was removed" test only if cwd can actually be removed
On some platforms, cwd can't be removed. In which case, util.unlinkpath()
continues with no error since the failure of directory removal isn't critical.
So it doesn't make sense to run the test added by 6395630fdfdc on those
platforms. OTOH, we need to run the test in test-rebase-scenario-global.t
since the repository is referenced after that.
2016-10-26 22:50:06 +09:00
Gábor Stefanik
5533b05a12 merge: avoid superfluous filemerges when grafting through renames (issue5407)
This is a fix for a regression introduced by the patches for issue4028.

The test changes are due to us doing fewer _checkcopies searches now, which
makes some test outputs revert to the pre-issue4028 behavior. That issue itself
remains fixed, we only skip copy tracing for files where it isn't relevant.
As a nice side effect, this makes copy detection much faster when tracing
backwards through lots of renames.
2016-10-25 21:01:53 +02:00
Simon Farnsworth
06082f0f98 tests: fix test-casefolding.t
The message had changed, but the test was not updated. This test does not
run on Linux, but failed on my Mac.
2016-10-21 16:31:16 +01:00
Gregory Szorc
3f32afbd84 commands: print security protocol support in debuginstall
Over the past week I've had to instruct multiple people to run
Python code to query the ssl module to see what TLS protocol support
is present. I think it would be useful for `hg debuginstall` to print
this info to make it easier to access and debug why Mercurial is
complaining about using an insecure TLS 1.0 protocol.

Ideally we'd also print the path to the CA cert bundle. But the APIs
for querying that in sslutil can emit warnings, making it slightly
more difficult to integrate into `hg debuginstall`. That work will
have to wait for another day.
2016-10-19 15:07:11 -07:00
Kevin Bullock
734a4f1625 merge default into stable for 4.0 code freeze 2016-10-18 14:15:15 -05:00
Mads Kiilerich
8f6d6ccc08 largefiles: fix 'deleted' files sometimes persistently appearing with R status
A code snippet that has been around since largefiles was introduced was wrong:
Standins no longer found in lfdirstate has *not* been removed -
they have probably just been deleted ... or not created.

This wrong reporting did that 'up -C' didn't undo the change and didn't sync
the two dirstates.

Instead of reporting such files as removed, propagate the deletion to the
standin file and report the file as deleted.
2016-10-17 17:12:24 +02:00
Mads Kiilerich
231fdaf8a2 largefiles: more safe handling of interruptions while updating modifications
Largefiles are fragile with the design where dirstate and lfdirstate must be
kept in sync.

To be less fragile, mark all clean largefiles as unsure ("normallookup") before
updating standins. After standins have been updated and we know exactly which
largefile standins actually was changed, mark the unchanged largefiles back to
clean ("normal").

This will make the failure mode more safe. If interrupted, the next command
will continue to perform extra hashing of all largefiles. That will do that all
largefiles that are out of sync with their standin will be marked dirty and
they will show up in status and can be cleaned with update --clean.
2016-10-16 02:29:45 +02:00
Mads Kiilerich
3482fa8368 largefiles: test coverage of fatal interruption of update
Test using existing changesets in a clean working directory, revealing problems
with files that don't show up as modified or do show up as removed when they
just not have been written yet.
2016-10-16 02:26:38 +02:00
Pierre-Yves David
667d10975b changegroup: skip delta when the underlying revlog do not use them
Revlog can now be configured to store full snapshot only. This is used on the
changelog. However, the changegroup packing was still recomputing deltas to be
sent over the wire.

We now just reuse the full snapshot directly in this case, skipping delta
computation. This provides use with a large speed up(-30%):

# perfchangegroupchangelog on mercurial
! wall 2.010326 comb 2.020000 user 2.000000 sys 0.020000 (best of 5)
! wall 1.382039 comb 1.380000 user 1.370000 sys 0.010000 (best of 8)

# perfchangegroupchangelog on pypy
! wall 5.792589 comb 5.780000 user 5.780000 sys 0.000000 (best of 3)
! wall 3.911158 comb 3.920000 user 3.900000 sys 0.020000 (best of 3)

# perfchangegroupchangelog on mozilla central
! wall 20.683727 comb 20.680000 user 20.630000 sys 0.050000 (best of 3)
! wall 14.190204 comb 14.190000 user 14.150000 sys 0.040000 (best of 3)

Many tests have to be updated because of the change in bundle content. All
theses update have been verified.  Because diffing changelog was not very
valuable, the resulting bundle have similar size (often a bit smaller):

# full bundle of mozilla central
with delta:    1142740533B
without delta: 1142173300B

So this is a win all over the board.
2016-10-14 01:31:11 +02:00
Gábor Stefanik
2f48be6841 copies: make _checkcopies handle copy sequences spanning the TCA (issue4028)
When working in a rotated DAG (for a graftlike merge), there can be files
that are renamed both between the base and the topological CA, and between
the TCA and the endpoint farther from the base. Such renames span the TCA
(and thus need both passes of _checkcopies to be fully detected), but may
not necessarily be divergent.

Make _checkcopies return "incomplete copies" and "incomplete divergences"
in this case, and let mergecopies recombine them once data from both passes
of _checkcopies is available.

With this patch, all known cases involving renames and grafts pass.

(Developed together with Pierre-Yves David)
2016-10-11 04:39:47 +02:00
Gábor Stefanik
242c4897e8 checkcopies: handle divergences contained entirely in tca::ctx
During a graftlike merge, _checkcopies runs from ctx to tca, possibly
passing over the merge base. If there is a rename both before and after
the base, then we're actually dealing with divergent renames.
If there is no rename on the other side of tca, then the divergence is
contained entirely in the range of one _checkcopies invocation, and
should be detected "in the loop" without having to rely on the other
_checkcopies pass.
2016-10-12 11:54:03 +02:00
Augie Fackler
1fc82bbf21 py3: update test expectation on stable 2016-09-23 14:37:15 -04:00
Kevin Bullock
9eb7f2dc02 grep: rewrite help to better document current (confusing) behavior 2016-09-23 12:45:10 -05:00
timeless
aa2c0ad5a3 crecord: properly handle files with No newline at eof (issue5268)
Yes, this bug was a single character with the wrong case...
2016-09-02 20:15:37 +00:00
Jun Wu
a5ec43fe40 annotate: pre-calculate the "needed" dictionary (issue5360)
The "needed" dict is used as a reference counter to free items in the giant
"hist" dict. However, currently it is not very accurate and can lead to
dropping "hist" items unnecessarily, for example, with the following DAG,

       -3-
      /   \
  0--1--2--4--

The current algorithm will visit and calculate rev 1 twice, undesired. And
it tries to be smart by clearing rev 1's parents: "pcache[1] = []" at the
time hist[1] being accessed (note: hist[1] needs to be used twice, by rev 2
and rev 3). It can result in incorrect results if p1 of rev 4 deletes chunks
belonging to rev 0.

However, simply removing "needed" is not okay, because it will consume 10x
memory:

  # without any change
  % HGRCPATH= lrun ./hg annotate mercurial/commands.py -r d130a38 3>&2 [1]
  MEMORY   49074176
  CPUTIME  9.213
  REALTIME 9.270

  # with "needed" removed
  MEMORY   637673472
  CPUTIME  8.164
  REALTIME 8.249

This patch moves "needed" (and "pcache") calculation to a separate DFS to
address the issue. It improves perf and fixes issue5360 by correctly reusing
hist, while maintaining low memory usage. Some additional attempt has been
made to further reduce memory usage, like changing "pcache[f] = []" to "del
pcache[f]". Therefore the result can be both faster and lower memory usage:

  # with this patch applied
  MEMORY   47575040
  CPUTIME  7.870
  REALTIME 7.926

[1]: lrun is a lightweight sandbox built on Linux cgroup and namespace. It's
     used to measure CPU and memory usage here. Source code is available at
     github.com/quark-zju/lrun.
2016-09-02 15:20:59 +01:00
Gábor Stefanik
a47c5119e6 update: enable copy tracing for backwards and non-linear updates
As a followup to the issue4028 series, this fixes a variant of the issue
that can occur when updating with uncommited local changes.

The duplicated .hgsub warning is coming from wc.dirty(). We would previously
skip this call because it's only relevant when we're going to perform copy
tracing, which we didn't do before.

The change to the update summary line is because we now treat the rename as a
proper rename (which counts as a change), rather than an add+delete pair
(which counts as a change and a delete).
2016-08-25 22:02:26 +02:00
Mads Kiilerich
2373d2e7bb tests: add more test coverage of phase changes when pushing
Prepare for test coverage of phase updates with future push --readonly option,
both with and without actually pushing changesets.
2016-08-21 01:12:00 +02:00
Gábor Stefanik
d967d939d6 mergecopies: invoke _computenonoverlap for both base and tca during merges
The algorithm of _checkcopies can only walk backwards in the DAG, never
forward. Because of this, the two _checkcopies patches need to run from
their respective endpoints to the TCA to cover the entire subgraph where
the merge is being performed. However, detection of files new in both
endpoints, as well as directory rename detection, need to run with respect
to the merge base, so we need lists of new files both from the TCA's and
the merge base's viewpoint to correctly detect renames in a graft-like
merge scenario.

(Series reworked by Pierre-Yves David)
2016-10-13 02:19:43 +02:00