contrib/tmplrewrite.py
author Brodie Rao <brodie@bitheap.org>
Sat, 09 Oct 2010 17:02:28 -0500
changeset 12681 bc13e17067d9
parent 8432 94ef2c8ce683
permissions -rwxr-xr-x
update: use higher level wording for "crosses branches" error When using "hg update" to update to a revision on another branch, if the user has uncommitted changes in the working directory, hg aborts with the following message: abort: crosses branches (use 'hg merge' to merge or use 'hg update -C' to discard changes) If the user isn't trying to update to tip and they follow the command examples verbatim, they would end up updating to the wrong revision. This patch removes the command examples in favor of just telling the user to either merge or use --clean: abort: crosses branches (merge branches or use --clean to discard changes) hg also aborts if the user tries to use "hg update" to get to tip (without specifying a revision) and tip is on another branch: abort: crosses branches (use 'hg merge' or use 'hg update -c') This message is changed in the same fashion: abort: crosses branches (merge branches or use --check to force update)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8432
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     1
#!/usr/bin/python
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     2
import sys, os, re
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     3
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     4
IGNORE = ['.css', '.py']
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     5
oldre = re.compile('#([\w\|%]+)#')
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     6
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     7
def rewrite(fn):
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     8
    f = open(fn)
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     9
    new = open(fn + '.new', 'wb')
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    10
    for ln in f:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    11
        new.write(oldre.sub('{\\1}', ln))
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    12
    new.close()
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    13
    f.close()
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    14
    os.rename(new.name, f.name)
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    15
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    16
if __name__ == '__main__':
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    17
    if len(sys.argv) < 2:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    18
        print 'usage: python tmplrewrite.py [file [file [file]]]'
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    19
    for fn in sys.argv[1:]:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    20
        if os.path.splitext(fn) in IGNORE:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    21
            continue
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    22
        print 'rewriting %s...' % fn
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    23
        rewrite(fn)