Summary:
Implement `linelog_annotate`, which is the core algorithm for generating
`linelog_annotateresult`. It is basically walking though and executing
the instructions.
Test Plan: `gcc -Wall -Wextra -Wconversion -c linelog.c`
Reviewers: #mercurial, ttung, simonfar
Reviewed By: simonfar
Subscribers: simonfar, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3629591
Tasks: 12416202
Signature: t1:3629591:1470157936:764bb7c5d1208e73d93d26063a8ad380dbceb495
Summary:
As mentioned in D3628571, the `.c` code manages the memory of
`linelog_annotateresult.lines`. We need a resize function for it.
Test Plan:
`gcc -Wall -Wextra -Wconversion -c linelog.c` and it only reports
"defined but not used" warnings.
Reviewers: #mercurial, ttung, simonfar
Reviewed By: simonfar
Subscribers: simonfar, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3629350
Tasks: 12416202
Signature: t1:3629350:1470055356:01993a6df2ccd849ed01961eb996c86bb0a17c78
Summary:
As described in the README (D3628440), the linelog buffer is an array of
instructions. The `.h` file only declares the plain buffer but not the
internal representation of the instruction. They are intended to be
invisible to users.
This diff declares the instruction structure, related types and helpers in
`linelog.c`. `decode` and `encode` translate between the internal (`.c`,
structured `linelog_inst`) and the external (`.h`, plain `linelog_buf`)
representation. Other macros are to help making code shorter and easier to
understand.
Test Plan: `gcc -Wall -Wextra -Wconversion -c linelog.c`
Reviewers: #mercurial, ttung, simonfar
Reviewed By: simonfar
Subscribers: simonfar, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3629132
Signature: t1:3629132:1470157631:4523c53a3af28061828980845d3acfbd82c58361
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