mercurial/bookmarks.py
changeset 23458 756376ec6c12
parent 23360 e06daad65f85
child 23469 65e48b8d20f5
equal deleted inserted replaced
23457:fc76f55705eb 23458:756376ec6c12
    28 
    28 
    29     def __init__(self, repo):
    29     def __init__(self, repo):
    30         dict.__init__(self)
    30         dict.__init__(self)
    31         self._repo = repo
    31         self._repo = repo
    32         try:
    32         try:
    33             bkfile = None
    33             bkfile = self.getbkfile(repo)
    34             if 'HG_PENDING' in os.environ:
       
    35                 try:
       
    36                     bkfile = repo.vfs('bookmarks.pending')
       
    37                 except IOError, inst:
       
    38                     if inst.errno != errno.ENOENT:
       
    39                         raise
       
    40             if bkfile is None:
       
    41                 bkfile = repo.vfs('bookmarks')
       
    42             for line in bkfile:
    34             for line in bkfile:
    43                 line = line.strip()
    35                 line = line.strip()
    44                 if not line:
    36                 if not line:
    45                     continue
    37                     continue
    46                 if ' ' not in line:
    38                 if ' ' not in line:
    54                 except LookupError:
    46                 except LookupError:
    55                     pass
    47                     pass
    56         except IOError, inst:
    48         except IOError, inst:
    57             if inst.errno != errno.ENOENT:
    49             if inst.errno != errno.ENOENT:
    58                 raise
    50                 raise
       
    51 
       
    52     def getbkfile(self, repo):
       
    53         bkfile = None
       
    54         if 'HG_PENDING' in os.environ:
       
    55             try:
       
    56                 bkfile = repo.vfs('bookmarks.pending')
       
    57             except IOError, inst:
       
    58                 if inst.errno != errno.ENOENT:
       
    59                     raise
       
    60         if bkfile is None:
       
    61             bkfile = repo.vfs('bookmarks')
       
    62         return bkfile
    59 
    63 
    60     def recordchange(self, tr):
    64     def recordchange(self, tr):
    61         """record that bookmarks have been changed in a transaction
    65         """record that bookmarks have been changed in a transaction
    62 
    66 
    63         The transaction is then responsible for updating the file content."""
    67         The transaction is then responsible for updating the file content."""