##// END OF EJS Templates
subrepo: add abstract superclass for subrepo classes
Martin Geisler -
r11559:9d885974 default
parent child Browse files
Show More
@@ -172,22 +172,49 b' def subrepo(ctx, path):'
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 """
190 raise NotImplementedError
191
192 def remove(self):
193 """remove the subrepo
189
194
190 class hgsubrepo(object):
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
@@ -284,7 +311,7 b' class hgsubrepo(object):'
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
General Comments 0
You need to be logged in to leave comments. Login now