Mercurial > hg
changeset 1259:f75567782aba
Merge with BOS
author | mpm@selenic.com |
---|---|
date | Thu, 15 Sep 2005 03:00:10 -0500 |
parents | 1945754e466b (diff) fe7fbfdb066d (current diff) |
children | 4603eef60237 |
files | |
diffstat | 6 files changed, 118 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/hg.1.txt Thu Sep 15 00:04:29 2005 -0700 +++ b/doc/hg.1.txt Thu Sep 15 03:00:10 2005 -0500 @@ -188,6 +188,10 @@ This command takes effect in the next commit. + NOTE: This command should be treated as experimental. While it + should properly record copied files, this information is not yet + fully used by merge, nor fully reported by log. + Options: -A, --after record a copy that has already occurred -I, --include <pat> include names matching the given patterns @@ -476,6 +480,10 @@ This command takes effect in the next commit. + NOTE: This command should be treated as experimental. While it + should properly record rename files, this information is not yet + fully used by merge, nor fully reported by log. + Options: -A, --after record a rename that has already occurred -f, --force forcibly copy over an existing managed file
--- a/doc/hgrc.5.txt Thu Sep 15 00:04:29 2005 -0700 +++ b/doc/hgrc.5.txt Thu Sep 15 03:00:10 2005 -0500 @@ -61,6 +61,26 @@ Mercurial "hgrc" file, the purpose of each section, its possible keys, and their possible values. +decode/encode:: + Filters for transforming files on checkout/checkin. This would + typically be used for newline processing or other + localization/canonicalization of files. + + Filters consist of a filter pattern followed by a filter command. + The command must accept data on stdin and return the transformed + data on stdout. + + Example: + + [encode] + # uncompress gzip files on checkin to improve delta compression + # note: not necessarily a good idea, just an example + *.gz = gunzip + + [decode] + # recompress gzip files when writing them to the working dir + *.gz = gzip + hooks:: Commands that get automatically executed by various actions such as starting or finishing a commit.
--- a/mercurial/localrepo.py Thu Sep 15 00:04:29 2005 -0700 +++ b/mercurial/localrepo.py Thu Sep 15 03:00:10 2005 -0500 @@ -33,6 +33,8 @@ self.changelog = changelog.changelog(self.opener) self.tagscache = None self.nodetagscache = None + self.encodepats = None + self.decodepats = None if create: os.mkdir(self.path) @@ -160,9 +162,37 @@ return self.wopener(f, mode) def wread(self, filename): - return self.wopener(filename, 'r').read() + if self.encodepats == None: + l = [] + for pat, cmd in self.ui.configitems("encode"): + mf = util.matcher("", "/", [pat], [], [])[1] + l.append((mf, cmd)) + self.encodepats = l + + data = self.wopener(filename, 'r').read() + + for mf, cmd in self.encodepats: + if mf(filename): + self.ui.debug("filtering %s through %s\n" % (filename, cmd)) + data = util.filter(data, cmd) + break + + return data def wwrite(self, filename, data, fd=None): + if self.decodepats == None: + l = [] + for pat, cmd in self.ui.configitems("decode"): + mf = util.matcher("", "/", [pat], [], [])[1] + l.append((mf, cmd)) + self.decodepats = l + + for mf, cmd in self.decodepats: + if mf(filename): + self.ui.debug("filtering %s through %s\n" % (filename, cmd)) + data = util.filter(data, cmd) + break + if fd: return fd.write(data) return self.wopener(filename, 'w').write(data)
--- a/mercurial/util.py Thu Sep 15 00:04:29 2005 -0700 +++ b/mercurial/util.py Thu Sep 15 03:00:10 2005 -0500 @@ -12,7 +12,23 @@ import os, errno from demandload import * -demandload(globals(), "re cStringIO shutil") +demandload(globals(), "re cStringIO shutil popen2 threading") + +def filter(s, cmd): + "filter a string through a command that transforms its input to its output" + (pout, pin) = popen2.popen2(cmd, -1, 'b') + def writer(): + pin.write(s) + pin.close() + + # we should use select instead on UNIX, but this will work on most + # systems, including Windows + w = threading.Thread(target=writer) + w.start() + f = pout.read() + pout.close() + w.join() + return f def binary(s): """return true if a string is binary data using diff's heuristic"""
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-encode Thu Sep 15 03:00:10 2005 -0500 @@ -0,0 +1,34 @@ +#!/bin/sh + +hg init + +cat > .hg/hgrc <<EOF +[encode] +*.gz = gunzip + +[decode] +*.gz = gzip + +EOF + +echo "this is a test" | gzip > a.gz +hg add a.gz +hg ci -m "test" -d "0 0" +echo %% no changes +hg status +touch a.gz + +echo %% no changes +hg status + +echo %% uncompressed contents in repo +hg debugdata .hg/data/a.gz.d 0 + +echo %% uncompress our working dir copy +gunzip < a.gz + +rm a.gz +hg co + +echo %% uncompress our new working dir copy +gunzip < a.gz
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-encode.out Thu Sep 15 03:00:10 2005 -0500 @@ -0,0 +1,8 @@ +%% no changes +%% no changes +%% uncompressed contents in repo +this is a test +%% uncompress our working dir copy +this is a test +%% uncompress our new working dir copy +this is a test