sapling
sapling copied to clipboard
`sl pr` crashes at first use
following the tutorial here: https://sapling-scm.com/docs/introduction/getting-started
my guess is that my system's python doesn't work with sl?
$ sl pr
** Sapling SCM (version 0.1.20221118-210929-cfbb68aa) has crashed:
Traceback (most recent call last):
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/__init__.py", line 106, in run
dispatch.run(args, fin, fout, ferr, config)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 161, in run
status = (dispatch(req) or 0) & 255
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 503, in dispatch
ret = _runcatch(req)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 712, in _runcatch
return _callcatch(ui, req, _runcatchfunc)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 721, in _callcatch
return scmutil.callcatch(ui, req, func)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/scmutil.py", line 147, in callcatch
return func()
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 683, in _runcatchfunc
return _dispatch(req)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 1218, in _dispatch
ret = runcommand(
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/undo.py", line 146, in _runcommandwrapper
result = orig(lui, repo, cmd, fullargs, *args)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/journal.py", line 80, in runcommand
return orig(lui, repo, cmd, fullargs, *args)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/sparse.py", line 504, in _tracktelemetry
res = runcommand(lui, repo, *args)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/copytrace.py", line 173, in _runcommand
return orig(lui, repo, cmd, fullargs, ui, *args, **kwargs)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 913, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 1259, in _runcommand
return cmdfunc()
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/dispatch.py", line 1217, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/util.py", line 1285, in check
return func(*args, **kwargs)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/github/__init__.py", line 32, in pull_request_command
return submit.submit(ui, repo, *args, **opts)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/github/submit.py", line 28, in submit
return asyncio.run(update_commits_in_stack(ui, repo, github_repo))
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/github/submit.py", line 116, in update_commits_in_stack
repository = await get_repository_for_origin(
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/github/submit.py", line 353, in get_repository_for_origin
return await get_repo(hostname, origin_owner, origin_name)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/github/submit.py", line 373, in get_repo
repo_result = await gh_submit.get_repository(hostname, owner, name)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/github/gh_submit.py", line 101, in get_repository
repository = _parse_repository_from_dict(repo, hostname=hostname, upstream=upstream)
File "/usr/local/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/github/gh_submit.py", line 157, in _parse_repository_from_dict
default_branch=repo_obj["defaultBranchRef"]["name"],
TypeError: 'NoneType' object is not subscriptable
this might be because I don't have a branch name or something? I just cloned a new repo from github and added commits with sl ci
❯ sl
@ 56b0d3e81 4 minutes ago >
│ adding baz
│
o c4a3c72d9 4 minutes ago >
│ adding bar
│
o 5446f4d30 5 minutes ago >
│ adding foo
│
o 5c1e38820 5 minutes ago >
first commit
OK I think the problem is that the get_repository() function actually gets defaultBranchRef from querying a Github repo, and on a brand new Github project there's no default branch I guess? Perhaps this code should change:
def _parse_repository_from_dict(repo_obj, hostname: str, upstream=None) -> Repository:
+ default_branch = "main" if "defaultBranchRef" not in repo_obj else repo_obj["defaultBranchRef"]["name"]
return Repository(
id=repo_obj["id"],
hostname=hostname,
owner=repo_obj["owner"]["login"],
name=repo_obj["name"],
- default_branch=repo_obj["defaultBranchRef"]["name"],
+ default_branch=default_branch,
is_fork=repo_obj["isFork"],
upstream=upstream,
)
Fixed by https://github.com/facebook/sapling/commit/9360b18ef1ac2e4fd095ef34c69bc3b1aaddb7fb