21 from . import ( |
21 from . import ( |
22 narrowrevlog, |
22 narrowrevlog, |
23 narrowspec, |
23 narrowspec, |
24 ) |
24 ) |
25 |
25 |
26 requirement = 'narrowhg' |
26 REQUIREMENT = 'narrowhg' |
27 |
27 |
28 def wrappostshare(orig, sourcerepo, destrepo, **kwargs): |
28 def wrappostshare(orig, sourcerepo, destrepo, **kwargs): |
29 orig(sourcerepo, destrepo, **kwargs) |
29 orig(sourcerepo, destrepo, **kwargs) |
30 if requirement in sourcerepo.requirements: |
30 if REQUIREMENT in sourcerepo.requirements: |
31 with destrepo.wlock(): |
31 with destrepo.wlock(): |
32 with destrepo.vfs('shared', 'a') as fp: |
32 with destrepo.vfs('shared', 'a') as fp: |
33 fp.write(narrowspec.FILENAME + '\n') |
33 fp.write(narrowspec.FILENAME + '\n') |
34 |
34 |
35 def unsharenarrowspec(orig, ui, repo, repopath): |
35 def unsharenarrowspec(orig, ui, repo, repopath): |
36 if (requirement in repo.requirements |
36 if (REQUIREMENT in repo.requirements |
37 and repo.path == repopath and repo.shared()): |
37 and repo.path == repopath and repo.shared()): |
38 srcrepo = share._getsrcrepo(repo) |
38 srcrepo = share._getsrcrepo(repo) |
39 with srcrepo.vfs(narrowspec.FILENAME) as f: |
39 with srcrepo.vfs(narrowspec.FILENAME) as f: |
40 spec = f.read() |
40 spec = f.read() |
41 with repo.vfs(narrowspec.FILENAME, 'w') as f: |
41 with repo.vfs(narrowspec.FILENAME, 'w') as f: |