Mercurial > hg
view tests/test-impexp-branch.t @ 32250:8a137ef6e5da
verify: always check rawsize
Previously, verify only checks "rawsize == len(rawtext)", if
"len(fl.read()) != fl.size()".
With flag processor, "len(fl.read()) != fl.size()" does not necessarily mean
"rawsize == len(rawtext)". So we may miss a useful check.
This patch removes the "if len(fl.read()) != fl.size()" condition so the
rawsize check is always performed.
With the condition removed, "fl.read(n)" looks unnecessary so a comment was
added to explain the side effect is wanted.
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 11 May 2017 14:52:02 -0700 |
parents | efedda4aed49 |
children | 75be14993fda |
line wrap: on
line source
$ echo '[extensions]' >> $HGRCPATH $ echo 'strip =' >> $HGRCPATH $ cat >findbranch.py <<EOF > import re, sys > > head_re = re.compile('^#(?:(?:\\s+([A-Za-z][A-Za-z0-9_]*)(?:\\s.*)?)|(?:\\s*))$') > > for line in sys.stdin: > hmatch = head_re.match(line) > if not hmatch: > sys.exit(1) > if hmatch.group(1) == 'Branch': > sys.exit(0) > sys.exit(1) > EOF $ hg init a $ cd a $ echo "Rev 1" >rev $ hg add rev $ hg commit -m "No branch." $ hg branch abranch marked working directory as branch abranch (branches are permanent and global, did you want a bookmark?) $ echo "Rev 2" >rev $ hg commit -m "With branch." $ hg export 0 > ../r0.patch $ hg export 1 > ../r1.patch $ cd .. $ if python findbranch.py < r0.patch; then > echo "Export of default branch revision has Branch header" 1>&2 > exit 1 > fi $ if python findbranch.py < r1.patch; then > : # Do nothing > else > echo "Export of branch revision is missing Branch header" 1>&2 > exit 1 > fi Make sure import still works with branch information in patches. $ hg init b $ cd b $ hg import ../r0.patch applying ../r0.patch $ hg import ../r1.patch applying ../r1.patch $ cd .. $ hg init c $ cd c $ hg import --exact --no-commit ../r0.patch applying ../r0.patch warning: can't check exact import with --no-commit $ hg st A rev $ hg revert -a forgetting rev $ rm rev $ hg import --exact ../r0.patch applying ../r0.patch $ hg import --exact ../r1.patch applying ../r1.patch Test --exact and patch header separators (issue3356) $ hg strip --no-backup . 1 files updated, 0 files merged, 0 files removed, 0 files unresolved >>> import re >>> p = file('../r1.patch', 'rb').read() >>> p = re.sub(r'Parent\s+', 'Parent ', p) >>> file('../r1-ws.patch', 'wb').write(p) $ hg import --exact ../r1-ws.patch applying ../r1-ws.patch $ cd ..