comparison mercurial/subrepo.py @ 12322:510afb31cf99

subrepo: introduce files and filedata methods for subrepo classes
author Martin Geisler <mg@aragost.com>
date Mon, 20 Sep 2010 15:44:30 +0200
parents c02e1ed3d407
children f00953d9533c
comparison
equal deleted inserted replaced
12321:11db6fa2961e 12322:510afb31cf99
268 return 1 268 return 1
269 269
270 def incoming(self, ui, source, opts): 270 def incoming(self, ui, source, opts):
271 return 1 271 return 1
272 272
273 def files(self):
274 """return filename iterator"""
275 raise NotImplementedError
276
277 def filedata(self, name):
278 """return file data"""
279 raise NotImplementedError
280
281 def fileflags(self, name):
282 """return file flags"""
283 return ''
284
273 class hgsubrepo(abstractsubrepo): 285 class hgsubrepo(abstractsubrepo):
274 def __init__(self, ctx, path, state): 286 def __init__(self, ctx, path, state):
275 self._path = path 287 self._path = path
276 self._state = state 288 self._state = state
277 r = ctx._repo 289 r = ctx._repo
403 def outgoing(self, ui, dest, opts): 415 def outgoing(self, ui, dest, opts):
404 return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts) 416 return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts)
405 417
406 def incoming(self, ui, source, opts): 418 def incoming(self, ui, source, opts):
407 return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts) 419 return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts)
420
421 def files(self):
422 rev = self._state[1]
423 ctx = self._repo[rev]
424 return ctx.manifest()
425
426 def filedata(self, name):
427 rev = self._state[1]
428 return self._repo[rev][name].data()
429
430 def fileflags(self, name):
431 rev = self._state[1]
432 ctx = self._repo[rev]
433 return ctx.flags(name)
434
408 435
409 class svnsubrepo(abstractsubrepo): 436 class svnsubrepo(abstractsubrepo):
410 def __init__(self, ctx, path, state): 437 def __init__(self, ctx, path, state):
411 self._path = path 438 self._path = path
412 self._state = state 439 self._state = state
506 533
507 def push(self, force): 534 def push(self, force):
508 # push is a no-op for SVN 535 # push is a no-op for SVN
509 return True 536 return True
510 537
538 def files(self):
539 output = self._svncommand(['list'])
540 # This works because svn forbids \n in filenames.
541 return output.splitlines()
542
543 def filedata(self, name):
544 return self._svncommand(['cat'], name)
545
546
511 types = { 547 types = {
512 'hg': hgsubrepo, 548 'hg': hgsubrepo,
513 'svn': svnsubrepo, 549 'svn': svnsubrepo,
514 } 550 }