comparison tests/test-annotate.t @ 45204:ce9ee81df9ff

commitctx: extract _filecommit too This function is exclusively used in `commitctx`. So we should extract it too for consistency and to reduce the `localrepo` bloat. This is part of a larger refactoring/cleanup of the commitctx code to clarify and augment the logic gathering metadata useful for copy tracing. The current code is a tad too long and entangled to make such update easy. Differential Revision: https://phab.mercurial-scm.org/D8710
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 07 Jul 2020 00:18:15 +0200
parents 509f5b6c0b7e
children 037e88d453fa
comparison
equal deleted inserted replaced
45203:ae5c1a3bc339 45204:ce9ee81df9ff
477 and (2) the extension to allow filelog merging between the revision 477 and (2) the extension to allow filelog merging between the revision
478 and its ancestor by overriding "repo._filecommit". 478 and its ancestor by overriding "repo._filecommit".
479 479
480 $ cat > ../legacyrepo.py <<EOF 480 $ cat > ../legacyrepo.py <<EOF
481 > from __future__ import absolute_import 481 > from __future__ import absolute_import
482 > from mercurial import error, node 482 > from mercurial import commit, error, extensions, node
483 > def reposetup(ui, repo): 483 > def _filecommit(orig, repo, fctx, manifest1, manifest2,
484 > class legacyrepo(repo.__class__): 484 > linkrev, tr, includecopymeta):
485 > def _filecommit(self, fctx, manifest1, manifest2, 485 > fname = fctx.path()
486 > linkrev, tr, includecopymeta): 486 > text = fctx.data()
487 > fname = fctx.path() 487 > flog = repo.file(fname)
488 > text = fctx.data() 488 > fparent1 = manifest1.get(fname, node.nullid)
489 > flog = self.file(fname) 489 > fparent2 = manifest2.get(fname, node.nullid)
490 > fparent1 = manifest1.get(fname, node.nullid) 490 > meta = {}
491 > fparent2 = manifest2.get(fname, node.nullid) 491 > copy = fctx.copysource()
492 > meta = {} 492 > if copy and copy != fname:
493 > copy = fctx.copysource() 493 > raise error.Abort('copying is not supported')
494 > if copy and copy != fname: 494 > if fparent2 != node.nullid:
495 > raise error.Abort('copying is not supported') 495 > return flog.add(text, meta, tr, linkrev,
496 > if fparent2 != node.nullid: 496 > fparent1, fparent2), 'modified'
497 > return flog.add(text, meta, tr, linkrev, 497 > raise error.Abort('only merging is supported')
498 > fparent1, fparent2), 'modified' 498 > def uisetup(ui):
499 > raise error.Abort('only merging is supported') 499 > extensions.wrapfunction(commit, '_filecommit', _filecommit)
500 > repo.__class__ = legacyrepo
501 > EOF 500 > EOF
502 501
503 $ cat > baz <<EOF 502 $ cat > baz <<EOF
504 > 1 503 > 1
505 > 2 504 > 2