comparison hgext/notify.py @ 2873: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 6b27a7125b67
children 20b95aef3fe0
comparison
equal deleted inserted replaced
2872:5dd6631c8238 2873:4ec58b157265
65 # push changes to, they can manage their own subscriptions. 65 # push changes to, they can manage their own subscriptions.
66 66
67 from mercurial.demandload import * 67 from mercurial.demandload import *
68 from mercurial.i18n import gettext as _ 68 from mercurial.i18n import gettext as _
69 from mercurial.node import * 69 from mercurial.node import *
70 demandload(globals(), 'email.Parser mercurial:commands,templater,util') 70 demandload(globals(), 'email.Parser mercurial:commands,patch,templater,util')
71 demandload(globals(), 'fnmatch socket time') 71 demandload(globals(), 'fnmatch socket time')
72 72
73 # template for single changeset can include email headers. 73 # template for single changeset can include email headers.
74 single_template = ''' 74 single_template = '''
75 Subject: changeset in {webroot}: {desc|firstline|strip} 75 Subject: changeset in {webroot}: {desc|firstline|strip}
236 maxdiff = int(self.ui.config('notify', 'maxdiff', 300)) 236 maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
237 if maxdiff == 0: 237 if maxdiff == 0:
238 return 238 return
239 fp = templater.stringio() 239 fp = templater.stringio()
240 prev = self.repo.changelog.parents(node)[0] 240 prev = self.repo.changelog.parents(node)[0]
241 commands.dodiff(fp, self.ui, self.repo, prev, ref) 241 patch.diff(self.repo, fp, prev, ref)
242 difflines = fp.getvalue().splitlines(1) 242 difflines = fp.getvalue().splitlines(1)
243 if maxdiff > 0 and len(difflines) > maxdiff: 243 if maxdiff > 0 and len(difflines) > maxdiff:
244 self.sio.write(_('\ndiffs (truncated from %d to %d lines):\n\n') % 244 self.sio.write(_('\ndiffs (truncated from %d to %d lines):\n\n') %
245 (len(difflines), maxdiff)) 245 (len(difflines), maxdiff))
246 difflines = difflines[:maxdiff] 246 difflines = difflines[:maxdiff]