mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
phases: mechanism to allow extension to alter initial computation of phase
This commit add a whennodata list where extension can register a callback to be called if no phase related data are found in the repository. The goal is to ensure the existing extension that move phase data in 2.1 can compute consistent phase boundary for existing repo.
This commit is contained in:
parent
03d7b0dd77
commit
7448ca3281
@ -37,6 +37,10 @@ class localrepository(repo.repository):
|
|||||||
self.baseui = baseui
|
self.baseui = baseui
|
||||||
self.ui = baseui.copy()
|
self.ui = baseui.copy()
|
||||||
self._dirtyphases = False
|
self._dirtyphases = False
|
||||||
|
# A list of callback to shape the phase if no data were found.
|
||||||
|
# Callback are in the form: func(repo, roots) --> processed root.
|
||||||
|
# This list it to be filled by extension during repo setup
|
||||||
|
self._phasedefaults = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.ui.readconfig(self.join("hgrc"), self.root)
|
self.ui.readconfig(self.join("hgrc"), self.root)
|
||||||
|
@ -109,7 +109,6 @@ phasenames = ['public', 'draft', 'secret']
|
|||||||
def readroots(repo):
|
def readroots(repo):
|
||||||
"""Read phase roots from disk"""
|
"""Read phase roots from disk"""
|
||||||
roots = [set() for i in allphases]
|
roots = [set() for i in allphases]
|
||||||
roots[0].add(nullid)
|
|
||||||
try:
|
try:
|
||||||
f = repo.sopener('phaseroots')
|
f = repo.sopener('phaseroots')
|
||||||
try:
|
try:
|
||||||
@ -121,6 +120,8 @@ def readroots(repo):
|
|||||||
except IOError, inst:
|
except IOError, inst:
|
||||||
if inst.errno != errno.ENOENT:
|
if inst.errno != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
|
for f in repo._phasedefaults:
|
||||||
|
roots = f(repo, roots)
|
||||||
return roots
|
return roots
|
||||||
|
|
||||||
def writeroots(repo):
|
def writeroots(repo):
|
||||||
|
@ -86,6 +86,7 @@ class statichttprepository(localrepo.localrepository):
|
|||||||
|
|
||||||
opener = build_opener(ui, authinfo)
|
opener = build_opener(ui, authinfo)
|
||||||
self.opener = opener(self.path)
|
self.opener = opener(self.path)
|
||||||
|
self._phasedefaults = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
requirements = scmutil.readrequires(self.opener, self.supported)
|
requirements = scmutil.readrequires(self.opener, self.supported)
|
||||||
|
Loading…
Reference in New Issue
Block a user