tests/test-fileset-generated.t
author Augie Fackler <augie@google.com>
Tue, 30 Jun 2015 19:19:17 -0400
changeset 25708 d3d32643c060
parent 24813 2553ef7355ab
child 27024 ceef5fb14872
permissions -rw-r--r--
wireproto: correctly escape batched args and responses (issue4739) This issue appears to be as old as wireproto batching itself: I can reproduce the failure as far back as 08ef6b5f3715 trivially by rebasing the test changes in this patch, which was back in the 1.9 era. I didn't test before that change, because prior to that the testfile has a different name and I'm lazy. Note that the test thought it was checking this case, but it actually wasn't: it put a literal ; in the arg and response for its greet command, but the mangle/unmangle step defined in the test meant that instead of "Fo, =;o" going over the wire, "Gp-!><p" went instead, which doesn't contain any special characters (those being [.=;]) and thus not exercising the escaping. The test has been updated to use pre-unmangled special characters, so the request is now "Fo+<:o", which mangles to "Gp,=;p". I have confirmed that the test fails without the adjustment to the escaping rules in wireproto.py. No existing clients of RPC batching were depending on the old behavior in any way. The only *actual* users of batchable RPCs in core were: 1) largefiles, wherein it batches up many statlfile calls. It sends hexlified hashes over the wire and gets a 0, 1, or 2 back as a response. No risk of special characters. 2) setdiscovery, which was using heads() and known(), both of which communicate via hexlified nodes. Again, no risk of special characters. Since the escaping functionality has been completely broken since it was introduced, we know that it has no users. As such, we can change the escaping mechanism without having to worry about backwards compatibility issues. For the curious, this was detected by chance: it happens that the lz4-compressed text of a test file for remotefilelog compressed to something containing a ;, which then caused the failure when I moved remotefilelog to using batching for file content fetching.

  $ 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: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=
  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()'