comparison hgext/share.py @ 31133:23080c03a604

share: add --relative flag to store a relative path to the source Storing a relative path the source repository is useful when exporting repositories over the network or when they're located on external drives where the mountpoint isn't always fixed. Currently, Mercurial interprets paths in `.hg/shared` relative to $PWD. I suspect this is very much unintentional, and you have to manually edit `.hg/shared` in order to trigger this behaviour. However, on the off chance that someone might rely on it, I added a new capability called 'relshared'. In addition, this makes earlier versions of Mercurial fail with a graceful error. I should note that I haven't tested this patch on Windows.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 13 Feb 2017 14:05:24 +0100
parents 0332b8fafd05
children ecbd378d9a7e
comparison
equal deleted inserted replaced
31132:bbdd712e9adb 31133:23080c03a604
63 # leave the attribute unspecified. 63 # leave the attribute unspecified.
64 testedwith = 'ships-with-hg-core' 64 testedwith = 'ships-with-hg-core'
65 65
66 @command('share', 66 @command('share',
67 [('U', 'noupdate', None, _('do not create a working directory')), 67 [('U', 'noupdate', None, _('do not create a working directory')),
68 ('B', 'bookmarks', None, _('also share bookmarks'))], 68 ('B', 'bookmarks', None, _('also share bookmarks')),
69 ('', 'relative', None, _('point to source using a relative path '
70 '(EXPERIMENTAL)')),
71 ],
69 _('[-U] [-B] SOURCE [DEST]'), 72 _('[-U] [-B] SOURCE [DEST]'),
70 norepo=True) 73 norepo=True)
71 def share(ui, source, dest=None, noupdate=False, bookmarks=False): 74 def share(ui, source, dest=None, noupdate=False, bookmarks=False,
75 relative=False):
72 """create a new shared repository 76 """create a new shared repository
73 77
74 Initialize a new repository and working directory that shares its 78 Initialize a new repository and working directory that shares its
75 history (and optionally bookmarks) with another repository. 79 history (and optionally bookmarks) with another repository.
76 80
85 parent". The only known workaround is to use debugsetparents on 89 parent". The only known workaround is to use debugsetparents on
86 the broken clone to reset it to a changeset that still exists. 90 the broken clone to reset it to a changeset that still exists.
87 """ 91 """
88 92
89 return hg.share(ui, source, dest=dest, update=not noupdate, 93 return hg.share(ui, source, dest=dest, update=not noupdate,
90 bookmarks=bookmarks) 94 bookmarks=bookmarks, relative=relative)
91 95
92 @command('unshare', [], '') 96 @command('unshare', [], '')
93 def unshare(ui, repo): 97 def unshare(ui, repo):
94 """convert a shared repository to a normal one 98 """convert a shared repository to a normal one
95 99