mercurial/subrepo.py
changeset 9092 9aebeea7ac00
parent 9049 38b5d5e0efab
child 9219 3f650f6aa130
equal deleted inserted replaced
9091:79a886bcf461 9092:9aebeea7ac00
     6 # GNU General Public License version 2, incorporated herein by reference.
     6 # GNU General Public License version 2, incorporated herein by reference.
     7 
     7 
     8 import errno, os
     8 import errno, os
     9 from i18n import _
     9 from i18n import _
    10 import config, util, node, error
    10 import config, util, node, error
    11 localrepo = hg = None
    11 hg = None
    12 
    12 
    13 nullstate = ('', '')
    13 nullstate = ('', '')
    14 
    14 
    15 def state(ctx):
    15 def state(ctx):
    16     p = config.config()
    16     p = config.config()
   115 def subrepo(ctx, path):
   115 def subrepo(ctx, path):
   116     # subrepo inherently violates our import layering rules
   116     # subrepo inherently violates our import layering rules
   117     # because it wants to make repo objects from deep inside the stack
   117     # because it wants to make repo objects from deep inside the stack
   118     # so we manually delay the circular imports to not break
   118     # so we manually delay the circular imports to not break
   119     # scripts that don't use our demand-loading
   119     # scripts that don't use our demand-loading
   120     global localrepo, hg
   120     global hg
   121     import localrepo as l, hg as h
   121     import hg as h
   122     localrepo = l
       
   123     hg = h
   122     hg = h
   124 
   123 
   125     util.path_auditor(ctx._repo.root)(path)
   124     util.path_auditor(ctx._repo.root)(path)
   126     state = ctx.substate.get(path, nullstate)
   125     state = ctx.substate.get(path, nullstate)
   127     if state[0].startswith('['): # future expansion
   126     if state[0].startswith('['): # future expansion
   133         self._path = path
   132         self._path = path
   134         self._state = state
   133         self._state = state
   135         r = ctx._repo
   134         r = ctx._repo
   136         root = r.wjoin(path)
   135         root = r.wjoin(path)
   137         if os.path.exists(os.path.join(root, '.hg')):
   136         if os.path.exists(os.path.join(root, '.hg')):
   138             self._repo = localrepo.localrepository(r.ui, root)
   137             self._repo = hg.repository(r.ui, root)
   139         else:
   138         else:
   140             util.makedirs(root)
   139             util.makedirs(root)
   141             self._repo = localrepo.localrepository(r.ui, root, create=True)
   140             self._repo = hg.repository(r.ui, root, create=True)
   142         self._repo._subparent = r
   141         self._repo._subparent = r
   143         self._repo._subsource = state[0]
   142         self._repo._subsource = state[0]
   144 
   143 
   145     def dirty(self):
   144     def dirty(self):
   146         r = self._state[1]
   145         r = self._state[1]