[PATCH] share: add --relative flag to store a relative path to the source

Yuya Nishihara yuya at tcha.org
Thu Mar 2 09:53:49 EST 2017


On Tue, 14 Feb 2017 16:53:47 +0100, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
> # Date 1486991124 -3600
> #      Mon Feb 13 14:05:24 2017 +0100
> # Node ID e6d4c5b2de24b6151d709696891eed665000d363
> # Parent  a0e3d808690d57d1c9dff840e0b8ee099526397b
> share: add --relative flag to store a relative path to the source

> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -195,7 +195,8 @@ def defaultdest(source):
>          return ''
>      return os.path.basename(os.path.normpath(path))
>  
> -def share(ui, source, dest=None, update=True, bookmarks=True, defaultpath=None):
> +def share(ui, source, dest=None, update=True, bookmarks=True, defaultpath=None,
> +          relative=False):
>      '''create a shared repository'''
>  
>      if not islocal(source):
> @@ -235,7 +236,16 @@ def share(ui, source, dest=None, update=
>          if inst.errno != errno.ENOENT:
>              raise
>  
> -    requirements += 'shared\n'
> +    if relative:
> +        try:
> +            sharedpath = os.path.relpath(sharedpath, destvfs.base)
> +            requirements += 'relshared\n'
> +        except IOError as e:
> +            raise error.Abort(_('cannot calculate relative path'),
> +                              hint=e.message)

BaseException.message is deprecated. Replaced with str(e) in flight.

Do you know when IOError would be raised? I suspect it might be OSError.


More information about the Mercurial-devel mailing list