# HG changeset patch # User Nicolas Dumazet # Date 1283162268 -32400 # Node ID 7edda6c7985dc18991d0bf75df96bfee35d20c96 # Parent 323292c2e566f0b9407b7bba5d6852cedad2546a tests: unify test-custom-filters diff -r 323292c2e566 -r 7edda6c7985d tests/test-custom-filters --- 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 < prefix.py < .hgignore < stuff.txt <> stuff.txt < morestuff.txt < .hg/hgrc < [extensions] + > prefixfilter = prefix.py + > [encode] + > *.txt = stripprefix: Copyright 2046, The Masters + > [decode] + > *.txt = insertprefix: Copyright 2046, The Masters + > EOF + + $ cat > prefix.py < 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 < .hgignore + > prefix.py + > prefix.pyc + > EOF + + $ cat > stuff.txt < 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 < Very very carefully. + > EOF + $ hg stat + M stuff.txt + + $ cat > morestuff.txt < 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