Commit Graph

32448 Commits

Author SHA1 Message Date
Gregory Szorc
efbb740737 revlog: skeleton support for version 2 revlogs
There are a number of improvements we want to make to revlogs
that will require a new version - version 2. It is unclear what the
full set of improvements will be or when we'll be done with them.
What I do know is that the process will likely take longer than a
single release, will require input from various stakeholders to
evaluate changes, and will have many contentious debates and
bikeshedding.

It is unrealistic to develop revlog version 2 up front: there
are just too many uncertainties that we won't know until things
are implemented and experiments are run. Some changes will also
be invasive and prone to bit rot, so sitting on dozens of patches
is not practical.

This commit introduces skeleton support for version 2 revlogs in
a way that is flexible and not bound by backwards compatibility
concerns.

An experimental repo requirement for denoting revlog v2 has been
added. The requirement string has a sub-version component to it.
This will allow us to declare multiple requirements in the course
of developing revlog v2. Whenever we change the in-development
revlog v2 format, we can tweak the string, creating a new
requirement and locking out old clients. This will allow us to
make as many backwards incompatible changes and experiments to
revlog v2 as we want. In other words, we can land code and make
meaningful progress towards revlog v2 while still maintaining
extreme format flexibility up until the point we freeze the
format and remove the experimental labels.

To enable the new repo requirement, you must supply an experimental
and undocumented config option. But not just any boolean flag
will do: you need to explicitly use a value that no sane person
should ever type. This is an additional guard against enabling
revlog v2 on an installation it shouldn't be enabled on. The
specific scenario I'm trying to prevent is say a user with a
4.4 client with a frozen format enabling the option but then
downgrading to 4.3 and accidentally creating repos with an
outdated and unsupported repo format. Requiring a "challenge"
string should prevent this.

Because the format is not yet finalized and I don't want to take
any chances, revlog v2's version is currently 0xDEAD. I figure
squatting on a value we're likely never to use as an actual revlog
version to mean "internal testing only" is acceptable. And
"dead" is easily recognized as something meaningful.

There is a bunch of cleanup that is needed before work on revlog
v2 begins in earnest. I plan on doing that work once this patch
is accepted and we're comfortable with the idea of starting down
this path.
2017-05-19 20:29:11 -07:00
Danek Duvall
e90fa83ca6 check-code: ban grep's context flags (-A/-B/-C) since they're not on Solaris 2017-06-06 08:58:27 -07:00
David Demelier
cdeab8bd8c patchbomb: avoid -r and -B options at the same time 2017-06-06 08:52:51 +02:00
Danek Duvall
9231e311ce debugbundle: add --part-type flag to emit only named part types
This removes the need in the tests for grep -A, which is not supported on
Solaris.
2017-06-05 16:19:41 -07:00
Matt Harbison
c1192b9b13 test-obsolete-bundle-strip: add globs for Windows 2017-06-05 20:37:45 -04:00
Jun Wu
7dac9c0bba obsstore: move header encoding to a separate function
This patch moves encodeheader from encodemarkers. So markers and header
could be encoded separately.
2017-06-04 00:38:11 -07:00
Jun Wu
ed047705d9 obsstore: move _version to a propertycache
This makes sure _version is correct even if "_all" is not called.
2017-06-04 08:49:15 -07:00
Jun Wu
3835d8bd52 obsstore: separate marker parsing from obsstore reading
This allows us to get raw obsstore content without parsing any markers.
Reading obsstore is much cheaper than parsing markers.
2017-06-02 20:38:01 -07:00
Jun Wu
4c6d8665c7 obsstore: move marker version reading to a separate function
This allows us to read marker version without reading markers.
2017-06-02 19:34:56 -07:00
Jun Wu
d9a63e5be4 obsstore: minor optimization for the obsolete revset
Use local variables in a loop.
2017-06-02 19:32:27 -07:00
Yuya Nishihara
02355fbadc dispatch: do not close stdout and stderr, just flush() instead
Since 348863ccec7e "util: always force line buffered stdout when stdout is
a tty", we have two file objects attached to the same STDOUT_FILENO. If one
is closed, the underlying file descriptor is also closed, and writing to
the other file object would crash the Python interpreter in a hard way, at
least on Windows.

So, it seems safer to not close the standard streams. This also matches
the behavior of the default sys.stdout/stderr.close(), which never close
the FILE* streams in C layer.

https://hg.python.org/cpython/file/v2.7.13/Python/sysmodule.c#l1401
2017-04-23 00:31:29 +09:00
Yuya Nishihara
74b8d80dfc windows: do not close stdout on flush() failure
It's been there since 84af5a079c7d (2007-02-19), but seems wrong since any
I/O operations to a closed file would raise ValueError, not IOError. We should
keep the file object open even if the underlying file descriptor is half dead.
2017-06-05 23:36:35 +09:00
Yuya Nishihara
2a6bbffb41 test-obsolete-bundle-strip: do not include \n in filename (issue5586) 2017-06-05 23:23:03 +09:00
Yuya Nishihara
685172007c revlog: add support for partial matching of wdir node id
The idea is simple. If the given node id prefix is 'ff...f', add +1 to the
number of matches (e.g. ambiguous if partial + maybewdir > 1).

This patch also fixes id() revset and shortest() template since _partialmatch()
can raise WdirUnsupported exception.
2016-08-19 18:26:04 +09:00
Yuya Nishihara
09869bc4c0 revset: add support for branch(wdir()) and wdir() & branch() 2016-08-20 18:15:19 +09:00
Siddharth Agarwal
b1a08c7ef4 dirstate: add docstring for invalidate
This always confuses me, and we already have a docstring on
localrepo.invalidatedirstate.
2017-06-04 16:08:50 -07:00
Martin von Zweigbergk
8a01c6200d tests: simplify and clarify test-obsolete-bundle-strip.t a little 2017-06-02 23:05:03 -07:00
Martin von Zweigbergk
14d7cb9694 tests: add missing parens in test-obsolete-bundle-strip.t
The "(not ${revs})" was missing parens around ${revs}, so when revs
was "A + B", it became "(not A + B)" when actually "(not (A + B))" was
intended. Fixing that leads to some more testing of strip.

Similarly, the parens were missing in "${revs}::", making it "A + B::"
instead of "(A + B)::". Thanks to Yuya for noticing this part. This
did not affect any existing tests.
2017-06-02 23:29:20 -07:00
Matt Harbison
eac709d9da test-clonebundles: conditionalize output for Windows
This was the fallout from 87957da1ca0b (on stable).  Now that individual lines
can be conditionalized, it seems better to be explicit, rather than mash all of
this into one regex.  "getaddrinfo failed" was added in efd8ac31a7e2 to support
Windows.
2017-06-04 20:37:32 -04:00
Matt Harbison
d898f4f6e4 tests: adjust recent output changes for Windows 2017-06-04 20:11:59 -04:00
Matt Harbison
66cdc3e9cb killdaemons: close pid file before killing processes
With #serve enabled on Windows, I was getting occasional stacktraces like this:

  Errored test-hgweb-json.t: Traceback (most recent call last):
    File "./run-tests.py", line 724, in run
      self.tearDown()
    File "./run-tests.py", line 805, in tearDown
      killdaemons(entry)
    File "./run-tests.py", line 540, in killdaemons
      logfn=vlog)
    File "...\tests\killdaemons.py", line 94, in killdaemons
      os.unlink(pidfile)
  WindowsError: [Error 32] The process cannot access the file because it is
     being used by another process: '...\\hgtests.zmpqj3\\child80\\daemon.pids'

Adrian suggested using util.posixfile, which works.  However, the 'mercurial'
package isn't in sys.path when invoking run-tests.py, and it isn't clear that
hacking[1] it in is a good thing (especially for test-run-tests.t, which uses an
installation in a temp folder).

I tried using ProcessMonitor to figure out what the other process is, but that
monitoring slows things down to such a degree that the issue doesn't occur.  I
was ready to blame the virus scanner, but it happens without that too.

Looking at the code, I don't see anything that would have the pid file open.
But I was able to get through about 20 full test runs without an issue with this
minor change, whereas before it was pretty certain to hit this at least once in
two or three runs.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097907.html
2017-05-22 21:45:02 -04:00
Matt Harbison
482ee81f5d win32: drop a py26 daemonizing hack
I'm not sure what the referenced hang specifically was, but the whole test suite
(with #serve) still runs on python 2.7.13.  Aside from no longer prepending
"cmd.exe /c", this backs out a2700a095510.

I'm trying to track down a rare failure of TerminateProcess() with an access
error, and I've seen random extra python processes hanging around after running
tests sometimes, so this might help.

However, c9d78bd0980d forces this change.  Since the pid object is no longer
converted to a string, the cmd.exe pid was being saved instead of the hg pid,
and none of the daemons were being killed.
2017-05-21 18:58:51 -04:00
Pierre-Yves David
92378aada1 checkheads: simplify the code around obsolescence post-processing
The 'discardedheads' return become unused and the relationship between newheads
and newhs can be clarified. Our next goal here is to be able to extract the
_postprocessobsolete call outside of the loop.

We keep returning the 'discardedheads' because we'll start using it again soon
in this series.
2017-05-29 05:23:30 +02:00
Pierre-Yves David
8ab44eb083 checkheads: drop now unused filtering of 'unsyncedheads'
Now that unsynced heads are no longer in the function inputs or returns, we can
simplify the code a bit.
2017-05-29 05:21:38 +02:00
Pierre-Yves David
12e4c6dacb checkheads: clarify that we no longer touch the head unknown locally
Since b5554fb97d46, heads unknown locally no longer get any post processing
from obsolescence markers. We clarify this fact by only feeding the list of
locally known new heads to the function. This simplification of the input will
help moving that post-processing earlier in the function.
2017-05-29 05:20:09 +02:00
Pierre-Yves David
25c3e1db72 headssummary: ensure all returned lists are sorted
This is a simple step that will help to keep a stable output in coming
refactoring.
2017-05-29 05:33:59 +02:00
Pierre-Yves David
20859d5371 discovery: also use lists for the returns of '_oldheadssummary'
The '_headssummary' function is documenting and using list objects in its
return.  We now use them in _oldheadssummary too for consistency. This does not
affect any usages of these values.
2017-05-29 05:37:19 +02:00
Pierre-Yves David
b4a185b2cf test: add a push race case where the updated head is obsoleted
This is the mirror of the previously added case. We check the case where the
racing-push obsoletes a head while the raced-push updates that same head.
2017-05-29 05:53:51 +02:00
Pierre-Yves David
da1588880d test: add a push race case where obsoleted head is updated
We check the case where the raced-push obsoletes a head while the racing-push
updates that same head.
2017-05-29 05:53:24 +02:00
Kyle Lippincott
91ebfaffc5 keepalive: set buffering=True to do more efficient reads of headers
Support for buffering was added to python in d09d6fe31b61, first released with
python2.7.  Without this, the entirety of the response headers is read
byte-by-byte (it does more efficient reads when it gets to the non-header part
of the response).
2017-06-02 14:08:26 -07:00
Kyle Lippincott
01d7c04db6 keepalive: pass the correct arguments to HTTPResponse
python2.7's httplib.HTTPResponse takes the arguments in the following order:
    sock, debuglevel, strict, method, buffering

This was previously passing them in as positional and skipped strict, so we set
strict=method.  I'm explicitly setting strict=True now to preserve the previous
behavior that has been there since this file was created.
2017-06-01 18:23:20 -07:00
Matt Harbison
fd4c90025c help: update the color documentation for Windows 10 ANSI support
It looks like only the initial release of Windows 10 lacked support for this
functionality. [1][2]  Since that build is no longer supported, I didn't bother
getting very specific, to keep the help text less cluttered.

[1] https://github.com/symfony/symfony/issues/17499#issuecomment-243481052
[2] https://en.wikipedia.org/wiki/Windows_10_version_history
2017-05-22 22:32:59 -04:00
Matt Harbison
2671b24110 color: enable ANSI support on Windows 10
This will display color if "color.mode=ansi", and default to 'ansi' if the mode
is set to 'auto'.  The 'debugcolor' command also reflects this policy.
Previously, "color.mode=ansi" on Windows printed jibberish around the normal
text.  Using ANSI color is better, as it avoids the normal loss of color when
the default pager is enabled on Windows.  See also issue5570.

When the underlying function fails (e.g. when run on older Windows), 'auto'
still falls back to 'win32'.  Apparently, Microsoft originally had this feature
turned on by default, and then made it opt-in[1].  Therefore, not enabling it
unconditionally seems safer.  Instead, only do it after processing the existing
check for support in a Unix-like environment.

[1] https://github.com/symfony/symfony/issues/17499#issuecomment-243481052
2017-05-22 22:20:38 -04:00
Matt Harbison
8487f39227 win32: add a method to enable ANSI color code processing on Windows 10
SetConsoleMode() fails with an invalid parameter error if given this option
prior to Windows 10, so indicate that to the caller instead of doing explicit
version checks.
2017-05-22 22:00:56 -04:00
Kevin Bullock
b00d7583d8 merge with stable 2017-06-04 08:57:37 -05:00
Kevin Bullock
37a82e2a00 Added signature for changeset 28e02e510eac 2017-06-04 08:16:37 -05:00
Yuya Nishihara
d2ef5f6afb export: map wctx.node() to 'ff...' node id (issue5438) 2017-06-03 19:17:19 +09:00
Yuya Nishihara
00d9212898 revset: add support for integer and hex wdir identifiers
As I said before, partial 'ff...' hash isn't supported yet.
2017-06-03 20:39:33 +09:00
Siddharth Agarwal
41dae969eb status: don't crash if a lookup file disappears
This can happen if another process (even another hg process!) comes along and
removes the file at that time.

This partly resolves issue5584, but not completely -- a bogus dirstate update
can still happen. However, the full fix is too involved for stable.
2017-06-02 22:27:52 -07:00
Xavier Lepaul
a75e0dc064 help: clarify the choice of pager
This follows the change made in 4fba4efc2e2e to use environment variables
between system and user configuration.
2017-06-02 10:44:40 +02:00
Wagner Bruna
66a53a8e31 i18n-pt_BR: fix syntax error on translation 2017-06-02 20:50:46 -03:00
Wagner Bruna
2d3ddc9080 i18n-pt_BR: synchronized with 98315436ecec 2017-06-01 20:06:02 -03:00
Kevin Bullock
f750e29306 merge with i18n 2017-06-01 12:24:16 -05:00
Wagner Bruna
6d75e48bdf i18n-pt_BR: synchronized with b0ea8556414f 2017-05-31 20:42:58 -03:00
Rodrigo Damazio Bovendorp
3a507184d3 debian: add less as a build dependency
For builds that run on hermetic environments, it's possible that the "less"
package is not installed by default, yet it's needed for tests to pass after
revision ca1519568a93 (which sets less as the fallback pager).
2017-05-26 19:33:20 -07:00
Kyle Lippincott
8175ca534f zsh_completion: install as _hg not hg
The contrib/zsh_completion file itself says to name it _hg.

With a name like `hg`, if the user has a line like `autoload ${^fpath}/*(N-.:t)`
in their zshrc, it will create a shell function named `hg` that will hide the
actual hg command and make hg unusable.

Separately from that though, the underscore prefix makes it actually work. The
zsh man page states:

    The convention for autoloaded functions used in completion is that they
    start with an underscore

This does not seem to just be a "convention", though. With the ill-advised line
removed from my zshrc and the file named
`/usr/local/share/zsh/site-functions/hg` (without the underscore), these
completions did not seem to get loaded and the ones from the zsh installation
were loaded instead.  If I renamed them to be
`/usr/local/share/zsh/site-functions/_hg`, however, they were loaded.

I manually tested the above statement by starting a new zsh instance with the
file in `/usr/local/share/zsh/site-functions` with the following names:
- As `hg`, `which _hg_labels` did not show anything
- As `_hg`, `which _hg_labels` showed the expected function.
2017-05-26 13:24:07 -07:00
Augie Fackler
8e4d9f1f1d osx: override default exclude filter for pkgbuild
To quote `man 1 pkgbuild`:

     --filter filter-expression
                 By default, --root will include the entire contents of the
                 given root-path in the package payload, except for any .svn
                 or CVS directories, and any .DS_Store files. You can override
                 these default filters by specifying one or more --filter
                 options. Each filter-expression is an re_format(7)
                 ``extended'' expression: any path in the root which matches
                 any of the given expressions will be excluded from the pack-
                 age payload. (Note that specifying even one --filter inhibits
                 the default filters, so you must respecify the default fil-
                 ters if you still want them to be used.)

It turns out the default filter these days *also* includes .git and
.hg. Notice how that filter expression is a regular expression?  That
(presumably unintentionally) prevents a file named "chg" or "_hg" from
getting included in the distribution. Many many thanks to spectral@
for trying to include a _hg file which led us to figure this bug out.

Bug filed with Apple for this as rdar://problem/32437369, mentioning
both the gap in documentation and the wrong defaults.
2017-05-26 20:03:05 -04:00
Wagner Bruna
8d9192e033 bugzilla: fix typo in help text 2017-05-31 19:24:00 -03:00
Wagner Bruna
d0831e7086 help: fix typos 2017-05-31 19:23:23 -03:00
FUJIWARA Katsunori
80da112aee win32mbcs: avoid unintentional failure at colorization
Since 1d07d9da84a0, pycompat.bytestr() wrapped by win32mbcs returns
unicode object, if an argument is not byte-str object. And this causes
unexpected failure at colorization.

pycompat.bytestr() is used to convert from color effect "int" value to
byte-str object in color module. Wrapped pycompat.bytestr() returns
unicode object for such "int" value, because it isn't byte-str.

If this returned unicode object is used to colorize non-ASCII byte-str
in cases below, UnicodeDecodeError is raised at an operation between
them.

  - colorization uses "ansi" color mode, or

    Even though this isn't default on Windows, user might use this
    color mode for third party pager.

  - ui.write() is buffered with labeled=True

    Buffering causes "ansi" color mode internally, regardless of
    actual color mode. With "win32" color mode, extra escape sequences
    are omitted at writing data out.

    For example, with "win32" color mode, "hg status" doesn't fail for
    non-ASCII filenames, but "hg log" does for non-ASCII text, because
    the latter implies buffered formatter.

There are many "color effect" value lines in color.py, and making them
byte-str objects isn't suitable for fixing on stable. In addition to
it, pycompat.bytestr will be used to get byte-str object from any
types other than int, too.

To resolve this issue, this patch does:

  - replace pycompat.bytestr in checkwinfilename() with newly added
    hook point util._filenamebytestr, and

  - make win32mbcs reverse-wrap util._filenamebytestr
    (this is a replacement of 1d07d9da84a0)

This patch does two things above at same time, because separately
applying the former change adds broken revision (from point of view of
win32mbcs) to stable branch.

"_" prefix is added to "filenamebytestr", because it is win32mbcs
specific hook point.
2017-05-31 23:44:33 +09:00