Mercurial > hg-stable
changeset 42327:278dcb24e535
copies: write empty entries in changeset when also writing to filelog
When writing to both changeset and filelog (during transition), we
don't want the reader to waste time by falling back to reading from
the filelog when there is no copy metadata. Let's write out empty copy
metadata instead (the read path is already prepared for this
case). Thanks to Greg for pointing this out.
Differential Revision: https://phab.mercurial-scm.org/D6306
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 23 Apr 2019 13:29:13 -0700 |
parents | 80a213f9ed87 |
children | 2a7109cc5a28 |
files | mercurial/changelog.py mercurial/localrepo.py tests/test-copies-in-changeset.t |
diffstat | 3 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changelog.py Mon May 13 14:19:36 2019 -0400 +++ b/mercurial/changelog.py Tue Apr 23 13:29:13 2019 -0700 @@ -591,11 +591,11 @@ elif branch in (".", "null", "tip"): raise error.StorageError(_('the name \'%s\' is reserved') % branch) - if (p1copies or p2copies) and extra is None: + if (p1copies is not None or p2copies is not None) and extra is None: extra = {} - if p1copies: + if p1copies is not None: extra['p1copies'] = encodecopies(p1copies) - if p2copies: + if p2copies is not None: extra['p2copies'] = encodecopies(p2copies) if extra:
--- a/mercurial/localrepo.py Mon May 13 14:19:36 2019 -0400 +++ b/mercurial/localrepo.py Tue Apr 23 13:29:13 2019 -0700 @@ -2650,6 +2650,14 @@ mn = p1.manifestnode() files = [] + if writecopiesto == 'changeset-only': + # If writing only to changeset extras, use None to indicate that + # no entry should be written. If writing to both, write an empty + # entry to prevent the reader from falling back to reading + # filelogs. + p1copies = p1copies or None + p2copies = p2copies or None + # update changelog self.ui.note(_("committing changelog\n")) self.changelog.delayupdate(tr)
--- a/tests/test-copies-in-changeset.t Mon May 13 14:19:36 2019 -0400 +++ b/tests/test-copies-in-changeset.t Tue Apr 23 13:29:13 2019 -0700 @@ -103,6 +103,7 @@ $ hg changesetcopies files: j p1copies: j\x00a (esc) + p2copies: $ hg debugdata j 0 \x01 (esc) copy: a @@ -115,6 +116,14 @@ a -> j $ hg showcopies --config experimental.copies.read-from=filelog-only a -> j +The entries should be written to extras even if they're empty (so the client +won't have to fall back to reading from filelogs) + $ echo x >> j + $ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility + $ hg changesetcopies + files: j + p1copies: + p2copies: Test writing only to filelog