hgext/rebase.py
changeset 38496 c92fdc27cbdd
parent 38495 ba6d2c32f34a
child 38497 9c3b48fb7ac5
equal deleted inserted replaced
38495:ba6d2c32f34a 38496:c92fdc27cbdd
   816         userrevs = list(repo.revs(opts.get(r'auto_orphans')))
   816         userrevs = list(repo.revs(opts.get(r'auto_orphans')))
   817         opts[r'rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)]
   817         opts[r'rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)]
   818         opts[r'dest'] = '_destautoorphanrebase(SRC)'
   818         opts[r'dest'] = '_destautoorphanrebase(SRC)'
   819 
   819 
   820     if dryrun:
   820     if dryrun:
   821         rbsrt = rebaseruntime(repo, ui, inmemory=True,
   821         return _dryrunrebase(ui, repo, **opts)
   822                               opts=pycompat.byteskwargs(opts))
       
   823         with repo.wlock(), repo.lock():
       
   824             try:
       
   825                 overrides = {('rebase', 'singletransaction'): True}
       
   826                 with ui.configoverride(overrides, 'rebase'):
       
   827                     _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
       
   828                                 leaveunfinished=True, **opts)
       
   829             except error.InMemoryMergeConflictsError:
       
   830                 ui.status(_('hit a merge conflict\n'))
       
   831                 return 1
       
   832             else:
       
   833                 ui.status(_('there will be no conflict, you can rebase\n'))
       
   834                 return 0
       
   835             finally:
       
   836                 rbsrt._prepareabortorcontinue(isabort=True)
       
   837     elif inmemory:
   822     elif inmemory:
   838         try:
   823         try:
   839             # in-memory merge doesn't support conflicts, so if we hit any, abort
   824             # in-memory merge doesn't support conflicts, so if we hit any, abort
   840             # and re-run as an on-disk merge.
   825             # and re-run as an on-disk merge.
   841             overrides = {('rebase', 'singletransaction'): True}
   826             overrides = {('rebase', 'singletransaction'): True}
   846                       ' merge\n'))
   831                       ' merge\n'))
   847             _origrebase(ui, repo, abort=True)
   832             _origrebase(ui, repo, abort=True)
   848             return _origrebase(ui, repo, inmemory=False, **opts)
   833             return _origrebase(ui, repo, inmemory=False, **opts)
   849     else:
   834     else:
   850         return _origrebase(ui, repo, **opts)
   835         return _origrebase(ui, repo, **opts)
       
   836 
       
   837 def _dryrunrebase(ui, repo, **opts):
       
   838     rbsrt = rebaseruntime(repo, ui, inmemory=True,
       
   839                           opts=pycompat.byteskwargs(opts))
       
   840     with repo.wlock(), repo.lock():
       
   841         try:
       
   842             overrides = {('rebase', 'singletransaction'): True}
       
   843             with ui.configoverride(overrides, 'rebase'):
       
   844                 _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
       
   845                             leaveunfinished=True, **opts)
       
   846         except error.InMemoryMergeConflictsError:
       
   847             ui.status(_('hit a merge conflict\n'))
       
   848             return 1
       
   849         else:
       
   850             ui.status(_('there will be no conflict, you can rebase\n'))
       
   851             return 0
       
   852         finally:
       
   853             rbsrt._prepareabortorcontinue(isabort=True)
   851 
   854 
   852 def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, rbsrt=None,
   855 def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, rbsrt=None,
   853                 **opts):
   856                 **opts):
   854     opts = pycompat.byteskwargs(opts)
   857     opts = pycompat.byteskwargs(opts)
   855     if not rbsrt:
   858     if not rbsrt: