mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
add template support to hg cloud sl
command
Summary: add template support to `hg cloud sl` command it is a bit unusual from user's point of view that it is not supported, now let's support it it also provides an easy way to see the full hashes Reviewed By: markbt Differential Revision: D41579865 fbshipit-source-id: 92f15394628799ee8f54796387f0055ed8bfac7e
This commit is contained in:
parent
38921ca3a0
commit
10a07cefed
@ -544,9 +544,13 @@ def cloudlog(ui, repo, **opts):
|
||||
|
||||
@subcmd(
|
||||
"smartlog|sl",
|
||||
cloudsmartlogopts + workspace.workspaceopts,
|
||||
[
|
||||
("T", "template", "", _("display with template"), _("TEMPLATE")),
|
||||
]
|
||||
+ cloudsmartlogopts
|
||||
+ workspace.workspaceopts,
|
||||
)
|
||||
def cloudsmartlog(ui, repo, template="sl_cloud", **opts):
|
||||
def cloudsmartlog(ui, repo, templatealias="sl_cloud", **opts):
|
||||
"""get smartlog view for the workspace specified
|
||||
|
||||
If the requested template is not defined in the config
|
||||
@ -558,7 +562,7 @@ def cloudsmartlog(ui, repo, template="sl_cloud", **opts):
|
||||
|
||||
if opts.get("history"):
|
||||
interactivehistory.showhistory(
|
||||
ui, repo, reponame, workspacename, template, **opts
|
||||
ui, repo, reponame, workspacename, templatealias, **opts
|
||||
)
|
||||
return
|
||||
|
||||
@ -609,15 +613,16 @@ def cloudsmartlog(ui, repo, template="sl_cloud", **opts):
|
||||
# set up pager
|
||||
ui.pager("smartlog")
|
||||
|
||||
smartlogstyle = ui.config("templatealias", template)
|
||||
# if style is defined in templatealias section of config apply that style
|
||||
if smartlogstyle:
|
||||
opts["template"] = "{%s}" % smartlogstyle
|
||||
else:
|
||||
ui.debug(
|
||||
_("style %s is not defined, skipping") % smartlogstyle,
|
||||
component="commitcloud",
|
||||
)
|
||||
if not opts.get("template"):
|
||||
smartlogstyle = ui.config("templatealias", templatealias)
|
||||
# if style is defined in templatealias section of config apply that style
|
||||
if smartlogstyle:
|
||||
opts["template"] = "{%s}" % smartlogstyle
|
||||
else:
|
||||
ui.debug(
|
||||
_("style %s is not defined, skipping") % smartlogstyle,
|
||||
component="commitcloud",
|
||||
)
|
||||
|
||||
# show all the nodes
|
||||
firstpublic, revdag = serv.makedagwalker(slinfo, repo)
|
||||
|
@ -16,7 +16,7 @@ from edenscm.i18n import _
|
||||
from . import service
|
||||
|
||||
|
||||
def showhistory(ui, repo, reponame, workspacename, template, **opts) -> None:
|
||||
def showhistory(ui, repo, reponame, workspacename, templatealias, **opts) -> None:
|
||||
class cloudsl(object):
|
||||
def __init__(self, ui, repo, reponame, workspacename, **opts):
|
||||
self.ui = ui
|
||||
@ -58,9 +58,10 @@ def showhistory(ui, repo, reponame, workspacename, template, **opts) -> None:
|
||||
"You have no recorded history at or after this date"
|
||||
)
|
||||
|
||||
smartlogstyle = ui.config("templatealias", template)
|
||||
if smartlogstyle:
|
||||
self.opts["template"] = "{%s}" % smartlogstyle
|
||||
if not self.opts.get("template"):
|
||||
smartlogstyle = ui.config("templatealias", templatealias)
|
||||
if smartlogstyle:
|
||||
self.opts["template"] = "{%s}" % smartlogstyle
|
||||
|
||||
if initversion:
|
||||
initversion = int(initversion)
|
||||
|
@ -1615,3 +1615,45 @@ Tests for hg cloud sl
|
||||
│
|
||||
o 073f98 (public) 2018-01-02 10:00 +0000
|
||||
some commit
|
||||
|
||||
$ cat > $TESTTMP/usersmartlogdata << EOF
|
||||
> {
|
||||
> "smartlog": {
|
||||
> "nodes": [
|
||||
> { "node": "0067e44d36d919bec1bff6ac65d277e8e0dc2250", "phase": "draft", "author": "Test User", "date": 1527626185, "message": "some commit", "parents": ["4b1141993451c32f5e1c285ddc88468255cdccf2"], "bookmarks": [] },
|
||||
> { "node": "30443c40415321c0157d3798f14c51068edb428d", "phase": "public", "author": "Test User", "date": 1529511690, "message": "some commit", "parents": ["5526fe82a2b98fb5f3a340f21712a3437ddeb300"], "bookmarks": [] },
|
||||
> { "node": "4b1141993451c32f5e1c285ddc88468255cdccf2", "phase": "public", "author": "Test User", "date": 1527625388, "message": "some commit", "parents": ["42a2e3678e5e79c482a5eb4af808429fc044ae88"], "bookmarks": [] },
|
||||
> { "node": "685a62272258b3bd4d71ac0b331486276b3c2599", "phase": "draft", "author": "Test User", "date": 1531408804, "message": "some commit", "parents": ["aa84f0443f949a6accca6d67b2790d2f37927451"], "bookmarks": [] },
|
||||
> { "node": "717dccd1a732f794c51df27f7ba143c5c743d770", "phase": "draft", "author": "Test User", "date": 1529528566, "message": "some commit", "parents": ["30443c40415321c0157d3798f14c51068edb428d"], "bookmarks": [] },
|
||||
> { "node": "773bd8234d94c44079b4409525028517fcbd98ba", "phase": "draft", "author": "Test User", "date": 1532525470, "message": "some commit", "parents": ["c609e6238e05accd090222c74a0699238f394ba4"], "bookmarks": ["somebookmark"] },
|
||||
> { "node": "99d5fb5998e4f0a77a6b867ddeee93e7666e76c6", "phase": "public", "author": "Test User", "date": 1531229959, "message": "some commit", "parents": ["0c9fb09820a8fecb7ca9f5c46a776b72ffe41f24"], "bookmarks": [] },
|
||||
> { "node": "aa84f0443f949a6accca6d67b2790d2f37927451", "phase": "draft", "author": "Test User", "date": 1531249011, "message": "some commit", "parents": ["99d5fb5998e4f0a77a6b867ddeee93e7666e76c6"], "bookmarks": [] },
|
||||
> { "node": "c609e6238e05accd090222c74a0699238f394ba4", "phase": "public", "author": "Test User", "date": 1532342212, "message": "some commit", "parents": ["8cf8e2da24fdedf8f90276663bf8bb8acf60af2d"], "bookmarks": [] }]
|
||||
> }
|
||||
> }
|
||||
> EOF
|
||||
|
||||
$ hg cloud sl -T {"node"}
|
||||
the repository is not connected to any workspace, assuming the 'default' workspace
|
||||
commitcloud: searching draft commits for the 'user/test/default' workspace for the 'server' repo
|
||||
Smartlog:
|
||||
|
||||
o 773bd8234d94c44079b4409525028517fcbd98ba
|
||||
╭─╯
|
||||
o c609e6238e05accd090222c74a0699238f394ba4
|
||||
╷
|
||||
╷ o 685a62272258b3bd4d71ac0b331486276b3c2599
|
||||
╷ │
|
||||
╷ o aa84f0443f949a6accca6d67b2790d2f37927451
|
||||
╭─╯
|
||||
o 99d5fb5998e4f0a77a6b867ddeee93e7666e76c6
|
||||
╷
|
||||
╷ o 717dccd1a732f794c51df27f7ba143c5c743d770
|
||||
╭─╯
|
||||
o 30443c40415321c0157d3798f14c51068edb428d
|
||||
╷
|
||||
╷ o 0067e44d36d919bec1bff6ac65d277e8e0dc2250
|
||||
╭─╯
|
||||
o 4b1141993451c32f5e1c285ddc88468255cdccf2
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user