sapling icon indicating copy to clipboard operation
sapling copied to clipboard

sl ghstack crashes if remote bookmark ancestor isn't pulled locally

Open discentem opened this issue 2 years ago • 7 comments

I cannot tell from this crash message why there was a crash. I wonder if it's because I don't have write access to the repo but not 100% sure.

% sl ghstack
** Sapling SCM (version 0.1.20221118-210929-cfbb68aa) has crashed:
Traceback (most recent call last):
  File "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/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 "/opt/homebrew/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/ghstack/__init__.py", line 51, in ghstack_command
    return submit_cmd(ui, repo, *args, **opts)
  File "/opt/homebrew/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/edenscm/ext/ghstack/__init__.py", line 104, in submit_cmd
    ghstack.submit.main(
  File "/opt/homebrew/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ghstack/submit.py", line 162, in main
    base = GitCommitHash(sh.git("merge-base", f"{remote_name}/{default_branch}", "HEAD"))
  File "/opt/homebrew/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ghstack/sapling_shell.py", line 50, in git
    return self._run_sapling_command(["log", "-T", "{node}", "-r", f"ancestor(., {remote})"])
  File "/opt/homebrew/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ghstack/sapling_shell.py", line 87, in _run_sapling_command
    stdout = self.sh(*full_args, env=env)
  File "/opt/homebrew/Cellar/[email protected]/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ghstack/shell.py", line 218, in sh
    raise RuntimeError(
RuntimeError: /opt/homebrew/bin/sl log -T {node} -r ancestor(., dev) failed with exit code 255

discentem avatar Dec 01 '22 17:12 discentem

RuntimeError: /opt/homebrew/bin/sl log -T {node} -r ancestor(., dev) failed with exit code 255

What happens if you try running /opt/homebrew/bin/sl log -T '{node}' -r 'ancestor(., dev)' by itself, are there any more helpful messages there?

shish avatar Dec 02 '22 17:12 shish

If you don't have write access to the repo, then sl ghstack will definitely not work, though if that is what is causing this output, we should certainly communicate that better.

bolinfest avatar Dec 05 '22 18:12 bolinfest

Hey folks sorry for the late reply!

@shish running it manually sort of gets a better error message but still unclear what it's trying to do? I guess it's trying to pull request with a branch that doesn't exist?

% /opt/homebrew/bin/sl log -T '{node}' -r 'ancestor(., dev)'
abort: unknown revision 'dev'!

discentem avatar Dec 17 '22 00:12 discentem

@bolinfest it turns out write access is not the issue. as a test I got myself write access and still ran into the same issue

discentem avatar Dec 17 '22 00:12 discentem

Okay I made some progress, but still not solved. The suggestion run the command manually really helped!

So it's looking for dev which is not a revision/bookmark I have locally. Okay fine...

sl pull -B dev

but then I run into another fun error:

The commit 5050b9a6e0d129dc12767b7a51e0e4f96e85681d has 2 parents, which makes my head
explode.  `git rebase -i` your diffs into a stack, then try again.

discentem avatar Dec 17 '22 01:12 discentem

There are a couple of issues with this error message though.

  • I can't use git in a sapling checkout. I guess this message is an artifact of using ghstack.
  • sl rebase -i asked me to specify a destination but it's not very clear what destination I should choose.

discentem avatar Dec 17 '22 01:12 discentem

Just in case it's helpful for someone to understand/explain the issue to me, here's my sl tree state: https://gist.github.com/discentem/482939c9250296b2ad8be17f1e46ea93. Not sure how to get out of this.

discentem avatar Dec 18 '22 00:12 discentem

I was able to rebase and get further with sl ghstack. However, because I had initially messed up my local state, I decide to reclone and try to pull in remote state of the stack by cloning the head branch and ran into this issue:

RuntimeError: This commit is poisoned: it is from a head or base branch--ghstack
cannot validly submit it.  The most common situation for this to
happen is if you checked out the head branch of a pull request that was
previously submitted with ghstack (e.g., by using hub checkout).
Making modifications on the head branch is not supported; instead,
you should fetch the original commits in question by running:

What's the correct way to import (e.g. pull down) the remote state of the stack?

discentem avatar Dec 19 '22 18:12 discentem

I ended up solving this by uncommitting the commit that was based on head and re-committing: this seems to satisfy ghstack.

discentem avatar Dec 19 '22 20:12 discentem

Submitted https://github.com/facebook/sapling/pull/340 to mitigate https://github.com/facebook/sapling/issues/290#issue-1471716614

discentem avatar Dec 20 '22 22:12 discentem