Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 13460:64bb8e586a92 stable
subrepo: expand relative sources for git subrepos
author | Eric Eisner <ede@mit.edu> |
---|---|
date | Tue, 22 Feb 2011 15:11:10 -0500 |
parents | 5a5bd7614401 |
children | fa88fabc1d66 |
comparison
equal
deleted
inserted
replaced
13459:acbe171c8fbe | 13460:64bb8e586a92 |
---|---|
657 self._state = state | 657 self._state = state |
658 self._ctx = ctx | 658 self._ctx = ctx |
659 self._path = path | 659 self._path = path |
660 self._relpath = os.path.join(reporelpath(ctx._repo), path) | 660 self._relpath = os.path.join(reporelpath(ctx._repo), path) |
661 self._abspath = ctx._repo.wjoin(path) | 661 self._abspath = ctx._repo.wjoin(path) |
662 self._subparent = ctx._repo | |
662 self._ui = ctx._repo.ui | 663 self._ui = ctx._repo.ui |
663 | 664 |
664 def _gitcommand(self, commands, env=None, stream=False): | 665 def _gitcommand(self, commands, env=None, stream=False): |
665 return self._gitdir(commands, env=env, stream=stream)[0] | 666 return self._gitdir(commands, env=env, stream=stream)[0] |
666 | 667 |
749 ref = self._gitcommand(['config', 'branch.%s.merge' % b]) | 750 ref = self._gitcommand(['config', 'branch.%s.merge' % b]) |
750 tracking['refs/remotes/%s/%s' % | 751 tracking['refs/remotes/%s/%s' % |
751 (remote, ref.split('/', 2)[2])] = b | 752 (remote, ref.split('/', 2)[2])] = b |
752 return tracking | 753 return tracking |
753 | 754 |
755 def _abssource(self, source): | |
756 self._subsource = source | |
757 return _abssource(self) | |
758 | |
754 def _fetch(self, source, revision): | 759 def _fetch(self, source, revision): |
755 if not os.path.exists(os.path.join(self._abspath, '.git')): | 760 if not os.path.exists(os.path.join(self._abspath, '.git')): |
756 self._ui.status(_('cloning subrepo %s\n') % self._relpath) | 761 self._ui.status(_('cloning subrepo %s\n') % self._relpath) |
757 self._gitnodir(['clone', source, self._abspath]) | 762 self._gitnodir(['clone', self._abssource(source), self._abspath]) |
758 if self._githavelocally(revision): | 763 if self._githavelocally(revision): |
759 return | 764 return |
760 self._ui.status(_('pulling subrepo %s\n') % self._relpath) | 765 self._ui.status(_('pulling subrepo %s\n') % self._relpath) |
761 # first try from origin | 766 # first try from origin |
762 self._gitcommand(['fetch']) | 767 self._gitcommand(['fetch']) |
763 if self._githavelocally(revision): | 768 if self._githavelocally(revision): |
764 return | 769 return |
765 # then try from known subrepo source | 770 # then try from known subrepo source |
766 self._gitcommand(['fetch', source]) | 771 self._gitcommand(['fetch', self._abssource(source)]) |
767 if not self._githavelocally(revision): | 772 if not self._githavelocally(revision): |
768 raise util.Abort(_("revision %s does not exist in subrepo %s\n") % | 773 raise util.Abort(_("revision %s does not exist in subrepo %s\n") % |
769 (revision, self._relpath)) | 774 (revision, self._relpath)) |
770 | 775 |
771 def dirty(self, ignoreupdate=False): | 776 def dirty(self, ignoreupdate=False): |