Mercurial > hg
comparison mercurial/narrowspec.py @ 38872:576eef1ab43d
narrow: move .hg/narrowspec to .hg/store/narrowspec (BC)
The narrowspec is more closely related to the store than to the
working copy. For example, if the narrowspec changes, the set of
revlogs also needs to change (the working copy may change, but that
depends on which commit is checked out). Also, when using the share
extension, the narrowspec needs to be shared along with the
store. This patch therefore moves the narrowspec into the store/
directory.
This is clearly a breaking change, but I haven't bothered trying to
fall back to reading the narrowspec from the old location (.hg/),
because there are very few users of narrow out there. (We'll add a
temporary hack to our Google-internal extension to handle the
migration.)
Differential Revision: https://phab.mercurial-scm.org/D4099
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 02 Aug 2018 14:57:20 -0700 |
parents | 204e074c188e |
children | 2675d561f5cb |
comparison
equal
deleted
inserted
replaced
38871:204e074c188e | 38872:576eef1ab43d |
---|---|
106 def needsexpansion(includes): | 106 def needsexpansion(includes): |
107 return [i for i in includes if i.startswith('include:')] | 107 return [i for i in includes if i.startswith('include:')] |
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". |
115 if e.errno == errno.ENOENT: | 115 if e.errno == errno.ENOENT: |
116 return set(), set() | 116 return set(), set() |
123 " suported in narrowspec")) | 123 " suported in narrowspec")) |
124 return includepats, excludepats | 124 return includepats, excludepats |
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.rename(backupname, FILENAME) | 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: |
144 return | 144 return |
145 repo.vfs.unlink(backupname) | 145 repo.vfs.unlink(backupname) |