D2694: merge: deprecate accessing update results by index
This revision was automatically updated to reflect the committed changes. Closed by commit rHG6f570c501e3e: merge: deprecate accessing update results by index (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2694?vs=7269=7284 REVISION DETAIL https://phab.mercurial-scm.org/D2694 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/commands.py mercurial/hg.py mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -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): diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -749,7 +749,7 @@ return srcpeer, destpeer def _showstats(repo, stats, quietempty=False): -if quietempty and not any(stats): +if quietempty and stats.isempty(): return repo.ui.status(_("%d files updated, %d files merged, " "%d files removed, %d files unresolved\n") % ( @@ -770,9 +770,9 @@ """update the working directory to node""" stats = updaterepo(repo, node, False, updatecheck=updatecheck) _showstats(repo, stats, quietempty) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in clone() _update = update @@ -783,7 +783,7 @@ repo.vfs.unlinkpath('graftstate', ignoremissing=True) if show_stats: _showstats(repo, stats, quietempty) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in updatetotally() _clean = clean @@ -882,12 +882,12 @@ labels=labels) _showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg merge --abort' to abandon\n")) elif remind and not abort: repo.ui.status(_("(branch merge, don't forget to commit)\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 def _incoming(displaychlist, subreporecurse, ui, repo, source, opts, buffered=False): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -629,7 +629,7 @@ repo.setparents(op1, op2) dsguard.close() hg._showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved " "file merges\n")) return 1 @@ -2311,7 +2311,7 @@ finally: repo.ui.setconfig('ui', 'forcemerge', '', 'graft') # report any conflicts -if stats[3] > 0: +if stats.unresolvedcount > 0: # write out state for --continue nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] repo.vfs.write('graftstate', ''.join(nodelines)) diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -525,7 +525,7 @@ with ui.configoverride(overrides, 'rebase'): stats = rebasenode(repo, rev, p1, base, self.collapsef, dest, wctx=self.wctx) -if stats[3] > 0: +if stats.unresolvedcount > 0: if self.inmemory: raise error.InMemoryMergeConflictsError() else: diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++
D2694: merge: deprecate accessing update results by index
indygreg updated this revision to Diff 7269. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2694?vs=6970=7269 REVISION DETAIL https://phab.mercurial-scm.org/D2694 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/commands.py mercurial/hg.py mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1408,9 +1408,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: @@ -1423,6 +1429,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): @@ -2070,7 +2078,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): diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -749,7 +749,7 @@ return srcpeer, destpeer def _showstats(repo, stats, quietempty=False): -if quietempty and not any(stats): +if quietempty and stats.isempty(): return repo.ui.status(_("%d files updated, %d files merged, " "%d files removed, %d files unresolved\n") % ( @@ -770,9 +770,9 @@ """update the working directory to node""" stats = updaterepo(repo, node, False, updatecheck=updatecheck) _showstats(repo, stats, quietempty) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in clone() _update = update @@ -783,7 +783,7 @@ repo.vfs.unlinkpath('graftstate', ignoremissing=True) if show_stats: _showstats(repo, stats, quietempty) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in updatetotally() _clean = clean @@ -882,12 +882,12 @@ labels=labels) _showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg merge --abort' to abandon\n")) elif remind and not abort: repo.ui.status(_("(branch merge, don't forget to commit)\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 def _incoming(displaychlist, subreporecurse, ui, repo, source, opts, buffered=False): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -628,7 +628,7 @@ repo.setparents(op1, op2) dsguard.close() hg._showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved " "file merges\n")) return 1 @@ -2310,7 +2310,7 @@ finally: repo.ui.setconfig('ui', 'forcemerge', '', 'graft') # report any conflicts -if stats[3] > 0: +if stats.unresolvedcount > 0: # write out state for --continue nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] repo.vfs.write('graftstate', ''.join(nodelines)) diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -525,7 +525,7 @@ with ui.configoverride(overrides, 'rebase'): stats = rebasenode(repo, rev, p1, base, self.collapsef, dest, wctx=self.wctx) -if stats[3] > 0: +if stats.unresolvedcount > 0: if self.inmemory: raise error.InMemoryMergeConflictsError() else: diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -492,7 +492,7 @@ hg.update(repo, self.state.parentctxnode, quietempty=True) stats = applychanges(repo.ui, repo, rulectx, {})
D2694: merge: deprecate accessing update results by index
martinvonz added a comment. This one failed to apply, probably because of my changes to rebase.py. I have to leave now, but I'll try again later tonight, whether or not you've gotten a chance to update it. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2694 To: indygreg, durin42, #hg-reviewers, martinvonz Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2694: merge: deprecate accessing update results by index
indygreg updated this revision to Diff 6970. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2694?vs=6654=6970 REVISION DETAIL https://phab.mercurial-scm.org/D2694 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/commands.py mercurial/hg.py mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1407,9 +1407,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: @@ -1422,6 +1428,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): @@ -2069,7 +2077,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): diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -745,7 +745,7 @@ return srcpeer, destpeer def _showstats(repo, stats, quietempty=False): -if quietempty and not any(stats): +if quietempty and stats.isempty(): return repo.ui.status(_("%d files updated, %d files merged, " "%d files removed, %d files unresolved\n") % ( @@ -766,9 +766,9 @@ """update the working directory to node""" stats = updaterepo(repo, node, False, updatecheck=updatecheck) _showstats(repo, stats, quietempty) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in clone() _update = update @@ -779,7 +779,7 @@ repo.vfs.unlinkpath('graftstate', ignoremissing=True) if show_stats: _showstats(repo, stats, quietempty) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in updatetotally() _clean = clean @@ -878,12 +878,12 @@ labels=labels) _showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg merge --abort' to abandon\n")) elif remind and not abort: repo.ui.status(_("(branch merge, don't forget to commit)\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 def _incoming(displaychlist, subreporecurse, ui, repo, source, opts, buffered=False): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -624,7 +624,7 @@ repo.setparents(op1, op2) dsguard.close() hg._showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved " "file merges\n")) return 1 @@ -2301,7 +2301,7 @@ finally: repo.ui.setconfig('ui', 'forcemerge', '', 'graft') # report any conflicts -if stats[3] > 0: +if stats.unresolvedcount > 0: # write out state for --continue nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] repo.vfs.write('graftstate', ''.join(nodelines)) diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -486,7 +486,7 @@ 'rebase') stats = rebasenode(repo, rev, p1, base, self.collapsef, dest, wctx=self.wctx) -if stats[3] > 0: +if stats.unresolvedcount > 0: if self.wctx.isinmemory(): raise error.InMemoryMergeConflictsError() else: diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -489,7 +489,7 @@ hg.update(repo, self.state.parentctxnode, quietempty=True) stats = applychanges(repo.ui,
D2694: merge: deprecate accessing update results by index
indygreg created this revision. Herald added a reviewer: durin42. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY 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? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2694 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/commands.py mercurial/hg.py mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1407,9 +1407,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: @@ -1422,6 +1428,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): @@ -2069,7 +2077,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): diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -744,7 +744,7 @@ return srcpeer, destpeer def _showstats(repo, stats, quietempty=False): -if quietempty and not any(stats): +if quietempty and stats.isempty(): return repo.ui.status(_("%d files updated, %d files merged, " "%d files removed, %d files unresolved\n") % ( @@ -765,9 +765,9 @@ """update the working directory to node""" stats = updaterepo(repo, node, False, updatecheck=updatecheck) _showstats(repo, stats, quietempty) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in clone() _update = update @@ -778,7 +778,7 @@ repo.vfs.unlinkpath('graftstate', ignoremissing=True) if show_stats: _showstats(repo, stats, quietempty) -return stats[3] > 0 +return stats.unresolvedcount > 0 # naming conflict in updatetotally() _clean = clean @@ -877,12 +877,12 @@ labels=labels) _showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg merge --abort' to abandon\n")) elif remind and not abort: repo.ui.status(_("(branch merge, don't forget to commit)\n")) -return stats[3] > 0 +return stats.unresolvedcount > 0 def _incoming(displaychlist, subreporecurse, ui, repo, source, opts, buffered=False): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -624,7 +624,7 @@ repo.setparents(op1, op2) dsguard.close() hg._showstats(repo, stats) -if stats[3]: +if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved " "file merges\n")) return 1 @@ -2301,7 +2301,7 @@ finally: repo.ui.setconfig('ui', 'forcemerge', '', 'graft') # report any conflicts -if stats[3] > 0: +if stats.unresolvedcount > 0: # write out state for --continue nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] repo.vfs.write('graftstate', ''.join(nodelines)) diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -490,7 +490,7 @@ 'rebase') stats = rebasenode(repo, rev, p1, base, self.state, self.collapsef, dest, wctx=self.wctx) -if stats[3] > 0: +if stats.unresolvedcount > 0: if self.wctx.isinmemory():