Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.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 | 95ec3ad62f62 |
children | afcc4b4a0826 |
comparison
equal
deleted
inserted
replaced
31132:bbdd712e9adb | 31133:23080c03a604 |
---|---|
242 class localrepository(object): | 242 class localrepository(object): |
243 | 243 |
244 supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest', | 244 supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest', |
245 'manifestv2')) | 245 'manifestv2')) |
246 _basesupported = supportedformats | set(('store', 'fncache', 'shared', | 246 _basesupported = supportedformats | set(('store', 'fncache', 'shared', |
247 'dotencode')) | 247 'relshared', 'dotencode')) |
248 openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2')) | 248 openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2')) |
249 filtername = None | 249 filtername = None |
250 | 250 |
251 # a list of (ui, featureset) functions. | 251 # a list of (ui, featureset) functions. |
252 # only functions defined in module of enabled extensions are invoked | 252 # only functions defined in module of enabled extensions are invoked |
323 if inst.errno != errno.ENOENT: | 323 if inst.errno != errno.ENOENT: |
324 raise | 324 raise |
325 | 325 |
326 self.sharedpath = self.path | 326 self.sharedpath = self.path |
327 try: | 327 try: |
328 vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'), | 328 sharedpath = self.vfs.read("sharedpath").rstrip('\n') |
329 realpath=True) | 329 if 'relshared' in self.requirements: |
330 sharedpath = self.vfs.join(sharedpath) | |
331 vfs = scmutil.vfs(sharedpath, realpath=True) | |
332 | |
330 s = vfs.base | 333 s = vfs.base |
331 if not vfs.exists(): | 334 if not vfs.exists(): |
332 raise error.RepoError( | 335 raise error.RepoError( |
333 _('.hg/sharedpath points to nonexistent directory %s') % s) | 336 _('.hg/sharedpath points to nonexistent directory %s') % s) |
334 self.sharedpath = s | 337 self.sharedpath = s |