Mercurial > piecrust2
comparison garcon/changelog.py @ 1000:68f799dc4680
cm: Generate CHANGELOG from the current branch instead of always master. Fix encoding problems.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 21 Nov 2017 10:52:51 -0800 |
parents | be8b233cc69a |
children | 2e5c5d33d62c |
comparison
equal
deleted
inserted
replaced
999:46025a1b5434 | 1000:68f799dc4680 |
---|---|
1 import os | 1 import os |
2 import os.path | 2 import os.path |
3 import re | 3 import re |
4 import time | 4 import time |
5 import codecs | |
5 import argparse | 6 import argparse |
6 import subprocess | 7 import subprocess |
7 | 8 |
8 | 9 |
9 hg_log_template = ("{if(tags, '>>{tags};{date|shortdate}\n')}" | 10 hg_log_template = ("{if(tags, '>>{tags};{date|shortdate}\n')}" |
48 if not os.path.exists('.hg'): | 49 if not os.path.exists('.hg'): |
49 raise Exception("You must run this script from the root of a " | 50 raise Exception("You must run this script from the root of a " |
50 "Mercurial clone of the PieCrust repository.") | 51 "Mercurial clone of the PieCrust repository.") |
51 hglog = subprocess.check_output([ | 52 hglog = subprocess.check_output([ |
52 'hg', 'log', | 53 'hg', 'log', |
53 '--rev', 'reverse(::master)', | 54 '--rev', 'reverse(::.)', |
54 '--template', hg_log_template]) | 55 '--template', hg_log_template]) |
55 hglog = hglog.decode('utf8') | 56 hglog = codecs.decode(hglog, encoding='utf-8', errors='replace') |
56 | 57 |
57 _, out_ext = os.path.splitext(out_file) | 58 _, out_ext = os.path.splitext(out_file) |
58 templates = _get_templates(out_ext) | 59 templates = _get_templates(out_ext) |
59 | 60 |
60 with open(out_file, 'w', encoding='utf8', newline='') as fp: | 61 with open(out_file, 'w', encoding='utf8', newline='') as fp: |