Summary:
The current linelog APIs are designed purely for the "annotate" operation.
It only supports getting lines from one single revisions, which is what
`annotate` does.
However the data structure is also useful to provide lines from different
revisions. Say if you want to know all lines from all revisions for a given
function. Or if you want to confirm if a chunk is "continuous" - nobody
inserts new lines among them. This diff adds the missing API, `getalllines`.
It returns information about all lines the linelog tracks. The caller could
provide an optional interval to limit the lines returned.
Its parameters use low-level raw offsets instead of line numbers, because it
gives the caller more control. The API don't need to handle open or close
interval issues that line numbers may have (see the previous diff about
deletion blocks).
This makes `lineinfo.offset` no longer internal-only - we have exposed the
offset concept to the API parameters. Therefore the comments are updated.
This also requires a clear way to distinguish unconditional jumps from
conditional one. We use `JGE 0` as unconditional jumps. To ensure this,
make `replacelines` reject 0 revision.
Test Plan: `cd linelog && make`
Reviewers: #mercurial, ttung, simonfar
Reviewed By: simonfar
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3716439
Signature: t1:3716439:1471265245:5a4b2f585284cba71ca3907c8e8826b2b00a4b49
Summary:
Declare core APIs for linelog:
- `annotate`, the "read" part
- `replacelines`, the "write" part
As mentioned in D3334518, this is part of a rewrite of D3334518.
These 2 APIs are the only ones involving core logic of the linelog structure.
Test Plan: `gcc -Wall -Wextra -Wconversion linelog.h`
Reviewers: #mercurial, zamsden, ttung, simonfar
Reviewed By: simonfar
Subscribers: akushner, zamsden, simonfar, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3628848
Tasks: 12416202
Signature: t1:3628848:1470080022:1f434d998c0bf63a494f70d47bc6a6fc05954446
Summary:
Declare some trivial APIs, which either clear the memory or return a value
without much calculation.
Test Plan: `gcc -Wall -Wextra linelog.h`
Reviewers: #mercurial, simonfar, ttung
Reviewed By: simonfar
Subscribers: simonfar, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3628681
Tasks: 12416202
Signature: t1:3628681:1469647679:437db1610dec8a21a71b2d94c64d6d085321e1cd
Summary:
Add essential data structures for upcoming APIs.
This is part of a rewrite of D3334518. The new API removes everything about
I/O (aka. `stdio.h`) and makes it the caller's responsibility to prepare
(`malloc` or `mmap`) and resize the memory buffer.
This makes it possible to have a much shorter (thus easier to review) code
more dedicated to core algorithm, as the following are no longer necessary:
- I/O related APIs: `open`, `close`, `flush`, `saveas`
- I/O error handling
The error handling part is also changed that we now can use integer error
numbers instead of a boolean value + an error string.
Test Plan: `gcc -Wall -Wextra linelog.h`
Reviewers: #mercurial, ttung, simonfar
Reviewed By: simonfar
Subscribers: durham, simonfar, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3628571
Tasks: 12416202
Signature: t1:3628571:1469643667:4fbf4fd7e624820ee6d8409e2067c8bd0e99a829