Commit Graph

10 Commits

Author SHA1 Message Date
Yuya Nishihara
6ecd008e93 annotate: port to generic templater enabled by hidden -T option
If the selected formatter is other than plainformatter, raw data are passed
to the formatter.  In this case, it isn't necessary (and not possible) to
calculate column widths.

Field names are substituted to be the same as "log" command.

There are a few limitations:

 - "binary file" message is not included in formatted output.
 - no data structure for multiple files. all lines are packed to single list.
2014-09-17 23:21:20 +09:00
FUJIWARA Katsunori
3a71637352 annotate: increase refcount of each revisions correctly (issue3841)
Before this patch, refcount (managed in "needed") of parents of each
revisions in "visit" is increased, only when parent is not annotated
yet (examined by "p not in hist").

But this causes less refcount of the revision like "A" in the tree
below ("A" is assumed as the second parent of "C"):

    A --- B --- C
      \       /
       \-----/

Steps of annotation for "C" in this case are shown below:

  1. for "C"
    1.1 increase refcount of "B"
    1.2 increase refcount of "A" (=> 1)
    1.3 defer annotation for "C"

  2. for "A"
    2.1 annotate for "A" (=> put result into "hist[A]")
    2.2 clear "pcache[A]" ("pcache[A] = []")

  3. for "B"
    3.1 not increase refcount of "A", because "A not in hist" is False
    3.2 annotate for "B"
    3.3 decrease refcount of "A" (=> 0)
    3.4 delete "hist[A]", even though "A" is still needed by "C"
    3.5 clear "pcache[B]"

  4. for "C", again
    4.1 not increase refcount of "B", because "B not in hist" is False
    4.2 increase refcount of "A" (=> 1)
    4.3 defer annotation for "C"

  5. for "A", again
    5.1 annotate for "A" (=> put result into "hist[A]", again)
    5.2 clear "pcache[A]"

  6. for "C", once again
    6.1 not increase refcount of "B", because "B not in hist" is False
    6.2 not increase refcount of "A", because "A not in hist" is False
    6.3 annotate for "C"
    6.4 decrease refcount of "A", and delete "hist[A]"
    6.5 decrease refcount of "B", and delete "hist[B]"
    6.6 clear "pcache[C]"

At step (5.1), annotation for "A" mis-recognizes that all lines are
created at "A", because "pcache[A]" already cleared at step (2.2)
prevents from scanning ancestors of "A".

So, annotation for "C" or its descendants loses information about "A"
or its ancestors.

The root cause of this problem is that refcount of "A" is decreased at
step (3.3), even though it isn't increased at step (3.1).

To increase refcount correctly, this patch increases refcount of each
parents of each revisions:

  - regardless of "p not in hist" or not, and
  - only once for each revisions in "visit" (by "not pcached")

In fact, this problem should occur only on legacy repositories in
which a filelog includes the merging between the revision and its
ancestor (as the second parent), because:

  - tree is scanned in depth-first

    without such merging, revisions in "visit" refer different
    revisions as parent each other

  - recent Mercurial doesn't allow such merging

    changelog and manifest can include such merging someway, but
    filelogs can't, because "localrepository._filecommit()" converts
    such merging request to linear history.

This patch tests merging cases below: these cases are from filelog of
"mercurial/commands.py" in the repository of Mercurial itself.

  - both parents are same

        10 --- 11 --- 12
                  \_/

        filelogrev: changesetid:
          10          526aca6bcb38
          11          05098100ff44
          12          2d4f4cfa81d6

  - the second parent is also ancestor of the first one

        37 --- 38 --- 39 --- 40
                  \________/

        filelogrev: changesetid:
          37          033dc4170fe6
          38          5ff1a23ce38c
          39          661a47367859
          40          a2ba99fd026f
2013-03-29 22:57:16 +09:00
Mads Kiilerich
59664fd950 check-code: fix check for trailing whitespace on continued lines too
The tests in test-annotate.t and test-import-git.t that relied on trailing
space in a file created by a here string is now masked by a literal 'EOL'
string that is removed.
2012-08-08 18:10:37 +02:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00
Ion Savin
029e0ada33 annotate: append newline after non newline-terminated file listings
The last line of a non newline-terminated file would mix with the first line of
the next file in multiple-file listings before this patch.

Possible compatibility issue: no longer possible to tell from the annotate
output if the file is terminated by new line or not.
2012-01-10 10:18:19 +02:00
Patrick Mezard
cc3315778f annotate: support diff whitespace filtering flags (issue3030)
splitblock() was added to handle blocks returned by bdiff.blocks() which differ
only by blank lines but are not made only of blank lines. I do not know exactly
how it could happen but mdiff.blocks() threshold behaviour makes me think it
can if those blocks are made of very popular lines mixed with popular blank
lines. If it is proven to be wrong, the function can be dropped.

The first implementation made annotate share diff configuration entries. But it
looks like users will user -w/b for annotate but not for diff, on both the
command line and hgweb. Since the latter cannot use command line entries, we
introduce a new [annotate] section duplicating the diff whitespace options.
2011-11-18 12:04:31 +01:00
Thomas Arendsen Hein
5921e1efcc annotate: fix alignment of columns in front of line numbers (issue2807) 2011-05-18 15:41:03 +02:00
Matt Mackall
ca9fdc1884 annotate: catch nonexistent files using match.bad callback (issue1590) 2011-03-19 01:34:49 -05:00
Martin Geisler
3d112b3042 tests: added a short description to issue numbers
Many tests already had a short line to describe what IssueXXX is
about. I find that quite useful when reading a test.
2010-09-24 10:13:49 +02:00
Martin Geisler
f90f39674a tests: unify test-annotate 2010-08-14 02:18:17 +02:00