Mercurial > hg
comparison mercurial/subrepo.py @ 24671:98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
This patch passes "ctx" and "path" instead of "ui" to
"abstractsubrepo.__init__()" and stores them as "_ctx" and "_path" to
use them in subsequent patches.
This also removes redundant field initializations in the constructor
of classes derived from "abstractsubrepo".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 10 Apr 2015 00:36:42 +0900 |
parents | b39afa36006a |
children | dd0b86f740ef |
comparison
equal
deleted
inserted
replaced
24670:dfb86af18a35 | 24671:98ab035e9332 |
---|---|
376 | 376 |
377 # subrepo classes need to implement the following abstract class: | 377 # subrepo classes need to implement the following abstract class: |
378 | 378 |
379 class abstractsubrepo(object): | 379 class abstractsubrepo(object): |
380 | 380 |
381 def __init__(self, ui): | 381 def __init__(self, ctx, path): |
382 self.ui = ui | 382 """Initialize abstractsubrepo part |
383 | |
384 ``ctx`` is the context referring this subrepository in the | |
385 parent repository. | |
386 | |
387 ``path`` is the path to this subrepositiry as seen from | |
388 innermost repository. | |
389 """ | |
390 self.ui = ctx.repo().ui | |
391 self._ctx = ctx | |
392 self._path = path | |
383 | 393 |
384 def storeclean(self, path): | 394 def storeclean(self, path): |
385 """ | 395 """ |
386 returns true if the repository has not changed since it was last | 396 returns true if the repository has not changed since it was last |
387 cloned from or pushed to a given repository. | 397 cloned from or pushed to a given repository. |
542 def shortid(self, revid): | 552 def shortid(self, revid): |
543 return revid | 553 return revid |
544 | 554 |
545 class hgsubrepo(abstractsubrepo): | 555 class hgsubrepo(abstractsubrepo): |
546 def __init__(self, ctx, path, state): | 556 def __init__(self, ctx, path, state): |
547 super(hgsubrepo, self).__init__(ctx.repo().ui) | 557 super(hgsubrepo, self).__init__(ctx, path) |
548 self._path = path | |
549 self._state = state | 558 self._state = state |
550 self._ctx = ctx | |
551 r = ctx.repo() | 559 r = ctx.repo() |
552 root = r.wjoin(path) | 560 root = r.wjoin(path) |
553 create = not r.wvfs.exists('%s/.hg' % path) | 561 create = not r.wvfs.exists('%s/.hg' % path) |
554 self._repo = hg.repository(r.baseui, root, create=create) | 562 self._repo = hg.repository(r.baseui, root, create=create) |
555 self.ui = self._repo.ui | 563 self.ui = self._repo.ui |
936 def shortid(self, revid): | 944 def shortid(self, revid): |
937 return revid[:12] | 945 return revid[:12] |
938 | 946 |
939 class svnsubrepo(abstractsubrepo): | 947 class svnsubrepo(abstractsubrepo): |
940 def __init__(self, ctx, path, state): | 948 def __init__(self, ctx, path, state): |
941 super(svnsubrepo, self).__init__(ctx.repo().ui) | 949 super(svnsubrepo, self).__init__(ctx, path) |
942 self._path = path | |
943 self._state = state | 950 self._state = state |
944 self._ctx = ctx | |
945 self._exe = util.findexe('svn') | 951 self._exe = util.findexe('svn') |
946 if not self._exe: | 952 if not self._exe: |
947 raise util.Abort(_("'svn' executable not found for subrepo '%s'") | 953 raise util.Abort(_("'svn' executable not found for subrepo '%s'") |
948 % self._path) | 954 % self._path) |
949 | 955 |
1166 return self._svncommand(['cat'], name)[0] | 1172 return self._svncommand(['cat'], name)[0] |
1167 | 1173 |
1168 | 1174 |
1169 class gitsubrepo(abstractsubrepo): | 1175 class gitsubrepo(abstractsubrepo): |
1170 def __init__(self, ctx, path, state): | 1176 def __init__(self, ctx, path, state): |
1171 super(gitsubrepo, self).__init__(ctx.repo().ui) | 1177 super(gitsubrepo, self).__init__(ctx, path) |
1172 self._state = state | 1178 self._state = state |
1173 self._ctx = ctx | |
1174 self._path = path | |
1175 self._relpath = os.path.join(reporelpath(ctx.repo()), path) | 1179 self._relpath = os.path.join(reporelpath(ctx.repo()), path) |
1176 self._abspath = ctx.repo().wjoin(path) | 1180 self._abspath = ctx.repo().wjoin(path) |
1177 self._subparent = ctx.repo() | 1181 self._subparent = ctx.repo() |
1178 self._ensuregit() | 1182 self._ensuregit() |
1179 | 1183 |