Skip to content

Fix-Check for heads before assigning branch tips#350

Open
delacor wants to merge 1 commit intofrej:masterfrom
delacor:Fix-empty-branchheads
Open

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

Conversation

@delacor
Copy link

@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
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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants