##// 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 import os, sys, errno, re, glob, tempfile
10 import os, sys, errno, re, glob, tempfile
11 import util, templater, patch, error, encoding, templatekw
11 import util, templater, patch, error, encoding, templatekw
12 import match as matchmod
12 import match as matchmod
13 import similar, revset
13 import similar, revset, subrepo
14
14
15 revrangesep = ':'
15 revrangesep = ':'
16
16
@@ -683,14 +683,7 b' def diffordiffstat(ui, repo, diffopts, n'
683 if listsubrepos:
683 if listsubrepos:
684 ctx1 = repo[node1]
684 ctx1 = repo[node1]
685 ctx2 = repo[node2]
685 ctx2 = repo[node2]
686 # Create a (subpath, ctx) mapping where we prefer subpaths
686 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):
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)
694 if node2 is not None:
687 if node2 is not None:
695 node2 = bin(ctx2.substate[subpath][1])
688 node2 = bin(ctx2.substate[subpath][1])
696 submatch = matchmod.narrowmatcher(subpath, match)
689 submatch = matchmod.narrowmatcher(subpath, match)
@@ -1161,14 +1161,7 b' class localrepository(repo.repository):'
1161 r = modified, added, removed, deleted, unknown, ignored, clean
1161 r = modified, added, removed, deleted, unknown, ignored, clean
1162
1162
1163 if listsubrepos:
1163 if listsubrepos:
1164 # Create a (subpath, ctx) mapping where we prefer subpaths
1164 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):
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)
1172 if working:
1165 if working:
1173 rev2 = None
1166 rev2 = None
1174 else:
1167 else:
@@ -184,6 +184,16 b' def _abssource(repo, push=False):'
184 return repo.ui.config('paths', 'default-push', repo.root)
184 return repo.ui.config('paths', 'default-push', repo.root)
185 return repo.ui.config('paths', 'default', repo.root)
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 def subrepo(ctx, path):
197 def subrepo(ctx, path):
188 """return instance of the right subrepo class for subrepo in path"""
198 """return instance of the right subrepo class for subrepo in path"""
189 # subrepo inherently violates our import layering rules
199 # subrepo inherently violates our import layering rules
General Comments 0
You need to be logged in to leave comments. Login now