Commit Graph

1590 Commits

Author SHA1 Message Date
Jun Wu
f94ba7eabd chg: downgrade "failed to read channel" from abortmsg to debugmsg
If the server has an uncaught exception, it will exit without being able to
write the channel information. In this case, the client is likely to complain
about "failed to read channel", which looks inconsistent with original hg.
This patch silences the error message and makes uncaught exception behavior
more like original hg. It will help chg to pass test-fileset.t.
2016-03-14 23:28:14 +00:00
Jun Wu
80fd75af3b chgserver: add an explicit "reconnect" instruction to validate
In some rare cases (next patch), we may want validate to do "unlink" without
forcing the client reconnect. This patch addes a new "reconnect" instruction
and makes "unlink" not to reconnect by default.
2016-03-14 13:48:33 +00:00
Gregory Szorc
891be7d008 help: document requirements
We didn't have unified documentation of the various repository
requirements. This patch changes that.
2016-03-12 18:51:07 -08:00
Pulkit Goyal
37b8e88ad9 showstack: use absolute_import 2016-03-13 01:59:18 +05:30
Pulkit Goyal
edde19dc54 contrib: use absolute_import in win32/hgwebdir_wsgi.py 2016-03-14 14:12:13 +05:30
Jun Wu
3303b6aab4 chgserver: handle ParseError during validate
Currently the validate command in chgserver expects config can be loaded
without issues but the config can be broken and chg will print a stacktrace
instead of the parsing error, if a chg server is already running.

This patch adds a handler for ParseError in validate and a new instruction
"exit" to make the client exit without abortmsg. A test is also added to make
sure it will behave as expected.
2016-03-14 12:52:35 +00:00
Yuya Nishihara
f65fcd1944 chg: provide early exception to user
See the previous patch for details. Since the socket will be closed by the
server, handleresponse() will never return:

  Traceback (most recent call last):
    ...
  chg: abort: failed to read channel
2016-03-12 22:17:30 +09:00
Pulkit Goyal
dd1cc9fd24 contrib: make memory.py use absolute_import 2016-03-13 01:32:42 +05:30
Pulkit Goyal
590ab61e6f check-code: use absolute_import and print_function 2016-03-13 01:08:39 +05:30
Jun Wu
e46af71471 chg: silently inherit server exit code
If chgserver aborts during startup, for example, error.ParseError when parsing
a config file, chg client probably just wants to exit with a same exit code
without printing other unrelated text. This patch changes the text "cmdserver
exited with status" from abortmsg to debugmsg and exits with a same exit code.
2016-03-11 02:52:06 +00:00
Pulkit Goyal
6eac74ace4 debugshell: use absolute_import 2016-03-06 03:19:08 +05:30
Yuya Nishihara
ef5269e2e1 test: make check-py3-compat.py ignore empty code more reliably
It couldn't exclude an empty file containing comments. That's why
hgext/__init__.py had been listed in test-check-py3-compat.t before
"hgext: officially turn 'hgext' into a namespace package".
2016-03-11 10:26:58 +09:00
Anton Shestakov
78963e34c6 dockerdeb: add Ubuntu Trusty
One problem reported by lintian is "bad-distribution-in-changes-file unstable"
in changelog, but the current changelog for the official package in Ubuntu also
uses that distribution name (unstable), because they import from Debian. This
certainly doesn't stop the build process.
2016-03-10 23:46:19 +08:00
Jun Wu
10d32ae3a0 chg: do not write pidfile
Current pidfile logic will only keep the pid of the newest server, which is
not very useful if we want to kill all servers, and will become outdated if
the server auto exits after being idle for too long.

Besides, the server-side pidfile writing logic runs before chgserver gets
confighash so it's not trivial to append confighash to pidfile basename like
we did for socket file.

This patch removes --pidfile from the command starting chgserver and switches
to an alternative way (unlink socket file) to stop the server.
2016-03-10 00:19:55 +00:00
Jun Wu
bac9bcbc56 chg: remove manual reload logic
chgserver now validates and reloads configs automatically. Manually reloading
is no longer necessary. Besides, we are deprecating pid files since the server
will periodically check its ownership of the socket file and exit if it does
not own the socket file any longer, which works more reliable than a pid file.
This patch removes the SIGHUP reload logic from both chg server and client.
2016-03-10 00:12:33 +00:00
Jun Wu
c1d58463c7 chg: use --daemon-postexec chdir:/ instead of --cwd /
The chgserver is designed to load repo config from current directory. "--cwd /"
will prevent chgserver from loading repo config and generate a wrong
confighash, which will result in a redirect loop. This patch removes "--cwd /"
and uses "--daemon-postexec chdir:/" instead.
2016-03-09 01:20:57 +00:00
Gregory Szorc
443b14a872 contrib: remove references to 2to3
The custom porting fixers are removed. A comment related to 2to3
has been removed from the import checker.

After this patch, no references to 2to3 remain.
2016-02-27 21:15:16 -08:00
Gregory Szorc
3e662313cc check-code: remove redundant import style check
We have a dedicated tool that checks for import conventions. Remove
a redundant and less powerful check.
2016-02-27 21:14:17 -08:00
Jun Wu
5ce2fd3a4b chg: limit reconnect attempts
Some users may have hg as a wrapper script which sets sensitive environment
variables (like setting up virtualenv). This will make chg redirect forever
because the environment variables are never considered up to date.
This patch adds a limit (10) for reconnect attempts and warn the user with
a possible solution if the limit is exceeded.
2016-03-02 10:42:58 +00:00
Jun Wu
7f85e71c20 chg: use validate to make sure the server is up to date
This patch uses the newly added validate method to make sure the server has
loaded the up-to-date config and extensions. If the server cannot validate
itself, the client will receive instructions and follow them to try to reach
another server that is more likely to validate itself. The instructions can
be a redirect (connect to another server address) and/or an unlink (stops an
out-dated server).
2016-03-06 14:22:37 +00:00
Jun Wu
4d98436906 chg: implement validate in hgclient
This patch implements the corresponding validate method in hgclient.
It will return instruction strings as is without taking any real action.
2016-03-06 14:21:52 +00:00
Pulkit Goyal
bc36832277 hgclient: use absolute_import and print_function 2016-03-06 03:15:45 +05:30
Pulkit Goyal
df7262ef1e fixpax: use absolute_import and print_function 2016-03-06 03:10:17 +05:30
Pulkit Goyal
2f8a8e257d debugcmdserver: use absolute_import and print_function 2016-03-06 03:06:09 +05:30
Pulkit Goyal
72963156f8 check-config: use absolute_import and print_function 2016-03-06 03:01:46 +05:30
Pulkit Goyal
7790f458a6 casesmash: use absolute_import 2016-03-06 02:25:50 +05:30
timeless
b31d4af380 import-checker: report local with stdlib late warning
Without this, developers have to figure it out on their own
2016-03-02 15:38:54 +00:00
Jun Wu
677d0dce4e chg: drop progress.assume-tty config
It was necessary to go through progress.uisetup() to set up the progressui
wrapper. Since the progress extension has got into the core, progress.assume-tty
is no longer necessary.
2016-02-29 11:43:25 +00:00
Jun Wu
93e167796f chg: detect chg started by chg
Sometimes people may create a symbol link from hg to chg, or write a wrapper
script named hg calling chg. Without $HG and $CHGHG set, this will lead to
chg executes itself causing deadlock. The user will notice chg hangs for some
time and aborts with a timed out message, without knowing the root cause and
how to solve it.

This patch sets a dummy environment variable before executing hg to detect
this situation, and print a fatal message with some possible solutions.

CHGINTERNALMARK is set by chg client to detect the situation that chg is
started by chg. It is temporary and should be dropped to avoid possible
side effects.
2016-02-26 14:13:12 +00:00
Jun Wu
2aca7b6e3b chg: fallback to original hg for some unsupported commands or flags
There are some known unsupported commands or flags for chg, such as hg serve -d
and hg foo --time. This patch detects these situations and transparently fall
back to the original hg. So the users won't bother remembering what chg can and
cannot do by themselves.

The current detection is not 100% accurate since we do not have an equivalent
command line parser in C. But it tries not to cause false positives that
prevents people from using chg for legit cases. In the future we may want to
implement a more accurate "unsupported" check server-side.
2016-02-26 14:17:59 +00:00
Jun Wu
c679d7cde1 chg: extract gethgcmd logic to a function
gethgcmd is to get original hg (not chg) binary name. This patch extracts
the logic from execcmdserver to make it available for the following patch.
2016-02-24 14:24:00 +00:00
Jun Wu
b3225df58f check-code: allow old style class with special comments
The following chgserver change will use an old style class to comply with
SocketServer's code style. This patch made it possible to pass check-code.
2016-02-24 18:42:14 +00:00
Jun Wu
8fd39d304f chg: hold a lock file before connected to server
This is a part of the one server per config series. In multiple-server setup,
multiple clients may try to start different servers (on demand) at the same
time. The old lock will not guarantee a client to connect to the server it
just started, and is not crash friendly.

This patch addressed above issues by using flock and does not release the lock
until the client actually connects to the server or times out.
2016-02-16 11:08:52 +00:00
Jun Wu
f5397047b4 serve: rename --daemon-pipefds to --daemon-postexec (BC)
Initially we use --daemon-pipefds to pass file descriptors for synchronization.
Later, in order to support Windows, --daemon-pipefds is changed to accept a
file path to unlink instead. The name is outdated since then.

chg client is designed to use flock, which will be held before starting a
server and until the client actually connects to the server it started. The
unlink synchronization approach is not so helpful in this case.

To address the issues, this patch renames pipefds to postexec and the following
patch will allow the value of --daemon-postexec to be things like
'unlink:/path/to/file' or 'none'.
2016-02-22 16:59:08 +00:00
Sune Foldager
5da16ec447 hgwebdir_wsgi: update script and expand help
I've updated the script to reflect changes in Mercurial and to include a much
more through installation guide with configuration examples and details on how
to configure IIS. I've used the script to set up a working server from scratch.
2016-02-19 17:50:28 +01:00
Jun Wu
9b4b8246df chg: pass sensitive command line flags to server
We are going to make chgserver load repo config, remember what it is, and
load repo config again to detect config change. This is the first step that
passes config, repo, cwd options to server. Traceback is passed as well to
cover errors before hitting chgserver.runcommand.
2016-02-17 15:00:47 +00:00
Jun Wu
b5898933a2 chg: use mallocx and reallocx in hgclient
This patch simplifies the code a bit, and reduces the binary size a little.
2016-02-17 15:08:09 +00:00
Jun Wu
a5c55dc9e7 chg: add utility functions mallocx, reallocx
They are like malloc and realloc but will abort the program on error.
A lot of places use {m,re}alloc and check their results. This patch
can simplify them.
2016-02-17 14:51:38 +00:00
Jun Wu
4da8e59d38 chg: forward umask from client to server
This is necessary to make chg test pass on test-inherit-mode.t.
2016-02-15 14:35:26 +00:00
Yuya Nishihara
cf8afe35a3 chg: forward job control signals to worker process (issue5051)
This is necessary to suspend/resume long pulls, interactive curses session,
etc.

The implementation is based on emacsclient, but our version doesn't test if
chg process is foreground or not before propagating SIGCONT. This is because
chg isn't always an interactive session. If we copy the SIGTTIN/SIGTTOU
emulation from emacsclient, non-interactive session can't be moved to a
background job.

  $ chg pull
  ^Z
  suspended
  $ bg %1
  [1] continued
  [1] suspended (tty input)  # wrong

https://github.com/emacs-mirror/emacs/blob/0e96320/lib-src/emacsclient.c#L1094
2016-01-19 22:31:59 +09:00
Yuya Nishihara
31584a86d7 chg: verify return value of sigaction() and sigemptyset()
They should never fail, but it couldn't hurt to be a paranoid.
2016-01-29 22:52:16 +09:00
Yuya Nishihara
f80facd9d0 chg: initialize sigaction fields more reliably
It seems calling memset() and sigemptyset() is common pattern to initialize
sigaction. And strictly speaking, sigset_t must be initialized by sigemptyset()
or sigfillset(). I saw git and uwsgi do that way, so let's follow them.
2016-01-29 22:42:22 +09:00
Durham Goode
e072959d9e revsetbenchmark: handle exception case
If the revset being benchmarked has an exception, the handling code was
encountering an error because the exception did not always have an "output"
attribute (I think it's a python 2.7 thing).
2016-02-10 12:39:25 -08:00
Yuya Nishihara
53de7956c0 chg: use in-tree hg executable to start server for testing 2016-01-03 12:45:32 +09:00
Yuya Nishihara
58036583d5 chg: import frontend sources
These files are copied from
https://bitbucket.org/yuja/chg/ -r f897faa79687
2016-01-03 12:39:27 +09:00
FUJIWARA Katsunori
5e089ee084 check-code: add rule to detect usage of external diff via extdiff
This rule detects "hg extdiff" invocation without -p/--program and
-o/--option.

This patch specifies "-p diff" explicitly in test-extdiff.t to avoid
false positive matching.
2016-02-11 02:15:45 +09:00
FUJIWARA Katsunori
34295148ed check-code: examine magic pattern matching against contents of a file
Before this patch, check-code examines "magic" pattern (e.g.
'^#!.*python') matching against not contents of a file, but name of
it.

This unintentionally omits code checking against Python source file,
of which filename doesn't end with "*.py" or "*.cgi", even though
contents of it starts with "#!/bin/python" or so.

In this change, 'pre' refers contents of file 'f'.
2016-02-10 22:44:29 +09:00
FUJIWARA Katsunori
0e48f36a63 misc: use modern exception syntax
This is fixing for 'legacy exception syntax; use "as" instead of ","'
check-code rule.

check-code has overlooked these, because files aren't recognized as
one to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:29 +09:00
FUJIWARA Katsunori
05a600c8af hg-ssh: parenthesize non-translated message
This is fixing for 'missing _() in ui message (use () to hide
false-positives)' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:28 +09:00
FUJIWARA Katsunori
ae585f8a5f check-commit: omit whitespace
This is fixing for 'no whitespace around = for named parameters'
check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:28 +09:00