Skip to content

Fix-Check for heads before assigning branch tips#350

Closed
delacor wants to merge 1 commit into
frej:masterfrom
delacor:Fix-empty-branchheads
Closed

Fix-Check for heads before assigning branch tips#350
delacor wants to merge 1 commit into
frej:masterfrom
delacor:Fix-empty-branchheads

Conversation

@delacor
Copy link
Copy Markdown

@delacor delacor commented Feb 27, 2026

branchheads() reports an empty list for some branches which result in:

Traceback (most recent call last):
  File "/home/john/git/fast-export/hg-fast-export.py", line 739, in <module>
    sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/john/git/fast-export/hg-fast-export.py", line 556, in hg2git
    if not verify_heads(ui,repo,heads_cache,force,ignore_unnamed_heads,branchesmap):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/john/git/fast-export/hg-fast-export.py", line 494, in verify_heads
    branches[bn] = branchtip(repo, heads)
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/john/git/fast-export/hg-fast-export.py", line 482, in branchtip
    tip = heads[-1]
          ~~~~~^^^^
IndexError: list index out of range

branchheads() reports an empty list for some branches which result in:
```
Traceback (most recent call last):
  File "/home/john/git/fast-export/hg-fast-export.py", line 739, in <module>
    sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/john/git/fast-export/hg-fast-export.py", line 556, in hg2git
    if not verify_heads(ui,repo,heads_cache,force,ignore_unnamed_heads,branchesmap):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/john/git/fast-export/hg-fast-export.py", line 494, in verify_heads
    branches[bn] = branchtip(repo, heads)
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/john/git/fast-export/hg-fast-export.py", line 482, in branchtip
    tip = heads[-1]
          ~~~~~^^^^
IndexError: list index out of range

```
@delacor delacor changed the title Check for heads before assigning branch tips Fix-Check for heads before assigning branch tips Feb 27, 2026
@frej
Copy link
Copy Markdown
Owner

frej commented Feb 27, 2026

@delacor, can you create a small test example where this error occurs or check that you get the crash for closed branches?

It may be that the change in 76db75d should be using heads = repo.branchmap().branchheads(bn, closed=True) in order to preserve the old behaviour.

@frej frej added the Abandoned/No-activity Contributor does not respond to or act on review comments label Mar 14, 2026
@frej
Copy link
Copy Markdown
Owner

frej commented Mar 14, 2026

Closing, no response from the MR author in two weeks.

@frej frej closed this Mar 14, 2026
@delacor
Copy link
Copy Markdown
Author

delacor commented Mar 14, 2026

Sorry, Im busy with moving right now, will answer if I manage to get time. There is a closed branch, but I don't know if it crashes excactly there. But it is likely.

@frej
Copy link
Copy Markdown
Owner

frej commented Apr 2, 2026

Superseded by #353.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned/No-activity Contributor does not respond to or act on review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants