diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1466,8 +1466,8 @@ def _changesetlabels(ctx): labels.append('changeset.obsolete') if ctx.troubled(): labels.append('changeset.troubled') - for trouble in ctx.troubles(): - labels.append('trouble.%s' % trouble) + for instability in ctx.instabilities(): + labels.append('trouble.%s' % instability) return ' '.join(labels) class changeset_printer(object): @@ -1579,7 +1579,8 @@ class changeset_printer(object): if ctx.troubled(): # i18n: column positioning for "hg log" - self.ui.write(_("instability: %s\n") % ', '.join(ctx.troubles()), + instabilities = ctx.instabilities() + self.ui.write(_("instability: %s\n") % ', '.join(instabilities), label='log.trouble') self._exthook(ctx) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4850,9 +4850,10 @@ def summary(ui, repo, **opts): if p.obsolete(): ui.write(_(' (obsolete)')) if p.troubled(): + instabilities = (ui.label(instability, 'trouble.%s' % instability) + for instability in p.instabilities()) ui.write(' (' - + ', '.join(ui.label(trouble, 'trouble.%s' % trouble) - for trouble in p.troubles()) + + ', '.join(instabilities) + ')') ui.write('\n') if p.description(): diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -226,21 +226,38 @@ class basectx(object): return self.unstable() or self.bumped() or self.divergent() def troubles(self): - """return the list of troubles affecting this changesets. + """Keep the old version around in order to avoid breaking extensions + about different return values. + """ + msg = ("'context.troubles' is deprecated, " + "use 'context.instabilities'") + self._repo.ui.deprecwarn(msg, '4.4') - Troubles are returned as strings. possible values are: + troubles = [] + if self.unstable(): + troubles.append('orphan') + if self.bumped(): + troubles.append('bumped') + if self.divergent(): + troubles.append('divergent') + return troubles + + def instabilities(self): + """return the list of instabilities affecting this changeset. + + Instabilities are returned as strings. possible values are: - orphan, - phase-divergent, - content-divergent. """ - troubles = [] + instabilities = [] if self.unstable(): - troubles.append('orphan') + instabilities.append('orphan') if self.bumped(): - troubles.append('phase-divergent') + instabilities.append('phase-divergent') if self.divergent(): - troubles.append('content-divergent') - return troubles + instabilities.append('content-divergent') + return instabilities def parents(self): """return contexts for each parent changeset""" diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -681,7 +681,9 @@ def _pushcheckoutgoing(pushop): if ctx.obsolete(): raise error.Abort(mso % ctx) elif ctx.troubled(): - raise error.Abort(mst[ctx.troubles()[0]] % ctx) + # TODO print more than one instability in the abort + # message + raise error.Abort(mst[ctx.instabilities()[0]] % ctx) discovery.checkheads(pushop) return True diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -783,7 +783,7 @@ def showinstabilities(**args): (EXPERIMENTAL) """ args = pycompat.byteskwargs(args) - return showlist('trouble', args['ctx'].troubles(), args) + return showlist('trouble', args['ctx'].instabilities(), args) # tell hggettext to extract docstrings from these functions: i18nfunctions = keywords.values()