# HG changeset patch # User Sean Farley # Date 1379478897 18000 # Node ID e61c6138fa33ddc5127829481f863012405e58a5 # Parent 51988f008df3affda45ac5462a40e7146a32b04d context: move evolution functions from changectx to basectx This is just a code move and corrects an overlook from my previous patch series that assumed only a changectx would want this functionality. diff -r 51988f008df3 -r e61c6138fa33 mercurial/context.py --- a/mercurial/context.py Tue Sep 17 18:34:45 2013 -0500 +++ b/mercurial/context.py Tue Sep 17 23:34:57 2013 -0500 @@ -80,6 +80,53 @@ def mutable(self): return self.phase() > phases.public + def obsolete(self): + """True if the changeset is obsolete""" + return self.rev() in obsmod.getrevs(self._repo, 'obsolete') + + def extinct(self): + """True if the changeset is extinct""" + return self.rev() in obsmod.getrevs(self._repo, 'extinct') + + def unstable(self): + """True if the changeset is not obsolete but it's ancestor are""" + return self.rev() in obsmod.getrevs(self._repo, 'unstable') + + def bumped(self): + """True if the changeset try to be a successor of a public changeset + + Only non-public and non-obsolete changesets may be bumped. + """ + return self.rev() in obsmod.getrevs(self._repo, 'bumped') + + def divergent(self): + """Is a successors of a changeset with multiple possible successors set + + Only non-public and non-obsolete changesets may be divergent. + """ + return self.rev() in obsmod.getrevs(self._repo, 'divergent') + + def troubled(self): + """True if the changeset is either unstable, bumped or divergent""" + return self.unstable() or self.bumped() or self.divergent() + + def troubles(self): + """return the list of troubles affecting this changesets. + + Troubles are returned as strings. possible values are: + - unstable, + - bumped, + - divergent. + """ + troubles = [] + if self.unstable(): + troubles.append('unstable') + if self.bumped(): + troubles.append('bumped') + if self.divergent(): + troubles.append('divergent') + return troubles + def parents(self): """return contexts for each parent changeset""" return self._parents @@ -322,53 +369,6 @@ for d in self._repo.changelog.descendants([self._rev]): yield changectx(self._repo, d) - def obsolete(self): - """True if the changeset is obsolete""" - return self.rev() in obsmod.getrevs(self._repo, 'obsolete') - - def extinct(self): - """True if the changeset is extinct""" - return self.rev() in obsmod.getrevs(self._repo, 'extinct') - - def unstable(self): - """True if the changeset is not obsolete but it's ancestor are""" - return self.rev() in obsmod.getrevs(self._repo, 'unstable') - - def bumped(self): - """True if the changeset try to be a successor of a public changeset - - Only non-public and non-obsolete changesets may be bumped. - """ - return self.rev() in obsmod.getrevs(self._repo, 'bumped') - - def divergent(self): - """Is a successors of a changeset with multiple possible successors set - - Only non-public and non-obsolete changesets may be divergent. - """ - return self.rev() in obsmod.getrevs(self._repo, 'divergent') - - def troubled(self): - """True if the changeset is either unstable, bumped or divergent""" - return self.unstable() or self.bumped() or self.divergent() - - def troubles(self): - """return the list of troubles affecting this changesets. - - Troubles are returned as strings. possible values are: - - unstable, - - bumped, - - divergent. - """ - troubles = [] - if self.unstable(): - troubles.append('unstable') - if self.bumped(): - troubles.append('bumped') - if self.divergent(): - troubles.append('divergent') - return troubles - def filectx(self, path, fileid=None, filelog=None): """get a file context from this changeset""" if fileid is None: