Commit Graph

10843 Commits

Author SHA1 Message Date
Martijn Pieters
0344aed188 config: honour the trusted flag in ui.configbytes 2017-03-12 11:43:31 -07:00
Durham Goode
2e0dd44c19 branchmap: handle nullrev in setcachedata
906be86990 recently changed to switch from:

  self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec

to

  pack_into(_rbcrecfmt, self._rbcrevs, rbcrevidx, node, branchidx)

This causes an exception if rbcrevidx is -1 (i.e. the nullrev). The old code
handled this because python handles out of bound sets to arrays gracefully. The
new code throws because the self._rbcrevs buffer isn't long enough to write 8
bytes to.  Normally it would've been resized by the immediately preceding line,
but because the 0 length buffer is greater than the idx (-1) times the size, no
resize happens.

Setting the branch for the nullrev doesn't make sense anyway, so let's skip it.
This was caught by external tests in the Facebook extensions repo, but I've
added a test here that catches the issue.
2017-03-15 15:48:57 -07:00
Yuya Nishihara
5ce2afb81d templatekw: make join() escape values of extras (BC) (issue5504)
Since extras may contain blob, the default template escapes its values:

  'extra': '{key}={value|stringescape}'

join() should follow the output style of the default template.
2017-03-15 23:21:30 +09:00
Yuya Nishihara
faf4fbd798 py3: prove hg tip works 2017-03-13 09:24:53 -07:00
Yuya Nishihara
af7f25fdb3 encoding: add converter between native str and byte string
This kind of encoding conversion is unavoidable on Python 3.
2017-03-13 09:12:56 -07:00
Yuya Nishihara
dcade16cf7 encoding: factor out unicode variants of from/tolocal()
Unfortunately, these functions will be commonly used on Python 3.
2017-03-13 09:11:08 -07:00
Pierre-Yves David
56371ac490 import-checkers: split tests of the tool from running it on the source
We did such splits for other tools already. The 'test-check-*.t' performs the
check of the source code while the regular tests verifies the tools works.

One of the benefit is that is provides a simple file to reuse in third party
extensions.
2017-03-14 23:07:08 -07:00
Yuya Nishihara
791afb08eb pycompat: add bytestr wrapper which mostly acts as a Python 2 str
This allows us to handle bytes in mostly the same manner as Python 2 str,
so we can get rid of ugly s[i:i + 1] hacks:

  s = bytestr(s)
  while i < len(s):
      c = s[i]
      ...

This is the simpler version of the previous RFC patch which tried to preserve
the bytestr type if possible. New version simply drops the bytestr wrapping
so we aren't likely to pass a bytestr to a function that expects Python 3
bytes.
2017-03-08 22:48:26 +09:00
Yuya Nishihara
8b296e4cfa tests: allow running doctests selectively on Python 3
Currently most doctests fail on Python 3, but I want to add some.
2017-03-08 22:13:32 +09:00
Ryan McElroy
5ffd6c8793 tests: properly drop back to root dir in test-status.t 2017-03-15 19:26:20 -07:00
Pierre-Yves David
a51384137e test: add a basic 'test-check-pylint.t'
We add a minimal check using pylint for one case we knows we care about:
"mutable default" argument.

We'll likely extend this over time to cover other useful checks but this is a
good starting point.
2016-12-28 23:42:50 +01:00
Martin von Zweigbergk
d32ca3644f pager: if old pager extensions is enabled, respect pager.attend
This patch makes us respect pager.attend again if the extension is
enabled. It also brings back the default attend list, so e.g. summary
is not paged by default, just like it used to be before pager was
moved into core.
2017-03-13 21:43:17 -07:00
Martin von Zweigbergk
ee1e520bcd tests: duplicate test for pager for old extension and for in-core pager
When the old pager extension is enabled, I think we should try to be
as BC as reasonable. To help with that, this patch brings back
test-pager.t as of 45ff5bf9e9c2 (pager: add a test of --pager=no
functionality, 2017-02-06), but under the name test-pager-legacy.t
However, since the behavior has changed in a few cases (notably by no
longer respecting pager.attend), the file is modified to work with the
current version. We will recover some lost BC in coming patches.

Also, to make sure the in-core pager does not depend on the pager
extension being enabled, this patch disables the extension in
test-pager.t. It turns out that pager.attend-$cmd was only supported
when the pager extension was enabled, so the tests are updated to
reflect that. We will need to decide what to do with these.
2017-03-13 21:42:59 -07:00
Kyle Lippincott
a0eab21ffc debuglabelcomplete: fix to call debugnamecomplete in new location
debugnamecomplete was moved in a9aa67ba from commands to debugcommands, but
debuglabelcomplete was not modified to call it in its new location.
2017-03-14 13:10:30 -07:00
Gregory Szorc
1deeab0dbf tests: prove that hg init works with Python 3
The previous patch made `hg init` work!
2017-03-13 13:06:37 -07:00
Gregory Szorc
c90e121239 tests: clean up bad extension
The presence of the "babar" extension breaks subsequent tests.
So delete the file and create an empty one to return the config
to sanity.
2017-03-13 13:08:11 -07:00
Mads Kiilerich
b41f3f4681 rebase: allow rebasing children of wd to wd if a new branch has been set (BC)
The named branch of the leaf changeset can be changed by updating to it,
setting the branch, and amending.

But previously, there was no good way to *just* change the branch of several
linear changes. If rebasing changes with another parent to '.', it would pick
up a pending branch change up. But when rebasing changes that have the same
parent, it would fail with 'nothing to rebase', even when the branch name was
set differently.

To fix this, allow rebasing to same parent when a branch has been set.
2017-03-12 16:44:01 -07:00
Augie Fackler
be3d23b263 py3: prove hg files --rev works 2017-03-12 03:33:38 -04:00
Augie Fackler
cf064d4eef tests: make a variable for hg binary location in test-check-py3-commands
The number of which calls in here is starting to get silly.
2017-03-12 03:37:45 -04:00
FUJIWARA Katsunori
9d450170ba py3: add "b" prefix to string literals related to module policy
String literals without explicit prefix in __init__.py and policy.py
are treated as unicode object on Python3, because these modules are
loaded before setup of our specific code transformation (the later
module is imported at the beginning of __init__.py).

BTW, "modulepolicy" in __init__.py is initialized by "policy.policy".

This causes issues below;

  - checking "policy" value in other modules causes unintentional result

    For example, "b'py' not in (u'c', u'py')" returns True
    unintentionally on Python3.

  - writing "policy" out fails at conversion from unicode to bytes

    db1ebf457295 fixed this issue for default code path, but "policy"
    can be overridden by HGMODULEPOLICY environment variable (it should
    be rare case for developer using Python3, though).

This patch does:

  - add "b" prefix to all string literals, which are related to module
    policy, in modules above.

  - check existence of HGMODULEPOLICY, and overwrite "policy" only if
    it exists

    For simplicity, this patch omits checking "supports_bytes_environ",
    switching os.environ/os.environb, and so on (Yuya agreed this in
    personal talking)
2017-03-13 04:06:36 +09:00
Pierre-Yves David
dfb3fbad15 test-bundle2-remote-changegroup: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:55 -08:00
Mads Kiilerich
6cbae57046 util: add debugstacktrace depth limit
Useful when you don't care about the start of the stack, but only want to see
the last entries.
2015-01-14 01:15:26 +01:00
Mads Kiilerich
97ac40d793 util: strip trailing newline from debugstacktrace message
This makes the function more convenient to use as drop-in replacement for
ui.write & co.
2015-01-16 04:26:40 +01:00
Mads Kiilerich
e5c197b9ce tests: rework util.debugstacktrace tests
Prepare for adding another test.
2015-01-16 04:26:40 +01:00
Augie Fackler
f3d54c952b policy: try and always have a bytes for module policy
debuginstall now runs cleanly in Python 3.
2017-03-08 18:11:41 -05:00
Augie Fackler
b39dab5e11 py3: add a test that proves %include and missing-extension code works 2017-03-03 13:52:08 -05:00
Martin von Zweigbergk
ef133769b3 rebase: abort if *any* commit in rebase set is public 2017-03-11 10:35:44 -08:00
Martin von Zweigbergk
df689070f8 rebase: unhide original working directory node as well (issue5219)
By including the working directory revision at the start of rebase in
the repo._rebaseset, we make sure it's not hidden when we update back
to it at the end of the rebase.

This feels like abusing the set a bit given its name (_rebaseset), but
I couldn't think of another name that's clearly better.
2017-03-10 23:07:20 -08:00
Martin von Zweigbergk
95e6286750 tests: demonstrate broken rebase from obsolete commit
This shows the bug I reported in issue 5219.
2017-02-01 09:18:44 -08:00
Durham Goode
2971a9e1cb treemanifest: make node reuse match flat manifest behavior
In a flat manifest, a node with the same content but different parents is still
considered a new node. In the current tree manifests however, if the content is
the same, we ignore the parents entirely and just reuse the existing node.

In our external treemanifest extension, we want to allow having one treemanifest
for every flat manifests, as a way of easeing the migration to treemanifests. To
make this possible, let's change the root node treemanifest behavior to match
the behavior for flat manifests, so we can have a 1:1 relationship.

While this sounds like a BC breakage, it's not actually a state users can
normally get in because: A) you can't make empty commits, and B) even if you try
to make an empty commit (by making a commit then amending it's changes away),
the higher level commit logic in localrepo.commitctx() forces the commit to use
the original p1 manifest node if no files were changed. So this would only
affect extensions and automation that reached passed the normal
localrepo.commit() logic straight into the manifest logic.
2017-03-01 16:19:41 -08:00
Augie Fackler
0ab8866ffd help: update help.internalstable for new censor docs 2017-03-10 17:37:39 -05:00
Gregory Szorc
967eed8566 sslutil: issue warning when [hostfingerprint] is used
Mercurial 3.9 added the [hostsecurity] section, which is better
than [hostfingerprints] in every way.

One of the ways that [hostsecurity] is better is that it supports
SHA-256 and SHA-512 fingerprints, not just SHA-1 fingerprints.

The world is moving away from SHA-1 because it is borderline
secure. Mercurial should be part of that movement.

This patch adds a warning when a valid SHA-1 fingerprint from
the [hostfingerprints] section is being used. The warning informs
users to switch to [hostsecurity]. It even prints the config
option they should set. It uses the SHA-256 fingerprint because
recommending a SHA-1 fingerprint in 2017 would be ill-advised.

The warning will print itself on every connection to a server until
it is fixed. There is no way to suppress the warning. I admit this
is annoying. But given the security implications of sticking with
SHA-1, I think this is justified. If this patch is accepted,
I'll likely send a follow-up to start warning on SHA-1
certificates in [hostsecurity] as well. Then sometime down
the road, we can drop support for SHA-1 fingerprints.

Credit for this idea comes from timeless in issue 5466.
2017-03-09 20:33:29 -08:00
Yuya Nishihara
cb8fe16f12 help: fix layout of pre-formatted text 2017-03-09 12:55:48 +09:00
Pierre-Yves David
87e91693db filecache: explicitly test 'repofilecache'
The tests is actually about testing a repofilecache (it uses a fake repo). We
make this clear to prevent blockers while cleaning theses API.
2017-03-08 16:43:16 -08:00
Denis Laxalde
e8f2a25582 test: end printed diff "hunks" with an empty string in test-context.py
So that the resulting diff is correct and does not include a spurious empty
line between lines "diff --git a/foo b/foo" and "--- a/foo".
2017-03-03 16:17:17 +01:00
Durham Goode
f20d9939b3 treemanifest: add tests covering hg diff of partial trees
Previously the hg files tests also covered the logic (i.e.
treemanifest.matches) that governed how hg diff limited its diff. In a future
patch we will be switching treemanifest.diff() to have a custom implementation,
so let's go ahead and add equivalent test coverage for hg diff.
2017-03-07 18:29:58 -08:00
Durham Goode
4dc06e6401 manifest: add match argument to diff and filesnotin
As part of removing manifest.matches (since it is O(manifest)), let's start by
adding match arguments to diff and filesnotin. As we'll see in later patches,
these are the only flows that actually use matchers, so by moving the matching
into the actual functions, other manifest implementations can make more efficient
algorithsm.

For instance, this will allow treemanifest diff's to only iterate over the files
that are different AND meet the match criteria.

No consumers are changed in this patches, but the code is fairly easy to verify
visually. Future patches will convert consumers to use it.

One test was affected because it did not use the kwargs version of the clean
parameter.
2017-03-07 09:56:11 -08:00
Pierre-Yves David
f53348b4a6 vfs: use 'vfs' module directly in 'test-clone-uncompressed'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:34:01 +01:00
Pierre-Yves David
63abb7df39 vfs: use 'vfs' module directly in 'test-filecache'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:33:28 +01:00
Pierre-Yves David
39137e24a7 vfs: use 'vfs' module directly in 'test-parseindex'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:33:16 +01:00
Pierre-Yves David
722a43e067 vfs: use 'vfs' module directly in 'test-lock'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:33:02 +01:00
Martin von Zweigbergk
17c020ee0a tests: make test-shelve.t timing-independent
It was sometimes taking 2s for me (not the "1s" the test expected).
2017-03-08 14:29:25 -08:00
Yuya Nishihara
bde72b6ed6 tests: make run-tests.py run on Python 3 again 2017-03-08 22:12:49 +09:00
Durham Goode
dbb351335e rebase: move actual rebase into a single transaction
Previously, rebasing would open several transaction over the course of rebasing
several commits. Opening a transaction can have notable overhead (like copying
the dirstate) which can add up when rebasing many commits.

This patch adds a single large transaction around the actual commit rebase
operation, with a catch for intervention which serializes the current state if
we need to drop back to the terminal for user intervention. Amazingly, almost
all the tests seem to pass.

On large repos with large working copies, this can speed up rebasing 7 commits
by 25%. I'd expect the percentage to be a bit larger for rebasing even more
commits.

There are minor test changes because we're rolling back the entire transaction
during unexpected exceptions instead of just stopping mid-rebase, so there's no
more backup bundle. It also leave an unknown file in the working copy, since our
clean up 'hg update' doesn't delete unknown files.
2017-03-07 16:27:32 -08:00
Durham Goode
defe69adff rebase: allow aborting if last-message.txt is missing
Previously, if .hg/rebasestate existed but .hg/last-message.txt was missing, 'hg
rebase --abort' would say there's no rebase in progress but 'hg checkout foo'
would say 'abort: rebase in progress'. It turns out loading the collapse message
will throw a "no rebase in progress" error if the file doesn't exist, even
though .hg/rebasestate obviously indicates a rebase is in progress.

The fix is to only throw an exception if we're trying to --continue, and to just
eat the issues if we're doing --abort.

This issue is exposed by us writing the rebase state earlier in the process.
This will be used by later patches to ensure the user can appropriately 'hg
rebase --abort' if there's a crash before the first the first commit has
finished rebasing. Tests cover all of this. The only negative affect is we now
require a hg rebase --abort in a very specific exception case, as shown in the
test.
2017-03-07 16:30:31 -08:00
Pierre-Yves David
e5cb48ac36 vfs: replace 'scmutil.opener' usage with 'scmutil.vfs'
The 'vfs' class is the first class citizen for years. We remove all usages of
the older API. This will let us remove the old API eventually.
2017-03-02 03:52:36 +01:00
Kyle Lippincott
2dc3df2798 help: fix internals.changegroups
Add information about tree manifests, copy edit the text and fix up a few
ambiguities.

The document also contains a few additional fixes from Siddharth Agarwal
<sid0@fb.com>, who used it to build a parser for changegroups in Rust.
2017-03-01 18:37:34 -08:00
Yuya Nishihara
bef32f9011 share: drop 'relshared' requirement as well 2017-03-03 00:11:51 +09:00
Yuya Nishihara
42f38a34a0 share: fix typo to drop 'shared' requirement on unshare
This must be a typo and it seems correct to drop the requirement since the
repo is no longer a shared repository.
2017-03-03 00:11:18 +09:00
Jun Wu
0bbf2239d3 dirstate: try to use hardlink to backup dirstate
This should be more efficient once util.copyfile has real hardlink support.
2017-03-01 17:59:21 -08:00