view tests/test-subrepo-paths.t @ 30675:112915e9a363

chg: let hgc_open support long path "sizeof(sun_path)" is too small. Use the chdir trick to support long socket path, like "mercurial.util.bindunixsocket". It's useful for cases where TMPDIR is long. Modern OS X rewrites TMPDIR to a long value. And we probably want to use XDG_RUNTIME_DIR [2] for Linux. The approach is a bit different from the previous plan, where we will have hgc_openat and pass cmdserveropts.sockdirfd to it. That's because the current change is easier: chg has to pass a full path to "hg" as the "--address" parameter. There is no "--address-basename" or "--address-dirfd" flags. The next patch will remove "sockdirfd". Note: It'd be nice if we can use a native "connectat" implementation. However, that's not available everywhere. Some platform (namely FreeBSD) does support it, but the implementation has bugs so it cannot be used [2]. [1]: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html [2]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/082892.html
author Jun Wu <quark@fb.com>
date Fri, 23 Dec 2016 16:37:00 +0000
parents ee07f9d142c9
children 4441705b7111
line wrap: on
line source

  $ hg init outer
  $ cd outer

  $ echo '[paths]' >> .hg/hgrc
  $ echo 'default = http://example.net/' >> .hg/hgrc

hg debugsub with no remapping

  $ echo 'sub = libfoo' > .hgsub
  $ hg add .hgsub

  $ hg debugsub
  path sub
   source   libfoo
   revision 

hg debugsub with remapping

  $ echo '[subpaths]' >> .hg/hgrc
  $ printf 'http://example.net/lib(.*) = C:\\libs\\\\1-lib\\\n' >> .hg/hgrc

  $ hg debugsub
  path sub
   source   C:\libs\foo-lib\
   revision 

test cumulative remapping, the $HGRCPATH file is loaded first

  $ echo '[subpaths]' >> $HGRCPATH
  $ echo 'libfoo = libbar' >> $HGRCPATH
  $ hg debugsub
  path sub
   source   C:\libs\bar-lib\
   revision 

test absolute source path -- testing with a URL is important since
standard os.path.join wont treat that as an absolute path

  $ echo 'abs = http://example.net/abs' > .hgsub
  $ hg debugsub
  path abs
   source   http://example.net/abs
   revision 

  $ echo 'abs = /abs' > .hgsub
  $ hg debugsub
  path abs
   source   /abs
   revision 

test bad subpaths pattern

  $ cat > .hg/hgrc <<EOF
  > [subpaths]
  > .* = \1
  > EOF
  $ hg debugsub
  abort: bad subrepository pattern in $TESTTMP/outer/.hg/hgrc:2: invalid group reference (glob)
  [255]

  $ cd ..