mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
ab3a7cb21f
Summary: In preparation for merging fb-mercurial sources to the Eden repository, move everything from the top-level directory into an `eden/scm` subdirectory.
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
from edenscm.mercurial import error, patch, registrar, templatekw, util
|
|
from edenscm.mercurial.i18n import _
|
|
|
|
|
|
templatefunc = registrar.templatefunc()
|
|
|
|
|
|
@templatefunc("stat(style=none)", argspec="style")
|
|
def showdiffstat(context, mapping, args):
|
|
"""String. Return diffstat-style summary of changes.
|
|
|
|
If 'style' is not 'none', it could be 'status', in which case "added",
|
|
"changed", "removed" will be shown before file names.
|
|
"""
|
|
if "style" in args:
|
|
style = args["style"][1]
|
|
else:
|
|
style = "none"
|
|
|
|
repo = mapping["repo"]
|
|
ctx = mapping["ctx"]
|
|
revcache = mapping["revcache"]
|
|
width = repo.ui.termwidth()
|
|
|
|
if style == "none":
|
|
status = None
|
|
elif style == "status":
|
|
status = templatekw.getfiles(repo, ctx, revcache)
|
|
else:
|
|
raise error.ParseError(_("stat does not support style %r") % (style,))
|
|
|
|
return patch.diffstat(
|
|
util.iterlines(ctx.diff(noprefix=False)), width=width, status=status
|
|
)
|