1200 if allopt: |
1200 if allopt: |
1201 raise util.Abort('cannot specify both "--all" and "--continue"') |
1201 raise util.Abort('cannot specify both "--all" and "--continue"') |
1202 graftcmd = commands.table['graft'][0] |
1202 graftcmd = commands.table['graft'][0] |
1203 return graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) |
1203 return graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) |
1204 |
1204 |
1205 tr = _picknexttroubled(ui, repo, anyopt or allopt) |
1205 tro = _picknexttroubled(ui, repo, anyopt or allopt) |
1206 if tr is None: |
1206 if tro is None: |
1207 if repo['.'].obsolete(): |
1207 if repo['.'].obsolete(): |
1208 displayer = cmdutil.show_changeset( |
1208 displayer = cmdutil.show_changeset( |
1209 ui, repo, {'template': shorttemplate}) |
1209 ui, repo, {'template': shorttemplate}) |
1210 successors = set() |
1210 successors = set() |
1211 |
1211 |
1253 if allopt: |
1253 if allopt: |
1254 ui.progress('evolve', seen, unit='changesets', total=count) |
1254 ui.progress('evolve', seen, unit='changesets', total=count) |
1255 seen = 1 |
1255 seen = 1 |
1256 count = allopt and _counttroubled(ui, repo) or 1 |
1256 count = allopt and _counttroubled(ui, repo) or 1 |
1257 |
1257 |
1258 while tr is not None: |
1258 while tro is not None: |
1259 progresscb() |
1259 progresscb() |
1260 result = _evolveany(ui, repo, tr, dryrunopt, progresscb=progresscb) |
1260 result = _evolveany(ui, repo, tro, dryrunopt, progresscb=progresscb) |
1261 progresscb() |
1261 progresscb() |
1262 seen += 1 |
1262 seen += 1 |
1263 if not allopt: |
1263 if not allopt: |
1264 return result |
1264 return result |
1265 progresscb() |
1265 progresscb() |
1266 tr = _picknexttroubled(ui, repo, anyopt or allopt) |
1266 tro = _picknexttroubled(ui, repo, anyopt or allopt) |
1267 |
1267 |
1268 if allopt: |
1268 if allopt: |
1269 ui.progress('evolve', None) |
1269 ui.progress('evolve', None) |
1270 |
1270 |
1271 |
1271 |
1272 def _evolveany(ui, repo, tr, dryrunopt, progresscb): |
1272 def _evolveany(ui, repo, tro, dryrunopt, progresscb): |
1273 repo = repo.unfiltered() |
1273 repo = repo.unfiltered() |
1274 tr = repo[tr.rev()] |
1274 tro = repo[tro.rev()] |
1275 cmdutil.bailifchanged(repo) |
1275 cmdutil.bailifchanged(repo) |
1276 troubles = tr.troubles() |
1276 troubles = tro.troubles() |
1277 if 'unstable' in troubles: |
1277 if 'unstable' in troubles: |
1278 return _solveunstable(ui, repo, tr, dryrunopt, progresscb) |
1278 return _solveunstable(ui, repo, tro, dryrunopt, progresscb) |
1279 elif 'bumped' in troubles: |
1279 elif 'bumped' in troubles: |
1280 return _solvebumped(ui, repo, tr, dryrunopt, progresscb) |
1280 return _solvebumped(ui, repo, tro, dryrunopt, progresscb) |
1281 elif 'divergent' in troubles: |
1281 elif 'divergent' in troubles: |
1282 repo = repo.unfiltered() |
1282 repo = repo.unfiltered() |
1283 tr = repo[tr.rev()] |
1283 tro = repo[tro.rev()] |
1284 return _solvedivergent(ui, repo, tr, dryrunopt, progresscb) |
1284 return _solvedivergent(ui, repo, tro, dryrunopt, progresscb) |
1285 else: |
1285 else: |
1286 assert False # WHAT? unknown troubles |
1286 assert False # WHAT? unknown troubles |
1287 |
1287 |
1288 def _counttroubled(ui, repo): |
1288 def _counttroubled(ui, repo): |
1289 """Count the amount of troubled changesets""" |
1289 """Count the amount of troubled changesets""" |
1294 return len(troubled) |
1294 return len(troubled) |
1295 |
1295 |
1296 def _picknexttroubled(ui, repo, pickany=False, progresscb=None): |
1296 def _picknexttroubled(ui, repo, pickany=False, progresscb=None): |
1297 """Pick a the next trouble changeset to solve""" |
1297 """Pick a the next trouble changeset to solve""" |
1298 if progresscb: progresscb() |
1298 if progresscb: progresscb() |
1299 tr = _stabilizableunstable(repo, repo['.']) |
1299 tro = _stabilizableunstable(repo, repo['.']) |
1300 if tr is None: |
1300 if tro is None: |
1301 wdp = repo['.'] |
1301 wdp = repo['.'] |
1302 if 'divergent' in wdp.troubles(): |
1302 if 'divergent' in wdp.troubles(): |
1303 tr = wdp |
1303 tro = wdp |
1304 if tr is None and pickany: |
1304 if tro is None and pickany: |
1305 troubled = list(repo.set('unstable()')) |
1305 troubled = list(repo.set('unstable()')) |
1306 if not troubled: |
1306 if not troubled: |
1307 troubled = list(repo.set('bumped()')) |
1307 troubled = list(repo.set('bumped()')) |
1308 if not troubled: |
1308 if not troubled: |
1309 troubled = list(repo.set('divergent()')) |
1309 troubled = list(repo.set('divergent()')) |
1310 if troubled: |
1310 if troubled: |
1311 tr = troubled[0] |
1311 tro = troubled[0] |
1312 |
1312 |
1313 return tr |
1313 return tro |
1314 |
1314 |
1315 def _stabilizableunstable(repo, pctx): |
1315 def _stabilizableunstable(repo, pctx): |
1316 """Return a changectx for an unstable changeset which can be |
1316 """Return a changectx for an unstable changeset which can be |
1317 stabilized on top of pctx or one of its descendants. None if none |
1317 stabilized on top of pctx or one of its descendants. None if none |
1318 can be found. |
1318 can be found. |