fbamend: make restack take inhibithack

Summary:
This hack is needed to make split + rebase work well inside a same transaction.

inhibit does special things at the end of a transaction which may override deinhibit.
Sometimes we want deinhibit to override the transaction close handler.

The hack will be removed once inhibit gets removed.

Test Plan: arc unit

Reviewers: #mercurial, ikostia

Reviewed By: ikostia

Subscribers: ikostia, mjpieters, medson

Differential Revision: https://phabricator.intern.facebook.com/D5254517

Signature: t1:5254517:1497519294:89b6de077514252c42fb128760cf9f9241180242
This commit is contained in:
Jun Wu 2017-06-16 13:55:29 -07:00
parent 30b417ea27
commit 08e9bc0bbf

View File

@ -42,12 +42,16 @@ def getchildrelationships(repo, revs):
children[parent].add(rev)
return children
def restackonce(ui, repo, rev, rebaseopts=None, childrenonly=False):
def restackonce(ui, repo, rev, rebaseopts=None, childrenonly=False,
inhibithack=False):
"""Rebase all descendants of precursors of rev onto rev, thereby
stabilzing any non-obsolete descendants of those precursors.
Takes in an optional dict of options for the rebase command.
If childrenonly is True, only rebases direct children of precursors
of rev rather than all descendants of those precursors.
inhibithack: temporarily, make deinhibit override inhibit transaction
handling. useful to make things obsoleted inside a transaction.
"""
# Get visible descendants of precusors of rev.
allprecursors = repo.revs('allprecursors(%d)', rev)
@ -80,6 +84,9 @@ def restackonce(ui, repo, rev, rebaseopts=None, childrenonly=False):
# Perform rebase.
with repo.ui.configoverride(overrides, 'restack'):
# hack: make rebase obsolete commits
if inhibithack and inhibitmod:
inhibitmod.deinhibittransaction = True
rebase.rebase(ui, repo, **rebaseopts)
# Remove any preamend bookmarks on precursors.
@ -95,6 +102,8 @@ def restackonce(ui, repo, rev, rebaseopts=None, childrenonly=False):
# entire stack.
ancestors = repo.set('%ld %% %d', allprecursors, rev)
deinhibit(repo, ancestors)
if inhibithack and inhibitmod:
inhibitmod.deinhibittransaction = False
def _clearpreamend(repo, revs):
"""Remove any preamend bookmarks on the given revisions."""