contrib/tmplrewrite.py
author Matt Harbison <matt_harbison@yahoo.com>
Sat, 20 Oct 2012 21:43:46 -0400
branchstable
changeset 17847 1e4eb1faba6e
parent 8432 94ef2c8ce683
permissions -rwxr-xr-x
largefiles: use 'default' instead of 'default-push' when pulling (issue3584) This only applies to downloading largefiles, and only when no source for the pull is explicitly provided. The repository itself was properly being pulled via 'default' previously. Using --all-largefiles is not necessary on a bare pull to test this (this existing test is merely a convenience), but it is required to test pulling on the rebase path. Note that the errors generated in the --rebase case are because the repo specified doesn't have the largefiles in its cache (though they are in the user cache), so the errors are misleading. Specifying --all-largefiles when cloning to 'b' fixes this, but instead of errors, it reports caching only 5 largefiles instead of the 9 that come up missing. Likely this is because the largefile download procedure tries to download missing files for each rev, and some of the files have standins in more than one rev that gets pulled.

#!/usr/bin/python
import sys, os, re

IGNORE = ['.css', '.py']
oldre = re.compile('#([\w\|%]+)#')

def rewrite(fn):
    f = open(fn)
    new = open(fn + '.new', 'wb')
    for ln in f:
        new.write(oldre.sub('{\\1}', ln))
    new.close()
    f.close()
    os.rename(new.name, f.name)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print 'usage: python tmplrewrite.py [file [file [file]]]'
    for fn in sys.argv[1:]:
        if os.path.splitext(fn) in IGNORE:
            continue
        print 'rewriting %s...' % fn
        rewrite(fn)