Commit Graph

14 Commits

Author SHA1 Message Date
Jun Wu
a72478f016 codemod: better #includes
Summary:
This patch removes all `#include "../` lines and use the shortest possible
include path.

Test Plan: `make clean build`

Reviewers: durham, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:5113672:1495565454:961fb6f2f57a81a95013e0b8f67b2917c2e4523e
2017-05-23 11:57:32 -07:00
Jun Wu
a63cbaaed1 portibility: move to clib
Summary:
It's a small C utility. It should belong to `clib` directory.

Also, `#include "../foo"` does not seem to be a good pattern. It makes
include files harder to follow and make code movement more difficult. Since
`clib` is already included in `-I` during compilation, remove `../`.

Test Plan: `make clean local`. It still builds.

Reviewers: ikostia, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, vsutaria

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

Signature: t1:5113236:1495562436:e8d64083ab0417c67b63223a092470739f4c1176
2017-05-23 11:47:40 -07:00
Jun Wu
80e40da9d6 sha1: switch to new implementation
Summary:
This diff changes our code to use the new SHA1 library. See the previous diff
for why we do this.

Test Plan:
Run related tests manually:

```
$ make local PYTHON=python2
$ rt test-remotefilelog-*.t
.........................
# Ran 25 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-treemanifest*.t
........
# Ran 8 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-fastmanifest*.t
.........
# Ran 9 tests, 0 skipped, 0 warned, 0 failed.
```

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4945025:1493154873:844e55a51ab250354fc08163e0949eed47b0a861
2017-04-25 14:53:32 -07:00
Wez Furlong
4a59f3b701 c-extensions: fixup some compiler/environment portability concerns
Summary:
I sync'd a copy of this code into the eden repository.
I had to adjust a couple of include paths to get the code to
compile correctly in the hermetic build environment that is
in use there.

In addition, our linter suite over there found a couple of C++ nits
to be fixed up.

Test Plan: make local

Reviewers: simpkins, ikostia, simonfar, durham

Reviewed By: durham

Subscribers: net-systems-diffs@fb.com, mjpieters

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

Signature: t1:4879285:1492039044:8cb1e033e35ee568806de94dda3d2f6f8e78f5cb
2017-04-12 16:34:53 -07:00
Kostia Balytskyi
918e1011b3 portability: use COMPOUND_LITERAL macro in place of actual compound literals
Summary:
This is a s//g replacement of all the `return (type_name) {` with
`return COMPOUND_LITERAL(type_name) {`.
This is the command which produced the diff:
`egrep 'return \(\w*\) \{' -Ir . --exclude='*.py*' --exclude-dir=.hg -l | xargs sed 's/return (\(\w*\)) {/return COMPOUND_LITERAL(\1) {/g' -i `

After I've done this, I checked:
`egrep '\(\w+\) \{' -Ir . --exclude='*.py*' --exclude-dir=.hg | egrep -v '(switch|while)' | grep -v 'if (' | grep -v 'COMPOUND_LITERAL' | less`
and it looks like the only things of `(something) {` syntax are function definitions, adding space before `(` in search pattern yields no results.

This is needed to make this compile on Windows under MSVC2015.

Depends on: D4843230

Test Plan:
- run `python setup.py build -f`, see it compile
- run all the tests, see them pass

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4843240:1491495690:a097bfab403805052d5ac25d1db7bb32af3bca28
2017-04-06 09:34:40 -07:00
Kostia Balytskyi
67b7f56ddb portability: add a portability header
Summary:
Proposed header (or its dir) is a single place to put MSVC/GCC hacks. So
far it only includes the COMPOUND_LITERAL macro which behaves differently
depending on MSVC mode.
When MSVC2015 is used in C++ mode, it does not support things like:
`(my_type) {initializers}`, but in C mode it does.

To clarify: I am not even sure whether we need to have the ability to compile in a purely C mode, but I did not want to figure out.

Test Plan: - on Linux, run `python setup.py build`, run all the tests, see them passing

Reviewers: #sourcecontrol, tja

Reviewed By: tja

Subscribers: tja, jsgf, mjpieters

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

Signature: t1:4843230:1491496062:3fa10ae5a5aac850689991de1ca6ee1ac86d9dce
2017-04-06 09:33:34 -07:00
Tony Tung
2b3e7ac198 port upgrades of buffer.h into clib
Summary:
buffer.h gained the ability to deal with non-char-sized buffers when I built cdatapack.  We need to update the callers in ctreemanifest to be aware of this.  Most of this is done with macro magic.

Some functionality was dropped from cdatapack's buffer.h (macro definitions to deal with paths).  Those are moved to path_buffer.h

Test Plan:
make local && clion build.
pass cfastmanifest unit tests.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3780767:1472255278:40a19edfd171df5804e9cdfa4444d5c6386f00e8
2016-08-26 17:14:52 -07:00
Tony Tung
2f5e85ccb8 move common code to clib
Test Plan: make local && build in clion

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3780622:1472250774:fa702d78dab39eb74c8de58c0d589ae36a2c42b3
2016-08-26 15:45:43 -07:00
Tony Tung
56aaa74bc9 collapse all the build files into one
Summary: One giant CMake file.  Only I use CLion, so i don't think this affects anyone else.

Test Plan: make in clion. run cfastmanifest unit tests.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir, mjpieters

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

Signature: t1:3780573:1472250750:ece55fb66a656624335c8432ab3c8334699ea36e
2016-08-26 15:41:33 -07:00
Tony Tung
a7555791cd [fastmanifest] fix unhexlify
Summary:
Strictly speaking, it doesn't care if it's the length is SHA1_BYTES * 2.  It just has to be even.

Also, size_t comes from stddef.h.

Test Plan: make local

Reviewers: durham, lcharignon

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3626828
2016-08-02 15:35:49 -07:00
Tony Tung
b0604f946a [fastmanifest] utility to dump some specs about a tree to disk
Test Plan: run tree_dump on a fastmanifest file.  did some spot checks against the text manifest with the same sha (`hg debugdata -m`)

Reviewers: lcharignon, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Tasks: 12119301

Signature: t1:3585843:1469050470:70729d5601f935f2de80f89a7ad83590bcb8dd00
2016-07-26 23:35:53 -07:00
Tony Tung
3cb14683b0 [fastmanifest] enforce strict prototypes
Summary: Newer versions of gcc (5.x) turn on `-Wstrict-prototype` by default.  Turn this on in our setup.py file for older compilers, and fix the errors that crop up from this.

Test Plan: make local

Reviewers: tnardone, wez, lcharignon

Reviewed By: lcharignon

Subscribers: mitrandir, mjpieters

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

Signature: t1:3414620:1465514102:d91026062582e2a3ab3fc773bbf17686fa38609f
2016-06-09 22:45:05 -07:00
Tony Tung
ca3c7733aa [fastmanifest] fix buffer expansion in tree conversion code
Summary:
# We need to track the enlarged buffer capacity.  If not, we will never enlarge the buffer again.
# The realloc was undersizing the buffer.

Test Plan:
successfully convert the opsfiles manifest using valgrind + test_convert_rt.

run `hg --config=extensions.fastmanifest= debugcache --all` on opsfiles-hg

Reviewers: wez, durham, lcharignon

Reviewed By: lcharignon

Subscribers: mitrandir, mjpieters

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

Signature: t1:3369621:1464792791:4bc83c39c0355644a0933b2ea3f544fd99894698
2016-06-01 09:27:17 -07:00
Tony Tung
fc8c0d61a1 [fastmanifest] rename fastmanifest c library directory to cfastmanifest
Summary: This allows us to use fastmanifest as a directory to drop in the python module.

Test Plan: compiles, passes existing tests.

Reviewers: lcharignon

Reviewed By: lcharignon

Subscribers: mitrandir, mjpieters

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

Signature: t1:3351021:1464284417:6cbcde514ab1fd7b5caa6c83cb5577f3502dbc58
2016-05-26 11:33:07 -07:00