Commit Graph

371 Commits

Author SHA1 Message Date
Jun Wu
1ed82fae8e setup: make the name of the main script flexible
Summary:
Previously, the main script is hard-coded as `hg`. We use a wrapper named
`hg` for logging. Therefore make the name more flexible by reading `HGNAME`.
The name is enforced starting with `hg` and cannot have strange characters.

Test Plan:
`HGNAME=hg-foobar python setup.py install --user`. Make sure the `hg-foobar`
script gets installed in `~/.local/bin`, has the correct `libdir` set, is
working, and the working copy does not have `hg-foobar`.

Also make sure `make local` does not write `$HGNAME` in the working copy.


Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham, phillco

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

Signature: 6695942:1515633395:dec1d46590a1210f2012de964f4b4ad830af9292
2018-01-10 12:06:26 -08:00
Jun Wu
4ead882012 setup: remove -Werror
Summary:
Newer gcc might add new warnings without notice. Having `-Werror` might break
build with newer gcc. For example, I got the following error with gcc 7.2:

```
In file included from /usr/include/python2.7/Python.h:80:0,
                 from hgext/extlib/cstore/py-cstore.cpp:14:
./hgext/extlib/cstore/py-treemanifest.h: In function ‘PyObject* treemanifest_hasdir(py_treemanifest*, PyObject*)’:
/usr/include/python2.7/object.h:769:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ((PyObject*)(op))->ob_refcnt++)
                      ^
/usr/include/python2.7/boolobject.h:27:31: note: in expansion of macro ‘Py_INCREF’
 #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
                               ^~~~~~~~~
./hgext/extlib/cstore/py-treemanifest.h:536:5: note: in expansion of macro ‘Py_RETURN_TRUE’
     Py_RETURN_TRUE;
     ^~~~~~~~~~~~~~
/usr/include/python2.7/object.h:769:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ((PyObject*)(op))->ob_refcnt++)
                      ^
/usr/include/python2.7/boolobject.h:28:32: note: in expansion of macro ‘Py_INCREF’
 #define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
                                ^~~~~~~~~
./hgext/extlib/cstore/py-treemanifest.h:538:5: note: in expansion of macro ‘Py_RETURN_FALSE’
     Py_RETURN_FALSE;
     ^~~~~~~~~~~~~~~
./hgext/extlib/cstore/py-treemanifest.h: In function ‘PyObject* treemanifest_text(py_treemanifest*, PyObject*, PyObject*)’:
/usr/include/python2.7/object.h:769:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ((PyObject*)(op))->ob_refcnt++)
                      ^
./hgext/extlib/cstore/py-treemanifest.h:1309:5: note: in expansion of macro ‘Py_INCREF’
     Py_INCREF(Py_False);
     ^~~~~~~~~
hgext/extlib/cstore/py-cstore.cpp: In function ‘void initcstore()’:
/usr/include/python2.7/object.h:769:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ((PyObject*)(op))->ob_refcnt++)
                      ^
hgext/extlib/cstore/py-cstore.cpp:37:3: note: in expansion of macro ‘Py_INCREF’
   Py_INCREF(&cdatapack_type);
   ^~~~~~~~~
/usr/include/python2.7/object.h:769:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ((PyObject*)(op))->ob_refcnt++)
                      ^
hgext/extlib/cstore/py-cstore.cpp:45:3: note: in expansion of macro ‘Py_INCREF’
   Py_INCREF(&treemanifestType);
   ^~~~~~~~~
/usr/include/python2.7/object.h:769:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ((PyObject*)(op))->ob_refcnt++)
                      ^
hgext/extlib/cstore/py-cstore.cpp:53:3: note: in expansion of macro ‘Py_INCREF’
   Py_INCREF(&datapackstoreType);
   ^~~~~~~~~
/usr/include/python2.7/object.h:769:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ((PyObject*)(op))->ob_refcnt++)
                      ^
hgext/extlib/cstore/py-cstore.cpp:61:3: note: in expansion of macro ‘Py_INCREF’
   Py_INCREF(&uniondatapackstoreType);
   ^~~~~~~~~
```

Explicitly suppressing warnings might break older gcc that does not support
those flags. Ideally the fix would be changing the source code. But in this
case it's in a library that cannot be easily fixed here in this repo.

Therefore just remove `-Werror`.


Test Plan: Confirm `make build` works after the change.

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham

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

Signature: 6695948:1515633376:67f40f0489b69a70700e181313d8ad837a76a2c9
2018-01-10 11:49:09 -08:00
Mark Thomas
88ed13464d rpm: update spec file for new build locations
Summary: Update RPM spec file to refer to the new locations.

Test Plan: Build an RPM (once @phillco's changes are in).

Reviewers: phillco, quark, #mercurial

Reviewed By: quark

Subscribers: quark

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

Tasks: T24908724

Signature: 6699351:1515632202:96f72e961f3bc5d501cb6fb1a945949e220b970b
2018-01-10 17:05:49 -08:00
Mateusz Kwapich
f98fdd4963 hgsubversion: fix help test
Summary:
This test discovers what python files are available and ensures help
text is available. Since hgsubversion is now in the repo, we need to enable it
so `hg help subversion` works.

Test Plan: Ran the tests

Reviewers: singhsrb, #mercurial

Reviewed By: singhsrb

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

Signature: 6698628:1515629061:5cc01e14e6884010e76608f51dbc675d79374568
2018-01-10 16:20:37 -08:00
Mateusz Kwapich
c2f660f16f hgsubversion: add to main setup.py
Summary: Adds to setup.py so it gets copied in the build.

Test Plan: make local

Reviewers: quark, singhsrb, #mercurial

Reviewed By: quark, singhsrb

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

Signature: 6698615:1515628425:85db99ed0dca711fb22b37216d7fbb3aa972ee8f
2018-01-10 16:20:27 -08:00
Durham Goode
96101c63b5 moreversion: move to hgext/
Summary:
Moves the moreversion extension to hgext/ and updates the core setup.py
to process it. Eventually we should get rid of this and store the version number
as the normal Mercurial number, but that can happen later.

Test Plan:
make local && ./hg version
Mercurial Distributed SCM (version 4.4.2+8922-aa235b4cbeac+20180110)
Facebook Mercurial release: UNKNOWN-RELEASE

Reviewers: phillco, #mercurial

Reviewed By: phillco

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

Signature: 6696199:1515621476:7835f9110ec143737c488faf49cf547eee8f918e
2018-01-10 16:16:45 -08:00
Ryan McElroy
4488942ef2 infinitepush: move infinitepush from fb-hgext to hgext
Summary:
This is part of the overall plan to move extensions from fb-hgext to
hgext. Follow up commits will address some of the test issues and move the
infinitepush related tests out of fb-hgext to hgext.

Test Plan: Ran all the tests.

Reviewers: rmcelroy, #mercurial, #sourcecontrol

Reviewed By: rmcelroy

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

Signature: 6691670:1515578586:8d7836aebb474856559c6dbe6fe2f572c8bdf7f1
2018-01-10 08:10:27 -08:00
Kostia Balytskyi
8159540c93 setup.py: add windows conditioning
Summary: This makes fb_build_nupkg.py work again on Windows.

Test Plan:
- run `python fb_build_nupkg.py clean build --release test`
- run `.\build\hg\hg.exe sl` and some similar commands, see things pass

Reviewers: rmcelroy, #sourcecontrol

Reviewed By: rmcelroy

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

Signature: 6692551:1515591647:b23106a6a4bbd7b6443512cc6f4514c8092b78d8
2018-01-10 05:51:25 -08:00
Mark Thomas
75980fb243 build: vendor in Rust dependencies
Summary:
Rust dependencies are vendored in by downloading a package containing all Rust
dependencies.

The package can be updated using the new `vendorcrates.py` script.

Test Plan: Build using the vendored packages.

Reviewers: quark, #mercurial

Reviewed By: quark

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

Tasks: T24908724

Signature: 6689642:1515548647:8051ec3dadd98873f0312bb67978846ba029b558
2018-01-09 17:48:32 -08:00
Jun Wu
898d4e21c5 setup: make rust a hard dependency
Summary:
This reduces the number of situations we have to think about, like whether to
enable clindex, treedirstate or not.

Test Plan: `make local`

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham, mbthomas

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

Signature: 6687198:1515543062:c4202564bce0f602ad4f898c23c9eeadd635aa3d
2018-01-09 13:44:53 -08:00
Durham Goode
3435e3fb82 cfastmanifest: move into hgext.extlib module 2018-01-09 15:23:52 -08:00
Saurabh Singh
6fbc1896e9 setup: remove unused import itertools
Summary: This was being reported by the test-check-pyflakes.t

Test Plan: Ran test-check-pyflakes.t.

Reviewers: phillco, #mercurial, #sourcecontrol

Reviewed By: phillco

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

Signature: 6687882:1515537725:e00da283e422ea363d11abd20cc63277bbe5cd9b
2018-01-09 14:42:45 -08:00
Jun Wu
dcbc5e9b19 setup: remove mercurial.cyext package
It was moved to other places.
2018-01-09 13:47:44 -08:00
Jun Wu
fc29bfdf18 patchrmdir: move to hgext
Summary: Also make it compatible with Windows by making it a no-op on Windows.

Test Plan:
`make local` and try from IPython:

```
In [1]: from hgext import patchrmdir

In [2]: os.rmdir
Out[2]: <function posix.rmdir>

In [3]: patchrmdir.uisetup(None)

In [4]: os.rmdir
Out[4]: <functools.partial at 0x375f580>
```

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham, fried

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

Signature: 6681125:1515523144:e186b45978d4a82ec8a0d18a02b0a524fca1c3b3
2018-01-08 19:25:13 -08:00
Jun Wu
a5976a9d50 traceprof: move to hgext and make it more portable
Summary:
Get rid of `gettimeofday` and switch to C++11 `std::chrono` for Windows/rare
platform compatibility.

Also format the code using clang-format.

Test Plan:
Make sure it build on both x64 and Power8 platform.
`make local` and try it in IPython:

```
In [1]: from hgext import traceprof

In [2]: def f():
   ...:     g(1)
   ...:

In [3]: def g(x):
   ...:     print(x+1)
   ...:

In [4]: from mercurial import ui

In [7]: with traceprof.profile(ui.ui(), sys.stderr):
   ...:     f()
   ...:
2
    | <module>                                  ipython2:3
    | start_ipython                             IPython/__init__.py:93
    | launch_instance                           application.py:650
    | start                                     ipapp.py:342
    | mainloop                                  interactiveshell.py:479
    | interact                                  interactiveshell.py:459
    | run_cell                                  interactiveshell.py:2591
    | run_ast_nodes                             interactiveshell.py:2770
    | run_code                                  interactiveshell.py:2851
    | <module>                                  <ipython-input-7-2e5a012739d1>:1
    | __exit__                                  contextlib.py:21
Total time: 0 ms
```

Note: it crashes on Windows, which will be workarounded in a later patch.

Reviewers: rmcelroy, #mercurial

Reviewed By: rmcelroy

Subscribers: fried

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

Tags: aarch64

Signature: 6681062:1515488414:6b7a51eda9e9764560d415350630590e4817fae2
2018-01-08 17:45:51 -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
Jun Wu
a50053ffbe cython: build all extensions by default
Summary: clindex does not use any POSIX APIs so it can work on Windows.

Test Plan: `make local` on both Windows and Linux.

Reviewers: durham, #mercurial

Reviewed By: durham

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

Signature: 6684821:1515523520:aa48d4669fe658563f9457fc1a6194ec7fadd937
2018-01-09 10:33:45 -08:00
Durham Goode
60349dec1e tests: fix some broken tests
The rust directory should be removed. fastmanifest should've had a module added
to setup.py. I accidentally moved a fastmanifest test in my earlier commit, so I
need to update it.
2018-01-09 12:58:51 -08:00
Durham Goode
fbed515666 setup: add directory modules to setup.py
setup.py needs an explicit list of all the directory modules, otherwise it
doesn't build them. This caused test-help to fail when run without -l because
they weren't copied to the target directory. I'm not sure how the tests have
been passing actually. My guess is they were importing the extensions from the
system python.
2018-01-09 12:38:05 -08:00
Saurabh Singh
9da30944be cfastmanifest: move to hgext/extlib/
Summary:
Moves ctreemanifest into hgext/extlib/. D6679698 was committed to scratch branch
by mistake.

Test Plan: make local && cd tests && ./run-tests.py

Reviewers: durham, #mercurial, #sourcecontrol

Reviewed By: durham

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

Signature: 6684623:1515522634:9bec363d00990d9ff7d5f655e30ab8cae636155c
2018-01-09 10:36:54 -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
Kostia Balytskyi
0904c08353 cython: do a minor refactoring of cythonization logic
Summary: Just a preparation to be used later.

Test Plan: - it builds!

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6683664
2018-01-09 08:42:20 -08:00
Durham Goode
fe980ff373 remotefilelog: move to hgext/
Summary:
Moves the remotefilelog extension into hgext/ and it's tests into
tests/.

I did not fix up all the check-module errors, since it's a ton of work for
very little impact at this point.

Test Plan: make local && ./run-tests.py

Reviewers: #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D6680030
2018-01-08 18:58:08 -08:00
Durham Goode
228e6a901e cstore: move to hgext/extlib/
Summary: Moves cstore to hgext/extlib/ and makes it build.

Test Plan: make local && run-tests.py

Reviewers: #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D6678852
2018-01-08 17:55:53 -08:00
Durham Goode
eb099b7fe1 cdatapack: move to lib/
Summary:
This moves the cdatapack code to the new lib/ directory and adds it to the main
setup.py.

Test Plan: hg purge --all && make local && cd tests && ./run-tests.py -S -j 48

Reviewers: #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D6677491
2018-01-08 17:55:53 -08:00
Jun Wu
0e18bfbbfa absorb: move to hgext
Summary: Move absorb to hgext.

Test Plan: `run-tests.py -l` with empty `PYTHONPATH`.

Reviewers: durham, #mercurial

Reviewed By: durham

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

Signature: 6678562:1515455701:8778bc0ce54ec017483f6826a9792bebcb9464d7
2018-01-08 13:57:01 -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
Mark Thomas
2e81565606 fb-hgext: integrate rust libraries and extensions with setup.py
Summary:
Move the rust libraries and extensions to their new locations, and integrate
them with the hg-crew setup.py.

Test Plan: Run `python setup.py build` and verify rust extensions are built.

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: fried, jsgf, mitrandir

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

Tasks: T24908724

Signature: 6677251:1515450235:920faf40babbce9b09e3283ff9ca328d1c5c51e6
2018-01-08 15:26:24 -08:00
Durham Goode
1ab0bb112d sha1: add sha1detectcoll library to setup.py
Summary:
cdatapack depends on sha1detectcoll, so let's add the library to setup.py before
we add cdatapack.

Test Plan:
hg purge --all && make local && cd tests/ && ./run-tests.py -S -j 48

Verified sha1dc was in the build output and the tests passed.

Reviewers: quark, #mercurial

Reviewed By: quark

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

Signature: 6676405:1515444508:2da65c6c3a18267a1d3c151c8e9acf60b674ffc2
2018-01-08 12:54:57 -08:00
Kostia Balytskyi
df1532996b windows: always build binaries with debug symbols in
(grafted from 67f37c3d0b13b68d2ec67c60ad4a49887a802dd1)
(grafted from 61cf4ec0aa662a3507aeaad5cec44037ac6956f2)
(grafted from 28de205abf73aba41723bc38e408d2939cefe2fb)
(grafted from 4498771b2622cf1aa3f1278f8e33b9e30c260f39)
(grafted from 2a32eb250049968c2d22c53c59be0973990543cb)
(grafted from ed1bf875a7d869508ec98c033fcb2f425d0bc521)
(grafted from 78e9a3e2a3667ac33251a769f9924a0352c84829)
(grafted from f608e564b0698a7704bbc041576a2472a8f15ccb)
(grafted from 2cab324128a009ad4d2e889ed25d283b1ed8d2ae)
2018-01-03 05:35:56 -08:00
Yuya Nishihara
2271f07b40 setup: convert version strings to unicode on Python 3
Fixes the following error:

  stderr from 'hg log -T x
   -r only(.,'b'4.4.2'')':
  b'  hg: parse error at 10: unexpected token: symbol'
2017-12-05 21:31:01 +09:00
Gregory Szorc
32f7e24bb4 setup: only write some autogenerated files if they change
Without this change, setup.py always writes some files on every
invocation. This prevents some builds from being a no-op when they
should. And, since times can sneak into generated .pyc files,
this prevents file content from being deterministic between
builds.

As part of the refactor, we treat file content as bytes.

The only potential regression from this would be if some tool
is looking at mtimes of the changed files to determine if
further action should be taken. But I don't think anything
critically important is keyed off the mtimes of these specific files.

Differential Revision: https://phab.mercurial-scm.org/D1580
2017-12-03 20:55:35 -08:00
Augie Fackler
31e42fb8de setup: add hgext.lfs to list of Python packages
This is needed for lfs to get installed. Probably could stand to go
into an earlier patch, but I just want to get this stuff pushed.
2017-11-20 18:00:02 -05:00
Kevin Bullock
6264723128 setup: filter out devel-warn messages from system hg
If we're going to use the user's installed and configured hg command
(which we do since a4a6cb293e63), we should prevent devel-warn messages
from interfering with locating it.
2017-10-23 22:13:59 -05:00
Kevin Bullock
1a166f93b9 setup: remove duplicate assignment of HGRCPATH
HGRCPATH is already set in localhgenv().
2017-10-23 21:30:59 -05:00
Kostia Balytskyi
830885ea92 windows: add an experimental option for long paths support
This commit adds an experimental --long-paths-support flag to build_hgexe
on Windows. It is off by default, but when supplied, causes setup.py to
embed some XML into the generated hg.exe, which in turn tells Windows to
allow this exe to use long paths (given that the appropriate registry setting
is enabled as well).
This was tested on Windows 10 14393 and 15063.

This commit introduces a badly-named initialize_options function, but its name
is dictated by distutils, rather than chosen.

# no-check-commit
2017-10-09 02:30:23 -07:00
Siddharth Agarwal
d801d9577c thirdparty: vendor attrs
The attrs package allows defining namedtuple-like classes with no weird
behavior and no runtime performance cost.

This patch vendors in attrs 17.2.0.

# no-check-commit

Differential Revision: https://phab.mercurial-scm.org/D867
2017-10-01 04:14:16 -07:00
Sean Farley
e18a90ab08 merge with stable 2017-08-21 21:35:06 -07: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
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
33738d760a setup: forcibly include cext/pure packages in py2exe (issue5625)
Since these modules are implicitly imported by policy.importmod(), py2exe
can't track them statically. cffi modules are excluded for now because they
wouldn't be useful in frozen (i.e. CPython) environment.
2017-07-20 22:47:40 +09:00
Yuya Nishihara
6a9bb7fcb6 setup: do not select hg executable that prints unexpected warnings
Otherwise the subsequent hg.run() would fail. This factors out the filtering
function so the same rule should apply.
2017-07-20 22:32:37 +09:00
Augie Fackler
ced1b0963a setup: fix mistake that prevented Python 3 from being excluded
My intent was to only allow Python 3 if the right environment variable
is set (for when people want to use `pip install .` on hg
locally). This fixes the bug in my previous change. I verified that
`python3.6 run-tests.py` still passes the tests that passed before,
and that all tests pass on 2.7 (including our virtualenv-using
installation test).

Differential Revision: https://phab.mercurial-scm.org/D185
2017-07-26 13:21:34 -04:00
Yuya Nishihara
c49455b105 setup: drop use of set literal so parsable on Python 2.6
Otherwise friendly error wouldn't be displayed.
2017-07-26 23:39:42 +09:00
Augie Fackler
527e838b00 setup: add extra logic to try and recommend a new pip on bad Python
Modern pip can detect supported Python versions (which we now
declare), and pull down a reasonable release. This trick was suggested
in http://bit.ly/pycon2017-build-bridges, and seems like a good
defensive maneuver so that when we want to move to Python 3 it's
less risky for existing users.

This moves the version-check logic after defining our printf function
so we can print more informative messages.
2017-07-21 10:46:31 -04:00
Augie Fackler
4b55d62a6d setup: explicitly declare supported Python versions
I think we should probably backport this to 4.2 as well, and do one
more release there that explicitly declares 2.6 support. That way
anyone stuck on Python 2.6 will end up getting the right hg if they
use a modern pip to install. Users can still use `python setup.py`
incantations to attempt installing Mercurial on unsupported Pythons,
including 3.5 and 3.6.

A followup change will switch to only doing our own
Python-version-check logic if we're not being installed by a
reasonable pip.
2017-07-21 10:39:52 -04:00
Yuya Nishihara
b32d207c09 cext: factor out header for charencode.c
This merges a part of util.h with the header which should exist for
charencode.c.
2017-05-21 14:23:22 +09:00
Yuya Nishihara
20afdd710d cext: split character encoding functions to new compilation unit
This extracts charencode.c from parsers.c, which seems big enough for me
to hesitate to add new JSON functions. Still charencode.o is linked to
parsers.so to avoid duplication of binary codes.
2017-07-31 22:28:27 +09:00
Adam Simpkins
f7ebee7cc9 setup: fix runcmd() usage on darwin
Fix one invocation of runcmd() that was missed in the recent change to
make runcmd() also return the process exit status.
2017-06-28 10:50:37 -07:00
Jun Wu
d6d4c8725e setup: fix localhgenv
It should return env as a dict instead of None.
2017-06-28 06:49:01 -07:00
Adam Simpkins
03e07a8e3b setup: prefer using the system hg to interact with the local repository
Add a findhg() function that tries to be smarter about figuring out how to run
hg for examining the local repository.  It first tries running "hg" from the
user's PATH, with the default HGRCPATH settings intact, but with HGPLAIN
enabled.  This will generally use the same version of mercurial and the same
settings used to originally clone the repository, and should have a higher
chance of working successfully than trying to run the hg script from the local
repository.  If that fails findhg() falls back to the existing behavior of
running the local hg script.
2017-06-27 16:15:32 -07:00
Adam Simpkins
6ae0f95e37 setup: replace runhg() with an hgcommand helper class
Replace the runhg() function with an hgcommand helper class.  hgcommand has as
run() function similar to runhg(), but no longer requires the caller to pass in
the exact path to python and the hg script, and the environment settings for
invoking hg.

For now this diff contains no behavior changes, but in the future this will
make it easier for the hgcommand helper class to more intelligently figure out
the proper way to invoke hg.
2017-06-27 16:15:32 -07:00
Adam Simpkins
5be8308b27 setup: move environment computation into a helper function
Add a helper function to compute the environment used for invoking mercurial,
rather than doing this computation entirely at global scope.  This will make it
easier to do some subsequent refactoring.
2017-06-26 11:31:30 -07:00
Adam Simpkins
f8d4797904 setup: update runcmd() to also return the exit status
Update the runcmd() helper function so it also returns the process exit status.
This allows callers to more definitively determine if a command failed, rather
than testing only for the presence of data on stderr.

I don't expect this to have any behavioral changes for now: the commands
invoked by setup generally should print data on stderr if and only if they
failed.
2017-06-26 11:31:30 -07:00
Adam Simpkins
1234fecf66 setup: fail if we cannot determine the version number
If running hg fails, exit the setup script unsuccessfully, rather than
proceeding to use a bogus version of "+0-".  Using an invalid version number
causes various tests to fail later.  Failing early makes it easier to identify
the source of the problem.

It is currently easy for setup.py to fail this way since it sets HGRCPTH to the
empty string before running "hg", which may often disable extensions necessary
to interact with the local repository.
2017-06-26 11:31:30 -07:00
Pulkit Goyal
bfb91c2ff5 py3: slice over bytes to prevent getting it's ascii value 2017-06-25 08:36:51 +05:30
Matt Harbison
6de437e52f setup: update a comment that blamed py26 for a Windows workaround 2017-06-16 21:57:22 -04:00
Matt Harbison
fcd2a4509b plan9: drop py26 hacks 2017-06-16 18:42:03 -04:00
Matt Harbison
34475a04af setup: avoid linker warnings on Windows about multiple export specifications
The PyMODINIT_FUNC macro contains __declspec(dllexport), and then the build
process adds an "/EXPORT func" to the command line.  The 64-bit linker flags
this [1].

Everything except zstd.c and bser.c are covered by redefining the macro in
util.h [2].  These modules aren't built with util.h in the #include path, so the
redefining hack would have to be open coded two more times.

After seeing that extra_linker_flags didn't work, I couldn't find anything
authoritative indicating why, though I did see an offhand comment on SO that
CFLAGS is also ignored on Windows.  I also don't fully understand the
interaction between msvccompiler and msvc9compiler- I first subclassed the
latter, but it isn't used when building with VS2008.

I know the camelcase naming isn't the standard, but the HackedMingw32CCompiler
class above it was introduced 5 years ago (and I think the current style was
in place by then), so I assume that there's some reason for it.

[1] https://support.microsoft.com/en-us/help/835326/you-receive-an-lnk4197-error-in-the-64-bit-version-of-the-visual-c-compiler
[2] https://bugs.python.org/issue9709#msg120859
2017-06-09 22:15:53 -04:00
Augie Fackler
f5d193d3cd setup: introduce dummy copies of setuptools flags
Since we're filtering out some egg gunk, we need to emulate these
flags which disable eggs so that pip still works.
2017-06-06 11:02:30 -04:00
Yuya Nishihara
4bbb13514b setup: do not overwrite local __modulepolicy__.py on out-of-source build
Since the default policy is selected depending on setup options, "make install"
shouldn't overwrite in-source __modulepolicy__.py generated by "make local".
2017-06-03 14:05:52 +09:00
Matt Harbison
db34f3fbb0 setup: prevent setuptools from laying an egg
Previously, test-hghave.t was failing on Windows (and on Linux if
$FORCE_SETUPTOOLS was set) with the following:

  --- c:/Users/Matt/Projects/hg/tests/test-hghave.t
  +++ c:/Users/Matt/Projects/hg/tests/test-hghave.t.err
  @@ -19,7 +19,11 @@
     >   foo
     > EOF
     $ run-tests.py $HGTEST_RUN_TESTS_PURE test-hghaveaddon.t
  +  warning: Testing with unexpected mercurial lib: c:\Users\Matt\Projects\hg\mercurial
  +           (expected ...\hgtests.mu9rou\install\lib\python\mercurial)
     .
  +  warning: Tested with unexpected mercurial lib: c:\Users\Matt\Projects\hg\mercurial
  +           (expected ...\hgtests.mu9rou\install\lib\python\mercurial)

Augie relayed concerns[1] about the first attempt at this, which also excluded
'install_egg_info'.  All that needs to be excluded to avoid the egg and make the
test work is to filter out 'bdist_egg'.  (Actually, the body of this class could
simply be 'pass', and 'bdist_egg' still isn't run.  But that seems to magical.)

Also note that prior to this (and still now), `make clean` doesn't delete the
'mercurial.egg-info' that is generated by `make install`.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097668.html

# no-check-commit
2017-05-07 23:29:03 -04:00
Yuya Nishihara
fa3c51ef73 cffi: put compiled modules into mercurial.cffi package
Don't pollute the top-level namespace.
2017-05-02 21:08:38 +09:00
Yuya Nishihara
5cccfd11fb cffi: rename build scripts
This frees up cffi package for modules to be split from pure.
2017-05-02 21:04:40 +09:00
Siddharth Agarwal
a41c665cd6 demandimport: move to separate package
In Python 3, demand loading is per-package. Keeping demandimport in the
mercurial package would disable demand loading for any modules in
mercurial.
2017-05-21 12:10:53 -07:00
Yuya Nishihara
79ebd14e1e cext: move util.h to cext tree
Since util.h isn't useful in plain C module, it should be placed in CPython
extension directory.
2017-05-21 13:35:19 +09:00
Gregory Szorc
9e19911eaa cext: extract revlog/index parsing code to own C file
parsers.c is ~3000 lines and ~2/3 of it is related to the revlog
index type.

We already have separate C source files for directory utilities
and manifest parsing. I think the quite unwieldy revlog/index
parsing code should be self-contained as well.

I performed the extraction as a file copy then removed content
from both sides in order to preserve file history and blame.

As part of this, I also had to move the hexdigit table and
function to a shared header since it is used by both parsers.c
and revlog.c

# no-check-commit
2017-05-20 14:01:05 -07:00
Yuya Nishihara
4563e16232 parsers: switch to policy importer
# no-check-commit
2016-08-13 12:23:56 +09:00
Yuya Nishihara
5fe7742660 mpatch: switch to policy importer 2016-08-13 12:18:58 +09:00
Yuya Nishihara
6130be9a6c diffhelpers: switch to policy importer
# no-check-commit
2016-08-13 12:15:49 +09:00
Yuya Nishihara
50b316b748 bdiff: switch to policy importer
# no-check-commit
2016-08-13 12:12:50 +09:00
Yuya Nishihara
a9b78ccb21 base85: switch to policy importer 2016-08-13 12:08:23 +09:00
Yuya Nishihara
70995f9aa9 osutil: switch to policy importer
"make clean" is recommended to test this change, though C API compatibility
should be preserved.
2016-08-12 11:35:17 +09:00
Yuya Nishihara
2fe12e4917 policy: relax the default for in-place build
We're going to make the 'c' policy more strict, where no missing attribute
will be allowed. Since we want to run 'hg bisect' without rebuilding the C
extension modules, we'll need a looser policy for development environment.

The default for system installation isn't changed.

Note that the current 'c' policy is practically 'allow'-ish as we have lots
of adhoc fallbacks to pure functions.
2017-04-26 23:02:43 +09:00
Gregory Szorc
c950654a68 setup: drop support for Python 2.6 (BC)
Per discussion on the mailing list and elsewhere, we've decided that
Python 2.6 is too old to continue supporting. We keep accumulating
hacks/fixes/workarounds for 2.6 and this is taking time away from
more important work.

So with this patch, we officially drop support for Python 2.6 and
require Python 2.7 to run Mercurial.
2017-05-02 16:19:04 -07:00
Yuya Nishihara
276d62703a policy: add "cext" package which will host CPython extension modules
I'm going to restructure cext/pure modules and get rid of our hgimporter
hack. C extension modules will be moved to cext/ directory so old and new
compiled modules can coexist in development tree. This is necessary to
run 'hg bisect' without recompiling.

New extension modules will be loaded by an importer function:

  base85 = policy.importmod('base85')  # select pure.base85 or cext.base85

This will also allow us to split cffi from pure modules, which is currently
difficult because pure modules can't be imported by name.
2016-08-12 11:06:14 +09:00
Alex Gaynor
7152638545 setup: sys.version_info always exists
It is documented as existing since Python 2.0, and empirically from
other OSS projects I maintain, there is no problem relying on its
existance.
2017-05-03 09:41:55 -04:00
Jun Wu
3633e80713 statfs: change Linux feature detection
Previously we check three things: "statfs" function, "linux/magic.h" and
"sys/vfs.h" headers. But we didn't check "struct statfs" or the "f_type"
field. That means if a system has "statfs" but "struct statfs" is not
defined in the two header files we check, or defined without the "f_type"
field, the compilation will fail.

This patch combines the checks (2 headers + 1 function + 1 field) together
and sets "HAVE_LINUX_STATFS". It makes setup.py faster (less checks), and
more reliable (immutable to the issue above).
2017-03-24 14:59:19 -07:00
Jun Wu
b78b032c28 setup: use a more strict way to test BSD or OSX's statfs
We want to use the `f_fstypename` field to get the filesystem type. Test it
directly. The new macro HAVE_BSD_STATFS implys the old HAVE_SYS_MOUNT_H and
HAVE_SYS_PARAM_H. So the latter ones are removed.
2017-03-23 22:15:36 -07:00
Jun Wu
f1184d5119 setup: test some header files
The next patch will use "statfs", which requires different header files on
different platforms.

Linux:

    sys/vfs.h or sys/statfs.h

FreeBSD or OSX:

    sys/param.h and sys/mount.h

Therefore test them so we can include the correct ones.
2017-03-20 15:43:27 -07:00
Jun Wu
416be40974 setup: detect statfs
statfs is not defined by POSIX but is available in various systems to help
decide filesystem type. Let's detect it and set the macro HAVE_STATFS.
2017-03-20 15:11:18 -07:00
Jun Wu
1aec4664c3 setup: add a function to test header files 2017-03-20 15:31:21 -07:00
Jun Wu
ca75eb2417 setup: split "hasfunction" to test arbitrary code
The next patch wants to test include files.
2017-03-20 15:28:08 -07:00
Gregory Szorc
ebff74a01c setup: convert setupversion to unicode
Something deep in the bowels of distutils expects "version" passed to
setup() to be a str/unicode. So, convert the type.

This still works on Python 2 because the string is ascii and an
implicit coercion back to str/bytes should work without issue. If
it does cause problems, we can always make the unicode conversion
dependent on running Python 3.

This change makes `python3.5 setup.py install` work.
2017-03-11 17:14:02 -08: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
Gregory Szorc
8df619ffe0 setup: use setuptools on Windows (issue5400)
We've had a long, complicated history with setuptools. We want to
make it the universal default. But when we do, it breaks things.

`python setup.py build` is broken on Windows today. Forcing
the use of setuptools via FORCE_SETUPTOOLS=1 unbreaks things.

Since the previous bustage with making setuptools the default
was on !Windows, it seems safe to move ahead with the setuptools
transition on Windows. So this patch does that.
2017-03-09 19:59:52 -08:00
FUJIWARA Katsunori
2afd920706 misc: update year in copyright lines
This patch also makes some expected output lines in tests glob-ed for
persistence of them.

BTW, files below aren't yet changed in 2017, but this patch also
updates copyright of them, because:

    - mercurial/help/hg.1.txt

      almost all of "man hg" output comes from online help of hg
      command, and is already changed in 2017

    - mercurial/help/hgignore.5.txt
    - mercurial/help/hgrc.5

      "copyright 2005-201X Matt Mackall" in them mentions about
      copyright of Mercurial itself
2017-02-12 02:23:33 +09:00
FUJIWARA Katsunori
e6f91a13e7 misc: replace domain of mercurial ML address by mercurial-scm.org
This patch also adds new check-code.py pattern to detect invalid usage
of "mercurial@selenic.com".

Change for test-convert-tla.t is tested, but similar change for almost
same test-convert-baz.t isn't yet tested actually, because I couldn't
find out the way to get "GNU Arch baz client".

AFAIK, buildbot skips test-convert-baz.t, too. Does anybody have
appropriate environment for testing?
2017-02-11 00:23:53 +09:00
Gregory Szorc
e72b99afbe setup: pass named argument to setup_zstd
The next release from upstream adds another named argument to this
function. Specify arguments by name so there is no ambiguity about
which argument is being passed.
2017-01-04 19:17:44 -08:00
Gábor Stefanik
0ee701a6a4 setup: include a dummy $PATH in the custom environment used by build.py
This is required for building with pypiwin32, the pip-installable replacement
for pywin32.
2016-10-28 17:44:28 +02:00
Gregory Szorc
41b3cb270e setup: add flag to build_ext to control building zstd
Downstream packagers will inevitably want to disable building the
vendored python-zstandard Python package. Rather than force them
to patch setup.py, let's give them a knob to use.

distutils Command classes support defining custom options. It requires
setting certain class attributes (yes, class attributes: instance
attributes don't work because the class type is consulted before it
is instantiated).

We already have a custom child class of build_ext, so we set these
class attributes, implement some scaffolding, and override
build_extensions to filter the Extension instance for the zstd
extension if the `--no-zstd` argument is specified.

Example usage:

  $ python setup.py build_ext --no-zstd
2016-11-17 20:09:10 -08:00
Gregory Szorc
c746a321ba setup: compile zstd C extension
Now that zstd and python-zstandard are vendored, we can start compiling
them as part of the install.

python-zstandard provides a self-contained Python function that returns
a distutils.extension.Extension, so it is really easy to add zstd
to our setup.py without having to worry about defining source files,
include paths, etc. The function even allows specifying the module
name the extension should be compiled as. This conveniently allows us
to compile the module into the "mercurial" package so "our" version
won't collide with a version installed under the canonical "zstd"
module name.
2016-11-10 22:26:35 -08:00
Jun Wu
4df846b1cb setup: test setproctitle before building osutil
We are going to use setproctitle (provided by FreeBSD) if it's available in
the next patch. Therefore provide a macro to give some clues to the C
pre-processor so it could choose code path wisely.
2016-11-11 20:45:40 +00:00
Jun Wu
13e79c95ee setup: move cffi stuff to mercurial/cffi
This patch moves all setup*cffi stuff to mercurial/cffi to make the root
directory cleaner. The idea was from mpm [1]:

  > It seems like we could have a fair amount of cffi definitions, and
  > cluttering the root directory (or mercurial/) with them is probably not
  > a great long-term solution. We could probably add a cffi/ directory
  > under mercurial/ to parallel pure/.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-July/086442.html
2016-11-09 22:08:30 +00:00
Maciej Fijalkowski
a33764dd71 bdiff: implement cffi version of blocks 2016-07-28 14:17:08 +02:00
Maciej Fijalkowski
c98b11e3dd mpatch: write a cffi version of mpatch.patches 2016-07-25 15:10:52 +02:00
Maciej Fijalkowski
3bdeeb5959 mpatch: split mpatch into two files 2016-07-18 19:02:30 +02:00
Maciej Fijalkowski
b0e2d543a3 osutil: add darwin-only version of os.listdir using cffi 2016-07-11 11:05:08 +02:00
Maciej Fijalkowski
04dfc79402 bdiff: split bdiff into cpy-aware and cpy-agnostic part 2016-07-13 10:46:26 +02:00
Maciej Fijalkowski
b3d62e8a18 setup: prepare for future cffi modules by adding placeholder in setup 2016-07-11 10:44:18 +02:00