本文整理汇总了Python中mercurial.patch.diffstat函数的典型用法代码示例。如果您正苦于以下问题:Python diffstat函数的具体用法?Python diffstat怎么用?Python diffstat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了diffstat函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _makeintro
def _makeintro(repo, sender, patches, **opts):
"""make an introduction email, asking the user for content if needed
email is returned as (subject, body, cumulative-diffstat)"""
ui = repo.ui
_charsets = mail._charsets(ui)
tlen = len(str(len(patches)))
flag = opts.get('flag') or ''
if flag:
flag = ' ' + ' '.join(flag)
prefix = '[PATCH %0*d of %d%s]' % (tlen, 0, len(patches), flag)
subj = (opts.get('subject') or
prompt(ui, '(optional) Subject: ', rest=prefix, default=''))
if not subj:
return None # skip intro if the user doesn't bother
subj = prefix + ' ' + subj
body = ''
if opts.get('diffstat'):
# generate a cumulative diffstat of the whole patch series
diffstat = patch.diffstat(sum(patches, []))
body = '\n' + diffstat
else:
diffstat = None
body = _getdescription(repo, body, sender, **opts)
msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
msg['Subject'] = mail.headencode(ui, subj, _charsets,
opts.get('test'))
return (msg, subj, diffstat)
开发者ID:RayFerr000,项目名称:PLTL,代码行数:33,代码来源:patchbomb.py
示例2: makeintro
def makeintro(patches):
tlen = len(str(len(patches)))
flag = opts.get('flag') or ''
if flag:
flag = ' ' + ' '.join(flag)
prefix = '[PATCH %0*d of %d%s]' % (tlen, 0, len(patches), flag)
subj = (opts.get('subject') or
prompt(ui, 'Subject: ', rest=prefix, default=''))
if not subj:
return None # skip intro if the user doesn't bother
subj = prefix + ' ' + subj
body = ''
if opts.get('diffstat'):
# generate a cumulative diffstat of the whole patch series
diffstat = patch.diffstat(sum(patches, []))
body = '\n' + diffstat
else:
diffstat = None
body = getdescription(body, sender)
msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
msg['Subject'] = mail.headencode(ui, subj, _charsets,
opts.get('test'))
return (msg, subj, diffstat)
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:28,代码来源:patchbomb.py
示例3: diff
def diff(self, ctx, ref=None):
maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
prev = ctx.p1().node()
if ref:
ref = ref.node()
else:
ref = ctx.node()
chunks = patch.diff(self.repo, prev, ref,
opts=patch.diffallopts(self.ui))
difflines = ''.join(chunks).splitlines()
if self.ui.configbool('notify', 'diffstat', True):
s = patch.diffstat(difflines)
# s may be nil, don't include the header if it is
if s:
self.ui.write('\ndiffstat:\n\n%s' % s)
if maxdiff == 0:
return
elif maxdiff > 0 and len(difflines) > maxdiff:
msg = _('\ndiffs (truncated from %d to %d lines):\n\n')
self.ui.write(msg % (len(difflines), maxdiff))
difflines = difflines[:maxdiff]
elif difflines:
self.ui.write(_('\ndiffs (%d lines):\n\n') % len(difflines))
self.ui.write("\n".join(difflines))
开发者ID:pierfort123,项目名称:mercurial,代码行数:28,代码来源:notify.py
示例4: cdiffstat
def cdiffstat(ui, summary, patchlines):
s = patch.diffstat(patchlines)
if summary:
ui.write(summary, '\n')
ui.write(s, '\n')
ans = prompt(ui, _('does the diffstat above look okay?'), 'y')
if not ans.lower().startswith('y'):
raise util.Abort(_('diffstat rejected'))
return s
开发者ID:Frostman,项目名称:intellij-community,代码行数:9,代码来源:patchbomb.py
示例5: cdiffstat
def cdiffstat(summary, patchlines):
s = patch.diffstat(patchlines)
if s:
if summary:
ui.write(summary, '\n')
ui.write(s, '\n')
confirm(_('Does the diffstat above look okay'),
_('diffstat rejected'))
elif s is None:
ui.warn(_('No diffstat information available.\n'))
s = ''
return s
开发者ID:c0ns0le,项目名称:cygwin,代码行数:12,代码来源:patchbomb.py
示例6: diffstat
def diffstat(self):
class patchbuf(object):
def __init__(self):
self.lines = []
# diffstat is stupid
self.name = 'cia'
def write(self, data):
self.lines.append(data)
def close(self):
pass
n = self.ctx.node()
pbuf = patchbuf()
cmdutil.export(self.cia.repo, [n], fp=pbuf)
return patch.diffstat(pbuf.lines) or ''
开发者ID:rybesh,项目名称:mysite-lib,代码行数:15,代码来源:hgcia.py
示例7: diffstat
def diffstat(self):
class patchbuf(object):
def __init__(self):
self.lines = []
# diffstat is stupid
self.name = "cia"
def write(self, data):
self.lines += data.splitlines(True)
def close(self):
pass
n = self.ctx.node()
pbuf = patchbuf()
cmdutil.export(self.cia.repo, [n], fp=pbuf)
return patch.diffstat(pbuf.lines) or ""
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:17,代码来源:hgcia.py
示例8: diffstat
def diffstat(ui, repo, **kwargs):
'''Example usage:
[hooks]
commit.diffstat = python:/path/to/this/file.py:diffstat
changegroup.diffstat = python:/path/to/this/file.py:diffstat
'''
if kwargs.get('parent2'):
return
node = kwargs['node']
first = repo[node].p1().node()
if 'url' in kwargs:
last = repo['tip'].node()
else:
last = node
diff = patch.diff(repo, first, last)
ui.write(patch.diffstat(util.iterlines(diff)))
开发者ID:cmjonze,项目名称:mercurial,代码行数:17,代码来源:python-hook-examples.py
示例9: diff
def diff(self, node, ref):
maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
prev = self.repo.changelog.parents(node)[0]
self.ui.pushbuffer()
patch.diff(self.repo, prev, ref)
difflines = self.ui.popbuffer().splitlines(1)
if self.ui.configbool('notify', 'diffstat', True):
s = patch.diffstat(difflines)
# s may be nil, don't include the header if it is
if s:
self.ui.write('\ndiffstat:\n\n%s' % s)
if maxdiff == 0:
return
if maxdiff > 0 and len(difflines) > maxdiff:
self.ui.write(_('\ndiffs (truncated from %d to %d lines):\n\n') %
(len(difflines), maxdiff))
difflines = difflines[:maxdiff]
elif difflines:
self.ui.write(_('\ndiffs (%d lines):\n\n') % len(difflines))
self.ui.write(*difflines)
开发者ID:carlgao,项目名称:lenga,代码行数:20,代码来源:notify.py
示例10: getpatchmsgs
def getpatchmsgs(patches, patchnames=None):
jumbo = []
msgs = []
ui.write(_('This patch series consists of %d patches.\n\n')
% len(patches))
name = None
for i, p in enumerate(patches):
jumbo.extend(p)
if patchnames:
name = patchnames[i]
msg = makepatch(ui, repo, p, opts, _charsets, i + 1,
len(patches), name)
msgs.append(msg)
if introneeded(opts, len(patches)):
tlen = len(str(len(patches)))
flag = ' '.join(opts.get('flag'))
if flag:
subj = '[PATCH %0*d of %d %s]' % (tlen, 0, len(patches), flag)
else:
subj = '[PATCH %0*d of %d]' % (tlen, 0, len(patches))
subj += ' ' + (opts.get('subject') or
prompt(ui, 'Subject: ', rest=subj))
body = ''
ds = patch.diffstat(jumbo)
if ds and opts.get('diffstat'):
body = '\n' + ds
body = getdescription(body, sender)
msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
msg['Subject'] = mail.headencode(ui, subj, _charsets,
opts.get('test'))
msgs.insert(0, (msg, subj, ds))
return msgs
开发者ID:MezzLabs,项目名称:mercurial,代码行数:39,代码来源:patchbomb.py
示例11: makepatch
def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered,
patchname=None):
desc = []
node = None
body = ''
for line in patchlines:
if line.startswith('#'):
if line.startswith('# Node ID'):
node = line.split()[-1]
continue
if line.startswith('diff -r') or line.startswith('diff --git'):
break
desc.append(line)
if not patchname and not node:
raise ValueError
if opts.get('attach') and not opts.get('body'):
body = ('\n'.join(desc[1:]).strip() or
'Patch subject is complete summary.')
body += '\n\n\n'
if opts.get('plain'):
while patchlines and patchlines[0].startswith('# '):
patchlines.pop(0)
if patchlines:
patchlines.pop(0)
while patchlines and not patchlines[0].strip():
patchlines.pop(0)
ds = patch.diffstat(patchlines, git=opts.get('git'))
if opts.get('diffstat'):
body += ds + '\n\n'
addattachment = opts.get('attach') or opts.get('inline')
if not addattachment or opts.get('body'):
body += '\n'.join(patchlines)
if addattachment:
msg = email.MIMEMultipart.MIMEMultipart()
if body:
msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
p = mail.mimetextpatch('\n'.join(patchlines), 'x-patch',
opts.get('test'))
binnode = bin(node)
# if node is mq patch, it will have the patch file's name as a tag
if not patchname:
patchtags = [t for t in repo.nodetags(binnode)
if t.endswith('.patch') or t.endswith('.diff')]
if patchtags:
patchname = patchtags[0]
elif total > 1:
patchname = cmdutil.makefilename(repo, '%b-%n.patch',
binnode, seqno=idx,
total=total)
else:
patchname = cmdutil.makefilename(repo, '%b.patch', binnode)
disposition = 'inline'
if opts.get('attach'):
disposition = 'attachment'
p['Content-Disposition'] = disposition + '; filename=' + patchname
msg.attach(p)
else:
msg = mail.mimetextpatch(body, display=opts.get('test'))
flag = ' '.join(opts.get('flag'))
if flag:
flag = ' ' + flag
subj = desc[0].strip().rstrip('. ')
if not numbered:
subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj)
else:
tlen = len(str(total))
subj = '[PATCH %0*d of %d%s] %s' % (tlen, idx, total, flag, subj)
msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
msg['X-Mercurial-Node'] = node
msg['X-Mercurial-Series-Index'] = '%i' % idx
msg['X-Mercurial-Series-Total'] = '%i' % total
return msg, subj, ds
开发者ID:RayFerr000,项目名称:PLTL,代码行数:82,代码来源:patchbomb.py
示例12: _incoming
def _incoming(ui, repo, **kwargs):
# Ensure that no fancying of output is enabled (e.g. coloring)
os.environ['TERM'] = 'dumb'
ui.setconfig('ui', 'interactive', 'False')
ui.setconfig('ui', 'formatted', 'False')
try:
colormod = sys.modules['hgext.color']
except KeyError:
pass
else:
colormod._styles.clear()
blacklisted = ui.config('mail', 'diff-blacklist', '').split()
displayer = cmdutil.changeset_printer(ui, repo, False, False, True)
ctx = repo[kwargs['node']]
displayer.show(ctx)
log = displayer.hunk[ctx.rev()]
user = os.environ.get('HGPUSHER', 'local')
path = '/'.join(repo.root.split('/')[4:])
body = []
#body += ['%s pushed %s to %s:' % (user, str(ctx), path), '']
body += [CSET_URL % (path, ctx)]
body += [line for line in log.splitlines()[:-2]
if line != 'tag: tip']
body += ['summary:\n ' + fromlocal(ctx.description())]
# ctx.files() gives us misleading info on merges, we use a diffstat instead
body += ['', 'files:']
diffopts = patch.diffopts(repo.ui, {'git': True, 'showfunc': True})
parents = ctx.parents()
node1 = parents and parents[0].node() or nullid
node2 = ctx.node()
diffchunks = list(patch.diff(repo, node1, node2, opts=diffopts))
diffstat = patch.diffstat(iterlines(diffchunks), width=60, git=True)
for line in iterlines([''.join(diffstat)]):
body.append(' ' + line)
body += ['', '']
diffchunks = strip_bin_diffs(diffchunks)
diffchunks = strip_blacklisted_files(diffchunks, blacklisted)
body.append(''.join(chunk for chunk in diffchunks))
body.append('-- ')
body.append('Repository URL: %s%s' % (BASE, path))
to = ui.config('mail', 'notify', None)
if to is None:
print 'no email address configured'
return False
from_ = ui.config('mail', 'sender', None)
if from_ is None:
from_ = to
sender = '%s <%s>' % (user, from_)
prefixes = [path]
if len(parents) == 2:
b1, b2, b = parents[0].branch(), parents[1].branch(), ctx.branch()
if b in (b1, b2):
bp = b2 if b == b1 else b1
# normal case
prefixes.append('(merge %s -> %s)' % (bp, b))
else:
# XXX really??
prefixes.append('(merge %s + %s -> %s)' % (b1, b2, b))
else:
branch = ctx.branch()
if branch != 'default':
prefixes.append('(%s)' % branch)
desc = ctx.description().splitlines()[0]
if len(desc) > 80:
desc = desc[:80]
if ' ' in desc:
desc = desc.rsplit(' ', 1)[0]
if prefixes:
prefixes = ' '.join(prefixes) + ': '
else:
prefixes = ''
subj = prefixes + desc
host = ui.config('smtp', 'host', '')
port = int(ui.config('smtp', 'port', 0))
smtp = smtplib.SMTP(host, port)
username = ui.config('smtp', 'username', '')
if username:
smtp.login(username, ui.config('smtp', 'password', ''))
send(smtp, subj, sender, to, '\n'.join(body) + '\n')
smtp.close()
ui.status('notified %s of incoming changeset %s\n' % (to, ctx))
return False
开发者ID:non-github,项目名称:python-hooks,代码行数:95,代码来源:mail.py
示例13: showdiffstat
def showdiffstat(repo, ctx, templ, **args):
"""String. Return diffstat-style summary of changes."""
width = repo.ui.termwidth()
return patch.diffstat(util.iterlines(ctx.diff(noprefix=False)), width=width)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:4,代码来源:stat.py
注:本文中的mercurial.patch.diffstat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论