D7902: merge: introduce a clean_update() for that use-case
Closed by commit rHGf546d2170b0f: merge: introduce a clean_update() for that use-case (authored by martinvonz). martinvonz marked an inline comment as done. This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7902?vs=19929=19970 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7902/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7902 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/hg.py mercurial/merge.py mercurial/shelve.py CHANGE DETAILS diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -745,7 +745,7 @@ try: checkparents(repo, state) -merge.update(repo, state.pendingctx, branchmerge=False, force=True) +merge.clean_update(state.pendingctx) if state.activebookmark and state.activebookmark in repo._bookmarks: bookmarks.activate(repo, state.activebookmark) mergefiles(ui, repo, state.wctx, state.pendingctx) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -2597,6 +2597,15 @@ return stats +def clean_update(ctx, wc=None): +"""Do a clean update to the given commit. + +This involves updating to the commit and discarding any changes in the +working copy. +""" +return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc) + + def graft( repo, ctx, diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1173,7 +1173,7 @@ node = repo[b'.'].hex() repo.ui.status(_(b"aborting the merge, updating back to %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True) +stats = mergemod.clean_update(repo[node]) assert stats.unresolvedcount == 0 _showstats(repo, stats) diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -800,9 +800,7 @@ # Update away from the rebase if necessary if shouldupdate: -mergemod.update( -repo, self.originalwd, branchmerge=False, force=True -) +mergemod.clean_update(repo[self.originalwd]) # Strip from the first rebased revision if rebased: @@ -1477,7 +1475,7 @@ else: if repo[b'.'].rev() != p1: repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx)) -mergemod.update(repo, p1, branchmerge=False, force=True) +mergemod.clean_update(p1ctx) else: repo.ui.debug(b" already in destination\n") # This is, alas, necessary to invalidate workingctx's manifest cache, diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -945,7 +945,7 @@ class base(histeditaction): def run(self): if self.repo[b'.'].node() != self.node: -mergemod.update(self.repo, self.node, branchmerge=False, force=True) +mergemod.clean_update(self.repo[self.node]) return self.continueclean() def continuedirty(self): To: martinvonz, durin42, #hg-reviewers, marmoute Cc: marmoute, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7902: merge: introduce a clean_update() for that use-case
martinvonz added inline comments. martinvonz marked an inline comment as done. INLINE COMMENTS > marmoute wrote in merge.py:2580 > The idea is great (I also always scratch my head at `merge.update`. However > can we can some solide documentation about what this function does ? Oh, of course we should. I added a sentence. I'm not sure if you consider that solid. Let me know what's missing otherwise. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7902/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7902 To: martinvonz, durin42, #hg-reviewers, marmoute Cc: marmoute, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7902: merge: introduce a clean_update() for that use-case
martinvonz updated this revision to Diff 19929. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7902?vs=19555=19929 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7902/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7902 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/hg.py mercurial/merge.py mercurial/shelve.py CHANGE DETAILS diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -745,7 +745,7 @@ try: checkparents(repo, state) -merge.update(repo, state.pendingctx, branchmerge=False, force=True) +merge.clean_update(state.pendingctx) if state.activebookmark and state.activebookmark in repo._bookmarks: bookmarks.activate(repo, state.activebookmark) mergefiles(ui, repo, state.wctx, state.pendingctx) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -2597,6 +2597,15 @@ return stats +def clean_update(ctx, wc=None): +"""Do a clean update to the given commit. + +This involves updating to the commit and discarding any changes in the +working copy. +""" +return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc) + + def graft( repo, ctx, diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1173,7 +1173,7 @@ node = repo[b'.'].hex() repo.ui.status(_(b"aborting the merge, updating back to %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True) +stats = mergemod.clean_update(repo[node]) assert stats.unresolvedcount == 0 _showstats(repo, stats) diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -800,9 +800,7 @@ # Update away from the rebase if necessary if shouldupdate: -mergemod.update( -repo, self.originalwd, branchmerge=False, force=True -) +mergemod.clean_update(repo[self.originalwd]) # Strip from the first rebased revision if rebased: @@ -1477,7 +1475,7 @@ else: if repo[b'.'].rev() != p1: repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx)) -mergemod.update(repo, p1, branchmerge=False, force=True) +mergemod.clean_update(p1ctx) else: repo.ui.debug(b" already in destination\n") # This is, alas, necessary to invalidate workingctx's manifest cache, diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -945,7 +945,7 @@ class base(histeditaction): def run(self): if self.repo[b'.'].node() != self.node: -mergemod.update(self.repo, self.node, branchmerge=False, force=True) +mergemod.clean_update(self.repo[self.node]) return self.continueclean() def continuedirty(self): To: martinvonz, durin42, #hg-reviewers, marmoute Cc: marmoute, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7902: merge: introduce a clean_update() for that use-case
This revision now requires changes to proceed. marmoute added inline comments. marmoute requested changes to this revision. INLINE COMMENTS > merge.py:2580 > > +def clean_update(ctx, wc=None): > +return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, > wc=wc) The idea is great (I also always scratch my head at `merge.update`. However can we can some solide documentation about what this function does ? REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7902/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7902 To: martinvonz, durin42, #hg-reviewers, marmoute Cc: marmoute, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7902: merge: introduce a clean_update() for that use-case
martinvonz edited the summary of this revision. martinvonz updated this revision to Diff 19555. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7902?vs=19338=19555 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7902/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7902 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/hg.py mercurial/merge.py mercurial/shelve.py CHANGE DETAILS diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -745,7 +745,7 @@ try: checkparents(repo, state) -merge.update(repo, state.pendingctx, branchmerge=False, force=True) +merge.clean_update(state.pendingctx) if state.activebookmark and state.activebookmark in repo._bookmarks: bookmarks.activate(repo, state.activebookmark) mergefiles(ui, repo, state.wctx, state.pendingctx) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -2577,6 +2577,10 @@ return stats +def clean_update(ctx, wc=None): +return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc) + + def graft( repo, ctx, base, labels=None, keepparent=False, keepconflictparent=False ): diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1182,7 +1182,7 @@ node = repo[b'.'].hex() repo.ui.status(_(b"aborting the merge, updating back to %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True) +stats = mergemod.clean_update(repo[node]) _showstats(repo, stats) return stats.unresolvedcount > 0 diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -799,9 +799,7 @@ # Update away from the rebase if necessary if shouldupdate: -mergemod.update( -repo, self.originalwd, branchmerge=False, force=True -) +mergemod.clean_update(repo[self.originalwd]) # Strip from the first rebased revision if rebased: @@ -1475,7 +1473,7 @@ else: if repo[b'.'].rev() != p1: repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx)) -mergemod.update(repo, p1, branchmerge=False, force=True) +mergemod.clean_update(p1ctx) else: repo.ui.debug(b" already in destination\n") # This is, alas, necessary to invalidate workingctx's manifest cache, diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -945,7 +945,7 @@ class base(histeditaction): def run(self): if self.repo[b'.'].node() != self.node: -mergemod.update(self.repo, self.node, branchmerge=False, force=True) +mergemod.clean_update(self.repo[self.node]) return self.continueclean() def continuedirty(self): To: martinvonz, durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7902: merge: introduce a clean_update() for that use-case
martinvonz created this revision. Herald added a reviewer: durin42. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY In the same vein as the previous patch. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D7902 AFFECTED FILES hgext/histedit.py hgext/rebase.py mercurial/hg.py mercurial/merge.py mercurial/shelve.py CHANGE DETAILS diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -745,7 +745,7 @@ try: checkparents(repo, state) -merge.update(repo, state.pendingctx, branchmerge=False, force=True) +merge.clean_update(state.pendingctx) if state.activebookmark and state.activebookmark in repo._bookmarks: bookmarks.activate(repo, state.activebookmark) mergefiles(ui, repo, state.wctx, state.pendingctx) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -2591,6 +2591,10 @@ ) +def clean_update(ctx, wc=None): +return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc) + + def graft( repo, ctx, base, labels=None, keepparent=False, keepconflictparent=False ): diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1182,7 +1182,7 @@ node = repo[b'.'].hex() repo.ui.status(_(b"aborting the merge, updating back to %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True) +stats = mergemod.clean_update(repo[node]) _showstats(repo, stats) return stats.unresolvedcount > 0 diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -799,9 +799,7 @@ # Update away from the rebase if necessary if shouldupdate: -mergemod.update( -repo, self.originalwd, branchmerge=False, force=True -) +mergemod.clean_update(repo[self.originalwd]) # Strip from the first rebased revision if rebased: @@ -1475,7 +1473,7 @@ else: if repo[b'.'].rev() != p1: repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx)) -mergemod.update(repo, p1, branchmerge=False, force=True) +mergemod.clean_update(p1ctx) else: repo.ui.debug(b" already in destination\n") # This is, alas, necessary to invalidate workingctx's manifest cache, diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -945,7 +945,7 @@ class base(histeditaction): def run(self): if self.repo[b'.'].node() != self.node: -mergemod.update(self.repo, self.node, branchmerge=False, force=True) +mergemod.clean_update(self.repo[self.node]) return self.continueclean() def continuedirty(self): To: martinvonz, durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel