tests/test-impexp-branch.t
author Augie Fackler <augie@google.com>
Tue, 30 Jun 2015 19:19:17 -0400
changeset 25708 d3d32643c060
parent 22485 efedda4aed49
child 32940 75be14993fda
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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16475
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
     1
  $ echo '[extensions]' >> $HGRCPATH
20115
db6b958c4f35 tests: use strip extension instead of mq where it makes sense
Martin Geisler <martin@geisler.net>
parents: 16913
diff changeset
     2
  $ echo 'strip =' >> $HGRCPATH
16475
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
     3
12119
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
     4
  $ cat >findbranch.py <<EOF
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
     5
  > import re, sys
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
     6
  > 
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
     7
  > head_re = re.compile('^#(?:(?:\\s+([A-Za-z][A-Za-z0-9_]*)(?:\\s.*)?)|(?:\\s*))$')
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
     8
  > 
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
     9
  > for line in sys.stdin:
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    10
  >     hmatch = head_re.match(line)
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    11
  >     if not hmatch:
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    12
  >         sys.exit(1)
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    13
  >     if hmatch.group(1) == 'Branch':
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    14
  >         sys.exit(0)
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    15
  > sys.exit(1)
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    16
  > EOF
14126
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    17
12119
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    18
  $ hg init a
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    19
  $ cd a
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    20
  $ echo "Rev 1" >rev
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    21
  $ hg add rev
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    22
  $ hg commit -m "No branch."
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    23
  $ hg branch abranch
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    24
  marked working directory as branch abranch
15615
41885892796e branch: warn on branching
Matt Mackall <mpm@selenic.com>
parents: 14126
diff changeset
    25
  (branches are permanent and global, did you want a bookmark?)
12119
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    26
  $ echo "Rev  2" >rev
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    27
  $ hg commit -m "With branch."
14126
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    28
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    29
  $ hg export 0 > ../r0.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    30
  $ hg export 1 > ../r1.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    31
  $ cd ..
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    32
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    33
  $ if python findbranch.py < r0.patch; then
12119
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    34
  >     echo "Export of default branch revision has Branch header" 1>&2
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    35
  >     exit 1
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    36
  > fi
14126
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    37
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    38
  $ if python findbranch.py < r1.patch; then
12119
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    39
  >     :  # Do nothing
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    40
  > else
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    41
  >     echo "Export of branch revision is missing Branch header" 1>&2
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    42
  >     exit 1
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    43
  > fi
4442
871ff96a86cc Add a test for the Branch header being in hg export.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    44
12119
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    45
Make sure import still works with branch information in patches.
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    46
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    47
  $ hg init b
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    48
  $ cd b
14126
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    49
  $ hg import ../r0.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    50
  applying ../r0.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    51
  $ hg import ../r1.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    52
  applying ../r1.patch
12119
46ab8c5dd99a tests: unify test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 4444
diff changeset
    53
  $ cd ..
14126
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    54
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    55
  $ hg init c
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    56
  $ cd c
22485
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    57
  $ hg import --exact --no-commit ../r0.patch
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    58
  applying ../r0.patch
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    59
  warning: can't check exact import with --no-commit
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    60
  $ hg st
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    61
  A rev
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    62
  $ hg revert -a
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    63
  forgetting rev
efedda4aed49 import: let --exact 'work' with --no-commit (issue4376)
Matt Mackall <mpm@selenic.com>
parents: 20115
diff changeset
    64
  $ rm rev
14126
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    65
  $ hg import --exact ../r0.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    66
  applying ../r0.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    67
  $ hg import --exact ../r1.patch
fbbe9239574a tests: export patches only once in test-impexp-branch
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12119
diff changeset
    68
  applying ../r1.patch
16475
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    69
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    70
Test --exact and patch header separators (issue3356)
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    71
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    72
  $ hg strip --no-backup .
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    73
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    74
  >>> import re
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    75
  >>> p = file('../r1.patch', 'rb').read()
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    76
  >>> p = re.sub(r'Parent\s+', 'Parent ', p)
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    77
  >>> file('../r1-ws.patch', 'wb').write(p)
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    78
  $ hg import --exact ../r1-ws.patch
1f75c1decdeb patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard <patrick@mezard.eu>
parents: 15615
diff changeset
    79
  applying ../r1-ws.patch
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16475
diff changeset
    80
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16475
diff changeset
    81
  $ cd ..