hgext/share.py
changeset 31072 0332b8fafd05
parent 29852 d5883fd055c6
child 31148 23080c03a604
equal deleted inserted replaced
31071:96eaefd350ae 31072:0332b8fafd05
    46     cmdutil,
    46     cmdutil,
    47     commands,
    47     commands,
    48     error,
    48     error,
    49     extensions,
    49     extensions,
    50     hg,
    50     hg,
       
    51     txnutil,
    51     util,
    52     util,
    52 )
    53 )
    53 
    54 
    54 repository = hg.repository
    55 repository = hg.repository
    55 parseurl = hg.parseurl
    56 parseurl = hg.parseurl
   169 
   170 
   170 def getbkfile(orig, repo):
   171 def getbkfile(orig, repo):
   171     if _hassharedbookmarks(repo):
   172     if _hassharedbookmarks(repo):
   172         srcrepo = _getsrcrepo(repo)
   173         srcrepo = _getsrcrepo(repo)
   173         if srcrepo is not None:
   174         if srcrepo is not None:
       
   175             # just orig(srcrepo) doesn't work as expected, because
       
   176             # HG_PENDING refers repo.root.
       
   177             try:
       
   178                 fp, pending = txnutil.trypending(repo.root, repo.vfs,
       
   179                                                  'bookmarks')
       
   180                 if pending:
       
   181                     # only in this case, bookmark information in repo
       
   182                     # is up-to-date.
       
   183                     return fp
       
   184                 fp.close()
       
   185             except IOError as inst:
       
   186                 if inst.errno != errno.ENOENT:
       
   187                     raise
       
   188 
       
   189             # otherwise, we should read bookmarks from srcrepo,
       
   190             # because .hg/bookmarks in srcrepo might be already
       
   191             # changed via another sharing repo
   174             repo = srcrepo
   192             repo = srcrepo
       
   193 
       
   194             # TODO: Pending changes in repo are still invisible in
       
   195             # srcrepo, because bookmarks.pending is written only into repo.
       
   196             # See also https://www.mercurial-scm.org/wiki/SharedRepository
   175     return orig(repo)
   197     return orig(repo)
   176 
   198 
   177 def recordchange(orig, self, tr):
   199 def recordchange(orig, self, tr):
   178     # Continue with write to local bookmarks file as usual
   200     # Continue with write to local bookmarks file as usual
   179     orig(self, tr)
   201     orig(self, tr)