Commit Graph

20518 Commits

Author SHA1 Message Date
Phil Cohen
9eb001d7e0 hg: explain why util.safehasattr should be used
Reviewed By: quark-zju

Differential Revision: D7100678

fbshipit-source-id: f5a1033a53a0beec23f938d2eea592b50b13c9a5
2018-04-13 21:51:18 -07:00
Durham Goode
33e8ab11e3 hg: add ui to manifestlog
Summary:
We were already hacking the ui object onto the manifestlog via the
treemanifest extension, but it didn't cover all cases. Let's just put it on the
manifestlog via the constructor and get rid of the hack. An upcoming change
required this

Reviewed By: phillco

Differential Revision: D7083032

fbshipit-source-id: 4c577cb80193a9c4799853d75a71c26719348e8c
2018-04-13 21:51:18 -07:00
Durham Goode
87278eb711 hg: move mutable manifest lifetime to repo
Summary:
As part of moving the manifest mutable pack logic to be used optionally
without transactions, let's move the lifetime logic
out to the repo.transaction() function instead of being part of the primary manifest
write logic.

Differential Revision: D7083035

fbshipit-source-id: 9947d78db61a41896cc8bdfaaa20504ebb03a125
2018-04-13 21:51:18 -07:00
Durham Goode
119ee6bdea hg: move manifest mutable packs onto manifestlog object
Summary:
Previously the mutable packs were kept on the transaction and had a
lifetime that corresponded with it. In a future patch we want to enable mutable
packs that span for longer than the lifetime of the transaction, so let's move
the mutable pack maintenance on the manifestlog. For now the lifetime is still
maintained by the transaction, but a future diff will change that as well (and
will get rid of _writeclientmanifest entirely).

Differential Revision: D7083034

fbshipit-source-id: 3735eadfc18e5dd1015bfb82dbf5b9e9e6965cdf
2018-04-13 21:51:17 -07:00
Saurabh Singh
f8f319328f treemanifest: refactor write manifest wrapper
Summary:
D6867913 did a bunch of refactoring which can be extended for the write
manifest wrapper. This commit achieves the same.

Reviewed By: singhsrb

Differential Revision: D6867921

fbshipit-source-id: c86cf1d54ecd3503127d91acf7a114d4d99f50ff
2018-04-13 21:51:17 -07:00
Durham Goode
8822e371da hg: allow manifestlog to convert linkrevs/nodes
Summary:
A future patch will need the ability to convert a linknode to a linkrev and vice
versa without having access to the changelog (when converting a flat manifest
into a treemanifest we need to get the linknode from the flat manifest, and all
we're given is a linkrev). Let's stick the changelog on the manifestlog. Since
they are generally created together and have the same lifetime, this seems safe.

Reviewed By: ryanmce

Differential Revision: D7034091

fbshipit-source-id: df6915f894c6ef975ffd214c8e229f1085141fbc
2018-04-13 21:51:16 -07:00
Phil Cohen
b177b338b7 rebase: tactical fix for rebase dropping flags
Summary:
The root issue is described in the new ``workingflags()`` function -- ``workingfilectx.flags()`` ought to read from the working copy, but instead reads from the working copy's p1.

Rather than force a big rewrite to adapt all the old code (which might be a waste if we end up rewriting the context classes), let's add a new function with the behavior we want, and callers can detect for it and call it.

simplemerge is the only callsite that needs this behavior, AFAICT.

Previous attempt: D6694292

Reviewed By: singhsrb

Differential Revision: D7083239

fbshipit-source-id: 6f30b877958d40106203e088fe724ab491b541b9
2018-04-13 21:51:16 -07:00
Mark Thomas
0a7ff59302 diff: add --only-files-in-revs option to limit files diffed
Summary:
Add a new `--only-files-in-revs` option to `hg diff`.  This filters the files
that are considered down to the set of files that are touched in either of the
two revisions.

Reviewed By: ryanmce

Differential Revision: D7070102

fbshipit-source-id: b9140cd3a212af9554ef5b76785210c1dbba8ee0
2018-04-13 21:51:15 -07:00
Igor Sugak
d39d55b67c fix invalid-shift-base UBSAN in pathencode.c
Summary:
Exposed by UBSAN:
```lang=bash
 scm/hg/mercurial/cext/pathencode.c:61:40: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
     #0 0x7f60c372b2e7 in inset scm/hg/mercurial/cext/pathencode.c:61
     #1 0x7f60c373022c in _encode scm/hg/mercurial/cext/pathencode.c:424
     #2 0x7f60c372a605 in basicencode scm/hg/mercurial/cext/pathencode.c:480
     #3 0x7f60c3729f90 in pathencode scm/hg/mercurial/cext/pathencode.c:744
```
Use unsinged 1 in the shift operation to fix the UB

Reviewed By: wez

Differential Revision: D7073320

fbshipit-source-id: 8e714c41e94474c4c62b3b6730df6fe99f9c0391
2018-04-13 21:51:15 -07:00
Phil Cohen
0dec8a5893 context: replace _auditconflicts with experimental.merge.checkpathconflicts
Summary:
Turns out this function can read from the working copy because it calls `match`. `experimental.merge.checkpathconflicts` does what this function does without that problem and without a perf hit. So, nuke it!

Also add a test.

Previous version: D7070540

Reviewed By: singhsrb

Differential Revision: D7072247

fbshipit-source-id: a217ffd575daf8271411a77c422e1dcdd387dfbb
2018-04-13 21:51:15 -07:00
Stanislau Hlebik
1cc90e3064 merge: use relative path names
Summary:
Let's try to be consistent and print relative path names during merge. Note
that it changes test output for mq and subrepos, but we don't use these
features often, so it should be fine.

Differential Revision: D7067050

fbshipit-source-id: 3aba66e67657a1b1b30fcf239c03abd605eb5d9a
2018-04-13 21:51:14 -07:00
Gerardo Poggio
a9a16f92d8 ignore all errors when including config file
Summary:
"hg" only ignored ENOENT errors when including files (so it didn't abort when an included file didn't exist). But it aborted on every other error (e.g EPERM).
This diff makes it ignore any IOError and just print a warning.

Reviewed By: quark-zju

Differential Revision: D7029320

fbshipit-source-id: b1b8137cd575fc89fb5967e8d18fe82ab84a8f85
2018-04-13 21:51:14 -07:00
Adam Simpkins
f4abe113fa treemanifest: support pulling from local repositories
Summary:
Update the treemanifest extension to also add a 'gettreepack()' function to
localpeer, and add the 'gettreepack' capability to localpeer if the repository
supports acting as a treemanifest server.

Also update the _addmanifestgroup() wrapper to only forbid it from being called
in a treemanifest server repository.  When pulling from a local treemanifest
server repository this function may need to be invoked in the client
repository.

Reviewed By: DurhamG

Differential Revision: D6980931

fbshipit-source-id: 61519c7deeaa0347650323a0002b89597e91d9cc
2018-04-13 21:51:14 -07:00
Adam Simpkins
6c452184cb fix undefined behavior in bitmanipulation.h
Summary:
Previously some of this code had undefined behavior because it was performing
signed shifts that could overflow into the sign bit, as the result could not be
represented in a signed `int`.  This caused failures when built with UBSAN.

This updates the code to consistently use the built-in `_byteswap_*` functions
when compiling with Microsoft Visual Studio and the `__builtin_bswap*` when
compiling with gcc or clang.

Reviewed By: quark-zju

Differential Revision: D7008197

fbshipit-source-id: adbe22032f05a35468195922ee00ccc3ff5efff9
2018-04-13 21:51:13 -07:00
Serafeim Mellos
3a42733be6 Teach bisect to ignore empty commits on sparse checkouts
Summary: Skip empty commits in sparse repositories when doing bisection

Reviewed By: ryanmce, farnz

Differential Revision: D7001328

fbshipit-source-id: 8493d20389410b522e70ce41cc3e33ac9361781d
2018-04-13 21:51:12 -07:00
Kaley Huang
6425129a45 verify: add --rev support
Summary:
Currently, commits adding LFS files are not verified server-side since the LFS
extension explicitly skips hash checking during unbundle, to avoid overhead
downloading/reading LFS objects.

We'd like those commit hashes to be verified.  However, the existing verify
command does not scale with a huge repo.  So let's add `verify -r REV` support
to be able to incrementally verify a repo.

Reviewed By: quark-zju

Differential Revision: D6947227

fbshipit-source-id: 6ffda3a814822942630339fc7de62c3fcb284fda
2018-04-13 21:51:12 -07:00
David Soria Parra
9939f03d8e hg: make file view in hgweb working
Summary:
hgweb's file view must determine if the displayed file revision is
the head of the filelog graph. As remotefilelog does not implement file
revision, we have to check if headrevs is implemented.

Reviewed By: DurhamG

Differential Revision: D6954143

fbshipit-source-id: 0657e58110112537dc5baadf743c657d4ecf372a
2018-04-13 21:51:10 -07:00
Jun Wu
e5e4d70d16 inhibit: move part of logic to core
Summary:
inhibit has a very hacky way to disable obsmarker cycle check.
Move that to core to clean up the code.

Reviewed By: ryanmce

Differential Revision: D6956217

fbshipit-source-id: 18370721ec80e74008232e09049a057ee080e7d5
2018-04-13 21:51:10 -07:00
Ryan McElroy
c3b1e55546 ui: improve performance for multi-component writes
Summary:
This is a backport of e49c39ffeac2 from upstream.

It is more efficient to pass down one large string to the output streams
than many small ones. For a ``hg diff`` test case, it improves time from
2m26s to 2m8s.

Reviewed By: quark-zju

Differential Revision: D6951390

fbshipit-source-id: 5f6faacb4c77678a6abca863bf931de4bce2dfde
2018-04-13 21:51:10 -07:00
Ryan McElroy
c3c6110969 mdiff: remove rewindhunk by yielding a bool first to indicate data
Summary: This backports upstream rev 6a33e81e4c5e.

Reviewed By: quark-zju

Differential Revision: D6951333

fbshipit-source-id: 90b77aa1b758ffe794c82b859bc00bc7122f1cf7
2018-04-13 21:51:10 -07:00
Ryan McElroy
b3ba4d0fde mdiff: explicitly compute places for the newline marker
Summary:
This backports upstream rev a9d07bd8f758. This continues a patch series
that Augie thought was well worth the speed up it provided.

Reviewed By: quark-zju

Differential Revision: D6951332

fbshipit-source-id: a35fce1560a3e2b182faf5871ceb9068a52d697b
2018-04-13 21:51:10 -07:00
Ryan McElroy
edae55b64a patch: avoid repeated binary checks if all files in a patch are text
Summary: This backports upstream rev 079b27b5a869. It saves 3-4% on diffs.

Reviewed By: quark-zju

Differential Revision: D6951334

fbshipit-source-id: 889851e9638e2eeb43549af31e25d75632eccc2b
2018-04-13 21:51:09 -07:00
Jun Wu
ad0942500c flake8: enable some E checks
Summary: They look useful.

Reviewed By: DurhamG

Differential Revision: D6934534

fbshipit-source-id: 4179a50c073909a8139dfdd91885f729e7d0a4b3
2018-04-13 21:51:09 -07:00
Jun Wu
f1c575a099 flake8: enable F821 check
Summary:
This check is useful and detects real errors (ex. fbconduit).  Unfortunately
`arc lint` will run it with both py2 and py3 so a lot of py2 builtins will
still be warned.

I didn't find a clean way to disable py3 check. So this diff tries to fix them.
For `xrange`, the change was done by a script:

```
import sys
import redbaron

headertypes = {'comment', 'endl', 'from_import', 'import', 'string',
               'assignment', 'atomtrailers'}

xrangefix = '''try:
    xrange(0)
except NameError:
    xrange = range

'''

def isxrange(x):
    try:
        return x[0].value == 'xrange'
    except Exception:
        return False

def main(argv):
    for i, path in enumerate(argv):
        print('(%d/%d) scanning %s' % (i + 1, len(argv), path))
        content = open(path).read()
        try:
            red = redbaron.RedBaron(content)
        except Exception:
            print('  warning: failed to parse')
            continue
        hasxrange = red.find('atomtrailersnode', value=isxrange)
        hasxrangefix = 'xrange = range' in content
        if hasxrangefix or not hasxrange:
            print('  no need to change')
            continue

        # find a place to insert the compatibility  statement
        changed = False
        for node in red:
            if node.type in headertypes:
                continue
            # node.insert_before is an easier API, but it has bugs changing
            # other "finally" and "except" positions. So do the insert
            # manually.
            # # node.insert_before(xrangefix)
            line = node.absolute_bounding_box.top_left.line - 1
            lines = content.splitlines(1)
            content = ''.join(lines[:line]) + xrangefix + ''.join(lines[line:])
            changed = True
            break

        if changed:
            # "content" is faster than "red.dumps()"
            open(path, 'w').write(content)
            print('  updated')

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
```

For other py2 builtins that do not have a py3 equivalent, some `# noqa`
were added as a workaround for now.

Reviewed By: DurhamG

Differential Revision: D6934535

fbshipit-source-id: 546b62830af144bc8b46788d2e0fd00496838939
2018-04-13 21:51:09 -07:00
Jun Wu
0daed9e7f6 flake8: resolve some F checks
Summary:
Solves issues below:
```
hgext/backups.py:18:1: F811 redefinition of unused 'registrar' from line 17
hgext/catnotate.py:1:1: F811 redefinition of unused 'util' from line 1
hgext/remotenames.py:57:5: F811 redefinition of unused 'registrar' from line 34
hgsubversion/setup.py:103:5: F401 'mercurial' imported but unused
hgsubversion/setup.py:109:5: F401 'hgsubversion.svnwrap.svn_swig_wrapper' imported but unused
i18n/polib.py:1281:29: F841 local variable 'exc' is assigned to but never used (Python 2)
i18n/polib.py:1427:13: F841 local variable 'typ' is assigned to but never used
i18n/polib.py:28:1: F401 'sys' imported but unused
mercurial/manifest.py:411:5: F811 redefinition of unused '_lazymanifest' from line 168
mercurial/posix.py:419:5: F811 redefinition of unused 'normcasefallback' from line 362
mercurial/posix.py:425:5: F811 redefinition of unused 'checkexec' from line 167
mercurial/posix.py:431:5: F811 redefinition of unused 'checklink' from line 234
mercurial/pycompat.py:29:5: F401 'http.cookiejar as cookielib' imported but unused
mercurial/pycompat.py:30:5: F401 'http.client as httplib' imported but unused
mercurial/pycompat.py:31:5: F401 'pickle' imported but unused
mercurial/pycompat.py:33:5: F401 'socketserver' imported but unused
mercurial/pycompat.py:34:5: F401 'xmlrpc.client as xmlrpclib' imported but unused
mercurial/statprof.py:573:36: F812 list comprehension redefines 'parent' from line 562 (Python 2)
mercurial/util.py:1076:5: F811 redefinition of unused 'nogc' from line 1051
mercurial/util.py:3221:5: F811 redefinition of unused 'dirs' from line 3184
tests/silenttestrunner.py:24:5: F811 redefinition of unused 'main' from line 6
tests/test-context.py:90:1: F811 redefinition of unused 'scmutil' from line 4
tests/test-fb-hgext-cstore-treemanifest.py:146:5: F811 redefinition of unused 'testDeeplyNested' from line 134
tests/test-fb-hgext-extutil.py:46:5: F811 redefinition of unused 'testbgcommandfailure' from line 37
tests/test_hgsubversion_util.py:47:1: F811 redefinition of unused 'svnwrap' from line 31 (Python 2)
tests/test_hgsubversion_util.py:49:1: F811 redefinition of unused 'svnwrap' from line 47 (Python 2)
```

Reviewed By: ryanmce

Differential Revision: D6934533

fbshipit-source-id: 8b51851a76fec88bb59107ed05a901d42c7326f8
2018-04-13 21:51:09 -07:00
Jun Wu
d56ebc52af buck: fix tests with opt build
Summary: D6937883 turns out to be ineffective. Let's fix it in another way.

Reviewed By: DurhamG

Differential Revision: D6940006

fbshipit-source-id: 082d0ddcf464d7056426bde2feab52a7717eb057
2018-04-13 21:51:09 -07:00
Jun Wu
2946a1c198 codemod: use single blank line
Summary: This makes test-check-code cleaner.

Reviewed By: ryanmce

Differential Revision: D6937934

fbshipit-source-id: 8f92bc32f75b9792ac67db77bb3a8756b37fa941
2018-04-13 21:51:08 -07:00
Jun Wu
b8967f2eef extensions: disable foreign import check if non-standard layout
Summary:
It seems the non-standard xar layout could conflict with the foreign
import check somehow.

Reviewed By: singhsrb

Differential Revision: D6937883

fbshipit-source-id: b7c4dfc6836f6f1c8a693775dc42c16c537dc8e6
2018-04-13 21:51:08 -07:00
Mark Thomas
d89367ab90 progress: add spinner context manager for easy spinners
Summary:
Some actions can take a long time, and not all of them have progress bars.
When this happen the user is left with an empty prompt and doesn't know that
Mercurial is actually working.

This adds a context manager which can be used to give long-running processes a
spinner-style progress bar, indicating that something is happening in the
background.

Reviewed By: farnz

Differential Revision: D6937079

fbshipit-source-id: 396d7b11157b4f13e0c12dac1e2403d9269938ab
2018-04-13 21:51:08 -07:00
Jun Wu
bc139eb86b hgweb: add --port-file flag
Summary:
This allows us to specify `-p 0 --port-file X` to get the port assigned in
an atomic way. So there won't be "server failed to start" caused by race
conditions in tests.

Reviewed By: DurhamG

Differential Revision: D6925397

fbshipit-source-id: 5bbb61b7eb2695f0a673afdb0730d2a61827f8b3
2018-04-13 21:51:07 -07:00
Jun Wu
4c44fcc611 revlog: calculate rawsize correctly when applying deltas
Summary: This fixes the `hg verify` issue.

Reviewed By: DurhamG

Differential Revision: D6920596

fbshipit-source-id: 4a777f182b58acf29a62d50aca65d668b307e5b3
2018-04-13 21:51:06 -07:00
Adam Simpkins
ee2ff2f2bd help: don't crash when trying to display help for disabled commands
Summary:
Check to see if the module documentation is None before trying to call
`splitlines()` on it.

Reviewed By: singhsrb

Differential Revision: D6919043

fbshipit-source-id: 93c458cde9643a3f1b2d6fe6eb56fa312ae2a192
2018-04-13 21:51:06 -07:00
Kostia Balytskyi
662ade9719 hg: make sure blocked times logged during atexit handlers are logged
Summary:
Previosuly, we would miss anything logged in the `ui.atexit`-registered
handler, since the actual logging would happen before those handlers were
called.

Reviewed By: quark-zju

Differential Revision: D6912321

fbshipit-source-id: 77600b7ae535b4da56fef1f92b51998de8e304e2
2018-04-13 21:51:06 -07:00
Jun Wu
49cbfb1878 filelog: allow trading file history correctness for performance
Summary:
With certain setup, the file history could be incorrect. That makes
`adjustlinknode` much slower since it has to scan the full history.
It is extremely slow if there is a commit with a massive renames.

This is undesirable since `hg log FILE` would give a wrong result.
But it does make the repo usable. Automation that does not care
about `hg log FILE` correctness can probably enable this relatively
safely.

This patch changes both shallow and full repos.

Reviewed By: DurhamG

Differential Revision: D6912051

fbshipit-source-id: 23d6f6c8dd91d4f72b43bc560cf26686bd6c4b47
2018-04-13 21:51:06 -07:00
Jun Wu
a226ef4969 revlog: forbid revdiff revisions with non-zero flags
Summary:
Calling revdiff with non-zero flags is a sign of a hard-to-debug
error. Raise ProgrammingError in this case.

The change is straightforward. Apply it to both shallow and full
repos.

Reviewed By: DurhamG

Differential Revision: D6910080

fbshipit-source-id: cbcf1a444de90e104867cc9f1525629b7edda851
2018-04-13 21:51:05 -07:00
Jun Wu
d76d41a0b2 revlog: resolve lfs rawtext to vanilla rawtext before applying delta
Summary:
This happens when the client with LFS revisions applies a bundle
with a delta base pointing to an LFS revision stored in the repo.

Reviewed By: DurhamG

Differential Revision: D6906210

fbshipit-source-id: 8b47f8304f8ef5ae4b02d7239b680f70106a4d83
2018-04-13 21:51:05 -07:00
Jun Wu
453b043043 revlog: do not use delta for lfs revisions
Summary:
This is similar to what we have done for changegroups, but for non-changegroup
(addrawrevision) case. This is needed to make sure the delta application code
path can assume deltas are always against vanilla (non-LFS) rawtext so the next
fix becomes possible.

Reviewed By: DurhamG

Differential Revision: D6906202

fbshipit-source-id: a7d62dfed4206d45b42299f1dabf013620ae52b3
2018-04-13 21:51:05 -07:00
Jun Wu
07042a2157 changegroup: do not delta lfs revisions
Summary:
There is no way to distinguish whether a delta base is LFS or non-LFS.

If the delta is against LFS rawtext, and the client trying to apply it has the
base revision stored as fulltext, the delta (aka. bundle) will fail to apply.

This patch forbids using delta on LFS revisions.

Note: this does not solve the problem entirely. Since the problem could also be
a client with base file revision being LFS tries to apply a non-LFS delta
(bundle).

Reviewed By: DurhamG

Differential Revision: D6878326

fbshipit-source-id: 9c3951e4673b8de61aae73a51e1bfff422f38d0f
2018-04-13 21:51:05 -07:00
Jun Wu
381158f7df test-lfs-bundle: new test testing lfs bundle exchanging behavior
Summary: This test covers bundle application between repos.

Reviewed By: DurhamG

Differential Revision: D6906245

fbshipit-source-id: 827b49eec49f1ffaac6363e38783705d0c399c45
2018-04-13 21:51:05 -07:00
Jun Wu
6529990478 debugfilerevision: add a new debug command
Summary:
This is similar to `debugdata`, but instead of taking a file revision (or
file node in remotefilelog's case), it takes a revset.

This is more useful practically, since the user would know commit hashes
easily but file nodes are hidden from the UI.

This is intended to make it easier to investigate LFS contents.

Reviewed By: DurhamG, ryanmce

Differential Revision: D6891770

fbshipit-source-id: 415da9b773c30830a48c09eda9f1854c416e3222
2018-04-13 21:51:05 -07:00
Jordi Llull Chavarria
cd33b0b3af Preserve order of revisions after hg pullbackup
Summary:
This diff fixes hg pullbackup so it retrieves commits in the same order that there were pushed. This was caused by commits being stored in sets and dictionare which are by unorered types. These have been replaced by OrderedDict to mantain the order.

**Description of the task:**
Infinitepush is a mercurial extension that allows sharing commits easily. Among other things it also backs up all local commites that were made on devservers and laptops. That means that we always have up-to-date backup You can read more about it here - https://our.intern.facebook.com/intern/dex/mercurial-workflow/infinitepush/ .

Backup is triggered whenever mercurial transaction is triggered i.e. during commit, rebase or any other operation that changes mercurial repo. `hg pullbackup` is the way to pull backed up commits.

There is a problem. Let's say host A has this repo:

` o`
` |`
` o  C1`
` |  /`
` |   C2`
` |  /`
` o`

So we have two draft commits: C1 and C2. C2 is probably an older commit. But if we restore it on another host we can get another output:

` o`
` |`
` o  C2`
` |  /`
` |   C1`
` |  /`
` o `

This happens because `hg sl` orders commits by it's revision number in revlog - https://www.mercurial-scm.org/wiki/Revlog .

The point of the task is to make sure commits are ordered by their creation date.

Link to comment: http://www.facebook.com/groups/scm/permalink/1504906422892306/?comment_id=1505017576214524&reply_comment_id=1506426179406997

Reviewed By: StanislavGlebik

Differential Revision: D6884670

fbshipit-source-id: 3281dbc1e25e24662a4b6ba78b96b85d5bae78c9
2018-04-13 21:51:05 -07:00
Jun Wu
2090a611ca config: change default debugger to ipdb
Summary: ipdb/ipython is more friendly than the default.

Reviewed By: phillco

Differential Revision: D6767252

fbshipit-source-id: 50028a9681965c868f2bcd5a025debe0f1130dbc
2018-04-13 21:51:04 -07:00
Phil Cohen
0584f5d23f hg: fastverify: unify and fold into core
Summary: `fastverifier` was sometimes being overriden by `shallowverifier` when remotefilelog was enabled. Since the latter is a subset of the former, let's just fold both into the core verifier code backed by a config, `verify.skipmanifests`, that we can default to true.

Reviewed By: DurhamG

Differential Revision: D6882222

fbshipit-source-id: 9f337ca031a070425ccdc9ee02f6765e68436da9
2018-04-13 21:51:03 -07:00
Jun Wu
5678d60890 buck: add mercurial.interpreter emulating python interpreter
Summary:
A lot of tests rely on `python` interpreter being able to do
things like `import mercurial`. This becomes tricker if hg is
built as a single binary by buck.

Therefore also add a interpreter target that can be used as
a drop-in replacement of `python` in tests.

Reviewed By: DurhamG

Differential Revision: D6879868

fbshipit-source-id: 2b1d2b6306e74ceff86750d1f86387b9fa493f9a
2018-04-13 21:51:02 -07:00
Jun Wu
f623fe9d3c main: add mercurial.main as an entry point
Summary:
The old mercurial.dispatch entry point works, except it breaks
extensions wrapping `dispatch.*` (ex. `dispatch.runcommand`).

That is because things happen in this order:
- Buck's python wrapper imports `mercurial.dispatch` as mod1.
- hgdemandimport is enabled.
- An extension imports `mercurial.dispatch` and it got mod2.
- mod2 != mod1. So any changes to mod2 won't be used.

Using a separate module (`mercurial.main`) as the entry point
solves the problem.

Reviewed By: DurhamG

Differential Revision: D6879873

fbshipit-source-id: 9779edac64bbeb53dd98dfab1b21575c3a60af01
2018-04-13 21:51:02 -07:00
Jun Wu
d0f9b4315d hgsubversion: move its help text to mercurial/help
Summary:
So the use of `os.path.dirname(__file__)` which won't work in buck
python binary can be removed.

Reviewed By: DurhamG

Differential Revision: D6881306

fbshipit-source-id: b6504beaf07fe9853abff08b9721a17b31ac7515
2018-04-13 21:51:02 -07:00
Jun Wu
52139b2825 util: set datapath dynamically using HGDATAPATH
Summary:
This allows `HGDATAPATH` to override where to look for data files
like builtin configs, templates, help texts.

It'll be useful for running tests with a packed hg binary.

Reviewed By: DurhamG

Differential Revision: D6879865

fbshipit-source-id: 4638a9eff62a5fab088215cbeb72740bb67cac04
2018-04-13 21:51:02 -07:00
Jun Wu
32aac9256d lazymanifest: do not read uninitialized memory
Summary:
Backported from https://phab.mercurial-scm.org/D1948.
Discovered by clang UBSAN.

Reviewed By: DurhamG, phillco

Differential Revision: D6879871

fbshipit-source-id: c068bdcf5b250c6586515960ef7ed9d0af3a2c59
2018-04-13 21:51:01 -07:00
Kostia Balytskyi
84129009ee hg: log time spent waiting for the pager
Summary:
Let's collect how long we wait for a pager so that we can later subtract it
from the elapsed time.
Currently, it's impossible to compute `elapsed - pager - editor - stdio`, which
would include startup time.

Reviewed By: quark-zju

Differential Revision: D6875447

fbshipit-source-id: d055e4ba5bf1ab7ee9e567c99b6708321ab7705b
2018-04-13 21:51:01 -07:00
Liubov Dmitrieva
b5b151319c backout: use only first line of commit message for backout default message
Summary: backout: use only first line of original commit message (title) for backout default message.

Reviewed By: phillco

Differential Revision: D6846109

fbshipit-source-id: 68efbff9db698599a12cef45de7ab4af96cf184f
2018-04-13 21:51:00 -07:00
Durham Goode
0e21c4e1ab hg: fix treeonly prepushrebase python hooks for treeonly pushes
Summary:
When pushing a treeonly commit to a tree+flat hybrid server, the server
needs to execute the hooks in treeonly mode so we never try to access the flat
manifests. Previously we did this for shell hooks by setting some environment
variables, but we didn't do it for python hooks that ran in process.

This diff makes the python hooks run against a bundle repo that is instantiated
in treeonly mode. No changes to any hooks are required, as the repo object they
are given is already in the correct mode.

Reviewed By: quark-zju

Differential Revision: D6840971

fbshipit-source-id: 9fcb97d972076911b35bccf3f79b60972bcafc33
2018-04-13 21:51:00 -07:00
Jun Wu
96a9afa2a5 drawdag: inline drawdag
Summary:
Since we have `debugbuilddag` as a builtin command, and `drawdag` is
pretty useful for writing clean test cases. Let's inline it. This would
simplify many tests since `drawdag=..." is no longer needed.

Reviewed By: DurhamG

Differential Revision: D6827925

fbshipit-source-id: b749f57fd5c55b2cb000dd2da2c2f9bc2386a519
2018-04-13 21:50:59 -07:00
Durham Goode
1f577c8417 hg: remove version check from crecord
Summary:
crecord locked out the amend functionality to older versions of
Mercurial. Since it's packaged in core now, let's always enable it.

Reviewed By: quark-zju

Differential Revision: D6837724

fbshipit-source-id: 2a0dae2e03346734f7d8298e5a073f776849005e
2018-04-13 21:50:59 -07:00
Durham Goode
210bd25b94 hg: fix check code errors
Summary: These snuck in.

Reviewed By: phillco

Differential Revision: D6821043

fbshipit-source-id: bd4d83e2460bebdb2061dfbf84bed0139d1b72e1
2018-04-13 21:50:58 -07:00
Liubov Dmitrieva
68ac2c6418 Improve backout default message
Summary: [backout] Improve backout default message

Reviewed By: phillco

Differential Revision: D6818834

fbshipit-source-id: 3dc2465f64e37ff4bc96eff512ae991cf2a2f96d
2018-04-13 21:50:58 -07:00
Simon Farnsworth
30e993a160 template: add functions to truncate blocks and lines
Summary:
smartlog, among other places, would benefit from being able to
strictly limit the size of text output to the terminal. Provide two functions:
one truncates long lines in a filled block, the other limits the number of
lines of output. Both can optionally add a truncation marker.

Reviewed By: markbt

Differential Revision: D6819153

fbshipit-source-id: d95b654f4a6fef49ad4840f26ef74a18c370bdd8
2018-04-13 21:50:58 -07:00
Mark Thomas
4b7dab149a hg: improve perf interactions with treedirstate
Summary:
There are a couple of ways that dirstate and fsmonitor interact with
treedirstate that are sub-optimal.

When iterating over all files in the dirstate map, use the iterator of keys
(`__iter__` rather than `iteritems`) to hit the treedirstate fastpath that
doesn't build the dirstate tuples.

Use `__getitem__` and catch the `KeyError` rather than `__contains__` followed
by `__getitem__`, as the latter involves two look-ups in the tree.

Skip the indirect call to `hastrackedfile` and `hasremovedfile` as these add
noticable overhead when called many times.

Also fix up the `test-check-code` failure for treedirstate.

Reviewed By: ryanmce

Differential Revision: D6818952

fbshipit-source-id: d49907c282a1b97c66a3d24257bdf54800d7da70
2018-04-13 21:50:58 -07:00
Jun Wu
d942f5a88e hg: basic support for building hg using buck
Summary:
Adds some basic building blocks to build hg using buck.

Header files are cleaned up, so they are relative to the project root.

Some minor changes to C code are made to remove clang build
warnings.

Rust dependencies, fb-hgext C/Python dependencies (ex. cstore,
mysql-connector), and 3rd-party dependencies like python-lz4
are not built yet. But the built hg binary should be able to run
most tests just fine.

Reviewed By: wez

Differential Revision: D6814686

fbshipit-source-id: 59eefd5a3ad86db2ad1c821ed824c9f1878c93e4
2018-04-13 21:50:58 -07:00
Durham Goode
3b2cabfe55 hg: fix extensions-default
Summary:
Suggesting disabled extensions uses extensions.loadpath, which is no
longer supported for core extensions. Since this test is just testing that the
extension can be disabled, let's not worry about the exact output.

Reviewed By: phillco

Differential Revision: D6802719

fbshipit-source-id: 2a602e086f4809676ef8dd36ffc30f021b3186fc
2018-04-13 21:50:57 -07:00
Durham Goode
16270db464 hg: fix check execute
Summary:
check-execute was failing because the filesets are too slow (about 45+s
each). This fixes the performance by optimizing some internal fileset logic, and
by fixing a fileset to be scoped to the current working directory instead of the
whole repo.

Unfortunately the fileset implementation optimization needs to be deployed
before the test can benefit from it (since the test runs the system hg), so we
need to leave the test disabled until the fix rolls out.

Reviewed By: quark-zju

Differential Revision: D6802078

fbshipit-source-id: 26767c989e15b6d0ae5f5d9560309dafa5c380ff
2018-04-13 21:50:57 -07:00
Phil Cohen
45c4a072f9 hgext: use relative imports wherever possible
Summary:
Port of D6798134 to fbsource. It eliminates module-import failures as well as errors like this:

```
mercurial.error.ForeignImportError: hgext.extlib.treedirstate: /home/phillco/.local/lib/python2.7/site-packages/hgext/extlib/treedirstate.so lives outside /..../hg
```

....that block other tests, like test-help.t

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D6799259

fbshipit-source-id: b77d1b565dbf52165e0847002be498648658e064
2018-04-13 21:50:56 -07:00
Phil Cohen
265c2610c7 simplecache: enable by default
Summary: Default-on this moderately hard extension.

Reviewed By: DurhamG, quark-zju

Differential Revision: D6792641

fbshipit-source-id: 475135f4f4f295a4e6356443405bd6eb185c310a
2018-04-13 21:50:55 -07:00
Phil Cohen
5cae81a643 extensions: default-on conflictinfo, errorredirect, ...
Summary: ...mergedriver, and progressfile.

Reviewed By: quark-zju, singhsrb

Differential Revision: D6765952

fbshipit-source-id: 8eddcdeffa5d6532f737f45f7e1071c1a563a3cd
2018-04-13 21:50:54 -07:00
Durham Goode
3666ccd6b2 clindex: disable by default for now
fbshipit-source-id: b1af6f49eebfbada4bf9637ea4935c618b0e7bb6
2018-04-13 21:50:53 -07:00
Phil Cohen
0900d9a168 extensions: add --excludedefault to hg debugextensions
Summary: Otherwise this test will fill up with default-on tests that will be a pain to filter manually. Plus it's a sensible flag to have.

Differential Revision: D6760553

fbshipit-source-id: 083cb2d8a7cffe28eef812edad2f4c5d997db981
2018-04-13 21:50:53 -07:00
Phil Cohen
02d588a3bc extensions: fix reposetup() not getting called for DEFAULT_EXTENSIONS
Summary:
`_peerorrepo` calls `extensions.extensions()` to figure out on which modules to run reposetup. This uses a slightly
different code path than that patched by D6716674 and double-checks if an extension is enabled. So we need to patch here too.

Reviewed By: quark-zju

Differential Revision: D6758486

fbshipit-source-id: b5bfe2d11e5e2aeb2d3a0ee7c9d6e3e2c213233d
2018-04-13 21:50:53 -07:00
Phil Cohen
c7ff97160f share: fix hg unshare
Summary:
This was blocking us default-enabling `fbsparse`; however, this function is actually incredibly fragile and can break with a variety of extensions enabled (even blackbox).

E.g., try this on the latest release and you'll get an exception!

```
cd $(mktemp -d); hg init a; hg share a b; cd b; hg unshare
```

That particular breakage is called by blackbox trying to look at `repo[None]` to do some logging, but anything that tries to read `repo.dirstate` after this will print the exception. The root cause is this line which is trying to override `repo.root`:

```
repo.unfiltered().__init__(repo.baseui, repo.root)
```

It's trying to update the repo's path to indicate that it is independent and no longer shared. But, the initializer isn't really designed to be called twice, AFAICT, and doing so here leaves the property caches out of sync with properties of the repo (namely `_filecache`).

Durham's suggestion was just to nuke `hg unshare`. This patch works around it for now, though, in case we want to keep it alive.

Reviewed By: quark-zju

Differential Revision: D6758397

fbshipit-source-id: 90d3773d9340f2a5b2e6e900a2194d8b931f410d
2018-04-13 21:50:53 -07:00
Phil Cohen
c71baa2944 debugextensions: list default-on extensions as '(default)'
Summary:
...instead of '(untested!)'.

Partly this is necessitated by the `hg debugextensions` call in test-extension.t (post
D6758486). But it also seems like the right thing to do.

Reviewed By: ryanmce

Differential Revision: D6758599

fbshipit-source-id: 3ecfa52b0c9c1a028201d2eda0eaa706d80225c0
2018-04-13 21:50:53 -07:00
Jun Wu
97dfe79221 perftweaks: fold isgooddelta tweak into core
Summary:
The isgooddelta tweak was introduced in D2693043 (perftweaks: change revlog
delta heuristic, 2015-11-24).  Comparing with the existing version, the only
change is that we removed `dist > maxdist` check.

Note that the upstream commit 895ecec31 (revlog: add an experimental option
to mitigated delta issues (issue5480), 2017-06-23) also introduces a config
option to override `maxdist` to make the condition fail, which basically does
a same thing.

Instead of introducing new config options or adding more "if"s to the
codebase to make it more obscure, let's just simplify it by disabling the
check entirely, and removing the `dist` concept, removing two config
options: `experimental.maxdeltachainspan` and `perftweaks.preferdeltas`.

The `chainlen > self._maxchainlen` check should be enough for keeping
delta chain length bounded.

Reviewed By: DurhamG

Differential Revision: D6752529

fbshipit-source-id: e8fd8ec39240191db5fb274190fc661e97087a78
2018-04-13 21:50:53 -07:00
Jun Wu
07522dbb4e clindex: enable by default
Summary:
This enables clindex for its nodemap. Verification is turned off by default
for the performance win since we have been running verification in
production for a while.

Reviewed By: phillco

Differential Revision: D6751412

fbshipit-source-id: bc3e87df86e86a758392bdd4aef3e282f397fe04
2018-04-13 21:50:52 -07:00
Jun Wu
7fa918cefd perftweaks: move commit head detection removal logic to core
Summary: Also change the internal API so it no longer accepts the "heads" argument.

Reviewed By: ryanmce

Differential Revision: D6745865

fbshipit-source-id: 368742be49b192f7630421003552d0a10eb0b76d
2018-04-13 21:50:52 -07:00
Jun Wu
fe0a348d39 perftweaks: move effectflag removal logic to core
Summary: This removes the effectflag logic from both core and perftweaks.

Reviewed By: ryanmce

Differential Revision: D6745769

fbshipit-source-id: 55ed1676e7117bca358471c256805ded7bc83f3c
2018-04-13 21:50:52 -07:00
Jun Wu
9e139f9716 log: optimize "log -f FILE"
Summary:
Previously it's `:. & follow(FILE)` and there is a Python loop iterating
`:.`. This patch makes it `follow(FILE) & :.`.

In the common case, `_logrevs` returns a large revset in desc order. So it
makes sense to put it at the right side of `&` operator. The only exception is
when `_logrevs` uses user-specified revset (`-r`), whose order needs to be
respected and size is unknown.

Test Plan:
Ran all tests.

Facebook:
This reduces `hg log FILE` from ~3 seconds to ~0.5 seconds.

```
# Before
% time hg log cmd_util.py --pager=off --config extensions.fastlog=! -T'{oneline}\n'
11e9d4 D5997870 mbolin Use --home-dir to compute the config dir, if specified.  2017-10-06
5041e2 D4888633 simpkins [eden] move eden/fs/cli to eden/cli  2017-04-14
7dc2bd D4760528 simpkins [eden] an "eden debug" CLI command and thrift APIs to support it  2017-04-03
hg log cmd_util.py --pager=off --config extensions.fastlog=! -T='{oneline}\n'  2.88s user 0.09s system 99% cpu 2.975 total

# After
% time hg log cmd_util.py --pager=off --config extensions.fastlog=! -T'{oneline}\n'
7dc2bd D4760528 simpkins [eden] an "eden debug" CLI command and thrift APIs to support it  2017-04-03
5041e2 D4888633 simpkins [eden] move eden/fs/cli to eden/cli  2017-04-14
11e9d4 D5997870 mbolin Use --home-dir to compute the config dir, if specified.  2017-10-06
hg log cmd_util.py --pager=off --config extensions.fastlog=! -T='{oneline}\n'  0.42s user 0.03s system 98% cpu 0.456 total
```

Fastlog is disabled since a network request makes the time less stable.
Logging a single file is answered locally by remotefilelog ancestor handling.

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham

Differential Revision: https://phabricator.intern.facebook.com/D6735007

Signature: 6735007:1516163080:0d7ddae9f24933d795ba7aaa4461916c7fdd2309
2018-01-16 18:37:49 -08:00
Jun Wu
19cda85a3a debugshell: enable it by default
Summary:
It's pretty handy. The implementation is simple and clean. So move it from
contrib and enable it by default. "import"s are adjusted to make the module
checker happy.

Security and UX wise, since we have `--debugger` already, adding another
REPL seems fine.

Test Plan: Ran all tests

Reviewers: phillco, #mercurial

Reviewed By: phillco

Differential Revision: https://phabricator.intern.facebook.com/D6741283

Signature: 6741283:1516225662:ddc19a663e7ecef2a1fdaa5041f308dc838a8471
2018-01-17 12:54:24 -08:00
Phil Cohen
740831270a context: fix a truthy check in overlayworkingctx.data()
Summary:
This if statement is testing whether we ever set any data, not whether the data is truthy.

This can cause a bug where rebasing an empty file can cause IMM to fail and restart.

Test Plan: ./run-tests.py

Reviewers: durham, #mercurial

Reviewed By: durham

Differential Revision: https://phabricator.intern.facebook.com/D6687459

Signature: 6687459:1515535581:c2018237f3ca9daed6a0cb2f5a1475d1dc8e4865
2018-01-16 17:24:23 -08:00
Phil Cohen
d252e1a488 merge: only abort in IMM if files are actually marked as driver-resolved
Summary:
Before, we would raise whenever the `usemergedriver` condition was set when merging in-memory,
which equated to "any merge with (cd, dc, or m) actions in a repo with a mergedriver script".
This was done to be as conservative as possible.

However, a better solution is to run the preprocess() script and only raise if any files are
marked to actually be driver-resolved. That way we only restart the merge if we absolutely need
to.

Since some of our preprocess() scripts aren't ready yet, I also added
experimental.inmemory.nomergedriver in a previous change so we can deploy this in a build before the preprocess scripts are good to go.

Test Plan: ./run-tests.py

Reviewers: quark, #sourcecontrol

Reviewed By: quark

Subscribers: durham

Differential Revision: https://phabricator.intern.facebook.com/D6668426

Signature: 6668426:1515185050:a640208454caf053f8213b831d0f8e645ebe682c
2018-01-16 17:24:16 -08:00
Phil Cohen
24f40237ba filemerge: fix backing up an in-memory file to a custom location
If the user specifies a ui.origbackuppath, we used to always copy the file
there, but if the source file is in memory we must write it instead of copying.

Differential Revision: https://phab.mercurial-scm.org/D1806
2018-01-16 17:23:40 -08:00
Phil Cohen
a1c1d5e38d merge: fix default value for experimental.inmemorydisallowedpaths 2018-01-16 17:23:22 -08:00
Phil Cohen
8a4473f1d0 merge: log which files were driver-resolved to scuba
Summary: Log whichever paths were driver-resolved but not in experimental.inmemorydisallowedpaths, so we can update experimental.inmemorydisallowedpaths and keep the experience of rebasing with IMM and
mergedriver a pleasant one.

Test Plan: .

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6656159
2018-01-16 17:23:15 -08:00
Kevin O'Sullivan
fa38fee98f Using a set() for names to remove duplicates before calling bookmarks.delete
Summary: Fixing a bug that causes a fatal crash when a user attempts to delete a bookmark by inputting it's name twice, for example:

# hg bookmark --delete name name
Test Plan: The following test has been added in the test/test-bookmarks.t file
https://pxl.cl/bmTf
 to test the new functionality:

~~~
kosullivan-mbp:hg-crew kosullivan$ hg diff tests/test-bookmarks.t
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -288,6 +288,10 @@
   abort: bookmark 'A' does not exist
   [255]

+ensure bookmark names are deduplicated before deleting
+  $ hg book delete-me
+  $ hg book -d delete-me delete-me
+
 bookmark name with spaces should be stripped

   $ hg bookmark ' x  y '
~~~
Reviewers: rmcelroy,rafeca
Subscribers: suiting
Tags: python,bootcamp,source_control
Tasks: 22525999
Differential Revision: https://phabricator.intern.facebook.com/D6711774
2018-01-16 15:20:21 +00:00
Phil Cohen
72085d2e96 testdir: fix test-extension.t for DEFAULT_EXTENSIONS
Differential Revision: https://phabricator.intern.facebook.com/D6718663
2018-01-14 14:53:52 -08:00
Phil Cohen
6095f32f96 extensions: enable githelp by default
Summary:
Demonstrate the full power of this batte station with the first extension to be default-enabled, `githelp.py`. This also lets us write a test for `DEFAULT_EXTENSIONS`
(`test-extensions-default.t`)

All other test changes are actual fallout from enabling the githelp extension.

Test Plan: Added a test.

Differential Revision: https://phabricator.intern.facebook.com/D6717098
2018-01-12 16:45:54 -08:00
Phil Cohen
051f25cfd3 extensions: add a list of always-on extensions
Summary:
Based on in-person discussion in the warroom, we think this is the right path forward to "upstream" certain extensions without actually folding them into the mercurial/ codebase.

Enabling extensions by default achieves most of our goals (testing _everything_ in tests, reducing configuration permutations) without having to pay an up-front cost of fixing all the code today or accepting subpar code in mercurial/.

Test Plan: ./run-tests.py.

Reviewers: quark, #mercurial

Reviewed By: quark

Subscribers: quark

Differential Revision: https://phabricator.intern.facebook.com/D6716674

Signature: 6716674:1515803845:a209ec288341e4de8e79fd3759250e834a3573e3
2018-01-12 16:45:54 -08:00
Phil Cohen
c097dde0b9 READMEs: tweaks based on feedback
Summary: Based on feedback to D6687860.

Test Plan: n/a

Reviewers: durham, #mercurial

Reviewed By: durham

Differential Revision: https://phabricator.intern.facebook.com/D6714211

Signature: 6714211:1515788399:386b8f7330f343349234d1f317e5ac0a594142cf
2018-01-12 12:35:52 -08:00
Jun Wu
5c05ef8327 extensions: forbid "foo=" from importing foreign mercurial modules
Summary: This avoids issues where a wrong (outside the repo) extension was used.

Test Plan: Ran all tests

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham

Differential Revision: https://phabricator.intern.facebook.com/D6690534

Signature: 6690534:1515632034:1353c9272650cf925dd299d252592afd52970e98
2018-01-09 17:06:09 -08:00
Phil Cohen
bf8527e7a9 lib: add READMEs to lib, extlib, cext 2018-01-09 15:20:46 -08:00
Jun Wu
26485b34fb cython: move extensions to better places
Summary:
clindex is an hg extension, so moved to `hgext`.
linelog is not an hg extension, but is only used by hg extensions, not
`mercurial/`, so moved to `hgext/extlib`.

Test Plan: `make local` and `run-tests.py` without `-l` and with an empty `PYTHONPATH`.

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: fried

Differential Revision: https://phabricator.intern.facebook.com/D6685080

Signature: 6685080:1515525106:88ebb275d0cac041911f243a3e82b82482b6cd34
2018-01-09 10:50:46 -08:00
Kostia Balytskyi
edc5c3ab25 fb-hgext: move clindex to core
Summary:
Move clindex to core.

Depends on D6683664

Test Plan: - run tests, see them pass

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6683689
2018-01-09 08:42:20 -08:00
Phil Cohen
bc45549249 filemerge: only write in-memory backup during premerge
This wasn't broken, but should mirror the non-in memory case to save an extra write.

Differential Revision: https://phab.mercurial-scm.org/D1807
(grafted from d592d5905ae972407fb6f9d649db1e2d41bf6c85)
(grafted from 9111386f1fe8316b9079669d0bd0e33704ba2a0c)
2018-01-09 06:29:25 -08:00
Mark Thomas
aeeba5db75 help: blacklist hgext/extlib module from help.
Summary:
`hg help` shows a list of all disabled extensions, which is gets by looking at
all submodules in the `hgext` modules.  Exclude the new `extlib` submodule,
which is actually just a container for extension libraries.

Test Plan: Re-run `test-help.t`.

Reviewers: durham, #mercurial

Reviewed By: durham

Differential Revision: https://phabricator.intern.facebook.com/D6679750

Tasks: T24908724

Signature: 6679750:1515458834:8813e9ea9aaf6a4d55d24bc8a48ddc628f6070fa
2018-01-08 17:01:31 -08:00
Jun Wu
1802036ff3 linelog: move to lib/ and mercurial/cyext
Summary:
The `lib/linelog` directory contains pure C code that is unrelated from
either Mercurial or Python. The `mercurial/cyext` contains Cython extension
code (although for linelog's case, the Cython extension is unrelated from
Mercurial).

Cython is now a hard dependence to simplify the code.

Test Plan: `make local` and check `from mercurial.cyext import linelog` works.

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham, fried

Differential Revision: https://phabricator.intern.facebook.com/D6678541

Signature: 6678541:1515455512:967266dc69c702dbff95fdea05671e11c32ebf28
2018-01-08 14:35:01 -08:00
Ryan McElroy
722a16ea0c lz4revlog: document uselz4 in config help 2018-01-03 07:16:04 -08:00
Phil Cohen
1a2012bad3 merge: raise before running mergedriver if using IMM
Merge driver scripts run in the working copy, so disable with IMM for now.

Differential Revision: https://phab.mercurial-scm.org/D1781
2018-01-03 05:35:56 -08:00
Phil Cohen
a39703fdff filemerge: only raise InMemoryMergeConflictsError when running _xmerge
The old code here was overly broad and would raise in cases when we didn't end
up calling `xmerge` and resolved using an internal tool (such as when
`premerge=True`).

Instead, let's swap out _xmerge if IMM is enabled and have the new tool raise
when called, which is the behavior we want.

Differential Revision: https://phab.mercurial-scm.org/D1739
2018-01-03 05:35:56 -08:00
Zhihui Huang
5518fa1a0b Backed out changeset 4dd462c5c1c3 2018-01-03 05:35:56 -08:00
Zhihui Huang
274bc5fb01 verify: add --rev support
Differential Revision: https://phabricator.intern.facebook.com/D6558110
2018-01-03 05:35:56 -08:00
Jun Wu
a597df3749 commandserver: unblock SIGCHLD
This enables the SIGCHLD handler to work properly if some buggy program
started chg server with SIGCHLD blocked.

A test of this probably requires C code, but we don't have such kind of
tests already. Since this is a simple and clear fix, I'm leaving it as
"untested" but I did a manual test and there were no longer zombie workers.

Differential Revision: https://phab.mercurial-scm.org/D1737
2018-01-03 05:35:56 -08:00
Jun Wu
57ef465cca osutil: add a function to unblock signals
Signals could be blocked by something like:

  #include <unistd.h>
  #include <signal.h>
  int main(int argc, char * const argv[]) {
    sigset_t set;
    sigfillset(&set);
    sigprocmask(SIG_BLOCK, &set, NULL);
    execv("/bin/hg", argv);
    return 0;
  }

One of the problems is if SIGCHLD is blocked, chgserver would not reap
zombie workers since it depends on SIGCHLD handler entirely.

While it's the parent process to blame but it seems a good idea to just
unblock the signal from hg. FWIW git does that for SIGPIPE already [1].

Unfortunately Python 2 does not reset or provide APIs to change signal
masks. Therefore let's add one in osutil. Note: Python 3.3 introduced
`signal.pthread_sigmask` which solves the problem.

`sigprocmask` is part of POSIX [2] so there is no feature testing in
`setup.py`.

[1]: 7559a1be8a
[2]: http://pubs.opengroup.org/onlinepubs/7908799/xsh/sigprocmask.html

Differential Revision: https://phab.mercurial-scm.org/D1736
2018-01-03 05:35:56 -08:00
Jun Wu
1c69fbf161 phase: backout "generate a push-race detection part on push"
It's causing issues with pushrebase. See https://fburl.com/hd5yz5w6
(grafted from 431521982e6add35955b5b5e8b74d9e317d9ca0c)
(grafted from 8e34bb24dfc0436a65724f30e601efd08b6f2abd)
(grafted from 72e1214d63bd8de353fd1e9d1ffedc4d338fadde)
(grafted from 3588155212ad313a7abd52e44f7ebde5fedbfe06)
(grafted from de91755cc930607220d0926effc69506ca85eabc)
(grafted from 8a44eb22d38c9a60ec6102d43f5b7b5ba60100ab)
(grafted from 396b563d93e5645d4a4ec60ecf56bd91ab28f3be)
(grafted from 14a53b4cf2b352e88a3bcfda5075f9679d067b61)
(grafted from 457c63699089270e6658e1186c70a5bc3426f183)
(grafted from 5e525709296041b77cda5d9f04176a31784afbb7)
(grafted from 80926668f057e712eb11fdc580f65501830f4f8c)
(grafted from a350ecb9b0e94a332fdfebb7f0bba72d87a687ca)
2018-01-03 05:35:56 -08:00
Jun Wu
db43fda5b7 bundlerepo: always copy bundle parts before processing
This fixes treemanifest-infinitepush.
(grafted from 0364e7f0f9ef7eb92c7ca6f825cd252d1ecdac2e)
(grafted from c62ae0604a5124ae799f3ba7e309c23696fbd03d)
(grafted from e4b056930eb739c01d34a04e852643bf9c175d77)
2018-01-03 05:35:56 -08:00