Mercurial > hg-stable
changeset 23614:cd79fb4d75fd
share: add option to share bookmarks
This patch adds the -B/--bookmarks option to the share command added by the
share extension. All it does for now is create a marker, 'bookmarks.shared',
that will be used by future code to implement the sharing functionality.
author | Ryan McElroy <rmcelroy@fb.com> |
---|---|
date | Sat, 13 Dec 2014 11:32:46 -0800 |
parents | 7b8ff3fd11d3 |
children | 7cfe58983bff |
files | hgext/share.py mercurial/hg.py tests/test-share.t |
diffstat | 3 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/share.py Wed Dec 17 13:25:24 2014 -0600 +++ b/hgext/share.py Sat Dec 13 11:32:46 2014 -0800 @@ -15,14 +15,15 @@ testedwith = 'internal' @command('share', - [('U', 'noupdate', None, _('do not create a working copy'))], - _('[-U] SOURCE [DEST]'), + [('U', 'noupdate', None, _('do not create a working copy')), + ('B', 'bookmarks', None, _('also share bookmarks'))], + _('[-U] [-B] SOURCE [DEST]'), norepo=True) -def share(ui, source, dest=None, noupdate=False): +def share(ui, source, dest=None, noupdate=False, bookmarks=False): """create a new shared repository Initialize a new repository and working directory that shares its - history with another repository. + history (and optionally bookmarks) with another repository. .. note:: @@ -36,7 +37,7 @@ the broken clone to reset it to a changeset that still exists. """ - return hg.share(ui, source, dest, not noupdate) + return hg.share(ui, source, dest, not noupdate, bookmarks) @command('unshare', [], '') def unshare(ui, repo):
--- a/mercurial/hg.py Wed Dec 17 13:25:24 2014 -0600 +++ b/mercurial/hg.py Sat Dec 13 11:32:46 2014 -0800 @@ -158,7 +158,7 @@ return '' return os.path.basename(os.path.normpath(path)) -def share(ui, source, dest=None, update=True): +def share(ui, source, dest=None, update=True, bookmarks=True): '''create a shared repository''' if not islocal(source): @@ -225,6 +225,9 @@ continue _update(r, uprev) + if bookmarks: + r.opener('bookmarks.shared', 'w').close() + def copystore(ui, srcrepo, destpath): '''copy files from store of srcrepo in destpath
--- a/tests/test-share.t Wed Dec 17 13:25:24 2014 -0600 +++ b/tests/test-share.t Sat Dec 13 11:32:46 2014 -0800 @@ -129,9 +129,9 @@ $ cd .. -test sharing bookmarks (manually add bookmarks.shared file for now) +test sharing bookmarks - $ hg share repo1 repo3 && touch repo3/.hg/bookmarks.shared + $ hg share -B repo1 repo3 updating working directory 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd repo1 @@ -212,7 +212,7 @@ test behavior when sharing a shared repo - $ hg share repo3 repo5 && touch repo5/.hg/bookmarks.shared + $ hg share -B repo3 repo5 updating working directory 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd repo5