mercurial/localrepo.py
changeset 24918 2eac3ae0d088
parent 24917 71a738a6a1c1
child 24934 5abd0a76bc8f
equal deleted inserted replaced
24917:71a738a6a1c1 24918:2eac3ae0d088
   204 
   204 
   205     def _baserequirements(self, create):
   205     def _baserequirements(self, create):
   206         return ['revlogv1']
   206         return ['revlogv1']
   207 
   207 
   208     def __init__(self, baseui, path=None, create=False):
   208     def __init__(self, baseui, path=None, create=False):
       
   209         self.requirements = set()
   209         self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True)
   210         self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True)
   210         self.wopener = self.wvfs
   211         self.wopener = self.wvfs
   211         self.root = self.wvfs.base
   212         self.root = self.wvfs.base
   212         self.path = self.wvfs.join(".hg")
   213         self.path = self.wvfs.join(".hg")
   213         self.origroot = path
   214         self.origroot = path
   240         if not self.vfs.isdir():
   241         if not self.vfs.isdir():
   241             if create:
   242             if create:
   242                 if not self.wvfs.exists():
   243                 if not self.wvfs.exists():
   243                     self.wvfs.makedirs()
   244                     self.wvfs.makedirs()
   244                 self.vfs.makedir(notindexed=True)
   245                 self.vfs.makedir(notindexed=True)
   245                 requirements = set(self._baserequirements(create))
   246                 self.requirements.update(self._baserequirements(create))
   246                 if self.ui.configbool('format', 'usestore', True):
   247                 if self.ui.configbool('format', 'usestore', True):
   247                     self.vfs.mkdir("store")
   248                     self.vfs.mkdir("store")
   248                     requirements.add("store")
   249                     self.requirements.add("store")
   249                     if self.ui.configbool('format', 'usefncache', True):
   250                     if self.ui.configbool('format', 'usefncache', True):
   250                         requirements.add("fncache")
   251                         self.requirements.add("fncache")
   251                         if self.ui.configbool('format', 'dotencode', True):
   252                         if self.ui.configbool('format', 'dotencode', True):
   252                             requirements.add('dotencode')
   253                             self.requirements.add('dotencode')
   253                     # create an invalid changelog
   254                     # create an invalid changelog
   254                     self.vfs.append(
   255                     self.vfs.append(
   255                         "00changelog.i",
   256                         "00changelog.i",
   256                         '\0\0\0\2' # represents revlogv2
   257                         '\0\0\0\2' # represents revlogv2
   257                         ' dummy changelog to prevent using the old repo layout'
   258                         ' dummy changelog to prevent using the old repo layout'
   258                     )
   259                     )
   259                 if self.ui.configbool('format', 'generaldelta', False):
   260                 if self.ui.configbool('format', 'generaldelta', False):
   260                     requirements.add("generaldelta")
   261                     self.requirements.add("generaldelta")
   261                 if self.ui.configbool('experimental', 'manifestv2', False):
   262                 if self.ui.configbool('experimental', 'manifestv2', False):
   262                     requirements.add("manifestv2")
   263                     self.requirements.add("manifestv2")
   263             else:
   264             else:
   264                 raise error.RepoError(_("repository %s not found") % path)
   265                 raise error.RepoError(_("repository %s not found") % path)
   265         elif create:
   266         elif create:
   266             raise error.RepoError(_("repository %s already exists") % path)
   267             raise error.RepoError(_("repository %s already exists") % path)
   267         else:
   268         else:
   268             try:
   269             try:
   269                 requirements = scmutil.readrequires(self.vfs, self.supported)
   270                 self.requirements = scmutil.readrequires(
       
   271                         self.vfs, self.supported)
   270             except IOError, inst:
   272             except IOError, inst:
   271                 if inst.errno != errno.ENOENT:
   273                 if inst.errno != errno.ENOENT:
   272                     raise
   274                     raise
   273                 requirements = set()
       
   274 
   275 
   275         self.sharedpath = self.path
   276         self.sharedpath = self.path
   276         try:
   277         try:
   277             vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'),
   278             vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'),
   278                               realpath=True)
   279                               realpath=True)
   283             self.sharedpath = s
   284             self.sharedpath = s
   284         except IOError, inst:
   285         except IOError, inst:
   285             if inst.errno != errno.ENOENT:
   286             if inst.errno != errno.ENOENT:
   286                 raise
   287                 raise
   287 
   288 
   288         self.store = store.store(requirements, self.sharedpath, scmutil.vfs)
   289         self.store = store.store(
       
   290                 self.requirements, self.sharedpath, scmutil.vfs)
   289         self.spath = self.store.path
   291         self.spath = self.store.path
   290         self.svfs = self.store.vfs
   292         self.svfs = self.store.vfs
   291         self.sopener = self.svfs
   293         self.sopener = self.svfs
   292         self.sjoin = self.store.join
   294         self.sjoin = self.store.join
   293         self.vfs.createmode = self.store.createmode
   295         self.vfs.createmode = self.store.createmode
   294         self.requirements = requirements
       
   295         self._applyopenerreqs()
   296         self._applyopenerreqs()
   296         if create:
   297         if create:
   297             self._writerequirements()
   298             self._writerequirements()
   298 
   299 
   299 
   300