comparison hgext/evolve.py @ 1323:603104c880f7

evolve: simplify the evolve function We compute the troubles once and use it in two places instead of recomputing them just to count them.
author Laurent Charignon <lcharignon@fb.com>
date Thu, 30 Apr 2015 14:25:37 -0700
parents f3e0686a63a1
children 739208d1ee62
comparison
equal deleted inserted replaced
1322:f3e0686a63a1 1323:603104c880f7
1256 allopt = opts['all'] 1256 allopt = opts['all']
1257 startnode = repo['.'] 1257 startnode = repo['.']
1258 dryrunopt = opts['dry_run'] 1258 dryrunopt = opts['dry_run']
1259 confirmopt = opts['confirm'] 1259 confirmopt = opts['confirm']
1260 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve') 1260 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
1261 troubled = set(repo.revs('troubled()'))
1261 1262
1262 # Progress handling 1263 # Progress handling
1263 seen = 1 1264 seen = 1
1264 count = allopt and _counttroubled(ui, repo) or 1 1265 count = allopt and len(troubled) or 1
1265 showprogress = allopt 1266 showprogress = allopt
1266 1267
1267 def progresscb(): 1268 def progresscb():
1268 if allopt: 1269 if allopt:
1269 ui.progress('evolve', seen, unit='changesets', total=count) 1270 ui.progress('evolve', seen, unit='changesets', total=count)
1315 elif 'divergent' in troubles: 1316 elif 'divergent' in troubles:
1316 return _solvedivergent(ui, repo, tro, dryrunopt, confirmopt, 1317 return _solvedivergent(ui, repo, tro, dryrunopt, confirmopt,
1317 progresscb) 1318 progresscb)
1318 else: 1319 else:
1319 assert False # WHAT? unknown troubles 1320 assert False # WHAT? unknown troubles
1320
1321 def _counttroubled(ui, repo):
1322 """Count the amount of troubled changesets"""
1323 troubled = set()
1324 troubled.update(getrevs(repo, 'unstable'))
1325 troubled.update(getrevs(repo, 'bumped'))
1326 troubled.update(getrevs(repo, 'divergent'))
1327 return len(troubled)
1328 1321
1329 def _picknexttroubled(ui, repo, pickany=False, progresscb=None): 1322 def _picknexttroubled(ui, repo, pickany=False, progresscb=None):
1330 """Pick a the next trouble changeset to solve""" 1323 """Pick a the next trouble changeset to solve"""
1331 if progresscb: progresscb() 1324 if progresscb: progresscb()
1332 tro = _stabilizableunstable(repo, repo['.']) 1325 tro = _stabilizableunstable(repo, repo['.'])