tests/test-remote-hidden.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Mon, 21 May 2018 17:28:35 +0200
changeset 42126 ef0e3cc684b3
child 42127 70b71421fd33
permissions -rw-r--r--
repoview: introduce a filter for serving hidden changesets There are multiple usecase for being able to explicitly view or pull obsolete from a server. We need to be able to do so without exposing the secret changesets. We introduces a dedicated repository "view" to do so. Way to expose this "view" to the user will come later. To keep a behavior consistent with expected client/server behavior, the general idea is for the obsolete access to be explicitly requested by the code generating the request. In addition, the will be server side configuration to restrict the access to this feature.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42126
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     1
========================================================
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     2
Test the ability to access a hidden revision on a server
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     3
========================================================
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     4
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     5
#require serve
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     6
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     7
  $ . $TESTDIR/testlib/obsmarker-common.sh
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     8
  $ cat >> $HGRCPATH << EOF
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     9
  > [phases]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    10
  > # public changeset are not obsolete
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    11
  > publish=false
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    12
  > [experimental]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    13
  > evolution=all
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    14
  > [ui]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    15
  > logtemplate='{rev}:{node|short} {desc} [{phase}]\n'
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    16
  > EOF
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    17
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    18
Setup a simple repository with some hidden revisions
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    19
----------------------------------------------------
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    20
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    21
Testing the `served.hidden` view
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    22
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    23
  $ hg init repo-with-hidden
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    24
  $ cd repo-with-hidden
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    25
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    26
  $ echo 0 > a
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    27
  $ hg ci -qAm "c_Public"
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    28
  $ hg phase --public
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    29
  $ echo 1 > a
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    30
  $ hg ci -m "c_Amend_Old"
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    31
  $ echo 2 > a
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    32
  $ hg ci -m "c_Amend_New" --amend
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    33
  $ hg up ".^"
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    34
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    35
  $ echo 3 > a
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    36
  $ hg ci -m "c_Pruned"
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    37
  created new head
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    38
  $ hg debugobsolete --record-parents `getid 'desc("c_Pruned")'` -d '0 0'
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    39
  obsoleted 1 changesets
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    40
  $ hg up ".^"
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    41
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    42
  $ echo 4 > a
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    43
  $ hg ci -m "c_Secret" --secret
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    44
  created new head
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    45
  $ echo 5 > a
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    46
  $ hg ci -m "c_Secret_Pruned" --secret
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    47
  $ hg debugobsolete --record-parents `getid 'desc("c_Secret_Pruned")'` -d '0 0'
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    48
  obsoleted 1 changesets
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    49
  $ hg up null
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    50
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    51
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    52
  $ hg log -G -T '{rev}:{node|short} {desc} [{phase}]\n' --hidden
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    53
  x  5:8d28cbe335f3 c_Secret_Pruned [secret]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    54
  |
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    55
  o  4:1c6afd79eb66 c_Secret [secret]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    56
  |
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    57
  | x  3:5d1575e42c25 c_Pruned [draft]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    58
  |/
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    59
  | o  2:c33affeb3f6b c_Amend_New [draft]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    60
  |/
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    61
  | x  1:be215fbb8c50 c_Amend_Old [draft]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    62
  |/
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    63
  o  0:5f354f46e585 c_Public [public]
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    64
  
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    65
  $ hg debugobsolete
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    66
  be215fbb8c5090028b00154c1fe877ad1b376c61 c33affeb3f6b4e9621d1839d6175ddc07708807c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'amend', 'user': 'test'}
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    67
  5d1575e42c25b7f2db75cd4e0b881b1c35158fae 0 {5f354f46e5853535841ec7a128423e991ca4d59b} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    68
  8d28cbe335f311bc89332d7bbe8a07889b6914a0 0 {1c6afd79eb6663275bbe30097e162b1c24ced0f0} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    69
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    70
  $ cd ..
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    71
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    72
Test the feature
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    73
================
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    74
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    75
Check that the `served.hidden` repoview
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    76
---------------------------------------
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    77
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    78
  $ hg -R repo-with-hidden serve -p $HGPORT -d --pid-file hg.pid --config web.view=served.hidden
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    79
  $ cat hg.pid >> $DAEMON_PIDS
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    80
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    81
changesets in secret and higher phases are not visible through hgweb
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    82
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    83
  $ hg -R repo-with-hidden log --template "revision:    {rev}\\n" --rev "reverse(not secret())"
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    84
  revision:    2
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    85
  revision:    0
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    86
  $ hg -R repo-with-hidden log --template "revision:    {rev}\\n" --rev "reverse(not secret())" --hidden
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    87
  revision:    3
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    88
  revision:    2
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    89
  revision:    1
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    90
  revision:    0
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    91
  $ get-with-headers.py localhost:$HGPORT 'log?style=raw' | grep revision:
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    92
  revision:    3
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    93
  revision:    2
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    94
  revision:    1
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    95
  revision:    0
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    96
ef0e3cc684b3 repoview: introduce a filter for serving hidden changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    97
  $ killdaemons.py