Mercurial > hg-stable
changeset 12124:7edda6c7985d
tests: unify test-custom-filters
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 18:57:48 +0900 |
parents | 323292c2e566 |
children | e5ccb9ea8266 |
files | tests/test-custom-filters tests/test-custom-filters.out tests/test-custom-filters.t |
diffstat | 3 files changed, 69 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-custom-filters Mon Aug 30 18:55:00 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -#!/bin/sh - -hg init - -cat > .hg/hgrc <<EOF -[extensions] -prefixfilter = prefix.py -[encode] -*.txt = stripprefix: Copyright 2046, The Masters -[decode] -*.txt = insertprefix: Copyright 2046, The Masters -EOF - -cat > prefix.py <<EOF -from mercurial import util -def stripprefix(s, cmd, filename, **kwargs): - header = '%s\n' % cmd - if s[:len(header)] != header: - raise util.Abort('missing header "%s" in %s' % (cmd, filename)) - return s[len(header):] -def insertprefix(s, cmd): - return '%s\n%s' % (cmd, s) -def reposetup(ui, repo): - repo.adddatafilter('stripprefix:', stripprefix) - repo.adddatafilter('insertprefix:', insertprefix) -EOF - -cat > .hgignore <<EOF -.hgignore -prefix.py -prefix.pyc -EOF - -cat > stuff.txt <<EOF -Copyright 2046, The Masters -Some stuff to ponder very carefully. -EOF -hg add stuff.txt -hg ci -m stuff - -echo '% Repository data:' -hg cat stuff.txt - -echo '% Fresh checkout:' -rm stuff.txt -hg up -C -cat stuff.txt -echo >> stuff.txt <<EOF -Very very carefully. -EOF -hg stat - -cat > morestuff.txt <<EOF -Unauthorized material subject to destruction. -EOF - -echo '% Problem encoding:' -hg add morestuff.txt -hg ci -m morestuff -hg stat
--- a/tests/test-custom-filters.out Mon Aug 30 18:55:00 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -% Repository data: -Some stuff to ponder very carefully. -% Fresh checkout: -1 files updated, 0 files merged, 0 files removed, 0 files unresolved -Copyright 2046, The Masters -Some stuff to ponder very carefully. -M stuff.txt -% Problem encoding: -abort: missing header "Copyright 2046, The Masters" in morestuff.txt -M stuff.txt -A morestuff.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-custom-filters.t Mon Aug 30 18:57:48 2010 +0900 @@ -0,0 +1,69 @@ + $ hg init + + $ cat > .hg/hgrc <<EOF + > [extensions] + > prefixfilter = prefix.py + > [encode] + > *.txt = stripprefix: Copyright 2046, The Masters + > [decode] + > *.txt = insertprefix: Copyright 2046, The Masters + > EOF + + $ cat > prefix.py <<EOF + > from mercurial import util + > def stripprefix(s, cmd, filename, **kwargs): + > header = '%s\n' % cmd + > if s[:len(header)] != header: + > raise util.Abort('missing header "%s" in %s' % (cmd, filename)) + > return s[len(header):] + > def insertprefix(s, cmd): + > return '%s\n%s' % (cmd, s) + > def reposetup(ui, repo): + > repo.adddatafilter('stripprefix:', stripprefix) + > repo.adddatafilter('insertprefix:', insertprefix) + > EOF + + $ cat > .hgignore <<EOF + > .hgignore + > prefix.py + > prefix.pyc + > EOF + + $ cat > stuff.txt <<EOF + > Copyright 2046, The Masters + > Some stuff to ponder very carefully. + > EOF + $ hg add stuff.txt + $ hg ci -m stuff + +Repository data: + + $ hg cat stuff.txt + Some stuff to ponder very carefully. + +Fresh checkout: + + $ rm stuff.txt + $ hg up -C + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cat stuff.txt + Copyright 2046, The Masters + Some stuff to ponder very carefully. + $ echo >> stuff.txt <<EOF + > Very very carefully. + > EOF + $ hg stat + M stuff.txt + + $ cat > morestuff.txt <<EOF + > Unauthorized material subject to destruction. + > EOF + +Problem encoding: + + $ hg add morestuff.txt + $ hg ci -m morestuff + abort: missing header "Copyright 2046, The Masters" in morestuff.txt + $ hg stat + M stuff.txt + A morestuff.txt