Patchwork [01,of,12] upgrade: import 'localrepo' globally

login
register
mail settings
Submitter Pierre-Yves David
Date April 11, 2017, 10:47 p.m.
Message ID <fa55b926460cbd7ef688.1491950861@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20114/
State Accepted
Headers show

Comments

Pierre-Yves David - April 11, 2017, 10:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1491940873 -7200
#      Tue Apr 11 22:01:13 2017 +0200
# Node ID fa55b926460cbd7ef688d34ac600367a5ae28a0e
# Parent  b6d792a9bd116969235f1eb21e25d244351a5549
# EXP-Topic upgraderepo
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r fa55b926460c
upgrade: import 'localrepo' globally

The in-function imports mention a cycle that seems to no longer be relevant. As
a result, we just import it globally.

Patch

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -15,6 +15,7 @@  from .i18n import _
 from . import (
     changelog,
     error,
+    localrepo,
     manifest,
     revlog,
     scmutil,
@@ -144,9 +145,6 @@  def findimprovements(repo):
     Returns a list of ``upgradeimprovement`` describing repository deficiencies
     and optimizations.
     """
-    # Avoid cycle: cmdutil -> repair -> localrepo -> cmdutil
-    from . import localrepo
-
     newreporeqs = localrepo.newreporequirements(repo)
 
     improvements = []
@@ -585,9 +583,6 @@  def _upgraderepo(ui, srcrepo, dstrepo, r
 
 def upgraderepo(ui, repo, run=False, optimize=None):
     """Upgrade a repository in place."""
-    # Avoid cycle: cmdutil -> repair -> localrepo -> cmdutil
-    from . import localrepo
-
     optimize = set(optimize or [])
     repo = repo.unfiltered()