Commit Graph

34856 Commits

Author SHA1 Message Date
Jun Wu
4129970972 rebase: move bookmarks with --keep (issue5682)
This is a regression caused by 80d53a39fbcc. We have documented the behavior
in rebase help:

    Rebase will destroy original commits unless you use "--keep". It will
    also move your bookmarks (even if you do).

So let's restore the old behavior.

It is done by changing `scmutil.cleanupnodes` to accept more information so
a node could have different "movement destination" from "successors". It
also helps simplifying the callsite as a side effect - the special bookmark
movement logic in rebase is removed.

Differential Revision: https://phab.mercurial-scm.org/D727
2017-09-18 10:54:00 -07:00
Martin von Zweigbergk
4af5345130 cleanupnodes: rename "mapping" to "replacements"
The next patch will pass in overrides for bookmark moves, which is a
mapping itself, so let's rename "mapping" to "replacements" to
distinguish them better.

Differential Revision: https://phab.mercurial-scm.org/D749
2017-09-20 09:32:26 -07:00
Martin von Zweigbergk
5e9148e31d cleanupnodes: separate out bookmark destination calculation from actual update
We will soon want to pass in overrides for bookmark movements and this
will make that patch simpler. I also think this makes the code easier
to follow regardless of the later patch.

Differential Revision: https://phab.mercurial-scm.org/D748
2017-09-20 09:10:43 -07:00
Mark Thomas
6fc38713f5 ui: check for progress singleton when clearing progress bar (issue5684)
A combination of wrapping `ui` and progress bars interrupted by exceptions can
lead to the progress bar not being cleared when the exception error is printed.
This results in corrupted-looking output like this:

```
updating [===============================>                        ] 1/2u
nresolved conflicts (see hg resolve, then hg rebase --continue)
```

This is because in `ui._progclear`, we only check the local reference to the
progress bar, not whether or not there is an instance of the singleton.  When a
progress bar is interrupted by an exception, the exception printing in
`scmutil.callcatch` uses the original instance of the `ui` object, not the
wrapped copy that has `_progbar` set.

When consider whether or not to clear the progress bar, check for the existence
of the singleton, rather than just whether or not we have a local reference to
it.

Differential Revision: https://phab.mercurial-scm.org/D743
2017-09-20 09:55:52 -07:00
Augie Fackler
ecf07c749f Added signature for changeset b153500bb831 2017-09-18 11:53:54 -04:00
Augie Fackler
5363193f8d merge with i18n 2017-09-18 11:51:41 -04:00
Boris Feld
7035ea8d86 hgwebdir: read 'web.template' untrusted
The 'hgweb_mod.py' version of this read it untrusted. For consistency we align
the two versions of this code.
2017-09-15 18:57:50 +02:00
Durham Goode
ea5a821949 ssh: fix flakey ssh errors on BSD systems
This is a trivial backport of 9f516a26a962 performed by
augie@google.com, but the change is still really Durham's not mine, so
I [augie] am leaving him as the author.
2017-09-11 15:59:18 -07:00
Martin von Zweigbergk
01e8a04410 repair: preserve phase also when not using generaldelta (issue5678)
It seems like we used to pick the oldest possible version of the
changegroup to use for bundles created by the repair module (used
e.g. by "hg strip" and for temporary bundles by "hg rebase"). I tried
to preserve that behavior when I created the changegroup.safeversion()
method in 77f74106b264 (changegroup: introduce safeversion(),
2016-01-19).

However, we have recently chagned our minds and decided that these
commands are only used locally and downgrades are unlikely. That
decicion allowed us to start adding obsmarker and phase information to
these bundles. However, as the bug report shows, it means we get
different behavior e.g. when generaldelta is not enabled (because when
it was enabled, it forced us to use bundle2). The commit that actually
caused the reported bug was 26d535788092 (strip: include phases in
bundle (BC), 2017-06-15).

So, since we now depend on having more information in the bundles,
let's make sure we instead pick the newest possible changegroup
version.

Differential Revision: https://phab.mercurial-scm.org/D715
2017-09-14 11:16:57 -07:00
Martin von Zweigbergk
ed1824051c tests: add test for issue5678
In addition to a test case for the direct problem described in the bug
report, this also adds a test case showing how obsmarkers can also get
lost when not using generaldelta.

Differential Revision: https://phab.mercurial-scm.org/D714
2017-09-14 11:16:47 -07:00
Mads Kiilerich
3676051d80 mq: create non-lossy patches, also with custom global diff configuration
Users with custom [diff] configuration most certainly didn't intend it to make
mq lose changes. It could:

 * git is handled perfectly fine.

 * nobinary could make mq leave some files out from the patches.

 * noprefix could make mq itself (and probably also other tools) fail to apply
   patches without the usual a/b prefix.

 * ignorews, ignorewsamount, or ignoreblanklines could create patches with
   missing whitespace that could fail to apply correctly.

Thus, when refreshing patches, use patch.difffeatureopts, optionally with git
as before, but without the config options for whitespace and format changing
that most likely will cause loss or problems.

(patch.diffopts is just patch.difffeatureopts with all options enabled and can
be replaced with that.)
2017-09-11 00:42:24 +02:00
Mads Kiilerich
4cfa527133 mq: test coverage of how [diff] configuration influence can break mq patches 2017-09-11 00:42:22 +02:00
Matt Harbison
19d34e4d32 debugssl: allow a URL to be specified without a local repository
This was the original intent, but I bungled the logic.  Otherwise if there is a
certificate chain issue, the repository can't be cloned in order for there to be
a repo object.  I think I missed this case because I was inside of a Mercurial
clone as I was originally developing and testing this.
2017-08-29 16:38:10 -04:00
Jun Wu
45a4782018 record: fix revert -i for lines without newline (issue5651)
This is a regression caused by 10c1efcbeb1e. Code prior to 10c1efcbeb1e
seems to miss the "\ No newline at end of file" line.

Differential Revision: https://phab.mercurial-scm.org/D528
2017-08-27 13:39:17 -07:00
Martin von Zweigbergk
7cd70adbc1 templatekw: choose {latesttag} by len(changes), not date (issue5659)
As Augie reported in the bug, the current heuristic of choosing the
best tag of a merge commit by taking the one with newest tag (in terms
of tagging date) currently fails in the Mercurial repo itself. Copying
the example from Yuya:

  $ hg glog -T '{node|short} {latesttag}+{latesttagdistance}\n' \
    -r '4.2.3: & (merge() + parents(merge()) + tag())'
  o    cc59efae4cc0 4.2.3+5
  |\
  | o    06f60e88fc3a 4.2.3+4
  | |\
  | | o  c191a9eb0b10 4.3-rc+109
  | | |
  | | ~
  o |  49ada93fdc10 4.3.1+2
  : |
  o |  229937197835 4.3.1+0
  |/
  o    6a83ad94c0f2 4.2.3+3
  |\
  | ~
  o  8e9dcdd1de74 4.2.3+2
  :
  o  525f2b18248f 4.2.3+0
  |
  ~

It seems to me like the best choice is the tag with the smallest
number of changes since it (across all paths, not the longest single
path). So that's what this patch does, even though it's
costly. Best-of-5 timings for Yuya's command above shows a slowdown
from 1.293s to 1.610s. We can optimize it later.

Differential Revision: https://phab.mercurial-scm.org/D447
2017-08-15 23:23:55 -07:00
Martin von Zweigbergk
8bb8bc19bb tests: use graph log in {latesttag} tests
The tests are much easier to read if one does not have to re-read the
setup part all the time to understand the graph shape.

Differential Revision: https://phab.mercurial-scm.org/D446
2017-08-18 12:50:26 -07:00
Gregory Szorc
8e7a19b422 ui: restore behavior to ignore some I/O errors (issue5658)
45345e9870c3 and b30126fa95bc refactored ui methods to no longer
silently swallow some IOError instances. This is arguably the
correct thing to do. However, it had the unfortunate side-effect
of causing StdioError to bubble up to sensitive code like
transaction aborts, leading to an uncaught exceptions and failures
to e.g. roll back a transaction. This could occur when a remote
HTTP or SSH client connection dropped. The new behavior is
resulting in semi-frequent "abandonded transaction" errors on
multiple high-volume repositories at Mozilla.

This commit effectively reverts 45345e9870c3 and b30126fa95bc to
restore the old behavior.

I agree with the principle that I/O errors shouldn't be ignored.
That makes this change... unfortunate. However, our hands are tied
for what to do on stable. I think the proper solution is for the
ui's behavior to be configurable (possibly via a context manager).
During critical sections like transaction rollback and abort, it
should be possible to suppress errors. But this feature would not
be appropriate on stable.
2017-08-15 13:04:31 -07:00
Gregory Szorc
e98da01acf tests: test behavior of IOError during transactions (issue5658)
ui._write(), ui._write_err(), and ui.flush() all trap IOError and
re-raise as error.StdioError. If a caller doesn't catch StdioError
when writing to stdio, it could bubble all the way to dispatch.

This commit adds tests for I/O failures around various transaction
operations.

The most notable badness is during abort. Here, an uncaught StdioError
will result in incomplete transaction rollback, requiring an
`hg rollback` to recover. This can result in a client "corrupting"
a remote repo via terminated HTTP and SSH socket.
2017-08-14 13:12:40 -07:00
Nathan Goldbaum
0de8be7e62 log: mention ui.logtemplate in the help text 2017-08-16 10:24:49 -05:00
Tristan Seligmann
0428b15b61 hg: avoid relying on errno numbers / descriptions
A few tests hardcode errno numbers and/or descriptions in the output, causing
test failures on platforms where these values are different.

Differential Revision: https://phab.mercurial-scm.org/D362
2017-08-12 14:29:22 +02:00
Tristan Seligmann
0fee28d767 hg: tolerate long vs. int in test-context.py
The file times here can be longs instead of ints on some platforms, which will
cause a test failure due to these printing with an L suffix; instead always
format with %d which will produce the same output in either case.

Differential Revision: https://phab.mercurial-scm.org/D361
2017-08-12 14:24:25 +02:00
Mike Hommey
634713aa96 setup: fix installing in a mingw environment
The addition, in 851d08ff7a58, of a hack for the MSVC compiler class was
overwriting the original class for the Mingw32CCompiler class, leading to an
error when the HackedMingw32CCompiler is instantiated.

Differential Revision: https://phab.mercurial-scm.org/D329
2017-08-11 10:16:00 +09:00
Kevin Bullock
5e1176676c osx: delay version computation on macOS builds
Before this patch, HGVER would be evaluated at the beginning of the make
execution, and would be unset because build/mercurial/ doesn't exist yet
at that point. Now we compute the version after the `make install` run
has completed.

This is backported to stable from 8626b44516c1, but that revision had an
error in the shell invocation syntax.
2017-08-10 21:25:02 -04:00
Mike Hommey
73f4a16a4f branchmap: revert a81106261d38 for Python 2.7 compatibility
Old versions of python 2.7 don't like that the second argument to
struct.unpack_from is a bytearray, so the change removing the util.buffer
around that argument in branchmap broke running on older versions of python
2.7.

Differential Revision: https://phab.mercurial-scm.org/D330
2017-08-10 20:47:19 -07:00
Augie Fackler
abe39330a6 Added signature for changeset 229937197835 2017-08-10 18:46:55 -04:00
Yuya Nishihara
509744ddfc ssh: unban the use of pipe character in user@host:port string
This vulnerability was fixed by the previous patch and there were more ways
to exploit than using '|shellcmd'. So it doesn't make sense to reject only
pipe character.

Test cases are updated to actually try to exploit the bug. As the SSH bridge
of git/svn subrepos are not managed by our code, the tests for non-hg subrepos
are just removed.

This may be folded into the original patches.
2017-08-07 22:22:28 +09:00
Jun Wu
a0e5a4defb ssh: quote parameters using shellquote (SEC)
This patch uses shellquote to quote ssh parameters more strictly to avoid
shell injection.
2017-08-04 23:54:12 -07:00
Matthieu Laneuville
7b14aa1a56 run-tests: $TESTDIR can be something else than $PWD
$TESTDIR is expected to be the directory were the test lives, and is often used
to reference helper functions. However, it is now set to $PWD at test invocation
time, so if `run-tests.py` is called from another folder, the test will fail.

The solution is to force $TESTDIR to be the base directory of the test itself,
irrespective of where the runner is called from.
2017-08-02 13:27:45 +09:00
Boris Feld
8be76ccfef obsolete: activate effect-flag by default
Let's activate effect-flag by default as Evolve is experimental and in order
to gather feedback from users.
2017-11-01 17:08:33 +01:00
Boris Feld
59dcbd2a4d debug: print parsed bundle2 capabilities with debugcapabilities
The bundle2 capabilities are hard to read in their encoded form. We parse and
print them in a human friendly way.
2017-10-30 17:09:29 +01:00
Boris Feld
9554fcac46 debug: add a debugcapabilities commands
This new debugcommand prints the capabilities of any remote in a human friendly
way. Improved bundle2 capabilities support will be introduced in the next
changesets.
2017-10-30 17:08:16 +01:00
Augie Fackler
3ff9746218 revert: no longer mark --interactive as experimental
We seem to have settled down on behavior changes here (nothing
matching revset `keyword(revert) and keyword(interactive)` since 4.2
was released), so let's go ahead and advertise this excellent feature.

.. feature:: revert --interactive

  The revert command now accepts the flag --interactive to allow reverting
  only some of the changes to the specified files.
2017-10-30 17:46:07 -04:00
Augie Fackler
ffa2157901 ui: add configlist doctest to document a bit more of the whitespace behavior
I'm surprised this wasn't explicitly tested, so I added a test.
2017-10-25 23:01:54 -04:00
Sean Farley
39898f2a8a subrepo: add tests for git rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 14:55:11 -07:00
Sean Farley
da301ac6a0 subrepo: add tests for svn rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 16:44:17 -07:00
Sean Farley
f904aef7aa subrepo: add tests for hg rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 16:04:44 -07:00
Sean Farley
ea5a6b2798 push: add tests for unsafe ssh url (SEC) 2017-07-31 14:40:28 -07:00
Wagner Bruna
8e84af047a i18n-pt_BR: synchronized with 9a68e2267bd0 2017-07-31 12:18:42 -03:00
Sean Farley
616cd64fcf pull: add tests for unsafe ssh url (SEC) 2017-07-28 16:47:32 -07:00
Sean Farley
ee608897f9 clone: add tests for unsafe ssh url (SEC) 2017-07-28 16:36:36 -07:00
Sean Farley
e199b92002 sshpeer: check for safe ssh url (SEC)
Checking in the sshpeer for a rogue ssh:// urls seems like the right
place to do it (instead of whack-a-mole with pull, clone, push, etc).
2017-08-01 14:40:19 -07:00
Augie Fackler
5f2d0af8a2 ssh: ban any username@host or host that starts with - (SEC)
This paranoia probably isn't required, but it can't hurt either.
2017-08-04 14:00:03 -04:00
Sean Farley
608ad9eb9e util: add utility method to check for bad ssh urls (SEC)
Our use of SSH has an exploit that will parse the first part of an url
blindly as a hostname. Prior to this set of security patches, a url
with '-oProxyCommand' could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' can be abused to execute
arbitrary commands in a similar fashion.

We defend against this by checking ssh:// URLs and looking for a
hostname that starts with a - or contains a |.

When this happens, let's throw a big abort into the user's face so
that they can inspect what's going on.
2017-07-28 16:32:25 -07:00
Jun Wu
51be9cd3a9 phabricator: convert unicode to binary when writing patches
This is a quick fix to make `hg phabread D189` work.

It seems we might want to replace all `r''` to `u''`, and add more
`encoding.*to*` to be more explicit when interacting with `json` module.

Differential Revision: https://phab.mercurial-scm.org/D192
2017-07-27 12:03:01 -07:00
Yuya Nishihara
4b047b0633 setup: silence warning of unknown option python_requires on distutils
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution
  option: 'python_requires'
2017-07-27 23:15:14 +09:00
Yuya Nishihara
ba69ca47d4 pathauditor: disable cache of audited paths by default (issue5628)
The initial attempt was to discard cache when appropriate, but it appears
to be error prone. We had to carefully inspect all places where audit() is
called e.g. without actually updating filesystem, before removing files and
directories, etc.

So, this patch disables the cache of audited paths by default, and enables
it only for the following cases:

 - short-lived auditor objects
 - repo.vfs, repo.svfs, and repo.cachevfs, which are managed directories
   and considered sort of append-only (a file/directory would never be
   replaced with a symlink)

There would be more cacheable vfs objects (e.g. mq.queue.opener), but I
decided not to inspect all of them in this patch. We can make them cached
later.

Benchmark result:

- using old clone of http://selenic.com/repo/linux-2.6/ (38319 files)
- on tmpfs
- run HGRCPATH=/dev/null hg up -q --time tip && hg up -q null
- try 4 times and take the last three results

original:
real 7.480 secs (user 1.140+22.760 sys 0.150+1.690)
real 8.010 secs (user 1.070+22.280 sys 0.170+2.120)
real 7.470 secs (user 1.120+22.390 sys 0.120+1.910)

clearcache (the other series):
real 7.680 secs (user 1.120+23.420 sys 0.140+1.970)
real 7.670 secs (user 1.110+23.620 sys 0.130+1.810)
real 7.740 secs (user 1.090+23.510 sys 0.160+1.940)

enable cache only for vfs and svfs (this series):
real 8.730 secs (user 1.500+25.190 sys 0.260+2.260)
real 8.750 secs (user 1.490+25.170 sys 0.250+2.340)
real 9.010 secs (user 1.680+25.340 sys 0.280+2.540)

remove cache function at all (for reference):
real 9.620 secs (user 1.440+27.120 sys 0.250+2.980)
real 9.420 secs (user 1.400+26.940 sys 0.320+3.130)
real 9.760 secs (user 1.530+27.270 sys 0.250+2.970)
2017-07-26 22:10:15 +09:00
Yuya Nishihara
116bb6f6f9 tests: show cache of audited paths is never invalidated 2017-08-01 21:03:25 +09:00
Augie Fackler
25ec33c0a4 stable: merge heads 2017-08-10 14:23:25 -04:00
Augie Fackler
1003d2c0a9 Added signature for changeset 525f2b18248f 2017-08-10 14:14:49 -04:00
Augie Fackler
fa0eb2f7c3 Added signature for changeset 9ab2705099b9 2017-08-10 13:29:09 -04:00