Commit Graph

31381 Commits

Author SHA1 Message Date
Matt Harbison
bbf17f3e32 pager: improve support for various flavors of more on Windows
Hardcoding 'more' -> 'more.com' means that 'more.exe' from MSYS would need to be
configured with its *.exe extension.  This will resolve to either one, as
cmd.exe would have done if the command ran through the shell.

Something that's maybe problematic with this is it comes after 'pageractive' and
various ui configs have been set by the calling method.  But the other early
exits in this method don't undo those changes either.
2017-03-24 22:40:08 -04:00
Jun Wu
43184506ff statfs: avoid static allocation
Previously we have "static struct statfs" to return a string. That is not
multiple-thread safe. This patch moves the allocation to the caller to
address the problem.
2017-03-24 15:05:42 -07:00
Jun Wu
3633e80713 statfs: change Linux feature detection
Previously we check three things: "statfs" function, "linux/magic.h" and
"sys/vfs.h" headers. But we didn't check "struct statfs" or the "f_type"
field. That means if a system has "statfs" but "struct statfs" is not
defined in the two header files we check, or defined without the "f_type"
field, the compilation will fail.

This patch combines the checks (2 headers + 1 function + 1 field) together
and sets "HAVE_LINUX_STATFS". It makes setup.py faster (less checks), and
more reliable (immutable to the issue above).
2017-03-24 14:59:19 -07:00
Martin von Zweigbergk
6a886bd950 rebase: don't require destination if commands.rebase.requiredest=False 2017-03-24 16:20:10 -07:00
Martin von Zweigbergk
1781d7139a tests: add tests with commands.{update,rebase}.requiredest=False
This shows how rebase is currently broken with
commands.rebase.requiredest=False.
2017-03-24 16:20:04 -07:00
Durham Goode
de02ce8716 rebase: move state serialization to use unfiltered repo
Now that rebasestate is serialized as part of the transaction, the repo state it
sees is the version at the end of the transaction, which may have hidden nodes.
Therefore, it's possible parts of the rebase commit set are no longer visible by
the time the transaction is closing, which causes a filtered revision error in
this code. I don't think state serialization should be blocked from accessing
commits it knows exist, especially if all it's trying to do is get the hex of
them, so let's use an unfiltered repo here.

Unfortunately, the only known repro is with the fbamend Facebook extension, so
I'm not sure how to repro it in core Mercurial for a test.
2017-03-12 12:33:35 -07:00
FUJIWARA Katsunori
7f301613fe largefiles: avoid redundant standin() invocations
There are some code paths, which apply standin() on same value
multilpe times instead of using already standin()-ed value.

"fstandin" is common name for "path to standin file" in lfutil.py, to
avoid shadowing "standin()".
2017-03-24 22:29:22 +09:00
FUJIWARA Katsunori
319a3de075 largefiles: replace hashrepofile by hashfile (API)
There is only one user for the former, and repo.wjoin()-ed value is
alread known by that user.
2017-03-24 22:29:22 +09:00
FUJIWARA Katsunori
b0cce9d114 largefiles: call readstandin() with changectx itself instead of rev or node
readstandin() takes "node" argument to get changectx by "repo[node]".

There are some readstandin() invocations, which use ctx.node(),
ctx.rev(), or '.' as "node" argument above, even though corresponded
changectx object is already looked up on caller side.

This patch calls readstandin() with already known changectx itself, to
avoid meaningless re-construction of changectx (indirect case via
copytostore() is also included).

BTW, copytostore() uses "rev" argument only for readstandin()
invocation. Therefore, this patch also renames it to "revorctx" to
indicate that it can take not only revision ID or so but also
changectx, for readability.
2017-03-24 22:26:34 +09:00
FUJIWARA Katsunori
0813b4a24f largefiles: omit redundant splitstandin() invocations
There are 3 splitstandin() invocations in updatestandin() for same
"standin" value.
2017-03-24 22:24:59 +09:00
FUJIWARA Katsunori
9222f27b6b largefiles: replace splitstandin() by isstandin() to omit str creation
If splitstandin()-ed str itself isn't used, isstandin() should be
used instead of it, to omit meaningless str creation.
2017-03-24 22:24:59 +09:00
FUJIWARA Katsunori
53a96c883c largefiles: omit redundant isstandin() before splitstandin()
There are many isstandin() invocations before splitstandin().

The former examines whether specified path starts with ".hglf/". The
latter returns after ".hglf/" of specified path if it starts with that
prefix, or returns None otherwise.

Therefore, value returned by splitstandin() can be used for
replacement of preceding isstandin(), and this replacement can omit
redundant string comparison after isstandin().
2017-03-24 22:24:58 +09:00
FUJIWARA Katsunori
aaa8db9cef misc: update descriptions about removed file for filectxfn
Since 2eef89bfd70d, filectxfn for memctx should return None for
removed file instead of raising IOError.
2017-03-24 22:13:23 +09:00
Augie Fackler
2c0fcba7fe osx: always purge build/mercurial before starting build
This prevents stray files from previous builds from polluting newer builds.
2017-03-20 17:58:44 -04:00
Augie Fackler
2d61fb35c8 osx: use more paranoid quoting in test 2017-03-20 17:49:47 -04:00
Augie Fackler
9e6dae6142 osx: install completion scripts using install(1) to avoid umask badness
This actually fixes some tests that were showing us umask badness that
had been overlooked.
2017-03-20 17:50:05 -04:00
Martin von Zweigbergk
2e8637ffda merge with stable 2017-03-24 08:37:26 -07:00
Gregory Szorc
6fb64a9cca changegroup: store old heads as a set
Previously, the "oldheads" variable was a list. On a repository at
Mozilla with 46,492 heads, profiling revealed that list membership
testing was dominating execution time of applying small changegroups.

This patch converts the list of old heads to a set. This makes
membership testing significantly faster. On the aforementioned
repository with 46,492 heads:

$ hg unbundle <file with 1 changeset>
before: 18.535s wall
after:   1.303s

Consumers of this variable only check for truthiness (`if oldheads`),
length (`len(oldheads)`), and (most importantly) item membership
(`h not in oldheads` - which occurs twice). So, the change to a set
should be safe and suitable for stable.

The practical effect of this change is that changegroup application
and related operations (like `hg push`) no longer exhibit an O(n^2)
CPU explosion as the number of heads grows.
2017-03-23 19:54:59 -07:00
Simon Farnsworth
ddbe7287e7 subrepo: move prompts out of the if (issue5505)
Prompts weren't available in the else clause
2017-03-20 04:36:55 -07:00
Augie Fackler
e788062ad2 py3: prove `hg {add,addremove,commit} all work
We can't do a second commit in a repo yet, because pure-Python bdiff
is broken on Python 3. That is probably a good next step.
2017-03-19 01:47:56 -04:00
Augie Fackler
b00133b3e1 revsetlang: perform quoting using ui.escapestr instead of repr()
This changes one of the doctest results, but I'm pretty sure on
inspection that it's an equivalent result.
2017-03-23 10:46:50 -04:00
Augie Fackler
7257c843f2 revsetlang: add docstring with some tests to _quote 2017-03-23 10:41:34 -04:00
Augie Fackler
434ea09250 revsetlang: move quoting function to not be a closure
I'm about to change the implementation here and I'd like to add some
doctests, which means this needs to not be hidden inside another
function.
2017-03-19 01:14:19 -04:00
Augie Fackler
9acabc5cd1 revsetlang: portably bytestring-ify another pair of int() calls 2017-03-23 10:33:20 -04:00
Jun Wu
7fa1b063a1 checkcode: enforce lowercase for extension docstring title
This will ensure new extensions are consistent and `hg help -e` has a
consistent output.

I have to add a new group since the normal "pypats" will be filtered by
"pyfilters", which will remove comments and docstrings.
2017-03-23 21:23:21 -07:00
Jun Wu
e8fd1a48ff logtoprocess: use lowercase for docstring title 2017-03-23 21:16:55 -07:00
Jun Wu
c896b34fa7 journal: use lowercase for docstring title
See the previous patch for why.
2017-03-23 21:16:29 -07:00
Jun Wu
0ac1f68fc3 automv: use lowercase for docstring title
The first line of docstring is used in `hg help -e`. Use lowercase to be
consistent with most extensions.
2017-03-23 21:15:39 -07:00
Jun Wu
057a1065b9 util: enable hardlink for some BSD-family filesystems
Since we can now detect filesystems on FreeBSD and OSX. Add their major
filesystems (ufs, zfs for FreeBSD; hfs for OSX) to the hardlink whitelist.
2017-03-23 22:31:50 -07:00
Jun Wu
b84e57666e osutil: report fstype for BSD and OSX 2017-03-23 22:13:02 -07:00
Jun Wu
b78b032c28 setup: use a more strict way to test BSD or OSX's statfs
We want to use the `f_fstypename` field to get the filesystem type. Test it
directly. The new macro HAVE_BSD_STATFS implys the old HAVE_SYS_MOUNT_H and
HAVE_SYS_PARAM_H. So the latter ones are removed.
2017-03-23 22:15:36 -07:00
Jun Wu
7fc770b181 debugfsinfo: use util.getfstype
This changes the behavior slightly. It now always prints fstype, regardless
of whether osutil.getfstype exists.
2017-03-23 12:03:19 -07:00
Jun Wu
443e227575 util: use util.getfstype 2017-03-23 12:01:18 -07:00
Jun Wu
43dc9d6102 util: add a getfstype method
The util version is a thin wrapper of the osutil version, which is not
always available.
2017-03-23 11:58:45 -07:00
Matt Harbison
6b815a9943 pager: fix the invocation of more on Windows
After 6a86fe38f1f6, with 'shell' being (mostly) set to False, invoking `more` no
longer worked.  Instead, a warning was printed and the pager was disabled.
Invoking `more.com` works.  Since a user may have configured 'pager.pager=more',
do this substitution at the end.  Surprisingly, `more` does allow for arguments,
so those are preserved.  This also allows `more` to work in MSYS.

Setting 'shell=False' runs the executable via CreateProcess(), which has rather
wonky rules for resolving an executable without an extension [1].  Resolving to
*.com is not among them.  Since 'shell=True' yields a cryptic error for a bad
$PAGER, and a *.exe program will work without specifying the extension, sticking
with current 'shell=False' seems like the right thing to do.  I don't think
there are any other *.com pagers out there, so this one special case seems OK.

If somebody wants to do something crazy that requires cmd.exe, I was able to get
normal paged output with 'pager.pager="cmd.exe /c more"'.  I assume you can
replace `more` with *.bat, *.vbs or various other creatures listed in $PATHEXT.

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
2017-03-20 00:19:33 -04:00
Martin von Zweigbergk
653c126971 help: format `commands` heading correctly
The number of dashes under it needs to match exactly for it to be
rendered as a heading. Without this change, the dashes end up on the
same line as "commands", and "hg help config.commands" does not work.
2017-03-22 16:36:53 -07:00
David Soria Parra
92f2b90f4d convert: fix the handling of empty changlist descriptions in P4
Empty changelist descriptions are valid in Perforce. If we encounter one of
them we are currently running into an IndexError. In case of empty commit
messages set the commit message to **empty changelist description**, which
follows Perforce terminology.
2017-03-22 14:12:58 -05:00
Martin von Zweigbergk
68e5878038 status: support commands.status.relative config
When the config is set to true, status output becomes relative to the
working directory. This has bugged me since I started using hg and it
turns it is sillily simple to support it (unless I missed something,
of course).

We could also add a --relative flag, but I would personally always
want that on, and I haven't heard any use for having it sometimes on,
so this patch only lets you enable it via config.
2017-03-21 17:50:44 -07:00
Martin von Zweigbergk
dc4c37c445 plain: ignore [commands] config
We only have commands.{update,rebase}.requiredest so far. We should
clearly ignore those two if HGPLAIN is in effect, and it seems like we
should ignore any future config that will be added in [commands] since
that is about changing the behavior of commands.

Thanks to Yuya for suggesting to centralize the code in ui.py.

While at it, remove the unnecessary False values passed to
ui.configbool() for the aforementioned config options.
2017-03-21 21:26:52 -07:00
Pierre-Yves David
3e8a941a87 checkheads: extract obsolete post processing in its own function
The checkheads function is long and complex, extract that logic in a subfunction
is win in itself. As the comment in the code says, this postprocessing is
currently very basic and either misbehave or fails to detect valid push in many
cases. My deeper motive for this extraction is to be make it easier to provide
extensive testing of this case and strategy to cover them. Final test and logic
will makes it to core once done.
2017-03-21 23:30:13 +01:00
Kostia Balytskyi
ffc66837df tests: make test-simplekeyvaluefile.py py2.6-compatible
Python 2.6 unittest.TestCase does not have assertRaisesRegexp.
2017-03-22 11:26:23 -07:00
Yuya Nishihara
8a64b55504 similar: use cheaper hash() function to test exact matches
We just need a hash table {fctx.data(): fctx} which doesn't keep fctx.data()
in memory. Let's simply use hash(fctx.data()) to put data out from memory,
and manage collided fctx objects by list.

This isn't significantly faster than using sha1, but is more correct as we
know SHA-1 collision attack is getting practical.

Benchmark with 50k added/removed files, on tmpfs:

  $ hg addremove --dry-run --time -q

  previous:   real 12.420 secs (user 11.120+0.000 sys 1.280+0.000)
  this patch: real 12.350 secs (user 11.210+0.000 sys 1.140+0.000)
2017-03-23 20:57:27 +09:00
Yuya Nishihara
8c9b9d4020 similar: take the first match instead of the last
It seems more natural. This makes the next patch slightly cleaner.
2017-03-23 20:52:41 +09:00
Yuya Nishihara
9290e50162 similar: do not look up and create filectx more than once
Benchmark with 50k added/removed files, on tmpfs:

  $ hg addremove --dry-run --time -q

  previous:   real 16.070 secs (user 14.470+0.000 sys 1.580+0.000)
  this patch: real 12.420 secs (user 11.120+0.000 sys 1.280+0.000)
2017-03-23 21:17:08 +09:00
Yuya Nishihara
0087b0c7b8 similar: use common names for changectx variables
We generally use 'wctx' and 'pctx' for working context and its parent
respectively.
2017-03-23 21:10:45 +09:00
Yuya Nishihara
6a4b18deca similar: get rid of quadratic addedfiles.remove()
Instead, build a set of files to be removed and recreate addedfiles
only if necessary.

Benchmark with 50k added/removed files, on tmpfs:

  $ hg addremove --dry-run --time -q

  original:   real 16.550 secs (user 15.000+0.000 sys 1.540+0.000)
  previous:   real 16.730 secs (user 15.280+0.000 sys 1.440+0.000)
  this patch: real 16.070 secs (user 14.470+0.000 sys 1.580+0.000)
2017-03-23 20:50:33 +09:00
Gregory Szorc
aff9286eb0 exchange: use v2 bundles for modern compression engines (issue5506)
Previously, `hg bundle zstd` on a non-generaldelta repo would
attempt to use a v1 bundle. This would fail because zstd is not
supported on v1 bundles.

This patch changes the behavior to automatically use a v2 bundle
when the user explicitly requests a bundlespec that is a compression
engine not supported on v1. If the bundlespec is <engine>-v1, it is
still explicitly rejected because that request cannot be fulfilled.
2017-03-16 12:33:15 -07:00
Gregory Szorc
3bbb6e2c52 exchange: reject new compression engines for v1 bundles (issue5506)
Version 1 bundles only support a fixed set of compression engines.
Before this change, we would accept any compression engine for v1
bundles, even those that may not work on v1. This could lead to
an error.

We define a fixed set of compression engines known to work with v1
bundles and we add checking to ensure a newer engine (like zstd)
won't work with v1 bundles.

I also took the liberty of adding test coverage for unknown compression
names because I noticed we didn't have coverage of it before.
2017-03-16 12:23:56 -07:00
Augie Fackler
5811358454 pycompat: verify sys.argv exists before forwarding it (issue5493)
ISAPI_WSGI doesn't set up sys.argv, so we have to look for the
attribute before assuming it exists.
2017-03-07 13:24:24 -05:00
Augie Fackler
821171d27f Added signature for changeset dcc2d404963a 2017-03-02 20:19:45 -05:00