hgext/share.py
changeset 49306 2e726c934fcd
parent 48875 6000f5b25c9b
child 50796 7a50e1720f6d
equal deleted inserted replaced
49305:53e9422a9b45 49306:2e726c934fcd
    64     For resharing existing shares, make sure your working directory is clean
    64     For resharing existing shares, make sure your working directory is clean
    65     and there are no untracked files, delete that share and create a new share.
    65     and there are no untracked files, delete that share and create a new share.
    66 '''
    66 '''
    67 
    67 
    68 
    68 
    69 import errno
       
    70 from mercurial.i18n import _
    69 from mercurial.i18n import _
    71 from mercurial import (
    70 from mercurial import (
    72     bookmarks,
    71     bookmarks,
    73     commands,
    72     commands,
    74     error,
    73     error,
   175         # Kind of a lie, but it means that we skip our custom reads and writes
   174         # Kind of a lie, but it means that we skip our custom reads and writes
   176         # from/to the source repo.
   175         # from/to the source repo.
   177         return False
   176         return False
   178     try:
   177     try:
   179         shared = repo.vfs.read(b'shared').splitlines()
   178         shared = repo.vfs.read(b'shared').splitlines()
   180     except IOError as inst:
   179     except FileNotFoundError:
   181         if inst.errno != errno.ENOENT:
       
   182             raise
       
   183         return False
   180         return False
   184     return hg.sharedbookmarks in shared
   181     return hg.sharedbookmarks in shared
   185 
   182 
   186 
   183 
   187 def getbkfile(orig, repo):
   184 def getbkfile(orig, repo):
   197                 if pending:
   194                 if pending:
   198                     # only in this case, bookmark information in repo
   195                     # only in this case, bookmark information in repo
   199                     # is up-to-date.
   196                     # is up-to-date.
   200                     return fp
   197                     return fp
   201                 fp.close()
   198                 fp.close()
   202             except IOError as inst:
   199             except FileNotFoundError:
   203                 if inst.errno != errno.ENOENT:
   200                 pass
   204                     raise
       
   205 
   201 
   206             # otherwise, we should read bookmarks from srcrepo,
   202             # otherwise, we should read bookmarks from srcrepo,
   207             # because .hg/bookmarks in srcrepo might be already
   203             # because .hg/bookmarks in srcrepo might be already
   208             # changed via another sharing repo
   204             # changed via another sharing repo
   209             repo = srcrepo
   205             repo = srcrepo