##// END OF EJS Templates
localrepo: remove all external users of localrepo.opener...
Angel Ezquerra -
r23877:7cc77030 default
parent child Browse files
Show More
@@ -112,7 +112,7 b' def wrapui(ui):'
112 lastblackbox = blackbox
112 lastblackbox = blackbox
113
113
114 def setrepo(self, repo):
114 def setrepo(self, repo):
115 self._bbopener = repo.opener
115 self._bbopener = repo.vfs
116
116
117 ui.__class__ = blackboxui
117 ui.__class__ = blackboxui
118
118
@@ -141,7 +141,7 b' def blackbox(ui, repo, *revs, **opts):'
141 return
141 return
142
142
143 limit = opts.get('limit')
143 limit = opts.get('limit')
144 blackbox = repo.opener('blackbox.log', 'r')
144 blackbox = repo.vfs('blackbox.log', 'r')
145 lines = blackbox.read().split('\n')
145 lines = blackbox.read().split('\n')
146
146
147 count = 0
147 count = 0
@@ -319,7 +319,7 b' def reposetup(ui, repo):'
319 # longer match a file it matched before
319 # longer match a file it matched before
320 self.dirstate.normallookup(f)
320 self.dirstate.normallookup(f)
321 # Create or touch the cache to update mtime
321 # Create or touch the cache to update mtime
322 self.opener("eol.cache", "w").close()
322 self.vfs("eol.cache", "w").close()
323 wlock.release()
323 wlock.release()
324 except error.LockUnavailable:
324 except error.LockUnavailable:
325 # If we cannot lock the repository and clear the
325 # If we cannot lock the repository and clear the
@@ -103,7 +103,7 b' def sigwalk(repo):'
103 try:
103 try:
104 # read local signatures
104 # read local signatures
105 fn = "localsigs"
105 fn = "localsigs"
106 for item in parsefile(repo.opener(fn), fn):
106 for item in parsefile(repo.vfs(fn), fn):
107 yield item
107 yield item
108 except IOError:
108 except IOError:
109 pass
109 pass
@@ -250,7 +250,7 b' def sign(ui, repo, *revs, **opts):'
250
250
251 # write it
251 # write it
252 if opts['local']:
252 if opts['local']:
253 repo.opener.append("localsigs", sigmessage)
253 repo.vfs.append("localsigs", sigmessage)
254 return
254 return
255
255
256 if not opts["force"]:
256 if not opts["force"]:
@@ -411,7 +411,7 b' def demo(ui, repo, *args, **opts):'
411 if args:
411 if args:
412 # simulate hgrc parsing
412 # simulate hgrc parsing
413 rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
413 rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
414 fp = repo.opener('hgrc', 'w')
414 fp = repo.vfs('hgrc', 'w')
415 fp.writelines(rcmaps)
415 fp.writelines(rcmaps)
416 fp.close()
416 fp.close()
417 ui.readconfig(repo.join('hgrc'))
417 ui.readconfig(repo.join('hgrc'))
@@ -3215,7 +3215,7 b' def qqueue(ui, repo, name=None, **opts):'
3215
3215
3216 def _noqueues():
3216 def _noqueues():
3217 try:
3217 try:
3218 fh = repo.opener(_allqueues, 'r')
3218 fh = repo.vfs(_allqueues, 'r')
3219 fh.close()
3219 fh.close()
3220 except IOError:
3220 except IOError:
3221 return True
3221 return True
@@ -3226,7 +3226,7 b' def qqueue(ui, repo, name=None, **opts):'
3226 current = _getcurrent()
3226 current = _getcurrent()
3227
3227
3228 try:
3228 try:
3229 fh = repo.opener(_allqueues, 'r')
3229 fh = repo.vfs(_allqueues, 'r')
3230 queues = [queue.strip() for queue in fh if queue.strip()]
3230 queues = [queue.strip() for queue in fh if queue.strip()]
3231 fh.close()
3231 fh.close()
3232 if current not in queues:
3232 if current not in queues:
@@ -3243,13 +3243,13 b' def qqueue(ui, repo, name=None, **opts):'
3243 _setactivenocheck(name)
3243 _setactivenocheck(name)
3244
3244
3245 def _setactivenocheck(name):
3245 def _setactivenocheck(name):
3246 fh = repo.opener(_activequeue, 'w')
3246 fh = repo.vfs(_activequeue, 'w')
3247 if name != 'patches':
3247 if name != 'patches':
3248 fh.write(name)
3248 fh.write(name)
3249 fh.close()
3249 fh.close()
3250
3250
3251 def _addqueue(name):
3251 def _addqueue(name):
3252 fh = repo.opener(_allqueues, 'a')
3252 fh = repo.vfs(_allqueues, 'a')
3253 fh.write('%s\n' % (name,))
3253 fh.write('%s\n' % (name,))
3254 fh.close()
3254 fh.close()
3255
3255
@@ -3274,7 +3274,7 b' def qqueue(ui, repo, name=None, **opts):'
3274 if name == current:
3274 if name == current:
3275 raise util.Abort(_('cannot delete currently active queue'))
3275 raise util.Abort(_('cannot delete currently active queue'))
3276
3276
3277 fh = repo.opener('patches.queues.new', 'w')
3277 fh = repo.vfs('patches.queues.new', 'w')
3278 for queue in existing:
3278 for queue in existing:
3279 if queue == name:
3279 if queue == name:
3280 continue
3280 continue
@@ -3322,7 +3322,7 b' def qqueue(ui, repo, name=None, **opts):'
3322 raise util.Abort(_('non-queue directory "%s" already exists') %
3322 raise util.Abort(_('non-queue directory "%s" already exists') %
3323 newdir)
3323 newdir)
3324
3324
3325 fh = repo.opener('patches.queues.new', 'w')
3325 fh = repo.vfs('patches.queues.new', 'w')
3326 for queue in existing:
3326 for queue in existing:
3327 if queue == current:
3327 if queue == current:
3328 fh.write('%s\n' % (name,))
3328 fh.write('%s\n' % (name,))
@@ -234,7 +234,7 b' def _getdescription(repo, defaultbody, s'
234 'patch series.\n\n'))
234 'patch series.\n\n'))
235 body = ui.edit(defaultbody, sender)
235 body = ui.edit(defaultbody, sender)
236 # Save series description in case sendmail fails
236 # Save series description in case sendmail fails
237 msgfile = repo.opener('last-email.txt', 'wb')
237 msgfile = repo.vfs('last-email.txt', 'wb')
238 msgfile.write(body)
238 msgfile.write(body)
239 msgfile.close()
239 msgfile.close()
240 return body
240 return body
@@ -754,7 +754,7 b' def updatebookmarks(repo, targetnode, ns'
754 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
754 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
755 external, activebookmark):
755 external, activebookmark):
756 'Store the current status to allow recovery'
756 'Store the current status to allow recovery'
757 f = repo.opener("rebasestate", "w")
757 f = repo.vfs("rebasestate", "w")
758 f.write(repo[originalwd].hex() + '\n')
758 f.write(repo[originalwd].hex() + '\n')
759 f.write(repo[target].hex() + '\n')
759 f.write(repo[target].hex() + '\n')
760 f.write(repo[external].hex() + '\n')
760 f.write(repo[external].hex() + '\n')
@@ -789,7 +789,7 b' def restorestatus(repo):'
789 external = nullrev
789 external = nullrev
790 activebookmark = None
790 activebookmark = None
791 state = {}
791 state = {}
792 f = repo.opener("rebasestate")
792 f = repo.vfs("rebasestate")
793 for i, l in enumerate(f.read().splitlines()):
793 for i, l in enumerate(f.read().splitlines()):
794 if i == 0:
794 if i == 0:
795 originalwd = repo[l].rev()
795 originalwd = repo[l].rev()
@@ -95,7 +95,7 b' class shelvedstate(object):'
95
95
96 @classmethod
96 @classmethod
97 def load(cls, repo):
97 def load(cls, repo):
98 fp = repo.opener(cls._filename)
98 fp = repo.vfs(cls._filename)
99 try:
99 try:
100 version = int(fp.readline().strip())
100 version = int(fp.readline().strip())
101
101
@@ -121,7 +121,7 b' class shelvedstate(object):'
121
121
122 @classmethod
122 @classmethod
123 def save(cls, repo, name, originalwctx, pendingctx, stripnodes):
123 def save(cls, repo, name, originalwctx, pendingctx, stripnodes):
124 fp = repo.opener(cls._filename, 'wb')
124 fp = repo.vfs(cls._filename, 'wb')
125 fp.write('%i\n' % cls._version)
125 fp.write('%i\n' % cls._version)
126 fp.write('%s\n' % name)
126 fp.write('%s\n' % name)
127 fp.write('%s\n' % hex(originalwctx.node()))
127 fp.write('%s\n' % hex(originalwctx.node()))
@@ -115,7 +115,7 b' def readcurrent(repo):'
115 '''
115 '''
116 mark = None
116 mark = None
117 try:
117 try:
118 file = repo.opener('bookmarks.current')
118 file = repo.vfs('bookmarks.current')
119 except IOError, inst:
119 except IOError, inst:
120 if inst.errno != errno.ENOENT:
120 if inst.errno != errno.ENOENT:
121 raise
121 raise
@@ -144,7 +144,7 b' def setcurrent(repo, mark):'
144
144
145 wlock = repo.wlock()
145 wlock = repo.wlock()
146 try:
146 try:
147 file = repo.opener('bookmarks.current', 'w', atomictemp=True)
147 file = repo.vfs('bookmarks.current', 'w', atomictemp=True)
148 file.write(encoding.fromlocal(mark))
148 file.write(encoding.fromlocal(mark))
149 file.close()
149 file.close()
150 finally:
150 finally:
@@ -21,7 +21,7 b' def _filename(repo):'
21
21
22 def read(repo):
22 def read(repo):
23 try:
23 try:
24 f = repo.opener(_filename(repo))
24 f = repo.vfs(_filename(repo))
25 lines = f.read().split('\n')
25 lines = f.read().split('\n')
26 f.close()
26 f.close()
27 except (IOError, OSError):
27 except (IOError, OSError):
@@ -203,7 +203,7 b' class branchcache(dict):'
203
203
204 def write(self, repo):
204 def write(self, repo):
205 try:
205 try:
206 f = repo.opener(_filename(repo), "w", atomictemp=True)
206 f = repo.vfs(_filename(repo), "w", atomictemp=True)
207 cachekey = [hex(self.tipnode), str(self.tiprev)]
207 cachekey = [hex(self.tipnode), str(self.tiprev)]
208 if self.filteredhash is not None:
208 if self.filteredhash is not None:
209 cachekey.append(hex(self.filteredhash))
209 cachekey.append(hex(self.filteredhash))
@@ -1803,7 +1803,7 b' def debugbuilddag(ui, repo, text=None,'
1803 tr.close()
1803 tr.close()
1804
1804
1805 if tags:
1805 if tags:
1806 repo.opener.write("localtags", "".join(tags))
1806 repo.vfs.write("localtags", "".join(tags))
1807 finally:
1807 finally:
1808 ui.progress(_('building'), None)
1808 ui.progress(_('building'), None)
1809 release(tr, lock)
1809 release(tr, lock)
@@ -3377,7 +3377,7 b' def graft(ui, repo, *revs, **opts):'
3377 raise util.Abort(_("can't specify --continue and revisions"))
3377 raise util.Abort(_("can't specify --continue and revisions"))
3378 # read in unfinished revisions
3378 # read in unfinished revisions
3379 try:
3379 try:
3380 nodes = repo.opener.read('graftstate').splitlines()
3380 nodes = repo.vfs.read('graftstate').splitlines()
3381 revs = [repo[node].rev() for node in nodes]
3381 revs = [repo[node].rev() for node in nodes]
3382 except IOError, inst:
3382 except IOError, inst:
3383 if inst.errno != errno.ENOENT:
3383 if inst.errno != errno.ENOENT:
@@ -3506,7 +3506,7 b' def graft(ui, repo, *revs, **opts):'
3506 if stats and stats[3] > 0:
3506 if stats and stats[3] > 0:
3507 # write out state for --continue
3507 # write out state for --continue
3508 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3508 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3509 repo.opener.write('graftstate', ''.join(nodelines))
3509 repo.vfs.write('graftstate', ''.join(nodelines))
3510 raise util.Abort(
3510 raise util.Abort(
3511 _("unresolved conflicts, can't continue"),
3511 _("unresolved conflicts, can't continue"),
3512 hint=_('use hg resolve and hg graft --continue'))
3512 hint=_('use hg resolve and hg graft --continue'))
@@ -136,7 +136,7 b' def bisect(changelog, state):'
136 def load_state(repo):
136 def load_state(repo):
137 state = {'current': [], 'good': [], 'bad': [], 'skip': []}
137 state = {'current': [], 'good': [], 'bad': [], 'skip': []}
138 if os.path.exists(repo.join("bisect.state")):
138 if os.path.exists(repo.join("bisect.state")):
139 for l in repo.opener("bisect.state"):
139 for l in repo.vfs("bisect.state"):
140 kind, node = l[:-1].split()
140 kind, node = l[:-1].split()
141 node = repo.lookup(node)
141 node = repo.lookup(node)
142 if kind not in state:
142 if kind not in state:
@@ -146,7 +146,7 b' def load_state(repo):'
146
146
147
147
148 def save_state(repo, state):
148 def save_state(repo, state):
149 f = repo.opener("bisect.state", "w", atomictemp=True)
149 f = repo.vfs("bisect.state", "w", atomictemp=True)
150 wlock = repo.wlock()
150 wlock = repo.wlock()
151 try:
151 try:
152 for kind in sorted(state):
152 for kind in sorted(state):
@@ -193,7 +193,7 b' def share(ui, source, dest=None, update='
193
193
194 requirements = ''
194 requirements = ''
195 try:
195 try:
196 requirements = srcrepo.opener.read('requires')
196 requirements = srcrepo.vfs.read('requires')
197 except IOError, inst:
197 except IOError, inst:
198 if inst.errno != errno.ENOENT:
198 if inst.errno != errno.ENOENT:
199 raise
199 raise
@@ -206,7 +206,7 b' def share(ui, source, dest=None, update='
206
206
207 default = srcrepo.ui.config('paths', 'default')
207 default = srcrepo.ui.config('paths', 'default')
208 if default:
208 if default:
209 fp = r.opener("hgrc", "w", text=True)
209 fp = r.vfs("hgrc", "w", text=True)
210 fp.write("[paths]\n")
210 fp.write("[paths]\n")
211 fp.write("default = %s\n" % default)
211 fp.write("default = %s\n" % default)
212 fp.close()
212 fp.close()
@@ -226,7 +226,7 b' def share(ui, source, dest=None, update='
226 _update(r, uprev)
226 _update(r, uprev)
227
227
228 if bookmarks:
228 if bookmarks:
229 r.opener('bookmarks.shared', 'w').close()
229 r.vfs('bookmarks.shared', 'w').close()
230
230
231 def copystore(ui, srcrepo, destpath):
231 def copystore(ui, srcrepo, destpath):
232 '''copy files from store of srcrepo in destpath
232 '''copy files from store of srcrepo in destpath
@@ -441,7 +441,7 b' def clone(ui, peeropts, source, dest=Non'
441 destrepo = destpeer.local()
441 destrepo = destpeer.local()
442 if destrepo:
442 if destrepo:
443 template = uimod.samplehgrcs['cloned']
443 template = uimod.samplehgrcs['cloned']
444 fp = destrepo.opener("hgrc", "w", text=True)
444 fp = destrepo.vfs("hgrc", "w", text=True)
445 u = util.url(abspath)
445 u = util.url(abspath)
446 u.passwd = None
446 u.passwd = None
447 defaulturl = str(u)
447 defaulturl = str(u)
@@ -138,7 +138,7 b' class mergestate(object):'
138 """
138 """
139 records = []
139 records = []
140 try:
140 try:
141 f = self._repo.opener(self.statepathv1)
141 f = self._repo.vfs(self.statepathv1)
142 for i, l in enumerate(f):
142 for i, l in enumerate(f):
143 if i == 0:
143 if i == 0:
144 records.append(('L', l[:-1]))
144 records.append(('L', l[:-1]))
@@ -157,7 +157,7 b' class mergestate(object):'
157 """
157 """
158 records = []
158 records = []
159 try:
159 try:
160 f = self._repo.opener(self.statepathv2)
160 f = self._repo.vfs(self.statepathv2)
161 data = f.read()
161 data = f.read()
162 off = 0
162 off = 0
163 end = len(data)
163 end = len(data)
@@ -184,8 +184,8 b' class mergestate(object):'
184 # Check local variables before looking at filesystem for performance
184 # Check local variables before looking at filesystem for performance
185 # reasons.
185 # reasons.
186 return bool(self._local) or bool(self._state) or \
186 return bool(self._local) or bool(self._state) or \
187 self._repo.opener.exists(self.statepathv1) or \
187 self._repo.vfs.exists(self.statepathv1) or \
188 self._repo.opener.exists(self.statepathv2)
188 self._repo.vfs.exists(self.statepathv2)
189
189
190 def commit(self):
190 def commit(self):
191 """Write current state on disk (if necessary)"""
191 """Write current state on disk (if necessary)"""
@@ -205,7 +205,7 b' class mergestate(object):'
205
205
206 def _writerecordsv1(self, records):
206 def _writerecordsv1(self, records):
207 """Write current state on disk in a version 1 file"""
207 """Write current state on disk in a version 1 file"""
208 f = self._repo.opener(self.statepathv1, 'w')
208 f = self._repo.vfs(self.statepathv1, 'w')
209 irecords = iter(records)
209 irecords = iter(records)
210 lrecords = irecords.next()
210 lrecords = irecords.next()
211 assert lrecords[0] == 'L'
211 assert lrecords[0] == 'L'
@@ -217,7 +217,7 b' class mergestate(object):'
217
217
218 def _writerecordsv2(self, records):
218 def _writerecordsv2(self, records):
219 """Write current state on disk in a version 2 file"""
219 """Write current state on disk in a version 2 file"""
220 f = self._repo.opener(self.statepathv2, 'w')
220 f = self._repo.vfs(self.statepathv2, 'w')
221 for key, data in records:
221 for key, data in records:
222 assert len(key) == 1
222 assert len(key) == 1
223 format = '>sI%is' % len(data)
223 format = '>sI%is' % len(data)
@@ -234,7 +234,7 b' class mergestate(object):'
234 note: also write the local version to the `.hg/merge` directory.
234 note: also write the local version to the `.hg/merge` directory.
235 """
235 """
236 hash = util.sha1(fcl.path()).hexdigest()
236 hash = util.sha1(fcl.path()).hexdigest()
237 self._repo.opener.write('merge/' + hash, fcl.data())
237 self._repo.vfs.write('merge/' + hash, fcl.data())
238 self._state[fd] = ['u', hash, fcl.path(),
238 self._state[fd] = ['u', hash, fcl.path(),
239 fca.path(), hex(fca.filenode()),
239 fca.path(), hex(fca.filenode()),
240 fco.path(), hex(fco.filenode()),
240 fco.path(), hex(fco.filenode()),
@@ -284,7 +284,7 b' class mergestate(object):'
284 elif flags == fla:
284 elif flags == fla:
285 flags = flo
285 flags = flo
286 # restore local
286 # restore local
287 f = self._repo.opener('merge/' + hash)
287 f = self._repo.vfs('merge/' + hash)
288 self._repo.wwrite(dfile, f.read(), flags)
288 self._repo.wwrite(dfile, f.read(), flags)
289 f.close()
289 f.close()
290 r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca,
290 r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca,
@@ -109,7 +109,7 b' class statichttprepository(localrepo.loc'
109 self.names = namespaces.namespaces()
109 self.names = namespaces.namespaces()
110
110
111 try:
111 try:
112 requirements = scmutil.readrequires(self.opener, self.supported)
112 requirements = scmutil.readrequires(self.vfs, self.supported)
113 except IOError, inst:
113 except IOError, inst:
114 if inst.errno != errno.ENOENT:
114 if inst.errno != errno.ENOENT:
115 raise
115 raise
@@ -117,7 +117,7 b' class statichttprepository(localrepo.loc'
117
117
118 # check if it is a non-empty old-style repository
118 # check if it is a non-empty old-style repository
119 try:
119 try:
120 fp = self.opener("00changelog.i")
120 fp = self.vfs("00changelog.i")
121 fp.read(1)
121 fp.read(1)
122 fp.close()
122 fp.close()
123 except IOError, inst:
123 except IOError, inst:
@@ -614,7 +614,7 b' class hgsubrepo(abstractsubrepo):'
614 if defpath != defpushpath:
614 if defpath != defpushpath:
615 addpathconfig('default-push', defpushpath)
615 addpathconfig('default-push', defpushpath)
616
616
617 fp = self._repo.opener("hgrc", "w", text=True)
617 fp = self._repo.vfs("hgrc", "w", text=True)
618 try:
618 try:
619 fp.write(''.join(lines))
619 fp.write(''.join(lines))
620 finally:
620 finally:
@@ -62,7 +62,7 b' def findglobaltags(ui, repo, alltags, ta'
62 def readlocaltags(ui, repo, alltags, tagtypes):
62 def readlocaltags(ui, repo, alltags, tagtypes):
63 '''Read local tags in repo. Update alltags and tagtypes.'''
63 '''Read local tags in repo. Update alltags and tagtypes.'''
64 try:
64 try:
65 data = repo.opener.read("localtags")
65 data = repo.vfs.read("localtags")
66 except IOError, inst:
66 except IOError, inst:
67 if inst.errno != errno.ENOENT:
67 if inst.errno != errno.ENOENT:
68 raise
68 raise
@@ -193,7 +193,7 b' def _readtagcache(ui, repo):'
193 set, caller is responsible for reading tag info from each head.'''
193 set, caller is responsible for reading tag info from each head.'''
194
194
195 try:
195 try:
196 cachefile = repo.opener('cache/tags', 'r')
196 cachefile = repo.vfs('cache/tags', 'r')
197 # force reading the file for static-http
197 # force reading the file for static-http
198 cachelines = iter(cachefile)
198 cachelines = iter(cachefile)
199 except IOError:
199 except IOError:
@@ -303,7 +303,7 b' def _readtagcache(ui, repo):'
303 def _writetagcache(ui, repo, heads, tagfnode, cachetags):
303 def _writetagcache(ui, repo, heads, tagfnode, cachetags):
304
304
305 try:
305 try:
306 cachefile = repo.opener('cache/tags', 'w', atomictemp=True)
306 cachefile = repo.vfs('cache/tags', 'w', atomictemp=True)
307 except (OSError, IOError):
307 except (OSError, IOError):
308 return
308 return
309
309
General Comments 0
You need to be logged in to leave comments. Login now