Show proper error message on missing snapshot id

Summary: Currently, using `hg snapshot show` without a snapshot id, simply crashes. This diff makes it exit with a better message.

Reviewed By: markbt

Differential Revision: D33185824

fbshipit-source-id: c2eaf98623416ae7de3dc4221c601f9fd47f5fd4
This commit is contained in:
Yan Soares Couto 2022-01-10 13:30:04 -08:00 committed by Facebook GitHub Bot
parent a5978edae1
commit b29cec3f50
2 changed files with 6 additions and 2 deletions

View File

@ -10,7 +10,9 @@ from .createremote import parsemaxuntracked
from .latest import _isworkingcopy from .latest import _isworkingcopy
def cmd(ui, repo, csid, **opts): def cmd(ui, repo, csid=None, **opts):
if csid is None:
raise error.CommandError("snapshot isworkingcopy", _("missing snapshot id"))
try: try:
snapshot = repo.edenapi.fetchsnapshot( snapshot = repo.edenapi.fetchsnapshot(
{ {

View File

@ -74,7 +74,9 @@ def _snapshot2ctx(repo, snapshot):
return ctx return ctx
def show(ui, repo, csid, **opts): def show(ui, repo, csid=None, **opts):
if csid is None:
raise error.CommandError("snapshot show", _("missing snapshot id"))
try: try:
snapshot = repo.edenapi.fetchsnapshot( snapshot = repo.edenapi.fetchsnapshot(
{ {