Mercurial > hg-stable
changeset 29366:d269e7db2f55
ui: provide official way to reset internal state per command
This will allow us to clear in-memory password storage per runcommand().
I've updated commandserver to call resetstate() of both ui and repo.ui because
they may have different states in theory.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 12 Jun 2016 14:07:26 +0900 |
parents | f652e84f23f2 |
children | 4e6e280e238f |
files | mercurial/commandserver.py mercurial/ui.py |
diffstat | 2 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commandserver.py Sat Jun 11 10:17:49 2016 +0900 +++ b/mercurial/commandserver.py Sun Jun 12 14:07:26 2016 +0900 @@ -229,12 +229,8 @@ self.repo.ui = self.repo.dirstate._ui = repoui self.repo.invalidateall() - # reset last-print time of progress bar per command - # (progbar is singleton, we don't have to do for all uis) - if copiedui._progbar: - copiedui._progbar.resetstate() - for ui in uis: + ui.resetstate() # any kind of interaction must use server channels, but chg may # replace channels by fully functional tty files. so nontty is # enforced only if cin is a channel.
--- a/mercurial/ui.py Sat Jun 11 10:17:49 2016 +0900 +++ b/mercurial/ui.py Sun Jun 12 14:07:26 2016 +0900 @@ -138,6 +138,11 @@ def copy(self): return self.__class__(self) + def resetstate(self): + """Clear internal state that shouldn't persist across commands""" + if self._progbar: + self._progbar.resetstate() # reset last-print time of progress bar + def formatter(self, topic, opts): return formatter.formatter(self, topic, opts)