Mercurial > hg
comparison hgext/mq.py @ 23877:7cc77030c557
localrepo: remove all external users of localrepo.opener
This change touches every module in which repository.opener was being used, and
changes it for the equivalent repository.vfs. This is meant to make it easier
to split the repository.vfs into several separate vfs.
It should now be possible to remove localrepo.opener.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Thu, 15 Jan 2015 23:17:12 +0100 |
parents | 3b653c2fd6ba |
children | b88278a308c6 |
comparison
equal
deleted
inserted
replaced
23876:48fd1dfb99aa | 23877:7cc77030c557 |
---|---|
3213 cur = cur[8:] | 3213 cur = cur[8:] |
3214 return cur | 3214 return cur |
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 |
3222 | 3222 |
3223 return False | 3223 return False |
3224 | 3224 |
3225 def _getqueues(): | 3225 def _getqueues(): |
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: |
3233 queues.append(current) | 3233 queues.append(current) |
3234 except IOError: | 3234 except IOError: |
3241 raise util.Abort(_('new queue created, but cannot make active ' | 3241 raise util.Abort(_('new queue created, but cannot make active ' |
3242 'as patches are applied')) | 3242 'as patches are applied')) |
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 |
3256 def _queuedir(name): | 3256 def _queuedir(name): |
3257 if name == 'patches': | 3257 if name == 'patches': |
3272 current = _getcurrent() | 3272 current = _getcurrent() |
3273 | 3273 |
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 |
3281 fh.write('%s\n' % (queue,)) | 3281 fh.write('%s\n' % (queue,)) |
3282 fh.close() | 3282 fh.close() |
3320 | 3320 |
3321 if os.path.exists(newdir): | 3321 if os.path.exists(newdir): |
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,)) |
3329 if os.path.exists(olddir): | 3329 if os.path.exists(olddir): |
3330 util.rename(olddir, newdir) | 3330 util.rename(olddir, newdir) |