Mercurial > hg
changeset 20392:d4f804caa0ed
itersubrepos: move to scmutil to break a direct import cycle
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 03 Feb 2014 18:36:00 -0500 |
parents | 466e4c574db0 |
children | b0638b5b004d |
files | mercurial/cmdutil.py mercurial/localrepo.py mercurial/scmutil.py mercurial/subrepo.py tests/test-module-imports.t |
diffstat | 5 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Feb 07 02:59:46 2014 +0100 +++ b/mercurial/cmdutil.py Mon Feb 03 18:36:00 2014 -0500 @@ -10,7 +10,7 @@ import os, sys, errno, re, tempfile import util, scmutil, templater, patch, error, templatekw, revlog, copies import match as matchmod -import subrepo, context, repair, graphmod, revset, phases, obsolete, pathutil +import context, repair, graphmod, revset, phases, obsolete, pathutil import changelog import bookmarks import lock as lockmod @@ -629,7 +629,7 @@ if listsubrepos: ctx1 = repo[node1] ctx2 = repo[node2] - for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): + for subpath, sub in scmutil.itersubrepos(ctx1, ctx2): tempnode2 = node2 try: if node2 is not None:
--- a/mercurial/localrepo.py Fri Feb 07 02:59:46 2014 +0100 +++ b/mercurial/localrepo.py Mon Feb 03 18:36:00 2014 -0500 @@ -1579,7 +1579,7 @@ r = modified, added, removed, deleted, unknown, ignored, clean if listsubrepos: - for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): + for subpath, sub in scmutil.itersubrepos(ctx1, ctx2): if working: rev2 = None else:
--- a/mercurial/scmutil.py Fri Feb 07 02:59:46 2014 +0100 +++ b/mercurial/scmutil.py Mon Feb 03 18:36:00 2014 -0500 @@ -20,6 +20,16 @@ systemrcpath = scmplatform.systemrcpath userrcpath = scmplatform.userrcpath +def itersubrepos(ctx1, ctx2): + """find subrepos in ctx1 or ctx2""" + # Create a (subpath, ctx) mapping where we prefer subpaths from + # ctx1. The subpaths from ctx2 are important when the .hgsub file + # has been modified (in ctx2) but not yet committed (in ctx1). + subpaths = dict.fromkeys(ctx2.substate, ctx2) + subpaths.update(dict.fromkeys(ctx1.substate, ctx1)) + for subpath, ctx in sorted(subpaths.iteritems()): + yield subpath, ctx.sub(subpath) + def nochangesfound(ui, repo, excluded=None): '''Report no changes for push/pull, excluded is None or a list of nodes excluded from the push/pull.
--- a/mercurial/subrepo.py Fri Feb 07 02:59:46 2014 +0100 +++ b/mercurial/subrepo.py Mon Feb 03 18:36:00 2014 -0500 @@ -326,16 +326,6 @@ os.unlink(os.path.join(dirname, f)) os.walk(path, v, None) -def itersubrepos(ctx1, ctx2): - """find subrepos in ctx1 or ctx2""" - # Create a (subpath, ctx) mapping where we prefer subpaths from - # ctx1. The subpaths from ctx2 are important when the .hgsub file - # has been modified (in ctx2) but not yet committed (in ctx1). - subpaths = dict.fromkeys(ctx2.substate, ctx2) - subpaths.update(dict.fromkeys(ctx1.substate, ctx1)) - for subpath, ctx in sorted(subpaths.iteritems()): - yield subpath, ctx.sub(subpath) - def subrepo(ctx, path): """return instance of the right subrepo class for subrepo in path""" # subrepo inherently violates our import layering rules
--- a/tests/test-module-imports.t Fri Feb 07 02:59:46 2014 +0100 +++ b/tests/test-module-imports.t Mon Feb 03 18:36:00 2014 -0500 @@ -38,7 +38,7 @@ mercurial/ui.py mixed imports stdlib: formatter relative: config, error, scmutil, util - Import cycle: mercurial.cmdutil -> mercurial.subrepo -> mercurial.cmdutil Import cycle: mercurial.repoview -> mercurial.revset -> mercurial.repoview Import cycle: mercurial.fileset -> mercurial.merge -> mercurial.subrepo -> mercurial.match -> mercurial.fileset + Import cycle: mercurial.cmdutil -> mercurial.context -> mercurial.subrepo -> mercurial.cmdutil -> mercurial.cmdutil Import cycle: mercurial.filemerge -> mercurial.match -> mercurial.fileset -> mercurial.merge -> mercurial.filemerge