patch: include flag-only file changes in "special" when filtering (
issue5864)
This patch fix the
issue5864 (or maybe
issue5865 too) which occurs during
split (or I should say at the time of filtering the hunks in interactive
mode) where user hits a not ending loop of "no changes to record".
And it's not only the case for split it will happen in every interactive
case for e.g. `hg commit -i` or `hg uncommit -i`
After looking into code I found that when filtering we have some
notation called "special" for the file headers which doesn't contain
any hunk and just contain the header (for e.g. newly added empty file
or deleted file) where the user cannot change the content of operation.
And I think we can put this "flag-only" file change in that same bucket
of "special". But I doubt a bit about the case when a file have flag change
and atleast one hunk then user won't be able to separate the flag change
from hunks.
Changed test file reflect the fixed behaviour.
Differential Revision: https://phab.mercurial-scm.org/D6058
from __future__ import absolute_import, print_function
import os
from mercurial import (
dispatch,
ui as uimod,
)
from mercurial.utils import (
stringutil,
)
# ensure errors aren't buffered
testui = uimod.ui()
testui.pushbuffer()
testui.write((b'buffered\n'))
testui.warn((b'warning\n'))
testui.write_err(b'error\n')
print(stringutil.pprint(testui.popbuffer(), bprefix=True).decode('ascii'))
# test dispatch.dispatch with the same ui object
hgrc = open(os.environ["HGRCPATH"], 'wb')
hgrc.write(b'[extensions]\n')
hgrc.write(b'color=\n')
hgrc.close()
ui_ = uimod.ui.load()
ui_.setconfig(b'ui', b'formatted', b'True')
# we're not interested in the output, so write that to devnull
ui_.fout = open(os.devnull, 'wb')
# call some arbitrary command just so we go through
# color's wrapped _runcommand twice.
def runcmd():
dispatch.dispatch(dispatch.request([b'version', b'-q'], ui_))
runcmd()
print("colored? %s" % (ui_._colormode is not None))
runcmd()
print("colored? %s" % (ui_._colormode is not None))