comparison 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
comparison
equal deleted inserted replaced
37124:6715e8035b4f 37125:6f570c501e3e
1481 updatedcount = attr.ib() 1481 updatedcount = attr.ib()
1482 mergedcount = attr.ib() 1482 mergedcount = attr.ib()
1483 removedcount = attr.ib() 1483 removedcount = attr.ib()
1484 unresolvedcount = attr.ib() 1484 unresolvedcount = attr.ib()
1485 1485
1486 def isempty(self):
1487 return (not self.updatedcount and not self.mergedcount
1488 and not self.removedcount and not self.unresolvedcount)
1489
1486 # TODO remove container emulation once consumers switch to new API. 1490 # TODO remove container emulation once consumers switch to new API.
1487 1491
1488 def __getitem__(self, x): 1492 def __getitem__(self, x):
1493 util.nouideprecwarn('access merge.update() results by name instead of '
1494 'index', '4.6', 2)
1489 if x == 0: 1495 if x == 0:
1490 return self.updatedcount 1496 return self.updatedcount
1491 elif x == 1: 1497 elif x == 1:
1492 return self.mergedcount 1498 return self.mergedcount
1493 elif x == 2: 1499 elif x == 2:
1496 return self.unresolvedcount 1502 return self.unresolvedcount
1497 else: 1503 else:
1498 raise IndexError('can only access items 0-3') 1504 raise IndexError('can only access items 0-3')
1499 1505
1500 def __len__(self): 1506 def __len__(self):
1507 util.nouideprecwarn('access merge.update() results by name instead of '
1508 'index', '4.6', 2)
1501 return 4 1509 return 4
1502 1510
1503 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None): 1511 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
1504 """apply the merge action list to the working directory 1512 """apply the merge action list to the working directory
1505 1513
2162 # (ex: this happens during hg rebase --abort). 2170 # (ex: this happens during hg rebase --abort).
2163 if not branchmerge: 2171 if not branchmerge:
2164 sparse.prunetemporaryincludes(repo) 2172 sparse.prunetemporaryincludes(repo)
2165 2173
2166 if not partial: 2174 if not partial:
2167 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) 2175 repo.hook('update', parent1=xp1, parent2=xp2,
2176 error=stats.unresolvedcount)
2168 return stats 2177 return stats
2169 2178
2170 def graft(repo, ctx, pctx, labels, keepparent=False): 2179 def graft(repo, ctx, pctx, labels, keepparent=False):
2171 """Do a graft-like merge. 2180 """Do a graft-like merge.
2172 2181