tests/test-cache-abuse.t
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 17 Oct 2017 21:15:31 +0200
changeset 34857 84c6b9384d6a
parent 33794 6c1a9fd8361b
child 34866 1644623ab096
permissions -rw-r--r--
log: add -L/--line-range option to follow file history by line range We add an experimental -L/--line-range option to 'hg log' taking file patterns along with a line range using the (new) FILE,FROMLINE-TOLINE syntax where FILE may be a pattern (matching exactly one file). The resulting history is similar to what the "followlines" revset except that, if --patch is specified, only diff hunks within specified line range are shown. Basically, this brings the CLI on par with what currently only exists in hgweb through line selection in "file" and "annotate" views resulting in a file log with filtered patch to only display followed line range. The option may be specified multiple times and can be combined with --rev and regular file patterns to further restrict revisions. Usage of this option requires --follow; revisions are shown in descending order and renames are followed. Only the --graph option is currently not supported. The UI is the result of a consensus from review feedback at: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-October/106749.html The implementation spreads between commands.log() and cmdutil module. In commands.log(), the main loop may now use a "hunksfilter" factory (similar to "filematcher") that, for a given "rev", produces a filtering function for diff hunks for a given file context object. The logic to build revisions from -L/--line-range options lives in cmdutil.getloglinerangerevs() which produces "revs", "filematcher" and "hunksfilter" information. Revisions obtained by following files' line range are filtered if they do not match the revset specified by --rev option. If regular FILE arguments are passed along with -L options, both filematchers are combined into a new matcher. .. feature:: Add an experimental -L/--line-range FILE,FROMLINE-TOLINE option to 'hg log' command to follow the history of files by line range. In combination with -p/--patch option, only diff hunks within specified line range will be displayed. Feedback, especially on UX aspects, is welcome.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
Enable obsolete markers
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     2
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     3
  $ cat >> $HGRCPATH << EOF
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     4
  > [experimental]
33794
6c1a9fd8361b test: update evolution config
Boris Feld <boris.feld@octobus.net>
parents: 33611
diff changeset
     5
  > stabilization=createmarkers
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     6
  > [phases]
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
  > publish=False
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     8
  > EOF
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     9
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    10
Build a repo with some cacheable bits:
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
  $ hg init a
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
  $ cd a
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
  $ echo a > a
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
  $ hg ci -qAm0
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
  $ hg tag t1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    18
  $ hg book -i bk1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    19
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    20
  $ hg branch -q b2
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    21
  $ hg ci -Am1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    22
  $ hg tag t2
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    23
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    24
  $ echo dumb > dumb
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    25
  $ hg ci -qAmdumb
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
  $ hg debugobsolete b1174d11b69e63cb0c5726621a43c859f0858d7f
33542
b11e8c67fb0f debugobsolete: also report the number of obsoleted changesets
Boris Feld <boris.feld@octobus.net>
parents: 32511
diff changeset
    27
  obsoleted 1 changesets
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    28
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    29
  $ hg phase -pr t1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    30
  $ hg phase -fsr t2
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    32
Make a helper function to check cache damage invariants:
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
- command output shouldn't change
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
- cache should be present after first use
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    36
- corruption/repair should be silent (no exceptions or warnings)
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    37
- cache should survive deletion, overwrite, and append
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    38
- unreadable / unwriteable caches should be ignored
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
- cache should be rebuilt after corruption
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    40
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
  $ damage() {
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
  >  CMD=$1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
  >  CACHE=.hg/cache/$2
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
  >  CLEAN=$3
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
  >  hg $CMD > before
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    46
  >  test -f $CACHE || echo "not present"
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    47
  >  echo bad > $CACHE
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    48
  >  test -z "$CLEAN" || $CLEAN
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    49
  >  hg $CMD > after
33611
798f7beadbc9 tests: use pdiff instead of diff for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 33542
diff changeset
    50
  >  "$RUNTESTDIR/pdiff" before after || echo "*** overwrite corruption"
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    51
  >  echo corruption >> $CACHE
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    52
  >  test -z "$CLEAN" || $CLEAN
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
  >  hg $CMD > after
33611
798f7beadbc9 tests: use pdiff instead of diff for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 33542
diff changeset
    54
  >  "$RUNTESTDIR/pdiff" before after || echo "*** append corruption"
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    55
  >  rm $CACHE
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    56
  >  mkdir $CACHE
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    57
  >  test -z "$CLEAN" || $CLEAN
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    58
  >  hg $CMD > after
33611
798f7beadbc9 tests: use pdiff instead of diff for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 33542
diff changeset
    59
  >  "$RUNTESTDIR/pdiff" before after || echo "*** read-only corruption"
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    60
  >  test -d $CACHE || echo "*** directory clobbered"
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    61
  >  rmdir $CACHE
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    62
  >  test -z "$CLEAN" || $CLEAN
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    63
  >  hg $CMD > after
33611
798f7beadbc9 tests: use pdiff instead of diff for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 33542
diff changeset
    64
  >  "$RUNTESTDIR/pdiff" before after || echo "*** missing corruption"
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    65
  >  test -f $CACHE || echo "not rebuilt"
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    66
  > }
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    67
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    68
Beat up tags caches:
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    69
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    70
  $ damage "tags --hidden" tags2
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    71
  $ damage tags tags2-visible
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    72
  $ damage "tag -f t3" hgtagsfnodes1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    73
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    74
Beat up branch caches:
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    75
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    76
  $ damage branches branch2-base "rm .hg/cache/branch2-[vs]*"
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    77
  $ damage branches branch2-served "rm .hg/cache/branch2-[bv]*"
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    78
  $ damage branches branch2-visible
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    79
  $ damage "log -r branch(.)" rbc-names-v1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    80
  $ damage "log -r branch(default)" rbc-names-v1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    81
  $ damage "log -r branch(b2)" rbc-revs-v1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    82
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    83
We currently can't detect an rbc cache with unknown names:
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    84
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    85
  $ damage "log -qr branch(b2)" rbc-names-v1
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    86
  --- before	* (glob)
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    87
  +++ after	* (glob)
29255
b0b85d8695cb test-cache-abuse: correct for different hunk headers between Solaris and GNU
Danek Duvall <danek.duvall@oracle.com>
parents: 29041
diff changeset
    88
  @@ -1,8 +?,0 @@ (glob)
29041
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    89
  -2:5fb7d38b9dc4
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    90
  -3:60b597ffdafa
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    91
  -4:b1174d11b69e
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    92
  -5:6354685872c0
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    93
  -6:5ebc725f1bef
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    94
  -7:7b76eec2f273
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    95
  -8:ef3428d9d644
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    96
  -9:ba7a936bc03c
b962ae0a0a05 tests: test a variety of cache invariants
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    97
  *** append corruption