Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 2874:4ec58b157265
refactor text diff/patch code.
rename commands.dodiff to patch.diff.
rename commands.doexport to patch.export.
move some functions from commands to new mercurial.cmdutil module.
turn list of diff options into mdiff.diffopts class.
patch.diff and patch.export now has clean api for call from 3rd party
python code.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Sat, 12 Aug 2006 16:13:27 -0700 |
parents | 345bac2bc4ec |
children | 3848488244fc 8b02af865990 |
comparison
equal
deleted
inserted
replaced
2873:5dd6631c8238 | 2874:4ec58b157265 |
---|---|
6 # of the GNU General Public License, incorporated herein by reference. | 6 # of the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 from i18n import gettext as _ | 8 from i18n import gettext as _ |
9 from demandload import * | 9 from demandload import * |
10 demandload(globals(), "errno getpass os re smtplib socket sys tempfile") | 10 demandload(globals(), "errno getpass os re smtplib socket sys tempfile") |
11 demandload(globals(), "ConfigParser templater traceback util") | 11 demandload(globals(), "ConfigParser mdiff templater traceback util") |
12 | 12 |
13 class ui(object): | 13 class ui(object): |
14 def __init__(self, verbose=False, debug=False, quiet=False, | 14 def __init__(self, verbose=False, debug=False, quiet=False, |
15 interactive=True, traceback=False, parentui=None): | 15 interactive=True, traceback=False, parentui=None): |
16 self.overlay = {} | 16 self.overlay = {} |
167 result = {} | 167 result = {} |
168 for key, value in self.configitems("revlog"): | 168 for key, value in self.configitems("revlog"): |
169 result[key.lower()] = value | 169 result[key.lower()] = value |
170 return result | 170 return result |
171 | 171 |
172 def diffopts(self): | 172 def diffopts(self, opts={}): |
173 if self.diffcache: | 173 return mdiff.diffopts( |
174 return self.diffcache | 174 text=opts.get('text'), |
175 result = {'showfunc': True, 'ignorews': False, | 175 showfunc=(opts.get('show_function') or |
176 'ignorewsamount': False, 'ignoreblanklines': False} | 176 self.configbool('diff', 'showfunc', None)), |
177 for key, value in self.configitems("diff"): | 177 ignorews=(opts.get('ignore_all_space') or |
178 if value: | 178 self.configbool('diff', 'ignorews', None)), |
179 result[key.lower()] = (value.lower() == 'true') | 179 ignorewsamount=(opts.get('ignore_space_change') or |
180 self.diffcache = result | 180 self.configbool('diff', 'ignorewsamount', None)), |
181 return result | 181 ignoreblanklines=(opts.get('ignore_blank_lines') or |
182 self.configbool('diff', 'ignoreblanklines', None))) | |
182 | 183 |
183 def username(self): | 184 def username(self): |
184 """Return default username to be used in commits. | 185 """Return default username to be used in commits. |
185 | 186 |
186 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL | 187 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL |