Show More
@@ -16,7 +16,6 b" testedwith = 'ships-with-hg-core'" | |||
|
16 | 16 | |
|
17 | 17 | from mercurial import ( |
|
18 | 18 | extensions, |
|
19 | hg, | |
|
20 | 19 | localrepo, |
|
21 | 20 | registrar, |
|
22 | 21 | repository, |
@@ -86,8 +85,6 b' def _verifierinit(orig, self, repo, matc' | |||
|
86 | 85 | |
|
87 | 86 | def extsetup(ui): |
|
88 | 87 | extensions.wrapfunction(verifymod.verifier, '__init__', _verifierinit) |
|
89 | extensions.wrapfunction(hg, 'postshare', narrowrepo.wrappostshare) | |
|
90 | extensions.wrapfunction(hg, 'copystore', narrowrepo.unsharenarrowspec) | |
|
91 | 88 | |
|
92 | 89 | templatekeyword = narrowtemplates.templatekeyword |
|
93 | 90 | revsetpredicate = narrowtemplates.revsetpredicate |
@@ -7,34 +7,11 b'' | |||
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | from mercurial import ( | |
|
11 | hg, | |
|
12 | narrowspec, | |
|
13 | repository, | |
|
14 | ) | |
|
15 | ||
|
16 | 10 | from . import ( |
|
17 | 11 | narrowdirstate, |
|
18 | 12 | narrowrevlog, |
|
19 | 13 | ) |
|
20 | 14 | |
|
21 | def wrappostshare(orig, sourcerepo, destrepo, **kwargs): | |
|
22 | orig(sourcerepo, destrepo, **kwargs) | |
|
23 | if repository.NARROW_REQUIREMENT in sourcerepo.requirements: | |
|
24 | with destrepo.wlock(): | |
|
25 | with destrepo.vfs('shared', 'a') as fp: | |
|
26 | fp.write(narrowspec.FILENAME + '\n') | |
|
27 | ||
|
28 | def unsharenarrowspec(orig, ui, repo, repopath): | |
|
29 | if (repository.NARROW_REQUIREMENT in repo.requirements | |
|
30 | and repo.path == repopath and repo.shared()): | |
|
31 | srcrepo = hg.sharedreposource(repo) | |
|
32 | with srcrepo.vfs(narrowspec.FILENAME) as f: | |
|
33 | spec = f.read() | |
|
34 | with repo.vfs(narrowspec.FILENAME, 'w') as f: | |
|
35 | f.write(spec) | |
|
36 | return orig(ui, repo, repopath) | |
|
37 | ||
|
38 | 15 | def wraprepo(repo): |
|
39 | 16 | """Enables narrow clone functionality on a single local repository.""" |
|
40 | 17 |
@@ -811,7 +811,7 b' class localrepository(object):' | |||
|
811 | 811 | " working parent %s!\n") % short(node)) |
|
812 | 812 | return nullid |
|
813 | 813 | |
|
814 |
@r |
|
|
814 | @storecache(narrowspec.FILENAME) | |
|
815 | 815 | def narrowpats(self): |
|
816 | 816 | """matcher patterns for this repository's narrowspec |
|
817 | 817 | |
@@ -823,7 +823,7 b' class localrepository(object):' | |||
|
823 | 823 | source = hg.sharedreposource(self) |
|
824 | 824 | return narrowspec.load(source) |
|
825 | 825 | |
|
826 |
@r |
|
|
826 | @storecache(narrowspec.FILENAME) | |
|
827 | 827 | def _narrowmatch(self): |
|
828 | 828 | if repository.NARROW_REQUIREMENT not in self.requirements: |
|
829 | 829 | return matchmod.always(self.root, '') |
@@ -108,7 +108,7 b' def needsexpansion(includes):' | |||
|
108 | 108 | |
|
109 | 109 | def load(repo): |
|
110 | 110 | try: |
|
111 | spec = repo.vfs.read(FILENAME) | |
|
111 | spec = repo.svfs.read(FILENAME) | |
|
112 | 112 | except IOError as e: |
|
113 | 113 | # Treat "narrowspec does not exist" the same as "narrowspec file exists |
|
114 | 114 | # and is empty". |
@@ -125,19 +125,19 b' def load(repo):' | |||
|
125 | 125 | |
|
126 | 126 | def save(repo, includepats, excludepats): |
|
127 | 127 | spec = format(includepats, excludepats) |
|
128 | repo.vfs.write(FILENAME, spec) | |
|
128 | repo.svfs.write(FILENAME, spec) | |
|
129 | 129 | |
|
130 | 130 | def savebackup(repo, backupname): |
|
131 | 131 | if repository.NARROW_REQUIREMENT not in repo.requirements: |
|
132 | 132 | return |
|
133 | 133 | vfs = repo.vfs |
|
134 | 134 | vfs.tryunlink(backupname) |
|
135 | util.copyfile(vfs.join(FILENAME), vfs.join(backupname), hardlink=True) | |
|
135 | util.copyfile(repo.svfs.join(FILENAME), vfs.join(backupname), hardlink=True) | |
|
136 | 136 | |
|
137 | 137 | def restorebackup(repo, backupname): |
|
138 | 138 | if repository.NARROW_REQUIREMENT not in repo.requirements: |
|
139 | 139 | return |
|
140 |
repo.vfs. |
|
|
140 | util.rename(repo.vfs.join(backupname), repo.svfs.join(FILENAME)) | |
|
141 | 141 | |
|
142 | 142 | def clearbackup(repo, backupname): |
|
143 | 143 | if repository.NARROW_REQUIREMENT not in repo.requirements: |
@@ -317,8 +317,8 b' def _calcmode(vfs):' | |||
|
317 | 317 | mode = None |
|
318 | 318 | return mode |
|
319 | 319 | |
|
320 |
_data = ('data meta 00manifest.d 00manifest.i |
|
|
321 | ' phaseroots obsstore') | |
|
320 | _data = ('narrowspec data meta 00manifest.d 00manifest.i' | |
|
321 | ' 00changelog.d 00changelog.i phaseroots obsstore') | |
|
322 | 322 | |
|
323 | 323 | def isrevlog(f, kind, st): |
|
324 | 324 | return kind == stat.S_IFREG and f[-2:] in ('.i', '.d') |
@@ -546,7 +546,7 b' class fncachestore(basicstore):' | |||
|
546 | 546 | raise |
|
547 | 547 | |
|
548 | 548 | def copylist(self): |
|
549 | d = ('data meta dh fncache phaseroots obsstore' | |
|
549 | d = ('narrowspec data meta dh fncache phaseroots obsstore' | |
|
550 | 550 | ' 00manifest.d 00manifest.i 00changelog.d 00changelog.i') |
|
551 | 551 | return (['requires', '00changelog.i'] + |
|
552 | 552 | ['store/' + f for f in d.split()]) |
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | $ . "$TESTDIR/narrow-library.sh" |
|
2 | 2 | $ hg init repo |
|
3 | 3 | $ cd repo |
|
4 | $ cat << EOF > .hg/narrowspec | |
|
4 | $ cat << EOF > .hg/store/narrowspec | |
|
5 | 5 | > [include] |
|
6 | 6 | > path:foo |
|
7 | 7 | > [exclude] |
@@ -166,7 +166,6 b" Can use 'hg share':" | |||
|
166 | 166 | |
|
167 | 167 | We should also be able to unshare without breaking everything: |
|
168 | 168 | $ hg unshare |
|
169 | devel-warn: write with no wlock: "narrowspec" at: */hgext/narrow/narrowrepo.py:* (unsharenarrowspec) (glob) | |
|
170 | 169 | $ hg verify |
|
171 | 170 | checking changesets |
|
172 | 171 | checking manifests |
General Comments 0
You need to be logged in to leave comments.
Login now