Commit Graph

134 Commits

Author SHA1 Message Date
Martin von Zweigbergk
468a7b8172 changegroup: don't use 'repo' for non-repo 'self'
'repo' is a very confusing name to use for 'self', especially when
it's not a repo. Also drop repo.ui member (a.k.a. self.ui) now that
'self' doesn't shadow outer 'repo' variable.
2015-06-12 10:54:10 -07:00
Pierre-Yves David
15b83609e4 addchangegroup: accept an expected total number of changesets as argument
Caller can optionally informs how much changesets are expected to be added. This
will be used for a more useful progress bar output.
2015-06-07 15:57:40 -07:00
Pierre-Yves David
060a368fc5 changegroup: remove 'getchangegroupraw' function
There is no remaining caller for this function.
2015-06-07 15:49:57 -07:00
Gregory Szorc
ac42db2bfb changegroup: rename _computeoutgoing to computeoutgoing
We're going to use this function from another module in an upcoming
patch. Drop the _ prefix to mark it as non-private.
2015-06-02 19:58:06 -07:00
Martin von Zweigbergk
0059d15d29 changegroup: drop _changelog and _manifest properties
We already have a _repo property on the packer, and we only access the
changelog and manifest revlog in one place, so it's just as easy to
get them from self._repo.
2015-04-30 16:45:03 -07:00
Martin von Zweigbergk
5a53aebb16 changegroup: document the cases where reordering complicates linkrevs 2015-04-29 13:25:07 -07:00
Martin von Zweigbergk
d2ebe6d492 changegroup: extract condition for linkrev fastpath
The condition for taking the fastpath (or not) is used in two
places. By extracting it, we also provide a place to document what
it's about.
2015-04-29 10:34:28 -07:00
Martin von Zweigbergk
c581722414 changegroup.group: drop 'reorder' parameter
Since we always pass self._reorder to self.group(), let's drop the
parameter and let group() read from self._reorder itself. There are no
other in-tree callers to group().
2015-04-29 10:30:58 -07:00
Martin von Zweigbergk
933b6a8964 cg2packer: set reorder=False in __init__ instead of in group()
The difference between reorder=None (bundle.reorder=auto) and
reorder=False is that the generaldelta revlogs get reordered with the
former. In cg2packer, group() we check if the revlog uses generaldelta
and if reorder=None and then convert that to reorder=False. We are
effectively saying that whether or not generaldelta is used, we want
reorder=None to mean reorder=False for changegroup 2. To make this
clearer, check if reorder=None in the constructor and change it to
False there and drop the overriding of group(). Also document the
reason for turning reordering off.
2015-04-29 10:38:45 -07:00
Martin von Zweigbergk
b0cea1d15c changegroup: use 'reorder is None' instead of 'reorder is not True/False'
The config option bundle.reorder can be {on,off,auto}, which gets read
into the 'reorder' variable as {True,False,None}. In two places, we
need to decide how to handle the None/auto case. I personally find it
easier to read those expressions when written to explicitly compare to
None.
2015-04-23 09:44:22 -07:00
Martin von Zweigbergk
3c6a3be528 changegroup: close progress in same function as it's started
changegroup.group() and changegroup.generatefiles() both currently
start progress (with topic "bundling"), but changegroup.generate()
closes the topic. Move the closing to the functions that start the
topic, so it's easier to see where the topic is started and closed.

This completes a move that seems to have been started in f8f5836242c6
(bundle-ng: move progress handling out of the linkrev callback,
2013-05-10).
2015-04-22 15:03:09 -07:00
Martin von Zweigbergk
cf9f806198 changegroup: don't reuse 'mfest' variable for different type
We have a variable 'mfest' that's first a manifest nodeid and then a
manifest. Let's make it clearer by using separate variables for the
two uses.
2015-04-28 10:21:04 -07:00
Martin von Zweigbergk
67aa378a4f changegroup: rename 'mf' to 'ml' to match 'cl', since it's a revlog
The 'mf' variable is a manifest revlog, not a manifest, so let's
rename it accordingly. We already call the changelog variable 'cl', so
'ml' seems appropriate.
2015-04-28 10:19:42 -07:00
Martin von Zweigbergk
a2a1e5c7db changegroup: rename 'needed' to 'clrevs' to match 'clnodes' 2015-04-20 14:11:20 -07:00
Martin von Zweigbergk
725e64cb42 changegroup: document that 'source' parameter exists for extensions
The 'source' parameter passed to generatefiles() is unused by the
method itself, but Durham says it is used by an extension.
2015-04-28 13:49:19 -07:00
Martin von Zweigbergk
e67f94169b changegroup: removed unused 'source' parameter from prune()
The parameter has been unused since it was introduced in 40209abd6471
(bundle: refactor changegroup prune to be its own function,
2013-05-30), and Durham says it is not used by his extension either.
2015-04-28 13:40:00 -07:00
Matt Harbison
75f10ee474 changegroup: flush the ui stdio buffers after adding a changegroup
This eliminates the following test failure on Windows, as well as a similar one
in evolve's test-wireproto.t.  See the previous patch for details on the
problem.

  --- e:/Projects/hg/tests/test-init.t
  +++ e:/Projects/hg/tests/test-init.t.err
  @@ -216,10 +216,10 @@
      * test                      0:08b9e9f63b32
     $ hg clone -e "python \"$TESTDIR/dummyssh\"" local ssh://user@dummy/remote-bookmarks
     searching for changes
  +  exporting bookmark test
     remote: adding changesets
     remote: adding manifests
     remote: adding file changes
     remote: added 1 changesets with 1 changes to 1 files
  -  exporting bookmark test
     $ hg -R remote-bookmarks bookmarks
        test                      0:08b9e9f63b32
2015-04-10 23:34:06 -04:00
Pierre-Yves David
af7d20b000 bundle2: rename format, parts and config to final names
It is finally time to freeze the bundle2 format! To do so we:
- rename HG2Y to HG20,
- drop "b2x:" prefix from all part names,
- rename capability to "bundle2-exp" to "bundle2"
- rename the hook flag from 'bundle2-exp' to 'bundle2'
2015-04-09 16:25:48 -04:00
Mike Edgar
b4a5dfbe4d changegroup: emit full-replacement deltas if either revision is censored
To ensure that exchanged deltas in the presence of censored revisions can
always be applied to the recipient repository, the deltas must replace the
entire base text. To make this restriction reasonably enforceable, the delta
must do so with a single patch operation.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-01-21 22:09:32 -05:00
Mads Kiilerich
b2b60414f6 spelling: fixes from proofreading of spell checker issues 2015-01-18 02:38:57 +01:00
Mike Edgar
9635f8c5b0 revlog: in addgroup, reject ill-formed deltas based on censored nodes
To ensure interoperability when clones disagree about which file nodes are
censored, a restriction is made on deltas based on censored nodes. Any such
delta must replace the full text of the base in a single patch.

If the recipient of a delta considers the base to be censored and the delta
is not in the expected form, the recipient must reject it, as it can't know
if the source has also censored the base.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-02-06 00:55:29 +00:00
Eric Sumner
dab488d66f changegroup.getsubset: support multiple versions
Allow a version parameter to specify which version of the packer should be
used
2015-01-15 15:55:13 -08:00
Eric Sumner
96fb8b0c04 changegroup.writebundle: HG2Y support
This diff adds support to writebundle to generate a bundle2 wrapper; upcoming
diffs will add an option to write a v2 changegroup part instead of v1 in these
bundles.
2015-01-15 15:39:16 -08:00
Eric Sumner
7cbcf9bdca changegroup.writebundle: provide ui
The next diff will add support for writing bundle2 files to writebundle, but
the bundle2 generator wants access to a ui object.  This changes the signature
and callsites to pass one in.
2015-01-15 14:39:41 -08:00
Eric Sumner
c5cdff3779 pullbundle2: extract addchangegroup result combining into its own function
This will also be used for 'hg unbundle'
2015-01-16 12:53:45 -08:00
Mads Kiilerich
af8710d713 bundle: when verbose, show what takes up the space in the generated bundle
This is kind of similar to the debugbundle command but gives summarized actual
uncompressed number of bytes when creating the bundle. The numbers are as
usable as the bundle format is efficient. Hopefully bundle2 will make it a
better indicator of actual entropy.

This is useful when accepting pull requests to assess whether the repo size
increase seems reasonable for the diff before pushing stuff upstream, It has
helped me catching large files that should have been committed as largefiles
but was committed as regular files in intermediate changesets.

This output doesn't combine well with debug output so we only enable it when
verbose without debug.
2014-08-15 19:43:32 +02:00
Matt Mackall
174e7f793d merge with stable 2014-11-22 17:09:04 -06:00
Durham Goode
0a7a4a1f33 changegroup: fix file linkrevs during reorders (issue4462)
Previously, if reorder was true during the creation of a changegroup bundle,
it was possible that the manifest and filelogs would be reordered such that the
resulting bundle filelog had a linkrev that pointed to a commit that was not
the earliest instance of the filelog revision. For example:

With commits:

0<-1<---3<-4
  \       /
   --2<---

if 2 and 3 added the same version of a file, if the manifests of 2 and 3 have
their order reversed, but the changelog did not, it could produce a filelog with
linkrevs 0<-3 instead of 0<-2, which meant if commit 3 was stripped, it would
delete that file data from the repository and commit 2 would be corrupt (as
would any future pulls that tried to build upon that version of the file).

The fix is to make the linkrev fixup smarter. Previously it considered the first
manifest that added a file to be the first commit that added that file, which is
not true. Now, for every file revision we add to the bundle we make sure we
attach it to the earliest applicable linkrev.
2014-11-20 16:30:57 -08:00
Gregory Szorc
04eeb85285 changegroup: sparsely populate fnodes
Previously, fnodes had a key and empty dict value for every element in
changedfiles. This is somewhat wasteful. Empty dicts in CPython consume
a lot more memory than you would expect - 280 bytes.

On mozilla-central, which has ~190,000 files/fnodes keys, the previous
loop populating fnodes allocated 91,924 KB of memory, most of that for
the empty dicts.

With this patch in place, our peak RSS during mozilla-central clone
drops:

before:  364,356 KB
after:   326,008 KB
delta:   -38,348 KB

When combined with the previous patch, total peak RSS decrease is now
190,116 KB.
2014-11-06 22:48:20 -08:00
Gregory Szorc
c6e3c6fb27 changegroup: don't store unused value on fnodes (issue4443)
The contents of fnodes are only accessed once per key. It is wasteful to
cache the value since nobody will use it.

Before this patch, the caching of unused data in fnodes was effectively
causing a memory leak during the file streaming part of bundle creation.

On mozilla-central (which has ~190,000 entries in fnodes), this patch
has a significant impact on RSS at the end of generate():

before:  516,124 KB
after:   364,356 KB
delta:  -151,768 KB

The origin of this code can be traced back to 1f567a607f1f and has been
with us since the 2.7 release.
2014-11-06 22:33:48 -08:00
Gregory Szorc
0bfb4de7ec changegroup: don't define lookupmf() until it is needed
lookupmf() is currently defined earlier than when it is needed. Future
patches further refactoring this code will be easier to read when
lookupmf() is in its new home.
2014-11-06 20:57:12 -08:00
Pierre-Yves David
8259127ccb transaction: pass the transaction to 'postclose' callback
This mirrors the API for 'pending' and 'finalize' callbacks. I do not have
immediate usage planned for it, but I'm sure some callback will be happy to
access transaction related data.
2014-11-08 16:35:15 +00:00
Matt Mackall
816fd34333 merge with stable 2014-11-10 17:29:15 -06:00
Siddharth Agarwal
3e8587d071 changegroup.cg2packer: lookup 'group' via inheritance chain
This lets extensions insert themselves in the class hierarchy.
2014-11-07 17:54:59 -08:00
Pierre-Yves David
130c63f6e2 changegroup: use the 'postclose' API on transaction
The post-transaction hooks run after the lock release (because hooks may want to
touch the repository), but they must only run if the transaction is successfully
closed.

We use the new 'addpostclose' method on transaction to register a callback
installing this post-lock-release call.
2014-10-28 15:44:23 +01:00
Pierre-Yves David
8803fc197d changelog: rely on transaction for finalization
Instead of calling 'cl.finalize()' by hand (possibly at a bogus time) we
register it in the transaction during 'delayupdate' and rely on 'tr.close()' to
call it at the right time.
2014-10-18 01:09:41 -07:00
Pierre-Yves David
d6b8860637 changelog: handle writepending in the transaction
The 'delayupdate' method now takes a transaction object and registers its
'_writepending' method for execution in 'transaction.writepending()'. The hook can then
use 'transaction.writepending()' directly.

At some point this will allow the addition of other file creation
during writepending.
2014-10-17 21:55:31 -07:00
Sune Foldager
7cb0f8602d changegroup: introduce cg2packer/unpacker
cg2 supports generaldelta in changegroups, to be used in bundle2.
Since generaldelta is handled directly in cg2, reordering is switched
off by default.
2014-10-17 14:41:11 +02:00
Sune Foldager
efbba1affa changegroup: allow use of different cg#packer in getchangegroupraw
This will allow the use of general delta aware changegroup formats.
2014-10-17 14:41:21 +02:00
Sune Foldager
e8de499479 changegroup: introduce "raw" versions of some commands
The commands getchangegroup, getlocalchangegroup and getsubset now each
have a version ending in -raw. The raw versions return the chunk generator
from the changegroup packer directly, without wrapping it in a chunkbuffer
and unpacker. This avoids extra chunkbuffers in the bundle2 code path.

Also, the raw versions can be extended to support alternative packers
in the future, to be used from bundle2.
2014-10-17 14:41:02 +02:00
Pierre-Yves David
7e87948427 changegroup: add a "packermap" dictionary to track different packer versions
We only have "01" right now, but we should get general delta in soon.
Bundle2 is expected to make use of this to advertise and select the right packer
to use on both sides.
2014-09-24 21:24:06 -07:00
Pierre-Yves David
03cb1a74e8 changegroup: store source and url in the hookargs dict
We store the source and url of the current data into `transaction.hookargs` this
let us inherit it from upper layers that may have created a much wider
transaction. We have to modify bundle2 at the same time to register the source
and url in the transaction. We have to do it in the same patch otherwise, the
`addchangegroup` call would fill these values and the hook calling will crash
because of the duplicated 'source' and 'url' arguments passed to the hook call.
2014-10-14 00:06:46 -07:00
Pierre-Yves David
ce86284532 prechangegroup: use hook argument from the transaction
There can be useful data in there (eg: bundle2 related one)
2014-10-14 00:43:20 -07:00
Pierre-Yves David
0e7fe9a947 addchangegroup: call prechangegroup hook after transaction retrieval
We want to reused some possible information stored in the transaction
`hookargs` dict that may be stored by something handling the transaction at an
upper level (eg: bundle2) So we move the running of the hooks after transaction
creation. This has no visible effects (but an empty transaction roolback if the
hook fails) because nothing had happened in the transaction yet.
2014-10-14 00:09:25 -07:00
Pierre-Yves David
9e19dbeaf9 addchangegroup: get the node argument of incoming hook from transaction
The transaction is now carrying hook-related informations. So we use it to
retrieve the `node` argument. This will also carry around all kinds of other useful
informations (like: "are we in a bundle2 processing")
2014-10-14 00:03:03 -07:00
Mike Hommey
14669879bf changegroup: use a copy of hookargs when invoking the changegroup hook
addchangegroup creates a runhook function that is used to invoke the
changegroup and incoming hooks, but at the time the function is called,
the contents of hookargs associated with the transaction may have been
modified externally. For instance, bundle2 code affects it with
obsolescence markers and bookmarks info.

It also creates problems when a single transaction is used with multiple
changegroups added (as per an upcoming change), whereby the contents
of hookargs are that of after adding a latter changegroup when invoking
the hook for the first changegroup.
2014-10-16 15:54:53 +09:00
Sune Foldager
eb415860f8 changegroup: rename bundle-related functions and classes
Functions like getbundle and classes like unbundle10 really manipulate
changegroups and not bundles. A HG10 bundle is the same as a changegroup
plus a small header, but this is no longer the case for a HG2X bundle,
so it's better to separate the names a bit.
2014-09-02 12:11:36 +02:00
Pierre-Yves David
5f2b50474c phase: add a transaction argument to retractboundary
We now pass a transaction option to this phase movement function. The
object is currently not used by the function, but it will be in the
future.

All call sites have been updated. Most call sites were already enclosed in a
transaction for a long time. The handful of others have been recently
updated in previous commit.
2014-08-05 23:52:21 -07:00
Pierre-Yves David
a9275323db phase: add a transaction argument to advanceboundary
We now pass a transaction option to this phase movement function. The object
is currently not used by the function, but it will be in the future.

All call sites have been updated. Most call sites were already enclosed in a
transaction for a long time. The handful of others have been recently
updated in previous commit.

The retractboundary function remains to be upgraded.
2014-08-06 01:54:19 -07:00
Pierre-Yves David
8102dcd0f7 changegroup: add a targetphase argument to addchangegroup
This argument controls the phase used for the added changesets. This can be
useful to unbundle in "secret" phase as required by shelve.

This change aims at helping high-level code get rid of manual phase
movement. An important milestone for having phases part of the transaction.
2014-08-05 13:49:38 -07:00