comparison mercurial/context.py @ 44857:e607099d8b93

context: implement mergestate() method This will let us have the mergestate storage be controlled by the context. In particular, for working contexts we should use the existing mergestate, but for overlay contexts it's inappropriate to drop files in .hg/merge. Differential Revision: https://phab.mercurial-scm.org/D8551
author Augie Fackler <augie@google.com>
date Mon, 18 May 2020 16:00:26 -0400
parents 7c4b98a4e536
children 61719b9658b1
comparison
equal deleted inserted replaced
44856:b7808443ed6a 44857:e607099d8b93
32 dagop, 32 dagop,
33 encoding, 33 encoding,
34 error, 34 error,
35 fileset, 35 fileset,
36 match as matchmod, 36 match as matchmod,
37 mergestate as mergestatemod,
37 obsolete as obsmod, 38 obsolete as obsmod,
38 patch, 39 patch,
39 pathutil, 40 pathutil,
40 phases, 41 phases,
41 pycompat, 42 pycompat,
471 r.unknown.sort() 472 r.unknown.sort()
472 r.ignored.sort() 473 r.ignored.sort()
473 r.clean.sort() 474 r.clean.sort()
474 475
475 return r 476 return r
477
478 def mergestate(self, clean=False):
479 """Get a mergestate object for this context."""
480 raise NotImplementedError(
481 '%s does not implement mergestate()' % self.__class__
482 )
476 483
477 484
478 class changectx(basectx): 485 class changectx(basectx):
479 """A changecontext object makes access to data related to a particular 486 """A changecontext object makes access to data related to a particular
480 changeset convenient. It represents a read-only context already present in 487 changeset convenient. It represents a read-only context already present in
2001 # from immediately doing so for subsequent changing files 2008 # from immediately doing so for subsequent changing files
2002 self._repo.dirstate.write(self._repo.currenttransaction()) 2009 self._repo.dirstate.write(self._repo.currenttransaction())
2003 2010
2004 sparse.aftercommit(self._repo, node) 2011 sparse.aftercommit(self._repo, node)
2005 2012
2013 def mergestate(self, clean=False):
2014 if clean:
2015 return mergestatemod.mergestate.clean(self._repo)
2016 return mergestatemod.mergestate.read(self._repo)
2017
2006 2018
2007 class committablefilectx(basefilectx): 2019 class committablefilectx(basefilectx):
2008 """A committablefilectx provides common functionality for a file context 2020 """A committablefilectx provides common functionality for a file context
2009 that wants the ability to commit, e.g. workingfilectx or memfilectx.""" 2021 that wants the ability to commit, e.g. workingfilectx or memfilectx."""
2010 2022