This is an archive of the discontinued Mercurial Phabricator instance.

rebase: extract dryrun as a function
ClosedPublic

Authored by khanchi97 on Jun 28 2018, 4:10 PM.

Details

Summary

To avoid more number of indented blocks and make it easier to add
additional functionality in dryrun, extracted as a function.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

khanchi97 created this revision.Jun 28 2018, 4:10 PM
yuja added a subscriber: yuja.Jun 29 2018, 9:03 AM
rbsrt = rebaseruntime(repo, ui, inmemory, opts)
with repo.wlock(), repo.lock():
    try:
  • overrides = {('rebase', 'singletransaction'): True}
  • with ui.configoverride(overrides, 'rebase'):
  • _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
  • leaveunfinished=True, **opts)

+ _dryrunrebase(ui, repo, rbsrt, **opts)

except error.InMemoryMergeConflictsError:
    ui.status(_('hit a merge conflict\n'))
    return 1

Oops, I meant the whole dryrun process could be extracted to a function
because it's getting bigger.

if dryrun:
    return _dryrunrebase(...)
else:
    ...

But feel free to ignore my suggestion if there's a reason to not move
everything.

In D3855#60250, @yuja wrote:
rbsrt = rebaseruntime(repo, ui, inmemory, opts)
with repo.wlock(), repo.lock():
    try:
  • overrides = {('rebase', 'singletransaction'): True}
  • with ui.configoverride(overrides, 'rebase'):
  • _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
  • leaveunfinished=True, **opts)

+ _dryrunrebase(ui, repo, rbsrt, **opts)

except error.InMemoryMergeConflictsError:
    ui.status(_('hit a merge conflict\n'))
    return 1

Oops, I meant the whole dryrun process could be extracted to a function
because it's getting bigger.

if dryrun:
    return _dryrunrebase(...)
else:
    ...

But feel free to ignore my suggestion if there's a reason to not move
everything.

Aha, I thought you were pointing out to only "try:" block for more no. of indented blocks. I will update this.

khanchi97 updated this revision to Diff 9355.Jun 29 2018, 2:08 PM
This revision was automatically updated to reflect the committed changes.