From 76db75d9631fc90a25f58afa39b72822e792e724 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Sat, 14 Feb 2026 14:35:48 +0100 Subject: [PATCH] Support Mercurial 7.2 In Mercurial 7.2 the iteritems() method of the branchmap has been removed. Switch to iterating over the branches and then fetching heads by the branchheads() method. In 7.2, a call to mercurial.initialization.init() is also needed to process a repo using the largefiles extension. Thanks to Michael Cho (@cho-m) for suggesting the initialization fix. Closes #348 Co-developed-by: Michael Cho --- hg-fast-export.py | 4 +++- hg2git.py | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hg-fast-export.py b/hg-fast-export.py index c5f6f5d..bf8c310 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -488,7 +488,9 @@ def branchtip(repo, heads): def verify_heads(ui,repo,cache,force,ignore_unnamed_heads,branchesmap): branches={} - for bn, heads in repo.branchmap().iteritems(): + + for bn in repo.branchmap(): + heads = repo.branchmap().branchheads(bn) branches[bn] = branchtip(repo, heads) l=[(-repo.changelog.rev(n), n, t) for t, n in branches.items()] l.sort() diff --git a/hg2git.py b/hg2git.py index 73b475c..0bc74ff 100755 --- a/hg2git.py +++ b/hg2git.py @@ -30,6 +30,14 @@ def set_origin_name(name): origin_name = name.encode('utf8') def setup_repo(url): + try: + # Mercurial >= 7.2 requires explicit initialization for largefile + # support to work. + from mercurial import initialization + initialization.init() + except ImportError: + pass + try: myui=ui.ui(interactive=False) except TypeError: