Show More
@@ -172,6 +172,8 b' def reporelpath(repo):' | |||||
172 |
|
172 | |||
173 | def subrelpath(sub): |
|
173 | def subrelpath(sub): | |
174 | """return path to this subrepo as seen from outermost repo""" |
|
174 | """return path to this subrepo as seen from outermost repo""" | |
|
175 | if hasattr(sub, '_relpath'): | |||
|
176 | return sub._relpath | |||
175 | if not hasattr(sub, '_repo'): |
|
177 | if not hasattr(sub, '_repo'): | |
176 | return sub._path |
|
178 | return sub._path | |
177 | return reporelpath(sub._repo) |
|
179 | return reporelpath(sub._repo) | |
@@ -617,15 +619,17 b' class gitsubrepo(abstractsubrepo):' | |||||
617 | # TODO add git version check. |
|
619 | # TODO add git version check. | |
618 | self._state = state |
|
620 | self._state = state | |
619 | self._ctx = ctx |
|
621 | self._ctx = ctx | |
620 |
self._ |
|
622 | self._path = path | |
621 |
self._path = ctx._repo |
|
623 | self._relpath = os.path.join(reporelpath(ctx._repo), path) | |
|
624 | self._abspath = ctx._repo.wjoin(path) | |||
622 | self._ui = ctx._repo.ui |
|
625 | self._ui = ctx._repo.ui | |
623 |
|
626 | |||
624 | def _gitcommand(self, commands, env=None, stream=False): |
|
627 | def _gitcommand(self, commands, env=None, stream=False): | |
625 | return self._gitdir(commands, env=env, stream=stream)[0] |
|
628 | return self._gitdir(commands, env=env, stream=stream)[0] | |
626 |
|
629 | |||
627 | def _gitdir(self, commands, env=None, stream=False): |
|
630 | def _gitdir(self, commands, env=None, stream=False): | |
628 |
return self._gitnodir(commands, env=env, stream=stream, |
|
631 | return self._gitnodir(commands, env=env, stream=stream, | |
|
632 | cwd=self._abspath) | |||
629 |
|
633 | |||
630 | def _gitnodir(self, commands, env=None, stream=False, cwd=None): |
|
634 | def _gitnodir(self, commands, env=None, stream=False, cwd=None): | |
631 | """Calls the git command |
|
635 | """Calls the git command | |
@@ -711,9 +715,9 b' class gitsubrepo(abstractsubrepo):' | |||||
711 | return tracking |
|
715 | return tracking | |
712 |
|
716 | |||
713 | def _fetch(self, source, revision): |
|
717 | def _fetch(self, source, revision): | |
714 |
if not os.path.exists( |
|
718 | if not os.path.exists(os.path.join(self._abspath, '.git')): | |
715 | self._ui.status(_('cloning subrepo %s\n') % self._relpath) |
|
719 | self._ui.status(_('cloning subrepo %s\n') % self._relpath) | |
716 | self._gitnodir(['clone', source, self._path]) |
|
720 | self._gitnodir(['clone', source, self._abspath]) | |
717 | if self._githavelocally(revision): |
|
721 | if self._githavelocally(revision): | |
718 | return |
|
722 | return | |
719 | self._ui.status(_('pulling subrepo %s\n') % self._relpath) |
|
723 | self._ui.status(_('pulling subrepo %s\n') % self._relpath) | |
@@ -725,7 +729,7 b' class gitsubrepo(abstractsubrepo):' | |||||
725 | self._gitcommand(['fetch', source]) |
|
729 | self._gitcommand(['fetch', source]) | |
726 | if not self._githavelocally(revision): |
|
730 | if not self._githavelocally(revision): | |
727 | raise util.Abort(_("revision %s does not exist in subrepo %s\n") % |
|
731 | raise util.Abort(_("revision %s does not exist in subrepo %s\n") % | |
728 | (revision, self._path)) |
|
732 | (revision, self._relpath)) | |
729 |
|
733 | |||
730 | def dirty(self, ignoreupdate=False): |
|
734 | def dirty(self, ignoreupdate=False): | |
731 | # version checked out changed? |
|
735 | # version checked out changed? | |
@@ -859,16 +863,16 b' class gitsubrepo(abstractsubrepo):' | |||||
859 | def remove(self): |
|
863 | def remove(self): | |
860 | if self.dirty(): |
|
864 | if self.dirty(): | |
861 | self._ui.warn(_('not removing repo %s because ' |
|
865 | self._ui.warn(_('not removing repo %s because ' | |
862 | 'it has changes.\n') % self._path) |
|
866 | 'it has changes.\n') % self._relpath) | |
863 | return |
|
867 | return | |
864 | # we can't fully delete the repository as it may contain |
|
868 | # we can't fully delete the repository as it may contain | |
865 | # local-only history |
|
869 | # local-only history | |
866 | self._ui.note(_('removing subrepo %s\n') % self._path) |
|
870 | self._ui.note(_('removing subrepo %s\n') % self._relpath) | |
867 | self._gitcommand(['config', 'core.bare', 'true']) |
|
871 | self._gitcommand(['config', 'core.bare', 'true']) | |
868 | for f in os.listdir(self._path): |
|
872 | for f in os.listdir(self._abspath): | |
869 | if f == '.git': |
|
873 | if f == '.git': | |
870 | continue |
|
874 | continue | |
871 | path = os.path.join(self._path, f) |
|
875 | path = os.path.join(self._abspath, f) | |
872 | if os.path.isdir(path) and not os.path.islink(path): |
|
876 | if os.path.isdir(path) and not os.path.islink(path): | |
873 | shutil.rmtree(path) |
|
877 | shutil.rmtree(path) | |
874 | else: |
|
878 | else: | |
@@ -892,7 +896,7 b' class gitsubrepo(abstractsubrepo):' | |||||
892 | data = info.linkname |
|
896 | data = info.linkname | |
893 | else: |
|
897 | else: | |
894 | data = tar.extractfile(info).read() |
|
898 | data = tar.extractfile(info).read() | |
895 |
archiver.addfile(os.path.join(prefix, self._ |
|
899 | archiver.addfile(os.path.join(prefix, self._path, info.name), | |
896 | info.mode, info.issym(), data) |
|
900 | info.mode, info.issym(), data) | |
897 | ui.progress(_('archiving (%s)') % relpath, i + 1, |
|
901 | ui.progress(_('archiving (%s)') % relpath, i + 1, | |
898 | unit=_('files')) |
|
902 | unit=_('files')) |
@@ -34,7 +34,7 b' add subrepo clone' | |||||
34 | $ git clone -q ../gitroot s |
|
34 | $ git clone -q ../gitroot s | |
35 | $ hg add .hgsub |
|
35 | $ hg add .hgsub | |
36 | $ hg commit -m 'new git subrepo' |
|
36 | $ hg commit -m 'new git subrepo' | |
37 |
committing subrepository |
|
37 | committing subrepository s | |
38 | $ hg debugsub |
|
38 | $ hg debugsub | |
39 | path s |
|
39 | path s | |
40 | source ../gitroot |
|
40 | source ../gitroot | |
@@ -53,7 +53,7 b' record a new commit from upstream from a' | |||||
53 |
|
53 | |||
54 | $ cd .. |
|
54 | $ cd .. | |
55 | $ hg commit -m 'update git subrepo' |
|
55 | $ hg commit -m 'update git subrepo' | |
56 |
committing subrepository |
|
56 | committing subrepository s | |
57 | $ hg debugsub |
|
57 | $ hg debugsub | |
58 | path s |
|
58 | path s | |
59 | source ../gitroot |
|
59 | source ../gitroot | |
@@ -100,7 +100,7 b' clone root, make local change' | |||||
100 | $ cd ../ta |
|
100 | $ cd ../ta | |
101 | $ echo ggg >> s/g |
|
101 | $ echo ggg >> s/g | |
102 | $ hg commit -m ggg |
|
102 | $ hg commit -m ggg | |
103 |
committing subrepository |
|
103 | committing subrepository s | |
104 | $ hg debugsub |
|
104 | $ hg debugsub | |
105 | path s |
|
105 | path s | |
106 | source ../gitroot |
|
106 | source ../gitroot | |
@@ -120,7 +120,7 b' clone root separately, make different lo' | |||||
120 | $ cd .. |
|
120 | $ cd .. | |
121 |
|
121 | |||
122 | $ hg commit -m f |
|
122 | $ hg commit -m f | |
123 |
committing subrepository |
|
123 | committing subrepository s | |
124 | $ hg debugsub |
|
124 | $ hg debugsub | |
125 | path s |
|
125 | path s | |
126 | source ../gitroot |
|
126 | source ../gitroot | |
@@ -159,7 +159,7 b' user a pulls, merges, commits' | |||||
159 | gg |
|
159 | gg | |
160 | ggg |
|
160 | ggg | |
161 | $ hg commit -m 'merge' |
|
161 | $ hg commit -m 'merge' | |
162 |
committing subrepository |
|
162 | committing subrepository s | |
163 | $ hg debugsub |
|
163 | $ hg debugsub | |
164 | path s |
|
164 | path s | |
165 | source ../gitroot |
|
165 | source ../gitroot | |
@@ -212,7 +212,7 b' sync to upstream git, distribute changes' | |||||
212 | $ git pull -q >/dev/null 2>/dev/null |
|
212 | $ git pull -q >/dev/null 2>/dev/null | |
213 | $ cd .. |
|
213 | $ cd .. | |
214 | $ hg commit -m 'git upstream sync' |
|
214 | $ hg commit -m 'git upstream sync' | |
215 |
committing subrepository |
|
215 | committing subrepository s | |
216 | $ hg debugsub |
|
216 | $ hg debugsub | |
217 | path s |
|
217 | path s | |
218 | source ../gitroot |
|
218 | source ../gitroot | |
@@ -260,3 +260,35 b' archive subrepos' | |||||
260 | g |
|
260 | g | |
261 | gg |
|
261 | gg | |
262 | ggg |
|
262 | ggg | |
|
263 | ||||
|
264 | create nested repo | |||
|
265 | ||||
|
266 | $ cd .. | |||
|
267 | $ hg init outer | |||
|
268 | $ cd outer | |||
|
269 | $ echo b>b | |||
|
270 | $ hg add b | |||
|
271 | $ hg commit -m b | |||
|
272 | ||||
|
273 | $ hg clone ../t inner | |||
|
274 | updating to branch default | |||
|
275 | cloning subrepo s | |||
|
276 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
277 | $ echo inner = inner > .hgsub | |||
|
278 | $ hg add .hgsub | |||
|
279 | $ hg commit -m 'nested sub' | |||
|
280 | committing subrepository inner | |||
|
281 | ||||
|
282 | nested commit | |||
|
283 | ||||
|
284 | $ echo ffff >> inner/s/f | |||
|
285 | $ hg commit -m nested | |||
|
286 | committing subrepository inner | |||
|
287 | committing subrepository inner/s | |||
|
288 | ||||
|
289 | nested archive | |||
|
290 | ||||
|
291 | $ hg archive --subrepos ../narchive | |||
|
292 | $ ls ../narchive/inner/s | |||
|
293 | f | |||
|
294 | g |
General Comments 0
You need to be logged in to leave comments.
Login now