Commit Graph

11196 Commits

Author SHA1 Message Date
Pierre-Yves David
a04ebd710a util: support None size in chunkbuffer.read()
When no size is provided, read the whole buffer. This aligns with the usual
behavior of `read()` in python.
2014-04-10 22:10:26 -07:00
Pierre-Yves David
1726c7ed72 bundle2: move unpackheader closure into the class
With the same argument as the other one, we move this closure into the
`unbundlepart` class.
2014-04-11 15:47:38 -04:00
Pierre-Yves David
a5bcb69da6 bundle2: move the fromheader closure into the class itself
The class is now directly related to this header data. We can sanely move it on
the class.

I do not like closures very much...
2014-04-11 15:46:09 -04:00
Pierre-Yves David
0819f89a04 bundle2: add an unbundle part responsible from unbundling part
We have a new unbundle class and it is now responsible from extracting its own
data. The top level bundler only extracts the header (to detect an end of stream
marker) then leaves everything else to the `unbundlepart` class. The ultimate
goal is to have `unbundlepart` responsible for lazily extracting its payload.

This is mostly code movement.
2014-04-11 15:43:16 -04:00
Pierre-Yves David
10657d6382 bundle2: extract stream/unpack logic in an unpackermixin
The coming `unbundlepart` will need the same kind of method than `unbundle20`
for unpacking data from the stream. We extract them into a mixin class before
the creation of `unbundlepart`.
2014-04-11 15:19:54 -04:00
Pierre-Yves David
9498b02a99 exchange: restore truncated comment
The old version of this comment appeared to have been trunca
2014-04-13 12:21:09 -04:00
Takumi IINO
108a15e83e grep: highlight all matched words
"hg grep" highlights first matched word only.
This behavior is different from GNU grep.

This patch makes highlight all matched words.
2014-03-31 01:00:05 +09:00
Pierre-Yves David
e5b4ced868 bundle2: rename part to bundlepart
We are going to introduce an `unbundlepart` dedicated to reading bundle. So we
need to rename the one used to create bundle. Even if dedicated to creation, this
is still used for unbundling until we get the new class.
2014-04-11 07:36:14 -07:00
Pierre-Yves David
ef4a1b021a bundle2: comment to clarify why the handler call is where it is
The reason why it is here is not obvious. I'm the one who wrote it there in the
first place and almost moved it 2 weeks later.
2014-04-11 16:43:01 -04:00
Pierre-Yves David
f1960c11a4 bundle2: use chunkbuffer for exchange.getbundle
We can use `util.chunkbuffer` instead.
2014-04-12 00:53:15 -04:00
Pierre-Yves David
a90efe54ad bundle2: lazily generate the changegroup part in exchange.getbundle
Now that we have lazy generation of parts, let's use it.
2014-04-12 14:56:55 -04:00
Pierre-Yves David
be93303ad1 bundle2: support chunk iterator as part data
When the `part.data` attribute is an iterator, we assume it is an iterator of
chunks and use it.

We use a chunkbuffer to yield chunks of 4096 bytes.

The tests are updated to use this feature.
2014-04-11 08:04:16 -07:00
Pierre-Yves David
2cfe67ddd2 bundle2: extract a _payloadchunks method for part
We are preparing streaming capability for part. So the generation of payload
chunk will becomes more complex. We extract this part in its own function before
any changes.
2014-04-10 12:33:20 -07:00
Pierre-Yves David
a8e05fc7b8 changegroup: move chunk extraction into a getchunks method of unbundle10
This code used to be in `writebundle` only. We needs to make it more broadly
available for bundle2. The "changegroup" bundle2 part has to retrieve the
binary content of changegroup stream. We moved the chunks retrieving code into
the `unbundle10` object directly and the `writebundle` code is now using that.

This split is useful for bundle2 purpose, we want to be able to easily stream
changegroup content in a part.

To keep thing simples, we kept compression out of the new methods. If it make
more sense in the future, compression may get included in this function too.
2014-04-10 13:19:00 -07:00
Pierre-Yves David
c4bb78d90c bundle2: use reply part to return result of addchangegroup
We now have an official way to return the result of addchangegroup. The tests are
updated to check that the return bundle is properly created. It will be used
when push is bundle2 enabled.
2014-03-25 15:05:11 -07:00
Pierre-Yves David
e46e61d8b1 bundle2: produce a bundle2 reply
We do not know yet what kind of data future features and extensions will need to
exchange. To handle that, bundle2 allows to send arbitrary content to the
server. As a consequence, we need to be able to reply arbitrary content to the
client. And, we can use bundle2 to transmit those arbitrary data.

When a client will push a bundle2 to the server, the server will reply with a
bundle2 itself.

This changeset installs the first stone of this logic and test it.
2014-04-04 14:24:11 -07:00
Pierre-Yves David
90cfb42a5c bundle2: add reply awareness to unbundlerecords
We need an efficient way to handle bundle replies. The unbundle records class is
extended to carry such data.
2014-04-11 08:24:59 -07:00
Pierre-Yves David
311fe283fd bundle2: add an integer id to part
For sending response to a pushed bundle, we need to link reply parts to request
part. We introduce a part id for this purpose. This is a 32 bit unique
integer stored in the header.
2014-04-01 00:07:17 -07:00
Mads Kiilerich
b117005b7c revlog: use context ancestor instead of changelog ancestor
We want to move in this direction.
2014-04-07 23:17:51 +02:00
Mads Kiilerich
c55887b864 copies: guard debug section with ui.debugflag 2014-02-25 20:31:53 +01:00
Mads Kiilerich
210347bb4f copies: remove _checkcopies wrapper - it does no good
mergecopies might be doomed but it is not dead yet ...
2014-02-25 20:31:51 +01:00
Mads Kiilerich
861f191408 commit: use revlog.commonancestors instead of .ancestor
This do probably not make any real difference but is slightly more correct and
we would like to get rid of flog.ancestor.
2014-04-07 23:17:51 +02:00
Mads Kiilerich
723c536d44 backout: don't limit heritage check to a single ancestor
This do probably not make any real difference but is slightly more correct and
we would like to get rid of changelog.ancestor.
2014-04-07 23:17:51 +02:00
Mads Kiilerich
421298c7fe ancestor: remove unused genericancestor 2014-03-20 01:35:07 +01:00
Mads Kiilerich
c951e7f8b6 context: remove unused filectx.ancestor 2014-04-07 23:17:48 +02:00
FUJIWARA Katsunori
a40858d014 bundlerepo: treat temporarily extracted bundle file via vfs 2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
4956966646 vfs: add "mkstemp()" 2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
1a5bc49ece repair: make "strip()" treat bundle files via vfs
This patch makes "repair.strip()" treat bundle files via vfs.

This patch also avoids applying "vfs.join()" on the value returned by
"changegroup.writebundle()", to get relative path from "_bundle()".
2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
535cdba175 changegroup: add "vfs" argument to "readbundle()" to pass relative filename 2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
e26cca0dd1 repair: make paths in "_bundle()" relative to ".hg"
This patch makes paths below in "_bundle()" relative to ".hg":

  - backup directory ("strip-backup"), and
  - bundle file under backup directory

"vfs" is passed to "changegroup.writebundle()" to use relative path
directly.

This patch applies "vfs.join()" on the value returned by "_bundle()",
because the caller expect it to return absolute path.

This will be changed by succeeding patch changing the caller side.
2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
01e064edbb changegroup: add "vfs" argument to "writebundle()" for relative access via vfs
Before this patch, filename specified to "changegroup.writebundle()"
should be absolute one.

In some cases, they should be relative to repository root, store and
so on (backup before strip, for example).

This patch adds "vfs" argument to "writebundle()", and makes
"writebundle()" open (and unlink) "filename" via vfs for relative
access, if both filename and vfs are specified.
2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
836e13a2f2 localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"
Before this patch, "localrepository.undofiles()" returns list of
absolute filename of undo files.

This patch makes it return list of tuples "(vfs, relative filename)"
to access undo files via vfs.

This patch also changes "repair.strip()", which is the only user of
"localrepository.undofiles()".
2014-03-09 01:03:28 +09:00
Matt Mackall
48b15e4e36 exchange: fix pyflakes import complaint 2014-04-11 17:20:15 -04:00
Wei, Elson
9d83254247 hgweb: override the charset attribute in the http request
The default http request character set is UTF-8. If the message is not encoded
in UTF-8, such as big5, it cannot be shown correctly. The 'charset' is
overridden by the root document's, such that the user can select the proper
encoding in the browser.
2014-04-10 15:12:12 +08:00
Matt Mackall
34b49de789 diff: use second filename for --stat reporting on git patches (issue4221) 2014-04-11 16:38:55 -04:00
Pierre-Yves David
456f93543d exchange: drop useless line break 2014-04-11 13:43:41 -04:00
Matt Mackall
c73261da0c subrepo: check return code for git push (issue4223) 2014-04-11 15:38:18 -04:00
Pierre-Yves David
69ae281a65 localrepo: add unbundle support
Localrepo now supports the unbundle method of pushing changegroups. We
plan to use the unbundle call for bundle2 so it is important that all
peers supports it. The `peer.unbundle` and `peer.addchangegroup` code
path have small difference so cause some test output changes. None of those
changes seems problematic.
2014-04-04 17:50:44 -07:00
Pierre-Yves David
9c50815f66 unbundle: extract the core logic in another function
The `exchange` module now contains an `unbundle` function that holds the core
unbundle logic. The wire protocol keeps its own unbundle function. It enforces
wireprotocol-specific logic and then calls the extracted function.

This aims at implementing unbundle for localrepo.
2014-04-04 17:28:59 -07:00
Pierre-Yves David
f6ff0fbdf6 unbundle: extract checkheads in its own function
We are going to refactor the unbundle function to have it working on
a local repository too. Having this function extracted will ease the process.

In the case of non-matching heads, the function now directly raises an
exception. The top level of the function is catching it.
2014-04-04 17:15:25 -07:00
Pierre-Yves David
fddf556ac8 phase: apply publishing enforcement for "serve" source
When a changegroup is added by a push on a publishing server, we ensure they
are added as public. This is used to enforce publishing on server when the
client is not aware of phases. It also prevents race conditions where a reader
could see the changesets as draft before they get turned public by the client.
Finally, this save rounds trip as the client does not need additional request to
turn them public.

However, this logic was only enforced when the changegroup was from a "push"
source. And "push" is used for local pushes only. Wireprotocol push uses "serve"
as source since Mercurial 1.9. We now enforce this logic for both "push" and
"serve" sources.

One could note that this logic was mainly useful during wireprotocol exchanges.
So this code is finally put into good use, 9 versions after its introduction.
2014-04-07 18:10:50 -07:00
Matt Mackall
4610a4e481 merge with stable 2014-04-10 12:41:39 -04:00
Matt Mackall
b154d8d029 revlog: deal with chunk ranges over 2G on Windows (issue4215)
Python uses a C long (32 bits on Windows 64) rather than an ssize_t in
read(), and thus has a 2G size limit. Work around this by falling back
to reading one chunk at a time on overflow. This approximately doubles
our headroom until we run back into the size limit on single reads.
2014-04-07 14:18:10 -05:00
Sean Farley
90ccd3ca5f changegroup: remove unused variable caught by pyflakes 2014-04-03 20:29:03 -05:00
Yuya Nishihara
370defd044 backout: correct commit status of no changes made (BC) (issue4190)
If backout generated no changes to commit, it showed wrong status, "changeset
<target> backs out changeset <target>", and raised TypeError with -v option.

This changes the return code to 1, which is the same as "hg commit" and
"hg rebase".
2014-03-08 18:52:16 +09:00
Yuya Nishihara
d616c909d1 backout: document return code of merge conflict 2014-03-08 18:41:56 +09:00
FUJIWARA Katsunori
0eed53de6c i18n: fix "% inside _()" problems
Before this patch, "contrib/check-code.py" can't detect these
problems, because the regexp pattern to detect "% inside _()" doesn't
suppose the case that format string consists of multiple string
components concatenated implicitly or explicitly,

This patch does below for that regexp pattern to detect "% inside _()"
problems in such case.

  - put "+" into separator part ("[ \t\n]") for explicit concatenation
    ("...." + "...." style)

  - enclose "component and separator" part by "(?:....)+" for
    concatenation itself ("...." "...." or "...." + "....")
2014-04-01 02:46:03 +09:00
FUJIWARA Katsunori
01d8b27701 i18n: fix "% inside _()" problems
Before this patch, "contrib/check-code.py" can't detect these
problems, because the regexp pattern to detect "% inside _()" doesn't
suppose the case that the format string and "%" aren't placed in the
same line.

This patch replaces "\s" in that regexp pattern with "[ \t\n]" to
detect "% inside _()" problems in such case.

"[\s\n]" can't be used in this purpose, because "\s" is automatically
replaced with "[ \t]" by "_preparepats()" and "\s" in "[]" causes
nested "[]" unexpectedly.
2014-04-01 02:46:03 +09:00
FUJIWARA Katsunori
e0d81db88f merge: fix lack of "%s" in format string causing TypeError at runtime 2014-04-01 02:46:03 +09:00
FUJIWARA Katsunori
920a8f861c hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
Since changeset a8955c4d9ef5, "reposetup()" of each extensions is
invoked only on repositories enabling corresponded extensions.

This causes that largefiles specific interactions between the
repository enabling largefiles locally and remote (wire) peer fail,
because there is no way to know whether largefiles is enabled on the
remote repository behind the wire peer, and largefiles specific
"wireproto functions" are not given to any wire peers.

To avoid this problem, largefiles should be enabled in wider scope
than each repositories (e.g. user-wide "${HOME}/.hgrc").

This patch introduces "wirepeersetupfuncs" to setup wire peer by
extensions already enabled. Functions registered into
"wirepeersetupfuncs" are invoked for all wire peers.

This patch uses plain list instead of "util.hooks" for
"wirepeersetupfuncs", because the former allows to control order of
function invocation by order of extension enabling: it may be useful
for workaround of problems with combination of enabled extensions
2014-03-29 01:20:07 +09:00