view tests/test-fileset-generated.t @ 37048:fc5e261915b9

wireproto: require POST for all HTTPv2 requests Wire protocol version 1 transfers argument data via request headers by default. This has historically caused problems because servers institute limits on the length of individual HTTP headers as well as the total size of all request headers. Mercurial servers can advertise the maximum length of an individual header. But there's no guarantee any intermediate HTTP agents will accept headers up to that length. In the existing wire protocol, server operators typically also key off the HTTP request method to implement authentication. For example, GET requests translate to read-only requests and can be allowed. But read-write commands must use POST and require authentication. This has typically worked because the only wire protocol commands that use POST modify the repo (e.g. the "unbundle" command). There is an experimental feature to enable clients to transmit argument data via POST request bodies. This is technically a better and more robust solution. But we can't enable it by default because of servers assuming POST means write access. In version 2 of the wire protocol, the permissions of a request are encoded in the URL. And with it being a new protocol in a new URL space, we're not constrained by backwards compatibility requirements. This commit adopts the technically superior mechanism of using HTTP request bodies to send argument data by requiring POST for all commands. Strictly speaking, it may be possible to send request bodies on GET requests. But my experience is that not all HTTP stacks support this. POST pretty much always works. Using POST for read-only operations does sacrifice some RESTful design purity. But this API cares about practicality, not about being in Roy T. Fielding's REST ivory tower. There's a chance we may relax this restriction in the future. But for now, I want to see how far we can get with a POST only API. Differential Revision: https://phab.mercurial-scm.org/D2837
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 13 Mar 2018 11:57:43 -0700
parents fe0667cc521e
children cb70501d8b71
line wrap: on
line source

  $ hg init

Set up history and working copy

  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 1
  $ hg addremove -q --similarity 0
  $ hg commit -m first

  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 2
  $ hg addremove -q --similarity 0
  $ hg commit -m second

  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 wc
  $ hg addremove -q --similarity 0
  $ hg forget *_*_*-untracked
  $ rm *_*_missing-*

Test status

  $ hg st -A 'set:modified()'
  M content1_content1_content3-tracked
  M content1_content2_content1-tracked
  M content1_content2_content3-tracked
  M missing_content2_content3-tracked

  $ hg st -A 'set:added()'
  A content1_missing_content1-tracked
  A content1_missing_content3-tracked
  A missing_missing_content3-tracked

  $ hg st -A 'set:removed()'
  R content1_content1_content1-untracked
  R content1_content1_content3-untracked
  R content1_content1_missing-untracked
  R content1_content2_content1-untracked
  R content1_content2_content2-untracked
  R content1_content2_content3-untracked
  R content1_content2_missing-untracked
  R missing_content2_content2-untracked
  R missing_content2_content3-untracked
  R missing_content2_missing-untracked

  $ hg st -A 'set:deleted()'
  ! content1_content1_missing-tracked
  ! content1_content2_missing-tracked
  ! content1_missing_missing-tracked
  ! missing_content2_missing-tracked
  ! missing_missing_missing-tracked

  $ hg st -A 'set:missing()'
  ! content1_content1_missing-tracked
  ! content1_content2_missing-tracked
  ! content1_missing_missing-tracked
  ! missing_content2_missing-tracked
  ! missing_missing_missing-tracked

  $ hg st -A 'set:unknown()'
  ? content1_missing_content1-untracked
  ? content1_missing_content3-untracked
  ? missing_missing_content3-untracked

  $ hg st -A 'set:clean()'
  C content1_content1_content1-tracked
  C content1_content2_content2-tracked
  C missing_content2_content2-tracked

Test log

  $ hg log -T '{rev}\n' --stat 'set:modified()'
  1
   content1_content2_content1-tracked |  2 +-
   content1_content2_content3-tracked |  2 +-
   missing_content2_content3-tracked  |  1 +
   3 files changed, 3 insertions(+), 2 deletions(-)
  
  0
   content1_content1_content3-tracked |  1 +
   content1_content2_content1-tracked |  1 +
   content1_content2_content3-tracked |  1 +
   3 files changed, 3 insertions(+), 0 deletions(-)
  
Largefiles doesn't crash
  $ hg log -T '{rev}\n' --stat 'set:modified()' --config extensions.largefiles=
  The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
  1
   content1_content2_content1-tracked |  2 +-
   content1_content2_content3-tracked |  2 +-
   missing_content2_content3-tracked  |  1 +
   3 files changed, 3 insertions(+), 2 deletions(-)
  
  0
   content1_content1_content3-tracked |  1 +
   content1_content2_content1-tracked |  1 +
   content1_content2_content3-tracked |  1 +
   3 files changed, 3 insertions(+), 0 deletions(-)
  
  $ hg log -T '{rev}\n' --stat 'set:added()'
  1
   content1_missing_content1-tracked |  1 -
   content1_missing_content3-tracked |  1 -
   2 files changed, 0 insertions(+), 2 deletions(-)
  
  0
   content1_missing_content1-tracked |  1 +
   content1_missing_content3-tracked |  1 +
   2 files changed, 2 insertions(+), 0 deletions(-)
  
  $ hg log -T '{rev}\n' --stat 'set:removed()'
  1
   content1_content2_content1-untracked |  2 +-
   content1_content2_content2-untracked |  2 +-
   content1_content2_content3-untracked |  2 +-
   content1_content2_missing-untracked  |  2 +-
   missing_content2_content2-untracked  |  1 +
   missing_content2_content3-untracked  |  1 +
   missing_content2_missing-untracked   |  1 +
   7 files changed, 7 insertions(+), 4 deletions(-)
  
  0
   content1_content1_content1-untracked |  1 +
   content1_content1_content3-untracked |  1 +
   content1_content1_missing-untracked  |  1 +
   content1_content2_content1-untracked |  1 +
   content1_content2_content2-untracked |  1 +
   content1_content2_content3-untracked |  1 +
   content1_content2_missing-untracked  |  1 +
   7 files changed, 7 insertions(+), 0 deletions(-)
  
  $ hg log -T '{rev}\n' --stat 'set:deleted()'
  1
   content1_content2_missing-tracked |  2 +-
   content1_missing_missing-tracked  |  1 -
   missing_content2_missing-tracked  |  1 +
   3 files changed, 2 insertions(+), 2 deletions(-)
  
  0
   content1_content1_missing-tracked |  1 +
   content1_content2_missing-tracked |  1 +
   content1_missing_missing-tracked  |  1 +
   3 files changed, 3 insertions(+), 0 deletions(-)
  
  $ hg log -T '{rev}\n' --stat 'set:unknown()'
  1
   content1_missing_content1-untracked |  1 -
   content1_missing_content3-untracked |  1 -
   2 files changed, 0 insertions(+), 2 deletions(-)
  
  0
   content1_missing_content1-untracked |  1 +
   content1_missing_content3-untracked |  1 +
   2 files changed, 2 insertions(+), 0 deletions(-)
  
  $ hg log -T '{rev}\n' --stat 'set:clean()'
  1
   content1_content2_content2-tracked |  2 +-
   missing_content2_content2-tracked  |  1 +
   2 files changed, 2 insertions(+), 1 deletions(-)
  
  0
   content1_content1_content1-tracked |  1 +
   content1_content2_content2-tracked |  1 +
   2 files changed, 2 insertions(+), 0 deletions(-)
  
Test revert

  $ hg revert 'set:modified()'
  reverting content1_content1_content3-tracked
  reverting content1_content2_content1-tracked
  reverting content1_content2_content3-tracked
  reverting missing_content2_content3-tracked

  $ hg revert 'set:added()'
  forgetting content1_missing_content1-tracked
  forgetting content1_missing_content3-tracked
  forgetting missing_missing_content3-tracked

  $ hg revert 'set:removed()'
  undeleting content1_content1_content1-untracked
  undeleting content1_content1_content3-untracked
  undeleting content1_content1_missing-untracked
  undeleting content1_content2_content1-untracked
  undeleting content1_content2_content2-untracked
  undeleting content1_content2_content3-untracked
  undeleting content1_content2_missing-untracked
  undeleting missing_content2_content2-untracked
  undeleting missing_content2_content3-untracked
  undeleting missing_content2_missing-untracked

  $ hg revert 'set:deleted()'
  reverting content1_content1_missing-tracked
  reverting content1_content2_missing-tracked
  forgetting content1_missing_missing-tracked
  reverting missing_content2_missing-tracked
  forgetting missing_missing_missing-tracked

  $ hg revert 'set:unknown()'

  $ hg revert 'set:clean()'