Show More
@@ -172,6 +172,8 b' def reporelpath(repo):' | |||
|
172 | 172 | |
|
173 | 173 | def subrelpath(sub): |
|
174 | 174 | """return path to this subrepo as seen from outermost repo""" |
|
175 | if hasattr(sub, '_relpath'): | |
|
176 | return sub._relpath | |
|
175 | 177 | if not hasattr(sub, '_repo'): |
|
176 | 178 | return sub._path |
|
177 | 179 | return reporelpath(sub._repo) |
@@ -617,15 +619,17 b' class gitsubrepo(abstractsubrepo):' | |||
|
617 | 619 | # TODO add git version check. |
|
618 | 620 | self._state = state |
|
619 | 621 | self._ctx = ctx |
|
620 |
self._ |
|
|
621 |
self._path = ctx._repo |
|
|
622 | self._path = path | |
|
623 | self._relpath = os.path.join(reporelpath(ctx._repo), path) | |
|
624 | self._abspath = ctx._repo.wjoin(path) | |
|
622 | 625 | self._ui = ctx._repo.ui |
|
623 | 626 | |
|
624 | 627 | def _gitcommand(self, commands, env=None, stream=False): |
|
625 | 628 | return self._gitdir(commands, env=env, stream=stream)[0] |
|
626 | 629 | |
|
627 | 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 | 634 | def _gitnodir(self, commands, env=None, stream=False, cwd=None): |
|
631 | 635 | """Calls the git command |
@@ -711,9 +715,9 b' class gitsubrepo(abstractsubrepo):' | |||
|
711 | 715 | return tracking |
|
712 | 716 | |
|
713 | 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 | 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 | 721 | if self._githavelocally(revision): |
|
718 | 722 | return |
|
719 | 723 | self._ui.status(_('pulling subrepo %s\n') % self._relpath) |
@@ -725,7 +729,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
725 | 729 | self._gitcommand(['fetch', source]) |
|
726 | 730 | if not self._githavelocally(revision): |
|
727 | 731 | raise util.Abort(_("revision %s does not exist in subrepo %s\n") % |
|
728 | (revision, self._path)) | |
|
732 | (revision, self._relpath)) | |
|
729 | 733 | |
|
730 | 734 | def dirty(self, ignoreupdate=False): |
|
731 | 735 | # version checked out changed? |
@@ -859,16 +863,16 b' class gitsubrepo(abstractsubrepo):' | |||
|
859 | 863 | def remove(self): |
|
860 | 864 | if self.dirty(): |
|
861 | 865 | self._ui.warn(_('not removing repo %s because ' |
|
862 | 'it has changes.\n') % self._path) | |
|
866 | 'it has changes.\n') % self._relpath) | |
|
863 | 867 | return |
|
864 | 868 | # we can't fully delete the repository as it may contain |
|
865 | 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 | 871 | self._gitcommand(['config', 'core.bare', 'true']) |
|
868 | for f in os.listdir(self._path): | |
|
872 | for f in os.listdir(self._abspath): | |
|
869 | 873 | if f == '.git': |
|
870 | 874 | continue |
|
871 | path = os.path.join(self._path, f) | |
|
875 | path = os.path.join(self._abspath, f) | |
|
872 | 876 | if os.path.isdir(path) and not os.path.islink(path): |
|
873 | 877 | shutil.rmtree(path) |
|
874 | 878 | else: |
@@ -892,7 +896,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
892 | 896 | data = info.linkname |
|
893 | 897 | else: |
|
894 | 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 | 900 | info.mode, info.issym(), data) |
|
897 | 901 | ui.progress(_('archiving (%s)') % relpath, i + 1, |
|
898 | 902 | unit=_('files')) |
@@ -34,7 +34,7 b' add subrepo clone' | |||
|
34 | 34 | $ git clone -q ../gitroot s |
|
35 | 35 | $ hg add .hgsub |
|
36 | 36 | $ hg commit -m 'new git subrepo' |
|
37 |
committing subrepository |
|
|
37 | committing subrepository s | |
|
38 | 38 | $ hg debugsub |
|
39 | 39 | path s |
|
40 | 40 | source ../gitroot |
@@ -53,7 +53,7 b' record a new commit from upstream from a' | |||
|
53 | 53 | |
|
54 | 54 | $ cd .. |
|
55 | 55 | $ hg commit -m 'update git subrepo' |
|
56 |
committing subrepository |
|
|
56 | committing subrepository s | |
|
57 | 57 | $ hg debugsub |
|
58 | 58 | path s |
|
59 | 59 | source ../gitroot |
@@ -100,7 +100,7 b' clone root, make local change' | |||
|
100 | 100 | $ cd ../ta |
|
101 | 101 | $ echo ggg >> s/g |
|
102 | 102 | $ hg commit -m ggg |
|
103 |
committing subrepository |
|
|
103 | committing subrepository s | |
|
104 | 104 | $ hg debugsub |
|
105 | 105 | path s |
|
106 | 106 | source ../gitroot |
@@ -120,7 +120,7 b' clone root separately, make different lo' | |||
|
120 | 120 | $ cd .. |
|
121 | 121 | |
|
122 | 122 | $ hg commit -m f |
|
123 |
committing subrepository |
|
|
123 | committing subrepository s | |
|
124 | 124 | $ hg debugsub |
|
125 | 125 | path s |
|
126 | 126 | source ../gitroot |
@@ -159,7 +159,7 b' user a pulls, merges, commits' | |||
|
159 | 159 | gg |
|
160 | 160 | ggg |
|
161 | 161 | $ hg commit -m 'merge' |
|
162 |
committing subrepository |
|
|
162 | committing subrepository s | |
|
163 | 163 | $ hg debugsub |
|
164 | 164 | path s |
|
165 | 165 | source ../gitroot |
@@ -212,7 +212,7 b' sync to upstream git, distribute changes' | |||
|
212 | 212 | $ git pull -q >/dev/null 2>/dev/null |
|
213 | 213 | $ cd .. |
|
214 | 214 | $ hg commit -m 'git upstream sync' |
|
215 |
committing subrepository |
|
|
215 | committing subrepository s | |
|
216 | 216 | $ hg debugsub |
|
217 | 217 | path s |
|
218 | 218 | source ../gitroot |
@@ -260,3 +260,35 b' archive subrepos' | |||
|
260 | 260 | g |
|
261 | 261 | gg |
|
262 | 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