From patchwork Sun Jan 11 15:23:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: share: replace the bookmarks.shared file with an entry on a new shared.conf file From: Angel Ezquerra X-Patchwork-Id: 7434 Message-Id: <8eca5c61ad384fdd4640.1420989822@Angels-MacBook-Pro.local> To: mercurial-devel@selenic.com Date: Sun, 11 Jan 2015 16:23:42 +0100 # HG changeset patch # User Angel Ezquerra # Date 1420989615 -3600 # Sun Jan 11 16:20:15 2015 +0100 # Node ID 8eca5c61ad384fdd4640ff6ef0c51062d3171878 # Parent 678f53865c6860a950392691814766957ee89316 share: replace the bookmarks.shared file with an entry on a new shared.conf 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 share.conf file that will list what is shared for a given file. This should make it much easier to get a list of everything that is shared by a given shared repository. The shared file is a config file that can be read with mercurial's config module. I've decided against calling the config file "sharerc" to emphasize the fact that this file is not meant to be edited by users. Each shared "item" is added as an entry in the "share" section of the share.conf file. For now the only possible entry in that section is "bookmarks". diff --git a/hgext/share.py b/hgext/share.py --- a/hgext/share.py +++ b/hgext/share.py @@ -6,7 +6,7 @@ '''share a common history between several working directories''' from mercurial.i18n import _ -from mercurial import cmdutil, hg, util, extensions, bookmarks +from mercurial import cmdutil, hg, util, extensions, bookmarks, config from mercurial.hg import repository, parseurl import errno @@ -78,13 +78,11 @@ def _hassharedbookmarks(repo): """Returns whether this repo has shared bookmarks""" - try: - repo.vfs.read('bookmarks.shared') - return True - except IOError, inst: - if inst.errno != errno.ENOENT: - raise + if not repo.vfs.exists('share.conf'): return False + cfg = config.config() + cfg.read(repo.vfs.join('share.conf')) + return cfg.get('share', 'bookmarks', None) is not None def _getsrcrepo(repo): """ diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -226,7 +226,9 @@ _update(r, uprev) if bookmarks: - r.opener('bookmarks.shared', 'w').close() + fp = r.opener('share.conf', 'w') + fp.write('[share]\nbookmarks=\n') + fp.close() def copystore(ui, srcrepo, destpath): '''copy files from store of srcrepo in destpath