Commit Graph

12 Commits

Author SHA1 Message Date
Jun Wu
c41d432bb1 fastannotate: move to hgext3rd
Summary: Extensions should belong there.

Test Plan: Updated existing tests

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:5113146:1495562344:47bae69e6b22c14b32a8a9511878e88e89759d8f
2017-05-23 11:47:22 -07:00
Jun Wu
5a61921433 fastannotate: resolve revision number to node
Summary:
fastannotate has a fastpath, when the node (commit hash) exists in revmap,
it would generate the output instantly from the linelog without going
through the history.

In the "fctx" mode, the vanilla annotate command would pass the revision
number instead of changeset node to fastannotate, which prevents
fastannotate from using the fast path.

This diff converts the revision number to node before testing the fast path
to solve the problem.

Test Plan: Modified existing tests.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:4288927:1481073363:3330d60878161139ee195bc968c161d6c0d95ace
2016-12-07 00:09:04 +00:00
Jun Wu
5a5a7662cd tests.t: clean up the shell code a bit
Summary:
Simplifies some shell code, namely `$extpath` is duplicated with `$TESTDIR/..`
so remove one of them.

Change `library.sh` (used by remotefilelog tests) to reuse `$HGRCPATH` instead
of overriding the environment variable, because it never gets restored and the
current code would assume `$HGRCPATH` to have `.hgrc` as its basename, which is
not always true.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4256506:1480612191:73832c427b6562b9000a6df006226653157a7156
2016-12-01 02:06:57 +00:00
Jun Wu
a3dc8b960d fastannotate: support replacing fctx.annotate directly
Summary:
Previously, I have performance concern about the signature of
`fctx.annotate`: it returns fctxs, not ideal for performance since my
initial goal is to get rid of reading revlogs in the best case. And letting
the low-level `fctx.annotate` have some side effects writing to the disk is
not that pretty.

Because of that, fastannotate had re-invent part of the formatter (also
optimized for performance somehow), and still cannot support all the
features the original annotate supports, namely, templates.

Now it makes sense to just replace `fctx.annotate` with a sub-optimal
implementation, just for the flexibility of the template support of the
original annotate command. We can use a "fake" or "lazy" fctx object to
minimal the performance impact when people only need to print changeset
nodes and line numbers - in which case we don't read revlog.

Actually, the hgweb support already did a similar thing - converting
fastannotate output to annotate output. So we can reuse some code.

The next planned steps are:

  - Make the original "annotate" command aware of fastannotate protocol, do
    the pre-download stuff (downloading cache files at `fctx.annotate` is
    possible but inefficient because of not being batched).
  - "fastannotate" command remains a separated command optimized for perf
    and provides extra features like "--deleted".

Because of the plan, the "commands" option does not make much sense -
"fastannotate" command will not replace "annotate" directly thus dropped
from the config interface. A new "modes" config option is added to control
how fastannotate works.

Test Plan: Modified existing tests

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4238998:1480447679:c48e0e565663c086293265e104d9cf414d913aa7
2016-11-29 11:51:08 +00:00
Jun Wu
87a71c3a2f fastannotate: support -r wdir()
Summary:
Although `wdir()` is an undocumented feature, it exists in upstream annotate
tests. Let's support it so it is more similar to the vanilla annotate.

Test Plan: Added a new test

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4060169:1477402083:021cae092e695a72fff65cd07640c9f7984b2a60
2016-10-21 20:50:37 +01:00
Jun Wu
a91f5d53ac fastannotate: add a JSON formatter
Summary: The vanilla annotate command supports `-Tjson`. Let's implement it as well.

Test Plan: Added a new test

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4059577:1477074802:09b0b3ea0769d480eb3a2e42308636ff2b8d40d2
2016-10-21 19:28:30 +01:00
Jun Wu
dc07b62633 fastannotate: handle "draft" paths, and renames correctly
Summary:
Previously we can only answer the "path" information when the revision is in
the linelog revmap, and the code would crash if a revision is in a side
branch, and the user requests path information. This diff fixes it.

Besides, this diff improves rename handling. For example, given the following
chart:

```
  o---o  -o   file name: a
        /
  o---o-      file name: b
  ^   ^   ^
  1   2   3   revisions
```

Depending on the position of the `main branch` reference, fastannotate may
or may not use linelog:

- main branch is at rev 2, annotate a -r 3 will not take advantage of linelog
  (fallback to slow annotate)
- main branch is at rev 3, annotate a -r 2 will not take advantage of linelog

This is not ideal, but seems to be the best we can do for now.

Test Plan:
Added a new test, updated existing relevant tests. Some debug messages are
changed to reflect internals more precisely.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: stash, mjpieters

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

Signature: t1:4010964:1476458201:79875d96399d023d0000d0c4bb8b8d40ea43eef0
2016-10-09 19:47:01 +01:00
Jun Wu
38100f3be4 fastannotate: handle empty file correctly
Summary:
`_decorate` backported from upstream does not handle empty file correctly.
It would raise an assertion error when annotating an empty file:

  File "fastannotate/commands.py", line 138, in fastannotate
    not showdeleted))
  File "fastannotate/context.py", line 331, in annotate
    return self._refineannotateresult(result, revfctx, showpath, showlines)
  File "fastannotate/context.py", line 503, in _refineannotateresult
    if len(lines) != len(result):
  AssertionError

This patch fixes it.

Test Plan: Run the modified test.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:3944132:1475166894:e2610c6364806b77c8533315a1a0a08b6c158fe5
2016-09-29 16:48:40 +01:00
Jun Wu
56075d02ef fastannotate: encode directory names
Summary:
We need to reserve ".l", ".m" and ".lock". So encode directory names to
avoid collision.

Test Plan: Run the modified test

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:3944069:1475166648:055811239514cb699a0ebe1cfab809b661c6cfd2
2016-09-29 16:33:46 +01:00
Jun Wu
89c9da2b06 fastannotate: add a --deleted option
Summary:
This feature uses the linelog to show all lines ever existed (even deleted) in
a file. Helpful to see the history all the way back to the beginning.

Sadly it has to be inefficient currently as we have chosen to not store line
content (but only numbers) in linelog. Calculating the revisions and line
numbers is very fast because of linelog but resolving the line contents is
painfully slow. We may want a key-value database in the future, answering the
query:

  (path, node, linenum) -> content

How slow is it? With the linelog pre-built, generating the output for
`mercurial/commands.py` needs resolving 400+ revisions and is about 10+
seconds.

Test Plan: Run the changed `test-fastannotate.t`

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3849503:1475086235:83077c571746a7515b5ba75c4df37a1a400d9232
2016-09-11 22:52:29 +01:00
Jun Wu
58826b52c2 fastannotate: add a config option to replace the default command
Summary:
This diff adds a config option to replace the default annotate command using
fastannotate.

Test Plan: Run the modified test

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:3837499:1475076620:65dc656c74e9c8a969f68cc4a2480f5dcbeb6361
2016-09-08 21:52:01 +01:00
Jun Wu
cfb2b51726 fastannotate: add a simple test
Summary: This diff adds a simple test for the `fastannotate` command.

Test Plan: Run the newly added test.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:3836677:1475076179:fa8b8ff3711a8dad9410a15f77e23adaeb676d5e
2016-09-08 20:16:19 +01:00