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