Commit Graph

1295 Commits

Author SHA1 Message Date
Pierre-Yves David
6b773c187e bundle2: return a bundle20 object from exchanges.unbundle
When a bundle2 is pushed we return a bundle instead of an integer. We use to
return a binary stream. We now return a `bundle20` bundler to make the life of
wireprotocol implementation simpler.
2014-04-15 16:49:30 -04:00
Pierre-Yves David
7c36e663a1 bundle2: feed a binary stream to peer.unbundle
This input will have to travel over the wire anyway, so we feed the peer method
with a simple binary stream and rely on the server side to use `readbundle`
to create the python object.

The test output changes because the bundle is created marginally sooner and the
debug output interleaves in a different way.
2014-04-15 16:42:52 -04:00
Pierre-Yves David
466c622faa bundle2: return a stream from exchange.getbundle
For friendliness with the wire protocol implementation, the `exchange.getbundle` now
returns a binary stream when asked for a bundle2. We detect a bundle2 request and
upgrade the binary stream to an unbundler object.

In the future the unbundler may gain feature to look like a binary stream, but
we are not quite there yet.
2014-04-15 11:27:55 -04:00
FUJIWARA Katsunori
7b1e8194b5 localrepo: introduce "prepushoutgoinghooks" to extend outgoing check easily
This patch introduces "prepushoutgoinghooks" to extend outgoing check
before pushing changesets to remote easily.

This chooses the function returning "util.hooks" instead of the one to
be overridden.

The latter may cause problems silently, if one of overriders forgets
(or fails) to execute a kind of "super(xxx, self).overridden(...)". In
the other hand, the former can ensure that all registered functions
are invoked, unless one of them raises an exception.
2014-04-16 00:37:24 +09: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
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
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
Durham Goode
576523cd84 bundle2: use discard to remove bundle2 cap
caps.remove('bundle2') was throwing an exception if bundle2 wasn't present in
the capabilities. This was causing test-static-http.t to hang. Let's just use
discard, so we don't get an exception.
2014-04-08 13:05:29 -07:00
Pierre-Yves David
6feac7d5c2 bundle2: allow pulling changegroups using bundle2
This changeset refactors the pull code to use a bundle2 when available. We keep
bundle2 disabled by default. The current code is not ready for prime time.

Ultimately we'll want to unify the API of `bunde10` and `bundle20` to have less
different code. But for now, testing the bundle2 exchange flow is an higher
priority.
2014-04-01 23:41:32 -07:00
Pierre-Yves David
6bd17e6e6c bundle2: add an exchange.getbundle function
This function can return a `HG10` or `HG20` bundle. It uses the `bundlecaps`
parameters to decides which one to return.

This is a distinct function from `changegroup.getbundle` for two reasons. First
the APIs of `bundle10` and `bundle20` are not compatible yet. The two functions
may be reunited in the future. Second `exchange.getbundle` will grow parameters
for all kinds of data (phases, obsmarkers, ...) so it's better to keep the
changegroup generation in its own function for now.

This function will be used it in the next changesets.
2014-04-04 01:51:54 -07:00
Pierre-Yves David
c2ce1e9068 localpeer: propagate bundlecaps in getbundle call
Best arguments are the ones in use...
2014-04-04 01:33:20 -07:00
Pierre-Yves David
6b9778c026 localrepo: move the addchangegroup method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.
2014-04-01 15:27:53 -07:00
Pierre-Yves David
4d81b98c1e localrepo: move the addchangegroupfiles method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had a single caller, far too few for being kept in local repo.
2014-04-01 15:21:56 -07:00
Pierre-Yves David
8e0876686d localrepo: move the changegroup method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.

The peer API stay unchanged.
2014-04-01 15:08:27 -07:00
Pierre-Yves David
30f24fdb7a localrepo: move the getbundle method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.

The peer API remains unchanged.
2014-04-01 14:40:35 -07:00
Pierre-Yves David
47880ff5c9 localrepo: move the getlocalbundle method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had 3 callers total, far too few for being kept in local repo.
2014-04-01 14:33:23 -07:00
Pierre-Yves David
f14b79a23f localrepo: move the changegroupsubset method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.

The peer API remains unchanged.
2014-04-01 14:25:03 -07:00
Pierre-Yves David
eb9e40c9b6 localrepo: move the changegroupinfo method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had a single caller... already in this changegroup module.
2014-04-01 14:13:34 -07:00
Pierre-Yves David
691e520cd5 localrepo: move the _changegroupsubset method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had 3 callers total, far too few for being kept in local repo.
2014-04-01 13:59:55 -07:00
Pierre-Yves David
8ab4eab6ab push: pass a pushoperation object to localrepo.checkpush
The `pushoperation` object contains strictly more data the arguments currently
passed to `localrepo.checkpush` we pass the new object instead. This function is
used by MQ to abort push that includes MQ changesets.

Note: extension that may use this function will have to align.
2014-04-01 13:45:48 -07:00
Durham Goode
b9e3b76bea caches: invalidate store caches when lock is taken
The fncache was not being properly invalidated each time the lock was taken, so
in theory it could contain old data from prior to the caller having the lock.
This changes it to be invalidated as soon as the lock is taken (same as all our
other caches).
2014-03-24 15:35:07 -07:00
Durham Goode
950d3b4dd3 fncache: move fncache writing to be in a transaction
Previously the fncache was written at lock.release time. This meant it was not
tracked by a transaction, and if an error occurred during the fncache write it
would fail to update the fncache, but would not rollback the transaction,
resulting in an fncache that was not in sync with the files on disk (which
causes verify to fail, and causes streaming clones to not copy all the revlogs).

This uses the new transaction backup mechanism to make the fncache transacted.
It also moves the fncache from being written at lock.release time, to being
written at transaction.close time.
2014-03-24 15:42:13 -07:00
Durham Goode
4964eadcf8 clone: put streaming clones in a transaction
Streaming clones were writing to files outside of a transaction. Soon the
fncache will be written at transaction close time, so we need streaming clones
to be in a transaction.
2014-03-24 15:38:20 -07:00
FUJIWARA Katsunori
ccc7916e45 localrepo: omit ".hgsubstate" also from "added" files
Before this patch, "localrepository.commit()" omits ".hgsubstate" from
"modified" (changes[0]) and "removed" (changes[2]) file list before
checking subrepositories, but leaves one in "added" (changes[1]) as it
is.

Then, "localrepository.commit()" adds ".hgsubstate" into "modified" or
"removed" list forcibly, according to subrepository statuses.

If "added" contains ".hgsubstate", the committed context will contain
two ".hgsubstate" in its "files": one from "added" (not omitted one),
and another from "modified" or "removed" (newly added one).

How many times ".hgsubstate" appears in "files" changes node hash,
even though revision content is same, because node hash calculation
uses the specified "files" directly (without duplication check or so).

This means that node hash of committed revision changes according to
existence of ".hgsubstate" in "added" at "localrepository.commit()".

".hgsubstate" is treated as "added", not only in accidental cases, but
also in the case of "qpush" for the patch adding ".hgsubstate".

This patch omits ".hgsubstate" also from "added" files before checking
subrepositories. This patch also omits ".hgsubstate" exclusion in
"qnew"/"qrefresh" introduced by changeset bbb8109a634f, because this
patch makes them meaningless.

"hg parents --template '{files}\n'" newly added to "test-mq-subrepo.t"
enhances checking unexpected multiple appearances of ".hgsubstate" in
"files" of created/refreshed MQ revisions.
2014-03-22 23:39:51 +09:00
Pierre-Yves David
ce5ac68042 localrepo: rename capability set to lower case.
This is not C and they are not even constant.
2014-03-14 00:02:05 -07:00
Matt Mackall
ea6ffc9a80 merge with stable 2014-03-18 14:25:28 -05:00
FUJIWARA Katsunori
51bca8f3b4 localrepo: save manually edited commit message as soon as possible
Before this patch, "localrepository.commit()" invokes specified
"editor" to edit commit message manually, and saves it after checking
sub-repositories.

This may lose manually edited commit message, if unexpected exception
is raised while checking (or commiting recursively) sub-repositories.

This patch saves manually edited commit message as soon as possible.
2014-03-19 01:07:41 +09:00
Pierre-Yves David
6265090dee clone: do not turn hidden changeset public on publishing clone (issue3935)
Before this changeset local clone of a repo with hidden changeset would include
then in the clone (why not) and turn them public (plain wrong). This happened
because the copy clone publish by dropping the phaseroot file entirely making
everything in the repo public (and therefore immune to obsolescence marker).

This changeset takes the simplest fix, we deny the copy clone in the case of hidden
changeset falling back to pull clone that will exclude them from the clone and
therefore not turning them public.

A smarter version of copy clone could be done, but I prefer to go for the
simplest solution first.
2014-01-30 11:52:38 -08:00
Lucas Moscovicz
4eff61057b localrepo: changed revs to use spanset instead of baseset
Performance benchmarking:

$ time hg log -qf -l1
...

real  0m1.420s
user  0m1.249s
sys 0m0.167s

$ time ~/local/hg/hg log -qf -l1
...

real  0m0.719s
user  0m0.614s
sys 0m0.103s
2014-03-05 17:42:05 -08:00
Yuya Nishihara
cb7c7a6489 localrepo: add hook point to invalidate everything on each command-server run
MQ extension will wrap this function to invalidate its state.

repo.invalidate cannot be wrapped for this purpose because qpush obtains
repo.lock in the middle of the operation, triggering repo.invalidate.  Also,
it seems wrong to obtain lock earlier because mq data is non-store parts.
2014-03-03 19:41:23 +09:00
Olle Lundberg
c0ec4ee79c localrepo: language and spelling fixes in comment 2014-02-27 00:23:21 +01:00
Mads Kiilerich
8cf3bd4f00 localrepo: commit: avoid calling expensive ancestor function when p1 is nullrev 2014-02-24 22:42:14 +01:00
Pierre-Yves David
790a805eac exchange: extract pull function from localrepo
The localrepo class if far too big. Push and pull logic are extracted and
reworked to better fit with the fact we exchange more than bundle now.

This changeset extract the pulh code. later changeset will slowly slice it into
smaller brick.

The localrepo.pull method is kept for now to limit impact on user code. But it
will be ultimately removed, now that the public API is hold by peer.
2014-01-30 16:12:49 -08:00
Mads Kiilerich
a649a1436b localrepo: make it clear that changegroupsubset doesn't take bases but roots
changegroupsubset will take the parents of the roots to find the bases.

Other parts of Mercurial do not expect that, and a result of that is that some
bundles contain more changesets than necessary.

No real changes here - just renaming a parameter to document what it is.
2014-02-10 00:52:16 +01:00
Augie Fackler
8bfe6ea1ed itersubrepos: move to scmutil to break a direct import cycle 2014-02-03 18:36:00 -05:00
Mads Kiilerich
2e26bbb4c8 localrepo: give a sigh of relief when getting lock after waiting for it
A message like this was sometimes shown when pushing:
  remote: waiting for lock on repository foo held by 'mercurial:20858'
That could scare users, making them wonder whether the push actually succeeded.

To mitigate that fear, issue an additional "warning" such as:
  got lock after 2 seconds

The return value from lock.lock.lock() was unused - instead we return the
delay.

This also adds the first test coverage for waiting for locks.
2014-02-06 01:55:09 +01:00
Lucas Moscovicz
ef8bd69f5f revset: added baseset class (still empty) to improve revset performance
This class is going to be used to cache the set that is created from this list
in many cases while evaluating a revset.
2014-01-21 11:39:26 -08:00
Pierre-Yves David
f35f0a3cb0 exchange: extract push function from localrepo
The localrepo class if far too big. Push and pull logic will be extracted and
reworked to better fit with the fact they now exchange more than plain changeset
bundle.

This changeset extract the push code. later changeset will slowly slice this
over 200 hundred lines and 8 indentation level function into smaller saner
brick.

The localrepo.push method is kept for now to limit impact on user code. But it
will be ultimately removed, now that the public supposed API is hold by peer.
2014-01-30 15:34:01 -08:00
Pierre-Yves David
4a16e8a21b phase: properly compute ancestors of --rev on push (issue3786)
Now that discovery is working on unfiltered changeset, I had a good occasion to
look at that bug again. This let me realise that a trivial node vs rev
comparision was the cause of this two years old bugs…

Happy second birthday phases!
2013-01-28 15:16:49 +01:00
Matt Mackall
47af0ab954 localrepo: drop dead comment 2014-01-19 22:58:33 -06:00
Mads Kiilerich
1428b73c06 help: branch names primarily denote the tipmost unclosed branch head
Was the behavior correct and the description wrong so it should be updated as
in this patch? Or should the code work as the documentation says?

Both ways could make some sense ... but none of them are obvious in all cases.

One place where it currently cause problems is when the current revision has
another branch head that is closer to tip but closed. 'hg rebase' refuses to
rebase to that as it only see the tip-most unclosed branch head which is the
current revision.

/me kind of likes named branches, but no so much how branch closing works ...
2013-11-21 15:17:18 -05:00
Matt Mackall
dd9ef40be6 localrepo: drop unused variable 2014-01-10 17:29:16 -06:00
Pierre-Yves David
a296fcdefb pull: run findcommon incoming on unfiltered repo
The discovery is not yet ready for filtered repo. Pull was using filtered for
its discovery which is wrong. It worked by dumb luck because discovery mainly
use funtion that does not respect the filtering.

Trying to makes discovery work on filtered repo revealed this bug.
2013-11-16 11:53:44 -05:00
Pierre-Yves David
a9f4140d91 push: more robust check for bundle fast path
When all changesets in the local repo are either being pushed or remotly known,
we can take a fast path when bundling changeset because we are certain all local
deltas are computed againts base known remotely.

So we have a check to detect this situation, when we did a bare push and nothing
was excluded.

In a coming refactoring, the discovery will run on filtered view and the content
of `outgoing.excluded` will just include unserved (secret) changeset not filtered by the
repoview used to call push (usually "visible"). So we need to check if there is
both no excluded changeset and nothing filtered by the current repoview.
2013-11-05 18:37:44 +01:00
Pierre-Yves David
5567affae0 pull: fix post-pull common computation
Before that changes, pulled revision that happend to be already known locally
(so, not actually added) was not taken into account when computing the new
common set between local and remote.

It appears that we already know the heads of the pulled set. It is in the
`rheads` variable, so we are just using it and everything is works fine.

We are dropping the, now useless, computation of `added` set in the process.
2013-11-16 15:36:50 -05:00
Kevin Bullock
23ff9c2ce1 discovery: prefer loop to double-for list comprehension in changegroupsubset
The double-for form of list comprehensions gets particularly unreadable
when you throw in an 'if' condition. This expands the only remaining
instance of the double-for syntax in our codebase into a loop.
2013-11-24 17:33:39 -06:00
Brodie Rao
c42d4c5508 localrepo: remove unused repo.branchtags()/_branchtip() methods 2013-09-16 01:08:29 -07:00
Brodie Rao
af45025c76 localrepo: refactor repo.branchheads() to use repo.branchmap().branchheads() 2013-09-16 01:08:29 -07:00
Brodie Rao
b351ef136e localrepo: refactor repo.branchtip() to use repo.branchmap().branchtip() 2013-09-16 01:08:29 -07:00
Stephen Lee
7b97b6250a bookmarks: allow push -B to create a new remote head (issue2372)
Push is currently allowed to create a new head if there is a remote
bookmark that will be updated to point to the new head. If the
bookmark is not known remotely then push aborts, even if a -B argument
is about to push the bookmark. This change allows push to continue in
this case. This does not require a wireproto force.
2013-11-11 21:16:54 +11:00