hgext/evolve.py
changeset 706 90f0a1ede70a
parent 704 2ec7c3673679
child 707 f914e315b717
equal deleted inserted replaced
705:4884111bcb92 706:90f0a1ede70a
   886     contopt = opts['continue']
   886     contopt = opts['continue']
   887     anyopt = opts['any']
   887     anyopt = opts['any']
   888     allopt = opts['all']
   888     allopt = opts['all']
   889     dryrunopt = opts['dry_run']
   889     dryrunopt = opts['dry_run']
   890 
   890 
   891     evolved_changesets = 0
       
   892 
       
   893     if contopt:
   891     if contopt:
   894         if anyopt:
   892         if anyopt:
   895             raise util.Abort('can not specify both "--any" and "--continue"')
   893             raise util.Abort('can not specify both "--any" and "--continue"')
   896         if allopt:
   894         if allopt:
   897             raise util.Abort('can not specify both "--all" and "--continue"')
   895             raise util.Abort('can not specify both "--all" and "--continue"')
   898         graftcmd = commands.table['graft'][0]
   896         graftcmd = commands.table['graft'][0]
   899         return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
   897         return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
   900     while True:
   898 
   901         result = _evolveany(ui, repo, anyopt or allopt, dryrunopt)
   899     tr = _picknexttroubled(ui, repo, anyopt or allopt)
   902         if(1 == result):
       
   903             if(0 < evolved_changesets):
       
   904                 # We evolved some changesets, and now we're done
       
   905                 return 0
       
   906             ui.write_err(_('no troubled changeset\n')) 
       
   907         if not allopt:
       
   908             return result
       
   909         evolved_changesets+=1
       
   910         
       
   911 
       
   912 def _evolveany(ui, repo, anyopt, dryrunopt):
       
   913     tr = _picknexttroubled(ui, repo, anyopt)
       
   914     if tr is None:
   900     if tr is None:
   915         troubled = repo.revs('troubled()')
   901         troubled = repo.revs('troubled()')
   916         if troubled:
   902         if troubled:
   917             ui.write_err(_('nothing to evolve here\n'))
   903             ui.write_err(_('nothing to evolve here\n'))
   918             ui.status(_('(%i troubled changesets, do you want --any ?)\n')
   904             ui.status(_('(%i troubled changesets, do you want --any ?)\n')
   919                       % len(troubled))
   905                       % len(troubled))
   920             return 2
   906             return 2
   921         else:
   907         else:
       
   908             ui.write_err(_('no troubled changeset\n')) 
   922             return 1
   909             return 1
       
   910 
       
   911     while tr is not None:
       
   912         result = _evolveany(ui, repo, tr, dryrunopt)
       
   913         if 2 == result or not allopt:
       
   914             return result
       
   915         tr = _picknexttroubled(ui, repo, anyopt or allopt)
       
   916         
       
   917 
       
   918 def _evolveany(ui, repo, tr, dryrunopt):
   923     repo = repo.unfiltered()
   919     repo = repo.unfiltered()
   924     tr = repo[tr.rev()]
   920     tr = repo[tr.rev()]
   925     cmdutil.bailifchanged(repo)
   921     cmdutil.bailifchanged(repo)
   926     troubles = tr.troubles()
   922     troubles = tr.troubles()
   927     if 'unstable' in troubles:
   923     if 'unstable' in troubles: