Mercurial > hg
comparison hgext/narrow/narrowrepo.py @ 38835:a232e6744ba3
narrow: move requirement constant from changegroup to repository
As suggested by Gregory Szorc.
Differential Revision: https://phab.mercurial-scm.org/D4094
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 03 Aug 2018 11:02:34 -0700 |
parents | e411774a2e0f |
children | 576eef1ab43d |
comparison
equal
deleted
inserted
replaced
38834:c83ad57627ae | 38835:a232e6744ba3 |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 from mercurial import ( | 10 from mercurial import ( |
11 changegroup, | |
12 hg, | 11 hg, |
13 narrowspec, | 12 narrowspec, |
13 repository, | |
14 ) | 14 ) |
15 | 15 |
16 from . import ( | 16 from . import ( |
17 narrowdirstate, | 17 narrowdirstate, |
18 narrowrevlog, | 18 narrowrevlog, |
19 ) | 19 ) |
20 | 20 |
21 def wrappostshare(orig, sourcerepo, destrepo, **kwargs): | 21 def wrappostshare(orig, sourcerepo, destrepo, **kwargs): |
22 orig(sourcerepo, destrepo, **kwargs) | 22 orig(sourcerepo, destrepo, **kwargs) |
23 if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements: | 23 if repository.NARROW_REQUIREMENT in sourcerepo.requirements: |
24 with destrepo.wlock(): | 24 with destrepo.wlock(): |
25 with destrepo.vfs('shared', 'a') as fp: | 25 with destrepo.vfs('shared', 'a') as fp: |
26 fp.write(narrowspec.FILENAME + '\n') | 26 fp.write(narrowspec.FILENAME + '\n') |
27 | 27 |
28 def unsharenarrowspec(orig, ui, repo, repopath): | 28 def unsharenarrowspec(orig, ui, repo, repopath): |
29 if (changegroup.NARROW_REQUIREMENT in repo.requirements | 29 if (repository.NARROW_REQUIREMENT in repo.requirements |
30 and repo.path == repopath and repo.shared()): | 30 and repo.path == repopath and repo.shared()): |
31 srcrepo = hg.sharedreposource(repo) | 31 srcrepo = hg.sharedreposource(repo) |
32 with srcrepo.vfs(narrowspec.FILENAME) as f: | 32 with srcrepo.vfs(narrowspec.FILENAME) as f: |
33 spec = f.read() | 33 spec = f.read() |
34 with repo.vfs(narrowspec.FILENAME, 'w') as f: | 34 with repo.vfs(narrowspec.FILENAME, 'w') as f: |