Commit Graph

10155 Commits

Author SHA1 Message Date
timeless
80bbc318a8 tests: add run-test .testtimes basic testing 2016-04-03 20:49:30 +00:00
FUJIWARA Katsunori
6b3350290a check-code: make repquote distinguish more characters for exact detection
This patch makes repquote() distinguish more characters below, as a
preparation for exact detection in subsequent patch.

  - "%"  as "%"
  - "\\" as "b"(ackslash)
  - "*"  as "A"(sterisk)
  - "+"  as "P"(lus)
  - "-"  as "M"(inus)

Characters other than "%" don't use itself as replacement, because
they are treated as special ones in regexp.
2016-05-31 21:02:30 +09:00
FUJIWARA Katsunori
dfdbfa6418 check-code: replace quoted characters correctly
d19c9c93ad10 tried to detect '.. note::' more exactly. But
implementation of it seems not correct, because:

  - fromc.find(c) returns -1 for other than "." and ":"
  - tochr[-1] returns "q" for such characters, but
  - expected result for them is "o"

This patch uses dict to manage replacement instead of replacing
str.find() by str.index(), for improvement/refactoring in subsequent
patches. Examination by fixedmap is placed just after examination for
' ' and '\n', because subsequent patch will integrate the latter into
the former.

This patch also changes regexp for 'string join across lines with no
space' rule, and adds detailed test for it, because d19c9c93ad10 did:

  - make repquote() distinguish "." (as "p") and ":" (as "q") from
    others (as "o"), but

  - not change this regexp without any reason (in commit log, at
    least), even though this regexp depends on what "o" means

This patch doesn't focuses on deciding whether "." and/or ":" should
be followed by whitespace or not in translatable messages.
2016-05-31 20:58:10 +09:00
Yuya Nishihara
d8cec054b6 test-chg: add basic tests for server lifecycle
I'm going to move around the codes in AutoExitMixIn. This test should catch
a subtle bug of unlinking sockets which I made in draft patches.
2016-05-21 21:43:29 +09:00
Yuya Nishihara
cebb8a6a14 test-chg: run only with chg
It doesn't make sense to run test-chg.t without chg, so ignore it with vanilla
hg, and specify chg executable explicitly.

test-chg.t can host chg-specific tests.
2016-03-20 14:59:03 -07:00
Gregory Szorc
5ae8d037c8 sslutil: reference appropriate config section in messaging
Error messages reference the config section defining the host
fingerprint. Now that we have multiple sections where this config
setting could live, we need to point the user at the appropriate
one.

We default to the new "hostsecurity" section. But we will still
refer them to the "hostfingerprint" section if a value is defined
there.

There are some corner cases where the messaging might be off. e.g.
they could define a SHA-1 fingerprint in both sections. IMO the
messaging needs a massive overhaul. I plan to do this as part
of future refactoring to security settings.
2016-05-28 12:58:46 -07:00
Gregory Szorc
95fda4d981 sslutil: allow fingerprints to be specified in [hostsecurity]
We introduce the [hostsecurity] config section. It holds per-host
security settings.

Currently, the section only contains a "fingerprints" option,
which behaves like [hostfingerprints] but supports specifying the
hashing algorithm.

There is still some follow-up work, such as changing some error
messages.
2016-05-28 12:37:36 -07:00
timeless
0dcdb26a9d debuginstall: expose modulepolicy
With this, you can check for pure easily:
$ HGMODULEPOLICY=py ./hg debuginstall -T "{hgmodulepolicy}"
py
2016-03-09 19:55:45 +00:00
Yuya Nishihara
9079f0d3ff revset: factor out reverse flag of sort() key
Prepares for making a table of sort keys. This assumes 'k' has at least one
character, which should be guaranteed by keys.split().
2016-05-14 19:46:18 +09:00
Gregory Szorc
1246359d49 tests: don't save host fingerprints in hgrc
Previously, the test saved the host fingerprints in hgrc. Many tests
override the fingerprint at run-time. This was a bit dangerous and
was too magical for my liking. It will also interfere with a future
patch that adds a new source for obtaining fingerprints.

So change the test to require the fingerprint on every command
invocation.
2016-05-28 12:29:59 -07:00
timeless
02e1db6099 run-tests: use json.dumps(separators=)
Followup to eb3e07c0bd4b per Martijn Pieters
2016-05-26 02:35:44 +00:00
Matt Mackall
204bd1271d merge with stable 2016-05-25 15:32:35 -05:00
liscju
6d9c9237d1 bookmarks: allow pushing active bookmark on new remote head (issue5236)
Before 'hg push -B .' on new remote head complained with:
abort: push creates new remote head ...

It was because _nowarnheads was not expanding active bookmark
name, so it didn't add active bookmark "proper" name to no
warn heads list.
2016-05-24 23:36:27 +02:00
Laurent Charignon
94c489ecf6 strip: invalidate phase cache after stripping changeset (issue5235)
When we remove a changeset from the changelog, the phase cache must be
invalidated, otherwise it could refer to changesets that are no longer in the
repo.

To reproduce the failure, I created an extension querying the phase cache after
the strip transaction is over.

To do that, I stripped two commits with a bookmark on one of them to force
another transaction (we open a transaction for moving bookmarks)
after the strip transaction.

Without the fix in this patch, the test leads to a stacktrace showing the issue:
      repair.strip(ui, repo, revs, backup)
    File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/repair.py", line 205, in strip
      tr.close()
    File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/transaction.py", line 44, in _active
      return func(self, *args, **kwds)
    File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/transaction.py", line 490, in close
      self._postclosecallback[cat](self)
    File "$TESTTMP/crashstrip2.py", line 4, in test
      [repo.changelog.node(r) for r in repo.revs("not public()")]
    File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/changelog.py", line 337, in node
      return super(changelog, self).node(rev)
    File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/revlog.py", line 377, in node
      return self.index[rev][7]
  IndexError: revlog index out of range

The situation was encountered in inhibit (evolve's repo) where we would crash
following the volatile set invalidation submitted by Augie in
cbc52a99d057d11790cf5011e877c6f698bf57bf. Before his patch the issue was masked
as we were not accessing the phasecache after stripping a revision.

This bug uncovered another but in histedit (see explanation in issue5235).
I changed the histedit test accordingly to avoid fixing two things at once.
2016-05-12 06:13:59 -07:00
Mateusz Kwapich
718300b2b4 localrepo: prevent executable-bit only changes from being lost on amend
If you have just executable-bit change and amend it twice it will vanish:

 * After the first amend the commit will have the proper executable bit set
   in manifest but it won't have the the file on the list of files in
   changelog.

 * The second amend will read the wrong list of files from changelog and it
   will copy the manifest entry from parent for this file.

 * Voila! The change is lost.

This change repairs the bug in localrepo causing this and adds a test for it.
2016-05-19 14:35:22 -07:00
FUJIWARA Katsunori
e6eaaeeb67 tests: escape bytes setting MSB in input of grep for portability
GNU grep (2.21-2 or later) assumes that input is encoded in LC_CTYPE,
and input is binary if it contains byte sequence not valid for that
encoding.

For example, if locale is configured as C, a byte setting most
significant bit (MSB) makes such GNU grep show "Binary file <FILENAME>
matches" message instead of matched lines unintentionally.

This behavior is recognized as a bug, and fixed in GNU grep 2.25-1 or
later. But some distributions are shipped with such buggy version
(e.g. Ubuntu xenial, which is used by launchpad buildbot).

    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19230
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800670
    http://packages.ubuntu.com/xenial/grep

This causes failure of test-commit-interactive.t, which applies grep
on CP932 byte sequence since 4681296e309b.

But, explicit setting LC_CTYPE for CP932 might cause another problem,
because it can't be assumed that all environment running Mercurial
tests allows arbitrary locale setting.

To resolve this issue, this patch escapes bytes setting MSB in input
of grep.

For this purpose:

  - str.encode('string-escape') isn't useful, because it escapes also
    control code (less than 0x20), and makes EOL handling complicated

  - "f --hexdump" isn't useful, because it isn't line-oriented

  - "sed -n" seems reasonable, but "sed" itself sometimes causes
    portability issue, too (e.g. 215a8789129e or 6d02ef568139)

This patch is posted with "stable" flag, because 4681296e309b is on
stable branch.
2016-05-21 02:48:51 +09:00
FUJIWARA Katsunori
17fa5d0520 help: search section of help topic by translated section name correctly
Before this patch, "hg help topic.section" might show unexpected
section of help topic in some encoding.

It applies str.lower() instead of encoding.lower(str) on translated
message to search section case-insensitively, but some encoding uses
0x41(A) - 0x5a(Z) as the second or later byte of multi-byte character
(for example, ja_JP.cp932), and str.lower() causes unexpected result.

To search section of help topic by translated section name correctly,
this patch replaces str.lower() by encoding.lower(str) for both query
string (in commands.help()) and translated help text (in
minirst.getsections()).
2016-05-13 07:19:59 +09:00
FUJIWARA Katsunori
63611bb308 patch: show lower-ed translated message correctly
Before this patch, patch.filterpatch() shows meaningless translation
of help message for chunk selection in some encoding.

It applies str.lower() instead of encoding.lower(str) on translated
message, but some encoding uses 0x41(A) - 0x5a(Z) as the second or
later byte of multi-byte character (for example, ja_JP.cp932), and
str.lower() causes unexpected result.

To show lower-ed translated message correctly, this patch replaces
str.lower() by encoding.lower(str).
2016-05-13 07:19:59 +09:00
Yuya Nishihara
ff61ad577d tests: enable import checker for all python files (including no .py files)
i18n/posplit is excluded as it couldn't be trivially fixed. That's the same
as ade93acee2d6.
2016-05-15 10:48:05 +09:00
Yuya Nishihara
69cfb792fd tests: make 'f' utility import hashlib unconditionally
It must exist on Python 2.5+.
2016-05-15 10:45:32 +09:00
Yuya Nishihara
f979d1d5bd tests: fix typo of shebang prefix in test-check-pyflakes.t 2016-05-15 10:41:01 +09:00
Yuya Nishihara
4447701065 hghave: silence future pyflakes warning of unused import 2016-05-15 10:40:26 +09:00
Yuya Nishihara
b48c8b4cf5 tests: remove unused import from 'f' utility
It should have been caught by pyflakes.
2016-05-15 10:39:44 +09:00
timeless
6164721a93 test-run-tests: clean up inuse server eagerly 2016-05-11 15:20:25 +00:00
timeless
7176708168 tests: refactor run-tests helpers
test-run-tests-rev.t will need them
2016-05-11 16:40:16 +00:00
timeless
0c82fc02cd tests: silence test-repo obsolete warning
refactoring test-check-commit.t HGRCPATH bits as helpers-testrepo.sh
2016-05-11 04:49:27 +00:00
liscju
a5a56dc8d5 largefiles: send statlfile remote calls only for nonexisting locally files
Files that are already in local store should be checked locally. The problem
with this implementation is how difference in messages between local and remote
checks should look like. For now local errors for file missing and content
corrupted looks like this:

'changeset cset: filename references missing storepath\n'
'changeset cset: filename references corrupted storepath\n'

for remote it looks like:

'changeset cset: filename missing\n'
'changeset cset: filename: contents differ\n'

Contents differ error for remote calls is never raised currently - for now
statlfile implementation lacks checking file content.
2016-05-09 10:05:32 +02:00
Sean Farley
a69dcd1771 histedit: add experimental config for using the first word of the commit
This allows users to start a commit with "verb! ..." so that when this is
opened in histedit, the default action will be "verb". For example, "roll! foo"
will default to the action "roll". Currently, we'll allow any known verb to be
used but this is experimental.
2016-05-06 18:12:36 -07:00
Yuya Nishihara
d2b4cdf1ae tests: enable import checker for all **.py files
Several known-bad files are excluded as they couldn't be trivially fixed.
That's the same as ade93acee2d6.
2016-05-14 14:16:43 +09:00
Yuya Nishihara
e5d8ee2999 import-checker: extend check of symbol-import order to all local modules
It doesn't make sense that (a) is allowed whereas (b) is disallowed.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 13:39:33 +09:00
Yuya Nishihara
b268ea71bf import-checker: fix test to make a real package
Otherwise "testpackage" wouldn't be counted as a package when building a
list of imported symbols.
2016-05-14 13:49:46 +09:00
Yuya Nishihara
a5c934df3c py3: move up symbol imports to enforce import-checker rules
Since (b) is banned, we should do the same for (a) for consistency.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 14:03:12 +09:00
FUJIWARA Katsunori
0242ba3045 util: make atomictempfile avoid ambiguity of file stat if needed
Ambiguity check is executed at close(), only if:

  - atomictempfile is created with checkambig=True, and
  - target file exists before renaming

This restriction avoids performance decrement by needless examination
of file stat (for example, filelog doesn't need exact cache
validation, even though it uses atomictempfile to write changes out).

See description of filestat class for detail about why the logic in
this patch works as expected.

This patch is a part of preparation for "Exact Cache Validation Plan":

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
2016-05-19 00:20:38 +09:00
timeless
64b3f40be2 run-tests: handle json.dumps divergence
In py2, json.dumps includes a trailing space after a comma at the
end of lines. The py3 behavior which omits the trailing space is
preferable, so we're going to strip it.
2016-05-05 23:17:19 +00:00
timeless
93ae7771a2 tests: use debuginstall to retrieve hg version 2016-05-10 22:52:26 +00:00
timeless
bd5be422b3 debuginstall: add mercurial version 2016-05-10 22:45:45 +00:00
Pulkit Goyal
b5a523d524 py3: make tests/svn-safe-append.py use absolute_import 2016-05-16 04:31:20 +05:30
Pulkit Goyal
cae374e866 py3: make tests/test-atomictempfile.py use absolute_import 2016-05-16 04:28:22 +05:30
Pulkit Goyal
c5ff80fd8e py3: tests/test-check-py3-compat.t output updated
The lower part of the tests runs with Python 3.5 so its remains unchanged with
new commits.
2016-05-16 04:08:17 +05:30
Mateusz Kwapich
a7e298f9a4 localrepo: use dirstate savebackup instead of handling dirstate file manually
This is one step towards having dirstate manage its own storage. It will
be useful for the implementation of sql dirstate [1].

This introduced a small test change: now we always write the dirstate before
saving backup so in some cases where dirstate file didn't exist yet
savebackup can create it.

[1] https://www.mercurial-scm.org/wiki/SQLDirstatePlan
2016-05-11 14:18:52 -07:00
Sean Farley
dc865d7f73 hg-ssh: copy doc string to man page
This corrects a warning from lintian that we're shipping an executable without
a man page. Since there is a doc string in the text, let's use that for the man
page.
2016-05-06 23:03:41 -07:00
Matt Mackall
8568a2cad9 progress: stop excessive clearing (issue4801)
The progress bar was being cleared on every write(), regardless of
whether it was currently displayed. This could foul up the display of
any writes that didn't include a linebreak.

In particular, the win32 mode of the color extension was turning
single prompt string writes into two writes, and the resulting
clear/write/clear/write pattern was making the prompt invisible.

We fix this by insisting that we have shown a progress bar and haven't
just cleared it (setting lastprint to 0).

Conveniently, the test suite already had instances of duplicate
clears.. that are now cleared up.
2016-05-06 17:53:06 -05:00
Augie Fackler
5a2af0bc22 bookmarks: properly invalidate volatile sets when writing bookmarks
This corrects a regression introduced during the 3.7 cycle, but which
went undetected due to the surviving-but-deprecated write() method on
bmstore.
2016-05-04 22:44:30 -04:00
Augie Fackler
eb85279af2 test-obsolete: update extension in test to actually work
This hasn't been testing anything since partway through the 3.7 cycle
due to unrelated refactoring. Sadly, the behavior it was trying to
prevent reemerged in the codebase at that time. A fix is in the next
patch, because proving that the fix was actually correct ended up
being trickier than I expected.
2016-05-05 15:41:37 +02:00
Mike Hommey
50e9c3bb84 bundle2: properly request phases during getbundle
getbundle was requesting the "phase" namespace instead of the "phases"
namespace, which led to the client still requesting the phases
separately after getbundle finished.
2016-05-05 20:57:38 +09:00
timeless
312e7b0345 tests: mark test-atomictempfile.py write as binary 2016-04-20 19:55:59 +00:00
timeless
e059b2d0fc tests: mark test-context.py write as binary 2016-04-20 19:53:01 +00:00
Pierre-Yves David
3b0e4dbcf2 transaction: turn lack of locking into a hard failure (API)
We have been warning about transactions without locks for about a year (and
three releases), third party extensions had a fair grace period to fix their
code, we are moving lack of locking to a hard failure in order to protect users
against repository corruption.
2016-05-05 16:20:53 +02:00
Pierre-Yves David
85fe13b2bd test: extract develwarn transaction testing in its own command
The lack of locking for a transation is about to change from a warning to an
error. We first extract the test decidated to this warning to make the next
changeset clearer.
2016-05-05 16:13:22 +02:00
Martijn Pieters
d3f28a7e4b graphmod: update edgemap in-place
The edgemap update was not actually propagated to future asciiedge calls;
update the edge state dictionary in-place instead.
2016-05-16 16:41:26 +01:00