comparison hgsubversion/svncommands.py @ 1461:cbc48ed3b56c

rebuildmeta: extract utility function for iterating over repositories
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sun, 11 Aug 2013 21:59:17 +0200
parents 0a6b3da6d34c
children 16242cec256f
comparison
equal deleted inserted replaced
1460:e31c288e5059 1461:cbc48ed3b56c
104 104
105 # ctx.children() visits all revisions in the repository after ctx. Calling 105 # ctx.children() visits all revisions in the repository after ctx. Calling
106 # it would make us use O(revisions^2) time, so we perform an extra traversal 106 # it would make us use O(revisions^2) time, so we perform an extra traversal
107 # of the repository instead. During this traversal, we find all converted 107 # of the repository instead. During this traversal, we find all converted
108 # changesets that close a branch, and store their first parent 108 # changesets that close a branch, and store their first parent
109 for rev in xrange(startrev, len(repo)): 109 for ctx in util.get_contexts(repo, startrev):
110 ui.progress('prepare', rev - startrev, total=numrevs) 110 ui.progress('prepare', ctx.rev() - startrev, total=numrevs)
111 try:
112 ctx = repo[rev]
113 except error.RepoError:
114 # this revision is hidden
115 continue
116 111
117 convinfo = util.getsvnrev(ctx, None) 112 convinfo = util.getsvnrev(ctx, None)
118 if not convinfo: 113 if not convinfo:
119 continue 114 continue
120 svnrevnum = int(convinfo.rsplit('@', 1)[1]) 115 svnrevnum = int(convinfo.rsplit('@', 1)[1])
137 closed.add(parentctx.rev()) 132 closed.add(parentctx.rev())
138 133
139 ui.progress('prepare', None, total=numrevs) 134 ui.progress('prepare', None, total=numrevs)
140 135
141 revmapbuf = [] 136 revmapbuf = []
142 for rev in xrange(startrev, len(repo)): 137 for ctx in util.get_contexts(repo, startrev):
143 ui.progress('rebuild', rev-startrev, total=numrevs) 138 ui.progress('rebuild', ctx.rev() - startrev, total=numrevs)
144 try:
145 ctx = repo[rev]
146 except error.RepoError:
147 # this revision is hidden
148 continue
149 139
150 convinfo = util.getsvnrev(ctx, None) 140 convinfo = util.getsvnrev(ctx, None)
151 if not convinfo: 141 if not convinfo:
152 continue 142 continue
153 if '.hgtags' in ctx.files(): 143 if '.hgtags' in ctx.files():
251 continue 241 continue
252 242
253 branch = meta.layoutobj.localname(parentpath) 243 branch = meta.layoutobj.localname(parentpath)
254 break 244 break
255 245
256 if rev in closed: 246 if ctx.rev() in closed:
257 # a direct child of this changeset closes the branch; drop it 247 # a direct child of this changeset closes the branch; drop it
258 branchinfo.pop(branch, None) 248 branchinfo.pop(branch, None)
259 elif ctx.extra().get('close'): 249 elif ctx.extra().get('close'):
260 pass 250 pass
261 elif branch not in branchinfo: 251 elif branch not in branchinfo: