share: replace the bookmarks.shared file with an entry on a new "shared" file
authorAngel Ezquerra <angel.ezquerra@gmail.com>
Sun, 11 Jan 2015 16:20:15 +0100
changeset 23883 7e71898a7cdc
parent 23882 272b1cc3e83e
child 23884 ec2c2e1400f0
share: replace the bookmarks.shared file with an entry on a new "shared" file cd79fb4d75fd introduced a way to share bookmarks. When a repository share that shares bookmarks was created, a .hg/bookmarks.shared file was created to mark the repository share as one that shares its bookmarks. We have plans to introduce other levels of sharing, including a "full share" mode. Rather than creating a new ".shared" file for each new thing that we may want to share It seems better to create a single "shared" file that will list what is shared for a given shared repository. This should make it much easier to get a list of everything that is shared by a given shared repository. The shared file contains a list of shared "items" (such as bookmarks). Each shared "item" is added as a new line in the file. For now the only possible entry in the file is "bookmarks".
hgext/share.py
mercurial/hg.py
--- a/hgext/share.py	Sun Nov 02 02:36:47 2014 +0100
+++ b/hgext/share.py	Sun Jan 11 16:20:15 2015 +0100
@@ -79,12 +79,12 @@
 def _hassharedbookmarks(repo):
     """Returns whether this repo has shared bookmarks"""
     try:
-        repo.vfs.read('bookmarks.shared')
-        return True
+        shared = repo.vfs.read('shared').splitlines()
     except IOError, inst:
         if inst.errno != errno.ENOENT:
             raise
         return False
+    return 'bookmarks' in shared
 
 def _getsrcrepo(repo):
     """
--- a/mercurial/hg.py	Sun Nov 02 02:36:47 2014 +0100
+++ b/mercurial/hg.py	Sun Jan 11 16:20:15 2015 +0100
@@ -226,7 +226,9 @@
         _update(r, uprev)
 
     if bookmarks:
-        r.vfs('bookmarks.shared', 'w').close()
+        fp = r.vfs('shared', 'w')
+        fp.write('bookmarks\n')
+        fp.close()
 
 def copystore(ui, srcrepo, destpath):
     '''copy files from store of srcrepo in destpath