Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 42141:0e41f40b01cc
copies: add config option for writing copy metadata to file and/or changset
This introduces a config option that lets you choose to write copy
metadata to the changeset extras instead of to filelog. There's also
an option to write it to both places. I imagine that may possibly be
useful when transitioning an existing repo.
The copy metadata is stored as two fields in extras: one for copies
since p1 and one for copies since p2.
I may need to add more information later in order to make copy tracing
faster. Specifically, I'm thinking out recording which files were
added or removed so that copies._chaincopies() doesn't have to look at
the manifest for that. But that would just be an optimization and that
can be added once we know if it's necessary.
I have also considered saving space by using replacing the destination
file path by an index into the "files" list, but that can also be
changed later (but before the feature is ready to release).
Differential Revision: https://phab.mercurial-scm.org/D6183
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 27 Dec 2017 19:49:36 -0800 |
parents | 10a6725dca6e |
children | c2b83c957621 d345627d104b |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Apr 04 13:46:49 2019 +0200 +++ b/mercurial/localrepo.py Wed Dec 27 19:49:36 2017 -0800 @@ -2324,7 +2324,8 @@ """Returns the wlock if it's held, or None if it's not.""" return self._currentlock(self._wlockref) - def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): + def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist, + includecopymeta): """ commit an individual file as part of a larger transaction """ @@ -2383,8 +2384,9 @@ if cnode: self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(cnode))) - meta["copy"] = cfname - meta["copyrev"] = hex(cnode) + if includecopymeta: + meta["copy"] = cfname + meta["copyrev"] = hex(cnode) fparent1, fparent2 = nullid, newfparent else: self.ui.warn(_("warning: can't find ancestor for '%s' " @@ -2552,6 +2554,12 @@ p1, p2 = ctx.p1(), ctx.p2() user = ctx.user() + writecopiesto = self.ui.config('experimental', 'copies.write-to') + writefilecopymeta = writecopiesto != 'changeset-only' + p1copies, p2copies = None, None + if writecopiesto in ('changeset-only', 'compatibility'): + p1copies = ctx.p1copies() + p2copies = ctx.p2copies() with self.lock(), self.transaction("commit") as tr: trp = weakref.proxy(tr) @@ -2585,7 +2593,8 @@ else: added.append(f) m[f] = self._filecommit(fctx, m1, m2, linkrev, - trp, changed) + trp, changed, + writefilecopymeta) m.setflag(f, fctx.flags()) except OSError: self.ui.warn(_("trouble committing %s!\n") % @@ -2639,7 +2648,8 @@ self.changelog.delayupdate(tr) n = self.changelog.add(mn, files, ctx.description(), trp, p1.node(), p2.node(), - user, ctx.date(), ctx.extra().copy()) + user, ctx.date(), ctx.extra().copy(), + p1copies, p2copies) xp1, xp2 = p1.hex(), p2 and p2.hex() or '' self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, parent2=xp2)