##// END OF EJS Templates
subrepos: add function for iterating over ctx subrepos
Martin Geisler -
r12176:ecab1082 default
parent child Browse files
Show More
@@ -10,7 +10,7 b' from i18n import _'
10 10 import os, sys, errno, re, glob, tempfile
11 11 import util, templater, patch, error, encoding, templatekw
12 12 import match as matchmod
13 import similar, revset
13 import similar, revset, subrepo
14 14
15 15 revrangesep = ':'
16 16
@@ -683,14 +683,7 b' def diffordiffstat(ui, repo, diffopts, n'
683 683 if listsubrepos:
684 684 ctx1 = repo[node1]
685 685 ctx2 = repo[node2]
686 # Create a (subpath, ctx) mapping where we prefer subpaths
687 # from ctx1. The subpaths from ctx2 are important when the
688 # .hgsub file has been modified (in ctx2) but not yet
689 # committed (in ctx1).
690 subpaths = dict.fromkeys(ctx2.substate, ctx2)
691 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
692 for subpath, ctx in subpaths.iteritems():
693 sub = ctx.sub(subpath)
686 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):
694 687 if node2 is not None:
695 688 node2 = bin(ctx2.substate[subpath][1])
696 689 submatch = matchmod.narrowmatcher(subpath, match)
@@ -1161,14 +1161,7 b' class localrepository(repo.repository):'
1161 1161 r = modified, added, removed, deleted, unknown, ignored, clean
1162 1162
1163 1163 if listsubrepos:
1164 # Create a (subpath, ctx) mapping where we prefer subpaths
1165 # from ctx1. The subpaths from ctx2 are important when the
1166 # .hgsub file has been modified (in ctx2) but not yet
1167 # committed (in ctx1).
1168 subpaths = dict.fromkeys(ctx2.substate, ctx2)
1169 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
1170 for subpath, ctx in subpaths.iteritems():
1171 sub = ctx.sub(subpath)
1164 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):
1172 1165 if working:
1173 1166 rev2 = None
1174 1167 else:
@@ -184,6 +184,16 b' def _abssource(repo, push=False):'
184 184 return repo.ui.config('paths', 'default-push', repo.root)
185 185 return repo.ui.config('paths', 'default', repo.root)
186 186
187 def itersubrepos(ctx1, ctx2):
188 """find subrepos in ctx1 or ctx2"""
189 # Create a (subpath, ctx) mapping where we prefer subpaths from
190 # ctx1. The subpaths from ctx2 are important when the .hgsub file
191 # has been modified (in ctx2) but not yet committed (in ctx1).
192 subpaths = dict.fromkeys(ctx2.substate, ctx2)
193 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
194 for subpath, ctx in sorted(subpaths.iteritems()):
195 yield subpath, ctx.sub(subpath)
196
187 197 def subrepo(ctx, path):
188 198 """return instance of the right subrepo class for subrepo in path"""
189 199 # subrepo inherently violates our import layering rules
General Comments 0
You need to be logged in to leave comments. Login now