Mercurial > public > mercurial-scm > hg
diff mercurial/merge.py @ 37125:6f570c501e3e
merge: deprecate accessing update results by index
Now that we have named attributes, let's convert the code base to use
them. We also add deprecation warnings so legacy consumers are aware
of their transgressions.
``stats.unresolvedcount`` is much easier to read than ``stats[3]``,
don't you think?
Differential Revision: https://phab.mercurial-scm.org/D2694
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 05 Mar 2018 00:30:00 -0500 |
parents | 43ffd9070da1 |
children | daef13da66fe |
line wrap: on
line diff
--- a/mercurial/merge.py Sun Mar 25 11:58:05 2018 +0900 +++ b/mercurial/merge.py Mon Mar 05 00:30:00 2018 -0500 @@ -1483,9 +1483,15 @@ removedcount = attr.ib() unresolvedcount = attr.ib() + def isempty(self): + return (not self.updatedcount and not self.mergedcount + and not self.removedcount and not self.unresolvedcount) + # TODO remove container emulation once consumers switch to new API. def __getitem__(self, x): + util.nouideprecwarn('access merge.update() results by name instead of ' + 'index', '4.6', 2) if x == 0: return self.updatedcount elif x == 1: @@ -1498,6 +1504,8 @@ raise IndexError('can only access items 0-3') def __len__(self): + util.nouideprecwarn('access merge.update() results by name instead of ' + 'index', '4.6', 2) return 4 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None): @@ -2164,7 +2172,8 @@ sparse.prunetemporaryincludes(repo) if not partial: - repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) + repo.hook('update', parent1=xp1, parent2=xp2, + error=stats.unresolvedcount) return stats def graft(repo, ctx, pctx, labels, keepparent=False):