tests/test-encode.t
author Patrick Mezard <pmezard@gmail.com>
Tue, 14 Jun 2011 23:26:35 +0200
changeset 14611 adbf5e7df96d
parent 14182 ec5886db9dc6
child 16913 f2719b387380
permissions -rw-r--r--
import: add --bypass option This feature is more a way to test patching without a working directory than something people asked about. Adding a --rev option to specify the parent patch revision would make it a little more useful. What this change introduces is patch.repobackend class which let patches be applied against repository revisions. The caller must supply a filestore object to receive patched content, which can be turned into a memctx with patch.makememctx() helper.

Test encode/decode filters

  $ hg init
  $ cat > .hg/hgrc <<EOF
  > [encode]
  > not.gz = tr [:lower:] [:upper:]
  > *.gz = gzip -d
  > [decode]
  > not.gz = tr [:upper:] [:lower:]
  > *.gz = gzip
  > EOF
  $ echo "this is a test" | gzip > a.gz
  $ echo "this is a test" > not.gz
  $ hg add *
  $ hg ci -m "test"

no changes

  $ hg status
  $ touch *

no changes

  $ hg status

check contents in repo are encoded

  $ hg debugdata a.gz 0
  this is a test
  $ hg debugdata not.gz 0
  THIS IS A TEST

check committed content was decoded

  $ gunzip < a.gz
  this is a test
  $ cat not.gz
  this is a test
  $ rm *
  $ hg co -C
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved

check decoding of our new working dir copy

  $ gunzip < a.gz
  this is a test
  $ cat not.gz
  this is a test

check hg cat operation

  $ hg cat a.gz
  this is a test
  $ hg cat --decode a.gz | gunzip
  this is a test
  $ mkdir subdir
  $ cd subdir
  $ hg -R .. cat ../a.gz
  this is a test
  $ hg -R .. cat --decode ../a.gz | gunzip
  this is a test