mirror of
https://github.com/facebook/sapling.git
synced 2024-12-26 22:47:26 +03:00
phrevset: improve error message if the commit hash is not found
Summary: Make the error cleaner and more actionable. We don't autopull the commit because the revset layer might be not ready for it (ex. it expects commit graph to be immutable and might have done some calculations based on the old graph already). Reviewed By: sfilipco Differential Revision: D20845159 fbshipit-source-id: c51f2f52c612ff14a88fb891c10d1faad1094635
This commit is contained in:
parent
a06922ec0f
commit
bd55a2e946
@ -55,6 +55,25 @@ DESCRIPTION_REGEX = re.compile(
|
||||
|
||||
def graphqlgetdiff(repo, diffid):
|
||||
"""Resolves a phabricator Diff number to a commit hash of it's latest version """
|
||||
if util.istest():
|
||||
hexnode = repo.ui.config("phrevset", "mock-D%s" % diffid)
|
||||
if hexnode:
|
||||
return {
|
||||
"source_control_system": "hg",
|
||||
"description": "mock",
|
||||
"phabricator_version_properties": {
|
||||
"edges": [
|
||||
{
|
||||
"node": {
|
||||
"property_name": "local:commits",
|
||||
"property_value": json.dumps(
|
||||
{hexnode: {"commit": hexnode, "rev": hexnode}}
|
||||
),
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
timeout = repo.ui.configint("ssl", "timeout", 10)
|
||||
ca_certs = repo.ui.configpath("web", "cacerts")
|
||||
try:
|
||||
@ -265,8 +284,9 @@ def revsetdiff(repo, diffid):
|
||||
node = unfiltered[rev]
|
||||
except error.RepoLookupError:
|
||||
raise error.Abort(
|
||||
"Commit %s corresponding to D%s\n not found in the repo"
|
||||
% (rev, diffid)
|
||||
_("cannot find the latest version of D%s (%s) locally")
|
||||
% (diffid, rev),
|
||||
hint=_("try 'hg pull -r %s'") % rev,
|
||||
)
|
||||
successors = list(repo.revs("last(successors(%n))", node.node()))
|
||||
if len(successors) != 1:
|
||||
|
@ -453,7 +453,7 @@ def getreponame(ui):
|
||||
return "unknown"
|
||||
|
||||
|
||||
class MissingNodesError(error.Abort, KeyError):
|
||||
class MissingNodesError(error.Abort, error.Context, KeyError):
|
||||
def __init__(self, keys, message=None, hint=None):
|
||||
keys = list(keys)
|
||||
nodestr = ", ".join(
|
||||
|
@ -23,3 +23,14 @@ sh % "hg up D1234" == r"""
|
||||
This will be slow if the diff was not committed recently
|
||||
abort: phrevset.graphqlonly is set and Phabricator cannot resolve D1234
|
||||
[255]"""
|
||||
|
||||
sh % "drawdag" << "A"
|
||||
sh % "setconfig phrevset.mock-D1234=$A phrevset.callsign=R"
|
||||
sh % "hg log -r D1234 -T '{desc}\n'" == "A"
|
||||
|
||||
# Phabricator provides an unknown commit hash.
|
||||
sh % "setconfig phrevset.mock-D1234=6008bb23d775556ff6c3528541ca5a2177b4bb92"
|
||||
sh % "hg log -r D1234 -T '{desc}\n'" == r"""
|
||||
abort: cannot find the latest version of D1234 (6008bb23d775556ff6c3528541ca5a2177b4bb92) locally
|
||||
(try 'hg pull -r 6008bb23d775556ff6c3528541ca5a2177b4bb92')
|
||||
[255]"""
|
Loading…
Reference in New Issue
Block a user