Mercurial > public > mercurial-scm > hg
comparison mercurial/config.py @ 8180:6fc30fe7f3e7
hgweb: use config.config
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:43 -0500 |
parents | fca54469480e |
children | 2858ab754995 |
comparison
equal
deleted
inserted
replaced
8179:0f3b8404051b | 8180:6fc30fe7f3e7 |
---|---|
55 def set(self, section, item, value, source=""): | 55 def set(self, section, item, value, source=""): |
56 if section not in self: | 56 if section not in self: |
57 self._data[section] = sortdict() | 57 self._data[section] = sortdict() |
58 self._data[section][item] = (value, source) | 58 self._data[section][item] = (value, source) |
59 | 59 |
60 def read(self, path, fp): | 60 def read(self, path, fp=None): |
61 sectionre = re.compile(r'\[([^\[]+)\]') | 61 sectionre = re.compile(r'\[([^\[]+)\]') |
62 itemre = re.compile(r'([^=\s]+)\s*=\s*(.*)') | 62 itemre = re.compile(r'([^=\s]+)\s*=\s*(.*)') |
63 contre = re.compile(r'\s+(\S.*)') | 63 contre = re.compile(r'\s+(\S.*)') |
64 emptyre = re.compile(r'(;|#|\s*$)') | 64 emptyre = re.compile(r'(;|#|\s*$)') |
65 section = "" | 65 section = "" |
66 item = None | 66 item = None |
67 line = 0 | 67 line = 0 |
68 cont = 0 | 68 cont = 0 |
69 | |
70 if not fp: | |
71 fp = open(path) | |
72 | |
69 for l in fp: | 73 for l in fp: |
70 line += 1 | 74 line += 1 |
71 if cont: | 75 if cont: |
72 m = contre.match(l) | 76 m = contre.match(l) |
73 if m: | 77 if m: |