mercurial/subrepo.py
changeset 11559 9d88597470af
parent 11470 34e33d50c26b
child 11560 ea2cdee9a1fe
equal deleted inserted replaced
11558:d8f6458434ec 11559:9d88597470af
   170     state = ctx.substate.get(path, nullstate)
   170     state = ctx.substate.get(path, nullstate)
   171     if state[2] not in types:
   171     if state[2] not in types:
   172         raise util.Abort(_('unknown subrepo type %s') % state[2])
   172         raise util.Abort(_('unknown subrepo type %s') % state[2])
   173     return types[state[2]](ctx, path, state[:2])
   173     return types[state[2]](ctx, path, state[:2])
   174 
   174 
   175 # subrepo classes need to implement the following methods:
   175 # subrepo classes need to implement the following abstract class:
   176 # __init__(self, ctx, path, state)
   176 
   177 # dirty(self): returns true if the dirstate of the subrepo
   177 class abstractsubrepo(object):
   178 #   does not match current stored state
   178 
   179 # commit(self, text, user, date): commit the current changes
   179     def dirty(self):
   180 #   to the subrepo with the given log message. Use given
   180         """returns true if the dirstate of the subrepo does not match
   181 #   user and date if possible. Return the new state of the subrepo.
   181         current stored state
   182 # remove(self): remove the subrepo (should verify the dirstate
   182         """
   183 #   is not dirty first)
   183         raise NotImplementedError
   184 # get(self, state): run whatever commands are needed to put the
   184 
   185 #   subrepo into this state
   185     def commit(self, text, user, date):
   186 # merge(self, state): merge currently-saved state with the new state.
   186         """commit the current changes to the subrepo with the given
   187 # push(self, force): perform whatever action is analagous to 'hg push'
   187         log message. Use given user and date if possible. Return the
   188 #   This may be a no-op on some systems.
   188         new state of the subrepo.
   189 
   189         """
   190 class hgsubrepo(object):
   190         raise NotImplementedError
       
   191 
       
   192     def remove(self):
       
   193         """remove the subrepo
       
   194 
       
   195         (should verify the dirstate is not dirty first)
       
   196         """
       
   197         raise NotImplementedError
       
   198 
       
   199     def get(self, state):
       
   200         """run whatever commands are needed to put the subrepo into
       
   201         this state
       
   202         """
       
   203         raise NotImplementedError
       
   204 
       
   205     def merge(self, state):
       
   206         """merge currently-saved state with the new state."""
       
   207         raise NotImplementedError
       
   208 
       
   209     def push(self, force):
       
   210         """perform whatever action is analagous to 'hg push'
       
   211 
       
   212         This may be a no-op on some systems.
       
   213         """
       
   214         raise NotImplementedError
       
   215 
       
   216 
       
   217 class hgsubrepo(abstractsubrepo):
   191     def __init__(self, ctx, path, state):
   218     def __init__(self, ctx, path, state):
   192         self._path = path
   219         self._path = path
   193         self._state = state
   220         self._state = state
   194         r = ctx._repo
   221         r = ctx._repo
   195         root = r.wjoin(path)
   222         root = r.wjoin(path)
   282         self._repo.ui.status(_('pushing subrepo %s to %s\n') %
   309         self._repo.ui.status(_('pushing subrepo %s to %s\n') %
   283             (relpath(self), dsturl))
   310             (relpath(self), dsturl))
   284         other = hg.repository(self._repo.ui, dsturl)
   311         other = hg.repository(self._repo.ui, dsturl)
   285         return self._repo.push(other, force)
   312         return self._repo.push(other, force)
   286 
   313 
   287 class svnsubrepo(object):
   314 class svnsubrepo(abstractsubrepo):
   288     def __init__(self, ctx, path, state):
   315     def __init__(self, ctx, path, state):
   289         self._path = path
   316         self._path = path
   290         self._state = state
   317         self._state = state
   291         self._ctx = ctx
   318         self._ctx = ctx
   292         self._ui = ctx._repo.ui
   319         self._ui = ctx._repo.ui