Commit Graph

9 Commits

Author SHA1 Message Date
Jun Wu
978c03ef18 linelog: implement linelog_annotate
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
2016-07-27 19:37:41 +01:00
Jun Wu
28e914db8e linelog: implement trivial APIs
Summary: Implement the trivial APIs declared in D3628681.

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/D3629389

Tasks: 12416202

Signature: t1:3629389:1470087604:5b5a536630a6866df52d51fd163ed8f5301c734b
2016-07-27 19:25:31 +01:00
Jun Wu
a84fdfb62a linelog: add a helper function to resize linelog_annotateresult.lines
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
2016-07-27 19:16:03 +01:00
Jun Wu
ac5824243b linelog: add types and helpers for internal linelog instruction structure
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
2016-07-27 19:31:59 +01:00
Jun Wu
f918aa6566 linelog: declare core APIs
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
2016-07-29 00:49:38 +01:00
Jun Wu
d268bb5675 linelog: declare trivial APIs
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
2016-07-27 17:54:07 +01:00
Jun Wu
4f76b602eb linelog: declare data structures
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
2016-07-27 17:39:20 +01:00
Jun Wu
68e5a15af7 linelog: add a README explaining the file format
Summary: This should help reviewers.

Test Plan: Run some spell checkers.

Reviewers: #mercurial, simonfar, ttung

Reviewed By: simonfar

Subscribers: mpm, akushner, ikostia, simonfar, mjpieters

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

Tasks: 12416202

Signature: t1:3628440:1469640270:a44f682e22b59615d0d9f12c93417c905b035ab6
2016-07-27 17:12:15 +01:00
Jun Wu
6fa80e5cca linelog: add empty source files
Summary: Add (almost) empty `.c` and `.h` files with uninteresting headers.

Test Plan: Code review

Reviewers: #mercurial, mitrandir, ttung

Reviewed By: mitrandir

Subscribers: mjpieters

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

Tasks: 12416202

Signature: t1:3620623:1469560977:d05a2781499783a2238f602025e6765ad52c6f00
2016-07-26 16:58:19 +01:00