Show More
@@ -100,8 +100,9 b' def share(ui, source, dest=None, noupdat' | |||||
100 | the broken clone to reset it to a changeset that still exists. |
|
100 | the broken clone to reset it to a changeset that still exists. | |
101 | """ |
|
101 | """ | |
102 |
|
102 | |||
103 |
|
|
103 | hg.share(ui, source, dest=dest, update=not noupdate, | |
104 |
|
|
104 | bookmarks=bookmarks, relative=relative) | |
|
105 | return 0 | |||
105 |
|
106 | |||
106 | @command('unshare', [], '') |
|
107 | @command('unshare', [], '') | |
107 | def unshare(ui, repo): |
|
108 | def unshare(ui, repo): |
@@ -255,6 +255,7 b' def share(ui, source, dest=None, update=' | |||||
255 | r = repository(ui, destwvfs.base) |
|
255 | r = repository(ui, destwvfs.base) | |
256 | postshare(srcrepo, r, bookmarks=bookmarks, defaultpath=defaultpath) |
|
256 | postshare(srcrepo, r, bookmarks=bookmarks, defaultpath=defaultpath) | |
257 | _postshareupdate(r, update, checkout=checkout) |
|
257 | _postshareupdate(r, update, checkout=checkout) | |
|
258 | return r | |||
258 |
|
259 | |||
259 | def postshare(sourcerepo, destrepo, bookmarks=True, defaultpath=None): |
|
260 | def postshare(sourcerepo, destrepo, bookmarks=True, defaultpath=None): | |
260 | """Called after a new shared repo is created. |
|
261 | """Called after a new shared repo is created. |
@@ -857,21 +857,32 b' class hgsubrepo(abstractsubrepo):' | |||||
857 |
|
857 | |||
858 | def _get(self, state): |
|
858 | def _get(self, state): | |
859 | source, revision, kind = state |
|
859 | source, revision, kind = state | |
|
860 | parentrepo = self._repo._subparent | |||
|
861 | ||||
860 | if revision in self._repo.unfiltered(): |
|
862 | if revision in self._repo.unfiltered(): | |
861 | return True |
|
863 | # Allow shared subrepos tracked at null to setup the sharedpath | |
|
864 | if len(self._repo) != 0 or not parentrepo.shared(): | |||
|
865 | return True | |||
862 | self._repo._subsource = source |
|
866 | self._repo._subsource = source | |
863 | srcurl = _abssource(self._repo) |
|
867 | srcurl = _abssource(self._repo) | |
864 | other = hg.peer(self._repo, {}, srcurl) |
|
868 | other = hg.peer(self._repo, {}, srcurl) | |
865 | if len(self._repo) == 0: |
|
869 | if len(self._repo) == 0: | |
866 | self.ui.status(_('cloning subrepo %s from %s\n') |
|
|||
867 | % (subrelpath(self), srcurl)) |
|
|||
868 | parentrepo = self._repo._subparent |
|
|||
869 | # use self._repo.vfs instead of self.wvfs to remove .hg only |
|
870 | # use self._repo.vfs instead of self.wvfs to remove .hg only | |
870 | self._repo.vfs.rmtree() |
|
871 | self._repo.vfs.rmtree() | |
871 | other, cloned = hg.clone(self._repo._subparent.baseui, {}, |
|
872 | if parentrepo.shared(): | |
872 | other, self._repo.root, |
|
873 | self.ui.status(_('sharing subrepo %s from %s\n') | |
873 |
|
|
874 | % (subrelpath(self), srcurl)) | |
874 | self._repo = cloned.local() |
|
875 | shared = hg.share(self._repo._subparent.baseui, | |
|
876 | other, self._repo.root, | |||
|
877 | update=False, bookmarks=False) | |||
|
878 | self._repo = shared.local() | |||
|
879 | else: | |||
|
880 | self.ui.status(_('cloning subrepo %s from %s\n') | |||
|
881 | % (subrelpath(self), srcurl)) | |||
|
882 | other, cloned = hg.clone(self._repo._subparent.baseui, {}, | |||
|
883 | other, self._repo.root, | |||
|
884 | update=False) | |||
|
885 | self._repo = cloned.local() | |||
875 | self._initrepo(parentrepo, source, create=True) |
|
886 | self._initrepo(parentrepo, source, create=True) | |
876 | self._cachestorehash(srcurl) |
|
887 | self._cachestorehash(srcurl) | |
877 | else: |
|
888 | else: |
@@ -18,6 +18,57 b'' | |||||
18 | $ echo "subrepo = subrepo" > .hgsub |
|
18 | $ echo "subrepo = subrepo" > .hgsub | |
19 | $ hg add .hgsub |
|
19 | $ hg add .hgsub | |
20 | $ hg ci -m "add subrepo" |
|
20 | $ hg ci -m "add subrepo" | |
|
21 | ||||
|
22 | $ cat >> $HGRCPATH <<EOF | |||
|
23 | > [extensions] | |||
|
24 | > share = | |||
|
25 | > EOF | |||
|
26 | ||||
|
27 | hg subrepos are shared when the parent repo is shared | |||
|
28 | ||||
|
29 | $ cd .. | |||
|
30 | $ hg share test shared1 | |||
|
31 | updating working directory | |||
|
32 | sharing subrepo subrepo from $TESTTMP/test/subrepo | |||
|
33 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
34 | $ cat shared1/subrepo/.hg/sharedpath | |||
|
35 | $TESTTMP/test/subrepo/.hg (no-eol) (glob) | |||
|
36 | ||||
|
37 | hg subrepos are shared into existence on demand if the parent was shared | |||
|
38 | ||||
|
39 | $ hg clone -qr 1 test clone1 | |||
|
40 | $ hg share clone1 share2 | |||
|
41 | updating working directory | |||
|
42 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
43 | $ hg -R clone1 -q pull | |||
|
44 | $ hg -R share2 update tip | |||
|
45 | sharing subrepo subrepo from $TESTTMP/test/subrepo | |||
|
46 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
47 | $ cat share2/subrepo/.hg/sharedpath | |||
|
48 | $TESTTMP/test/subrepo/.hg (no-eol) (glob) | |||
|
49 | $ echo 'mod' > share2/subrepo/sub | |||
|
50 | $ hg -R share2 ci -Sqm 'subrepo mod' | |||
|
51 | $ hg -R clone1 update -C tip | |||
|
52 | cloning subrepo subrepo from $TESTTMP/test/subrepo | |||
|
53 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
54 | $ rm -rf clone1 | |||
|
55 | ||||
|
56 | $ hg clone -qr 1 test clone1 | |||
|
57 | $ hg share clone1 shared3 | |||
|
58 | updating working directory | |||
|
59 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
60 | $ hg -R clone1 -q pull | |||
|
61 | $ hg -R shared3 archive --config ui.archivemeta=False -r tip -S archive | |||
|
62 | sharing subrepo subrepo from $TESTTMP/test/subrepo | |||
|
63 | $ cat shared3/subrepo/.hg/sharedpath | |||
|
64 | $TESTTMP/test/subrepo/.hg (no-eol) (glob) | |||
|
65 | $ diff -r archive test | |||
|
66 | Only in test: .hg | |||
|
67 | Only in test/subrepo: .hg | |||
|
68 | [1] | |||
|
69 | $ rm -rf archive | |||
|
70 | ||||
|
71 | $ cd test | |||
21 |
$ |
|
72 | $ echo "[web]" >> .hg/hgrc | |
22 |
$ |
|
73 | $ echo "name = test-archive" >> .hg/hgrc | |
23 |
$ |
|
74 | $ echo "archivesubrepos = True" >> .hg/hgrc |
@@ -1181,10 +1181,32 b' subrepository:' | |||||
1181 | Check that share works with subrepo |
|
1181 | Check that share works with subrepo | |
1182 | $ hg --config extensions.share= share . ../shared |
|
1182 | $ hg --config extensions.share= share . ../shared | |
1183 | updating working directory |
|
1183 | updating working directory | |
1184 |
|
|
1184 | sharing subrepo subrepo-1 from $TESTTMP/subrepo-status/subrepo-1 | |
|
1185 | sharing subrepo subrepo-2 from $TESTTMP/subrepo-status/subrepo-2 | |||
1185 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1186 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1186 | $ test -f ../shared/subrepo-1/.hg/sharedpath |
|
1187 | $ find ../shared/* | sort | |
1187 | [1] |
|
1188 | ../shared/subrepo-1 | |
|
1189 | ../shared/subrepo-1/.hg | |||
|
1190 | ../shared/subrepo-1/.hg/cache | |||
|
1191 | ../shared/subrepo-1/.hg/cache/storehash | |||
|
1192 | ../shared/subrepo-1/.hg/cache/storehash/* (glob) | |||
|
1193 | ../shared/subrepo-1/.hg/hgrc | |||
|
1194 | ../shared/subrepo-1/.hg/requires | |||
|
1195 | ../shared/subrepo-1/.hg/sharedpath | |||
|
1196 | ../shared/subrepo-2 | |||
|
1197 | ../shared/subrepo-2/.hg | |||
|
1198 | ../shared/subrepo-2/.hg/branch | |||
|
1199 | ../shared/subrepo-2/.hg/cache | |||
|
1200 | ../shared/subrepo-2/.hg/cache/checkisexec (execbit !) | |||
|
1201 | ../shared/subrepo-2/.hg/cache/checklink (symlink !) | |||
|
1202 | ../shared/subrepo-2/.hg/cache/checklink-target (symlink !) | |||
|
1203 | ../shared/subrepo-2/.hg/cache/storehash | |||
|
1204 | ../shared/subrepo-2/.hg/cache/storehash/* (glob) | |||
|
1205 | ../shared/subrepo-2/.hg/dirstate | |||
|
1206 | ../shared/subrepo-2/.hg/hgrc | |||
|
1207 | ../shared/subrepo-2/.hg/requires | |||
|
1208 | ../shared/subrepo-2/.hg/sharedpath | |||
|
1209 | ../shared/subrepo-2/file | |||
1188 | $ hg -R ../shared in |
|
1210 | $ hg -R ../shared in | |
1189 | abort: repository default not found! |
|
1211 | abort: repository default not found! | |
1190 | [255] |
|
1212 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now