Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 5:3e0f25b30aaa
Module und function to read .hg_archival.txt and frieds and parse it's contents
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Fri, 14 Aug 2015 15:14:58 +0200 |
| parents | fa5189869651 |
| children | 538c8f20ed51 |
| files | read_revinfo.py |
| diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/read_revinfo.py Fri Aug 14 15:14:58 2015 +0200 @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +r"""Read the output of the revinfo extension. + +Reads also the contents of a ".hg_archival.txt" file. + +""" + +__version__ = "0" + +__author__ = "Franz Glasner" + + +def read_revinfo(filename): + """Read file file `filename` and return it's contents as dict. + + If `filename` does not exist return `None`. + + """ + try: + with open(filename, "rt") as f: + return dict([[i.strip() for i in line.split(":", 1)] for line in f]) + except EnvironmentError: + return None + +import sys +print read_revinfo(sys.argv[1])
