mercurial/tags.py
changeset 49306 2e726c934fcd
parent 49248 63fd0282ad40
child 49579 15a89b722937
equal deleted inserted replaced
49305:53e9422a9b45 49306:2e726c934fcd
    10 # Eventually, it could take care of updating (adding/removing/moving)
    10 # Eventually, it could take care of updating (adding/removing/moving)
    11 # tags too.
    11 # tags too.
    12 
    12 
    13 
    13 
    14 import binascii
    14 import binascii
    15 import errno
       
    16 import io
    15 import io
    17 
    16 
    18 from .node import (
    17 from .node import (
    19     bin,
    18     bin,
    20     hex,
    19     hex,
   240 
   239 
   241 def readlocaltags(ui, repo, alltags, tagtypes):
   240 def readlocaltags(ui, repo, alltags, tagtypes):
   242     '''Read local tags in repo. Update alltags and tagtypes.'''
   241     '''Read local tags in repo. Update alltags and tagtypes.'''
   243     try:
   242     try:
   244         data = repo.vfs.read(b"localtags")
   243         data = repo.vfs.read(b"localtags")
   245     except IOError as inst:
   244     except FileNotFoundError:
   246         if inst.errno != errno.ENOENT:
       
   247             raise
       
   248         return
   245         return
   249 
   246 
   250     # localtags is in the local encoding; re-encode to UTF-8 on
   247     # localtags is in the local encoding; re-encode to UTF-8 on
   251     # input for consistency with the rest of this module.
   248     # input for consistency with the rest of this module.
   252     filetags = _readtags(
   249     filetags = _readtags(
   650             repo.hook(b'tag', node=hex(node), tag=name, local=local)
   647             repo.hook(b'tag', node=hex(node), tag=name, local=local)
   651         return
   648         return
   652 
   649 
   653     try:
   650     try:
   654         fp = repo.wvfs(b'.hgtags', b'rb+')
   651         fp = repo.wvfs(b'.hgtags', b'rb+')
   655     except IOError as e:
   652     except FileNotFoundError:
   656         if e.errno != errno.ENOENT:
       
   657             raise
       
   658         fp = repo.wvfs(b'.hgtags', b'ab')
   653         fp = repo.wvfs(b'.hgtags', b'ab')
   659     else:
   654     else:
   660         prevtags = fp.read()
   655         prevtags = fp.read()
   661 
   656 
   662     # committed tags are stored in UTF-8
   657     # committed tags are stored in UTF-8