tests/test-log-exthook.t
author Gregory Szorc <gregory.szorc@gmail.com>
Wed, 17 Oct 2018 17:32:15 +0200
changeset 40392 595641bd8404
parent 39657 2b9f315a4217
child 40441 005bc856e919
permissions -rw-r--r--
sqlitestore: support for storing revisions without their parents This commit kinda/sorta implements the equivalent of ellipsis nodes for the SQLite storage backend. Without implementing full blown ellipsis nodes (and the necessary support for them in the wire protocol), we instead teach the store to rewrite the p1 and p2 nodes to nullid when the incoming parent isn't in the local store. This allows servers to remain dumb and send the real parent and have the clients deal with the missing parent problem. This obviously isn't ideal because a benefit of ellipsis nodes is we can insert a fake parent to ellide missing changesets. But neither solution is ideal because it drops the original parent from storage. We could probably teach the SQLite store to retain the original parent and handle missing parents at read time. However, parent revisions are stored as integers and it isn't trivial to store an "empty" revision in the store yet, which would be necessary to represent the "missing" parent. The store is somewhat intelligent in trying to remove the missing parents metadata when the revision is re-added. But, revision numbers will be all messed up in that case, so I'm not sure it is worth it. At some point we'll likely want to remove the concept of revision numbers from the database and have the store invent them at index generation time. Or even better, we can do away with revision numbers from the file storage interface completely. We'll get there eventually... Differential Revision: https://phab.mercurial-scm.org/D5168
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33154
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     1
Test hg log changeset printer external hook
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     2
-------------------------------------------
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     3
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     4
  $ cat > $TESTTMP/logexthook.py <<EOF
33964
bfafd189edd9 tests: update test-log-exthook to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33154
diff changeset
     5
  > from __future__ import absolute_import
39657
2b9f315a4217 py3: use codecs.encode() to encode in rot-13 encoding
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 35888
diff changeset
     6
  > import codecs
33964
bfafd189edd9 tests: update test-log-exthook to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33154
diff changeset
     7
  > from mercurial import (
bfafd189edd9 tests: update test-log-exthook to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33154
diff changeset
     8
  >   commands,
35888
c8e2d6ed1f9e cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents: 33964
diff changeset
     9
  >   logcmdutil,
33964
bfafd189edd9 tests: update test-log-exthook to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33154
diff changeset
    10
  >   repair,
bfafd189edd9 tests: update test-log-exthook to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33154
diff changeset
    11
  > )
33154
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    12
  > def rot13description(self, ctx):
39657
2b9f315a4217 py3: use codecs.encode() to encode in rot-13 encoding
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 35888
diff changeset
    13
  >     summary = codecs.encode("summary", 'rot-13')
33154
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    14
  >     description = ctx.description().strip().splitlines()[0].encode('rot13')
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    15
  >     self.ui.write("%s:     %s\n" % (summary, description))
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    16
  > def reposetup(ui, repo):
35888
c8e2d6ed1f9e cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents: 33964
diff changeset
    17
  >     logcmdutil.changesetprinter._exthook = rot13description
33154
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    18
  > EOF
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    19
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    20
Prepare the repository
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    21
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    22
  $ hg init empty
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    23
  $ cd empty
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    24
  $ touch ROOT
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    25
  $ hg commit -A -m "Root" ROOT
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    26
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    27
  $ touch a b c
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    28
  $ hg commit -A -m "Add A, B, C" a b c
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    29
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    30
Check the log
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    31
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    32
  $ hg log --config extensions.t=$TESTTMP/logexthook.py
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    33
  changeset:   1:70fc82b23320
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    34
  tag:         tip
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    35
  user:        test
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    36
  date:        Thu Jan 01 00:00:00 1970 +0000
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    37
  fhzznel:     Nqq N, O, P
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    38
  summary:     Add A, B, C
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    39
  
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    40
  changeset:   0:b00443a54871
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    41
  user:        test
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    42
  date:        Thu Jan 01 00:00:00 1970 +0000
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
  fhzznel:     Ebbg
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    44
  summary:     Root
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    45
  
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    46
Check that exthook is working with graph log too
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    47
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    48
  $ hg log -G --config extensions.t=$TESTTMP/logexthook.py
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    49
  @  changeset:   1:70fc82b23320
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    50
  |  tag:         tip
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    51
  |  user:        test
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    52
  |  date:        Thu Jan 01 00:00:00 1970 +0000
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    53
  |  fhzznel:     Nqq N, O, P
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    54
  |  summary:     Add A, B, C
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    55
  |
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    56
  o  changeset:   0:b00443a54871
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    57
     user:        test
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    58
     date:        Thu Jan 01 00:00:00 1970 +0000
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    59
     fhzznel:     Ebbg
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    60
     summary:     Root
4ecc6047d45f log: add an extension hook-point in changeset_printer
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    61