Mercurial > hg-stable
changeset 34787:754b5117622f
context: add workingfilectx.markcopied
With in-memory merge, copy information needs to be stored in-memory, not in the
dirstate.
To make this transition easy, move the existing dirstate-based approach to
workingfilectx; that way, other implementations can choose to store it
somewhere else.
Differential Revision: https://phab.mercurial-scm.org/D1106
author | Phil Cohen <phillco@fb.com> |
---|---|
date | Sun, 15 Oct 2017 20:36:29 -0700 |
parents | 9c899660700a |
children | babd168e994b |
files | hgext/rebase.py mercurial/context.py mercurial/copies.py mercurial/merge.py |
diffstat | 4 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Sun Oct 15 20:36:29 2017 -0700 +++ b/hgext/rebase.py Sun Oct 15 20:36:29 2017 -0700 @@ -977,10 +977,11 @@ repo.ui.debug(" detach base %d:%s\n" % (base, repo[base])) # When collapsing in-place, the parent is the common ancestor, we # have to allow merging with it. + wctx = repo[None] stats = mergemod.update(repo, rev, True, True, base, collapse, labels=['dest', 'source']) if collapse: - copies.duplicatecopies(repo, rev, dest) + copies.duplicatecopies(repo, wctx, rev, dest) else: # If we're not using --collapse, we need to # duplicate copies between the revision we're @@ -988,7 +989,7 @@ # duplicate any copies that have already been # performed in the destination. p1rev = repo[rev].p1().rev() - copies.duplicatecopies(repo, rev, p1rev, skiprev=dest) + copies.duplicatecopies(repo, wctx, rev, p1rev, skiprev=dest) return stats def adjustdest(repo, rev, destmap, state, skipped):
--- a/mercurial/context.py Sun Oct 15 20:36:29 2017 -0700 +++ b/mercurial/context.py Sun Oct 15 20:36:29 2017 -0700 @@ -1935,6 +1935,11 @@ self._repo.wwrite(self._path, data, flags, backgroundclose=backgroundclose) + def markcopied(self, src): + """marks this file a copy of `src`""" + if self._repo.dirstate[self._path] in "nma": + self._repo.dirstate.copy(src, self._path) + def clearunknown(self): """Removes conflicting items in the working directory so that ``write()`` can be called successfully.
--- a/mercurial/copies.py Sun Oct 15 20:36:29 2017 -0700 +++ b/mercurial/copies.py Sun Oct 15 20:36:29 2017 -0700 @@ -842,7 +842,7 @@ data['incompletediverge'][sf] = [of, f] return -def duplicatecopies(repo, rev, fromrev, skiprev=None): +def duplicatecopies(repo, wctx, rev, fromrev, skiprev=None): '''reproduce copies from fromrev to rev in the dirstate If skiprev is specified, it's a revision that should be used to @@ -863,5 +863,4 @@ # actually be in the dirstate if dst in exclude: continue - if repo.dirstate[dst] in "nma": - repo.dirstate.copy(src, dst) + wctx[dst].markcopied(src)
--- a/mercurial/merge.py Sun Oct 15 20:36:29 2017 -0700 +++ b/mercurial/merge.py Sun Oct 15 20:36:29 2017 -0700 @@ -2001,5 +2001,5 @@ repo.setparents(repo['.'].node(), pother) repo.dirstate.write(repo.currenttransaction()) # fix up dirstate for copies and renames - copies.duplicatecopies(repo, ctx.rev(), pctx.rev()) + copies.duplicatecopies(repo, repo[None], ctx.rev(), pctx.rev()) return stats