mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
4a7b28d08b
Summary: Previously `hg server` uses `HGPORT` that might be in use. This patch uses `-p 0 --port-file ...` so `hg server` always gets assigned a free port. The change was first made by the following Ruby script: ``` re = /^ \$ hg serve(.*) -p \$(HGPORT[12]?) (.*[^\\])$\n \$/ Dir['*.t'].each do |path| old = File.read(path) new = old.lines.map do |l| next l if l[/\(glob\)/] or not l['$HGPORT'] or l[/^ [$>]/] "#{l.chomp} (glob)\n" end.join.gsub re, <<-'EOS'.chomp $ hg serve\1 -p 0 --port-file $TESTTMP/.port \3 $ \2=`cat $TESTTMP/.port` $ EOS File.write(path, new) if old != new end ``` Then there are some manual changes: run-tests.py: It now treats `$HGPORT` in output as glob pattern `*`, since it does not know the assigned value in tests. test-bookmarks-pushpull.t, test-https.t: Some `hg pull`s were changed to use explicit paths instead of relying on `.hgrc` since the test restarts the server and `.hg/hgrc` having an outdated URL. test-schemes.t: The test writes `$HGPORT` to `.hgrc` before assigning it. Changed the order so the correct `$HGPORT` is written. test-patchbomb-tls.t: Changed `(?) (glob)` to `(glob) (?)`. Reviewed By: DurhamG Differential Revision: D6925398 fbshipit-source-id: d5c10476f43ce23f9e99618807580cf8ba92595c
83 lines
1.9 KiB
Turing
83 lines
1.9 KiB
Turing
#require serve
|
|
|
|
$ hgserve()
|
|
> {
|
|
> hg serve -a localhost -d --pid-file=hg.pid -E errors.log -v $@ \
|
|
> | sed -e "s/:$HGPORT1\\([^0-9]\\)/:HGPORT1\1/g" \
|
|
> -e "s/:$HGPORT2\\([^0-9]\\)/:HGPORT2\1/g" \
|
|
> -e 's/http:\/\/[^/]*\//http:\/\/localhost\//'
|
|
> cat hg.pid >> "$DAEMON_PIDS"
|
|
> echo % errors
|
|
> cat errors.log
|
|
> killdaemons.py hg.pid
|
|
> }
|
|
|
|
$ hg init test
|
|
$ cd test
|
|
$ echo '[web]' > .hg/hgrc
|
|
$ echo 'accesslog = access.log' >> .hg/hgrc
|
|
$ echo "port = $HGPORT1" >> .hg/hgrc
|
|
|
|
Without -v
|
|
|
|
$ hg serve -a localhost -p 0 --port-file $TESTTMP/.port -d --pid-file=hg.pid -E errors.log
|
|
$ HGPORT=`cat $TESTTMP/.port`
|
|
$ cat hg.pid >> "$DAEMON_PIDS"
|
|
$ if [ -f access.log ]; then
|
|
> echo 'access log created - .hg/hgrc respected'
|
|
> fi
|
|
access log created - .hg/hgrc respected
|
|
|
|
errors
|
|
|
|
$ cat errors.log
|
|
|
|
With -v
|
|
|
|
$ hgserve
|
|
listening at http://localhost/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
|
|
% errors
|
|
|
|
With -v and -p HGPORT2
|
|
|
|
$ hgserve -p "$HGPORT2"
|
|
listening at http://localhost/ (bound to *$LOCALIP*:HGPORT2) (glob) (?)
|
|
% errors
|
|
|
|
With -v and -p daytime (should fail because low port)
|
|
|
|
#if no-root no-windows
|
|
$ KILLQUIETLY=Y
|
|
$ hgserve -p daytime
|
|
abort: cannot start server at 'localhost:13': Permission denied
|
|
abort: child process failed to start
|
|
% errors
|
|
$ KILLQUIETLY=N
|
|
#endif
|
|
|
|
With --prefix foo
|
|
|
|
$ hgserve --prefix foo
|
|
listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
|
|
% errors
|
|
|
|
With --prefix /foo
|
|
|
|
$ hgserve --prefix /foo
|
|
listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
|
|
% errors
|
|
|
|
With --prefix foo/
|
|
|
|
$ hgserve --prefix foo/
|
|
listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
|
|
% errors
|
|
|
|
With --prefix /foo/
|
|
|
|
$ hgserve --prefix /foo/
|
|
listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
|
|
% errors
|
|
|
|
$ cd ..
|