Commit Graph

4 Commits

Author SHA1 Message Date
Jun Wu
c14c36aa26 linelog.pyx: implement file buffer
Summary: The file buffer uses `mmap` for `linelog_buf::data`.

Test Plan: `cython2 linelog.pyx`

Reviewers: #mercurial, rmcelroy, ttung

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3662790:1470860125:b68fc5e3ed14d56fbebe8a7de81ad7f67a622875
2016-08-10 21:15:43 +01:00
Jun Wu
97079280bf linelog.pyx: implement memory buffer
Summary:
The memory buffer implements `_buffer.resize` using `realloc`,
making linelog useful for in-memory modifications. For example,
the `smartfixup` extension (D3264203) would use an in-memory
linelog to avoid expensive merge operations and possible merge
conflicts.

Test Plan: `cython2 linelog.pyx`

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Tasks: 11291522

Signature: t1:3655491:1470402602:891fade362c8e0f6a3af64f1fbdfa0fbf556e68b
2016-08-10 18:54:55 +01:00
Jun Wu
a4dd17d71c linelog.pyx: add a thin wrapper around linelog_buf
Summary:
The thin wrapper defines common APIs like `resize` `flush`, `close`, and
`copyfrom`. Some of them are used in sub-classes. It also handles
`LINELOG_RESULT_ENEEDRESIZE` and raise `LinelogError` for other errors.

Test Plan: `cython2 linelog.pyx`

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Tasks: 11291522

Signature: t1:3655463:1470402560:75e552ed3d6205ae45812d1cdfe7bc14cfb1eec3
2016-08-02 13:40:27 +01:00
Jun Wu
ce97ea9aaf linelog.pyx: declare linelog functions
Summary:
`linelog.pyx` is meant to be the CPython wrapper for linelog.

This diff declares types and functions in `linelog.h`.

According to http://docs.cython.org/en/latest/src/userguide/external_C_code.html,
we have to duplicate them as Cython cannot parse `.h` files.

Test Plan: `cython2 linelog.pyx`

Reviewers: #mercurial, ttung, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Tasks: 11291522

Signature: t1:3655437:1470336663:802ede2b82790a6c901ba0cc76c4f39fcac1e6ac
2016-08-02 13:21:08 +01:00