Commit Graph

5084 Commits

Author SHA1 Message Date
Ryan McElroy
61f504197f strip: factor out revset calculation for strip -B
This will allow reusing it in evolve and overriding it in other extensions.
2015-10-09 14:48:59 -07:00
Gregory Szorc
5d1b4c49ee clonebundles: support for seeding clones from pre-generated bundles
Cloning can be an expensive operation for servers because the server
generates a bundle from existing repository data at request time. For
a large repository like mozilla-central, this consumes 4+ minutes
of CPU time on the server. It also results in significant network
utilization. Multiplied by hundreds or even thousands of clients and
the ensuing load can result in difficulties scaling the Mercurial server.

Despite generation of bundles being deterministic until the next
changeset is added, the generation of bundles to service a clone request
is not cached. Each clone thus performs redundant work. This is
wasteful.

This patch introduces the "clonebundles" extension and related
client-side functionality to help alleviate this deficiency. The
client-side feature is behind an experimental flag and is not enabled by
default.

It works as follows:

1) Server operator generates a bundle and makes it available on a
   server (likely HTTP).
2) Server operator defines the URL of a bundle file in a
   .hg/clonebundles.manifest file.
3) Client `hg clone`ing sees the server is advertising bundle URLs.
4) Client fetches and applies the advertised bundle.
5) Client performs equivalent of `hg pull` to fetch changes made since
   the bundle was created.

Essentially, the server performs the expensive work of generating a
bundle once and all subsequent clones fetch a static file from
somewhere. Scaling static file serving is a much more manageable
problem than scaling a Python application like Mercurial. Assuming your
repository grows less than 1% per day, the end result is 99+% of CPU
and network load from clones is eliminated, allowing Mercurial servers
to scale more easily. Serving static files also means data can be
transferred to clients as fast as they can consume it, rather than as
fast as servers can generate it. This makes clones faster.

Mozilla has implemented similar functionality of this patch on
hg.mozilla.org using a custom extension. We are hosting bundle files in
Amazon S3 and CloudFront (a CDN) and have successfully offloaded
>1 TB/day in data transfer from hg.mozilla.org, freeing up significant
bandwidth and CPU resources. The positive impact has been stellar and
I believe it has proved its value to be included in Mercurial core. I
feel it is important for the client-side support to be enabled in core
by default because it means that clients will get faster, more reliable
clones and will enable server operators to reduce load without
requiring any client-side configuration changes (assuming clients are
up to date, of course).

The scope of this feature is narrowly and specifically tailored to
cloning, despite "serve pulls from pre-generated bundles" being a valid
and useful feature. I would eventually like for Mercurial servers to
support transferring *all* repository data via statically hosted files.
You could imagine a server that siphons all pushed data to bundle files
and instructs clients to apply a stream of bundles to reconstruct all
repository data. This feature, while useful and powerful, is
significantly more work to implement because it requires the server
component have awareness of discovery and a mapping of which changesets
are in which files. Full, clone bundles, by contrast, are much simpler.

The wire protocol command is named "clonebundles" instead of something
more generic like "staticbundles" to leave the door open for a new, more
powerful and more generic server-side component with minimal backwards
compatibility implications. The name "bundleclone" is used by Mozilla's
extension and would cause problems since there are subtle differences
in Mozilla's extension.

Mozilla's experience with this idea has taught us that some form of
"content negotiation" is required. Not all clients will support all
bundle formats or even URLs (advanced TLS requirements, etc). To ensure
the highest uptake possible, a server needs to advertise multiple
versions of bundles and clients need to be able to choose the most
appropriate from that list one. The "attributes" in each
server-advertised entry facilitate this filtering and sorting. Their
use will become apparent in subsequent patches.

Initial inspiration and credit for the idea of cloning from static files
belongs to Augie Fackler and his "lookaside clone" extension proof of
concept.
2015-10-09 11:22:01 -07:00
Siddharth Agarwal
dd90f817f9 filemerge: introduce a premerge flag and function
This flag will let us get to our overall goal of performing all premerges
before any merges.
2015-10-11 20:47:04 -07:00
Siddharth Agarwal
82f2aec334 filemerge: also return whether the merge is complete
In future patches, we'll pause merges after the premerge step. After the
premerge step we'll return complete = False.
2015-10-11 12:56:21 -07:00
Siddharth Agarwal
da75e232c9 filemerge: add a wrapper around the filemerge function
We'll introduce a separate premerge function that calls the same code.
2015-10-11 12:31:08 -07:00
Pierre-Yves David
5e41fdb7bc shelve: rename 'publicancestors' to something accurate (issue4737)
That function is actually not returning public ancestors at all. This is
pointed by the second line of the docstring...

The bundling behavior was made correct in a5141977198d but with confusion
remaining regarding what each function was doing.

This close issue4737, because this highlight that shelve is actually -not-
bundling too much data (this was actually properly tested).
2015-10-09 15:31:50 -07:00
Emanuele Giaquinta
18869274ee cvsps: fix computation of parent revisions when log caching is on
cvsps computes the parent revisions of log entries by walking the cvs log
sorted by (rcs, revision) and by iteratively maintaining a 'versions'
dictionary which maps a (rcs, branch) pair onto the last revision seen for that
pair. When log caching is on and a log cache exists, cvsps fails to set the
parent revisions of new log entries because it does not iterate over the log
cache in the parents computation. A complication is that a file rcs can change
(move to/from the attic), with respect to its value in the log cache, if the
file is removed/added back. This patch adds an iteration over the log cache to
update the rcs of cached log entries, if changed, and to properly populate the
'versions' dictionary.
2015-10-07 11:33:52 +03:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Pierre-Yves David
7e69ac5da6 eol: rename 'error' to 'haserror'
The variable 'error' conflict with the module name that we would like to import
and use in a coming changeset.
2015-10-05 22:49:24 -07:00
Christian Delahousse
7472064a6f histedit: delete histedit statefile on any exception during abort
When an user aborts a histedit, many things could go wrong. At a minimum, after
a histedit abort failure, their repository should be out of that state. We've
found situations where the user could not exit the histedit state without
manually deleting the histedit state file. This patch ensures that if any
exception happens during an abort, the histedit statefile will be deleted so
that users are out of the histedit state and can at least manually get the repo
back to a workable condition.
2015-10-05 16:44:45 -07:00
Christian Delahousse
77b3596e11 histedit: check presence of statefile before deleting it
When the histeditstate class instance has it's clear() method called, there is
nothing to check to see if the state file exists before deleting it. It may not
exist, which would create an exception. This patch allows clear to be called at
any time.

This will be needed for the following patch.
2015-10-06 15:09:28 -07:00
Christian Delahousse
6f2b3a468a histedit: add inprogress method to state class
If a histedit is progress, the 'histedit-state' file should exist. The patch
implements a convenience function to do check if a histedit is in progress.

This method will be use in next patch in the series.
2015-10-05 16:34:17 -07:00
FUJIWARA Katsunori
f2187903e7 dirstate: remove meaningless dirstateguard
Previous patch made dirstate changes in a transaction scope "all or
nothing". Therefore, 'dirstateguard' is meaningless, if its scope is
as same as one of the related transaction.

This patch removes such meaningless 'dirstateguard' usage.
2015-10-09 03:53:46 +09:00
FUJIWARA Katsunori
45bfdb573e localrepo: execute appropriate actions for dirstate at releasing transaction
Before this patch, in-memory dirstate changes are still kept over a
transaction scope boundary regardless of the result of it.

For "all or nothing" policy of the transaction, in-memory dirstate
changes should be:

  - written out at successful closing a transaction, because
    subsequent 'dirstate.invalidate()' can lose them

  - discarded at failure of a transaction, because outer
    'wlock.release()' or so may write them out

To discard all changes in a transaction completely, this patch also
restores '.hg/dirstate' by '.hg/journal.dirstate' at failure, because
'transaction' itself does nothing for files related to '.hg/journal.*'
in such case (therefore, renaming in this patch is safe enough).

This is a part of preparations for "transactional dirstate". See also
the wiki page below for detail about it.

    https://mercurial.selenic.com/wiki/DirstateTransactionPlan

This patch also removes redundant 'dirstate.invalidate()' just before
aborting a transaction for shelve/unshelve.
2015-10-09 03:53:46 +09:00
Pierre-Yves David
70ea75bfe7 patchbomb: add a 'bundletype' config under 'patchbomb'
patchbomb relies on the 'hg bundle' command to generate an attached bundle using
--bundle. However, while 'hg bundle' has a --type option, patchbomb did not.
This is becoming very relevant since we are about to issue bundle2 for
general-delta repository.

This was tracked as issue4863
2015-10-01 23:13:57 -07:00
Pierre-Yves David
6554509d00 patchbomb: add experimental config of a "pullurl" and export it
This config allows to specify a public location where your changeset can be
found. It then include a dedicated patch header show a command to be used to
retrieve the change. See the test for example.

This is flagged as experimental because this feature is not safe until we have
more logic to test that:
- changeset actually exists on destination
- changeset is draft on destination.

As all this is experimental, bike shedding can happily happens before we remove
the experimental flag.
2015-10-06 01:49:04 -07:00
FUJIWARA Katsunori
012bda5d3c shelve: restore unshelved dirstate explicitly after aborting transaction
Before this patch, "hg unshelve" uses aborting a current transaction
to discard temporary changes while unshelving.

This assumes that dirstate changes in a transaction scope are kept
even after aborting it. But this assumption will be broken by
"transactional dirstate". See the wiki page below for detail about it.

    https://mercurial.selenic.com/wiki/DirstateTransactionPlan

This patch explicitly saves shelved dirstate just before aborting
current transaction, and restore dirstate with it after aborting by
utility function '_aborttransaction()' added by previous patch.
2015-10-08 01:41:30 +09:00
FUJIWARA Katsunori
b46183c6ee shelve: restore shelved dirstate explicitly after aborting transaction
Before this patch, "hg shelve" uses aborting a current transaction to
discard temporary changes while shelving.

This assumes that dirstate changes in a transaction scope are kept
even after aborting it. But this assumption will be broken by
"transactional dirstate". See the wiki page below for detail about it.

    https://mercurial.selenic.com/wiki/DirstateTransactionPlan

This patch explicitly saves shelved dirstate just before aborting
current transaction, and restore dirstate with it after aborting by
utility function '_aborttransaction()' added by previous patch.

This patch replaces 'if tr: tr.abort()' by 'lockmod.release(tr)',
because the former is already done in '_aborttransaction()' (and the
latter has no effect), if current transaction is aborted in it
successfully. Otherwise, the latter is enough to trigger aborting.
2015-10-08 01:41:30 +09:00
FUJIWARA Katsunori
6200027e0d shelve: add utility to abort current transaction but keep dirstate
"hg shelve" and "hg unshelve" use aborting a current transaction to
discard temporary changes while (un)shelving.

This assumes that dirstate changes in a transaction scope are kept
even after aborting it. But this assumption will be broken by
"transactional dirstate". See the wiki page below for detail about it.

    https://mercurial.selenic.com/wiki/DirstateTransactionPlan

This patch adds utility function "_aborttransaction()" to abort
current transaction but keep dirstate changes for (un)shelving.

'dirstate.invalidate()' just after aborting a transaction should be
removed soon by subsequent patch, which writes or discards in-memory
dirstate changes at releasing transaction according to the result of
it.

BTW, there are some other ways below, which (seem to, at first glance)
resolve this issue. But this patch chose straightforward way for ease
of review and future refactorring.

  - commit transaction at first, and then rollback it

    It causes unintentional "dirty read" of running transaction to
    other processes at committing it.

  - use dirstateguard to save and restore shelved dirstate

    After DirstateTransactionPlan, making 'dirstate.write()' write
    in-memory changes into actual file requires
    'transaction.writepending()' while transaction running.

    It causes meaningless writing other in-memory changes out, even
    though they are never referred.

    In addition to it, it isn't desirable that scope of dirstateguard
    and transaction intersects each other.

  - get list of files changed from the parent, keep it in memory, and
    emulate that changes after aborting transaction

    This additional memory consumption may block aborting transaction
    in large repository (on small resource environment).
2015-10-08 01:41:30 +09:00
FUJIWARA Katsunori
5b79d1f206 bookmarks: use recordchange instead of writing if transaction is active
Before this patch, 'bmstore.write()' always write in-memory bookmark
changes into '.hg/bookmarks' regardless of transaction activity.

If 'bmstore.write()' is invoked inside a transaction and it writes
changes into '.hg/bookmarks', then:

  - original bookmarks aren't restored at failure of that transaction

    This breaks "all or nothing" policy of the transaction.

    BTW, "hg rollback" can restore bookmarks successfully even before
    this patch, because original bookmarks are saved into
    '.hg/journal.bookmarks' at the beginning of the transaction, and
    it (actually renamed as '.hg/undo.bookmarks') is used by "hg
    rollback".

  - uncommitted bookmark changes are visible to other processes

    This is a kind of "dirty read"

For example, 'rebase.rebase()' implies 'bmstore.write()', and it may
be executed inside the transaction of "hg unshelve". Then, intentional
aborting at the end of "hg unshelve" transaction doesn't restore
original bookmarks (this is obviously a bug).

This patch uses 'bmstore.recordchange()' instead of actual writing by
'bmstore._writerepo()', if any transaction is active

This patch also removes meaningless restoring bmstore explicitly at
the end of "hg shelve".

This patch doesn't choose fixing each 'bmstore.write()' callers as
like below, because writing similar code here and there is very
redundant.

  before:
    bmstore.write()

  after:
    tr = repo.currenttransaction()
    if tr:
        bmstore.recordchange(tr)
    else:
        bmstore.write()

Even though 'bmstore.write()' itself may have to be discarded by
putting bookmark operations into transaction scope, this patch chose
fixing it to implement "transactional dirstate" at first.
2015-10-08 01:41:30 +09:00
Pierre-Yves David
28c5867b10 shelve: bundle using bundle2 if repository is general delta (issue4862)
This will prevent expensive delta computation on bundling and is similar to what we do
for strip backup.
2015-10-01 15:08:00 -07:00
Pierre-Yves David
06934a921e shelve: move changegroup generation inside writebundle
We will generate different changegroup if general delta is enabled so we gather
this in the lower level function. There wasn't any good reason to have it in
the main code anyway.
2015-10-01 15:09:32 -07:00
Pierre-Yves David
73c8125ae1 shelve: compress on-disk bundle
Shelve is using 'HG10UN' bundle for no obvious reason. Changing this to 'HG10BZ'
as we do for other bundle stored on disk.
2015-09-29 17:14:30 -07:00
Matt Mackall
86f1841884 merge with stable 2015-10-07 13:44:48 -05:00
Bruce Cran
f9dd2d6f9f notify: fix fromauthor setting for 'incoming' hook type (issue4194)
Set the author field in notification emails for the 'incoming' hook type
in addition to 'changegroup' and 'outgoing' types.
2015-10-05 10:43:16 -06:00
timeless@mozdev.org
28296ec06b rebase: enable histedit for useful help with it 2015-10-06 15:07:00 -04:00
timeless@mozdev.org
23e4331fc3 rebase: suggest help -e histedit
Users unfamiliar with an extension should be reading the
documentation for the feature, not the command.
2015-10-06 15:01:25 -04:00
timeless@mozdev.org
96a106318f rebase: factor out histedit help command 2015-10-06 15:05:40 -04:00
Matt Harbison
f5215c2c04 largefiles: restore archiving largefiles with hgweb (issue4859)
This regressed in f07f4c45a8f2, when trying to conditionally disable archiving
of largefiles.

I'm not sure if wrapfunction() is the right way to do this, but it seems to
work.  The mysterious issue with lfstatus getting out of sync in the proxy and
the unfiltered view crops up again here.  See the referenced cset for more info.
2015-09-29 23:29:44 -04:00
FUJIWARA Katsunori
419251cb13 keyword: make restrict mode False while updating files for rollback
This is a preparation for using 'repo.rollback()' instead of aborting
a current running transaction for "shelve" and "unshelve".

Before this patch, updating files as a part of 'repo.rollback()'
overridden by keyword extension always follows 'restrict' mode of the
command currently executed.

"merge", "unshelve" and so on should be 'restrict'-ed, because keyword
expansion may cause unexpected conflicts at merging while these
commands.

But, if 'repo.rollback()' is invoked while executing 'restrict'-ed
commands, modified files in the working directory are marked as
"CLEAN" unexpectedly by code path below:

        # 'lookup' below is True at updating modified files for rollback
        kwcmd = self.restrict and lookup # kwexpand/kwshrink
            :
                if kwcmd:
                    self.repo.dirstate.normal(f)

On the other hand, "rollback" command isn't 'restrict'-ed, because
rollbacking itself doesn't imply merging.

Therefore, disabling 'restrict' mode while updating files as a part of
'repo.rollback()' regardless of current 'restrict' mode should be
reasonable.
2015-10-04 21:33:29 +09:00
Yuya Nishihara
1f3d02756b pager: recreate stdout to make it line-buffered
We want to see partial command results as soon as possible. But the buffering
mode of stdout (= pager's stdin) was set to fully-buffered because it isn't
associated with a tty. So, this patch recreates new stdout object to force its
buffering mode.

Because two file objects are associated with the same stdout fd and their
destructors will call close(), one of them must be closed carefully. Python
expects that the stdout fd never be closed even after sys.stdout.close() [1],
but newstdout has no such hack. So this patch calls newstdout.close()
immediately before duplicating the original stdout fd to sys.stdout.

  operation              sys.stdout  newstdout  fd
  ---------------------  ----------  ---------  --------
  newstdout.close()      open        closed     closed
  os.dup2(stdoutfd, ..)  open        closed     open
  del sys.stdout         closed      closed     open [1]

 [1]: https://hg.python.org/cpython/file/v2.7.10/Python/sysmodule.c#l1391
2015-10-03 15:16:33 +09:00
Yuya Nishihara
20505cecd5 pager: rename variables of backup fds
The next patch will add backup file objects, so the original variable names
would be confusing.
2015-10-03 18:48:21 +09:00
Yuya Nishihara
cadf85db0f pager: inline _pagersubprocess() into _runpager()
We don't need _pagersubprocess() because the fork version was removed
at 783efe565d9e.
2015-10-03 15:02:52 +09:00
Matt Mackall
eb810eca5f merge with stable 2015-10-01 12:17:46 -05:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Matt Mackall
7543320395 urls: bulk-change BTS urls to new location 2015-09-30 15:31:07 -05:00
Yuya Nishihara
dac7167e8f help: include parens in DEPRECATED/EXPERIMENTAL keywords
In some languages that have no caps, "DEPRECATED" and "deprecated" can be
translated to the same byte sequence. So it is too wild to exclude messages
by _("DEPRECATED").
2015-09-26 11:38:39 +09:00
timeless@mozdev.org
e4c8525ba7 rebase: avoid losing branch commits with --keepbranch (issue4835) 2015-09-24 17:51:05 -04:00
Laurent Charignon
1cb3086e23 rebase: don't rebase obsolete commit whose successor is already rebased
This patch avoids unnecessary conflicts to resolve during rebase for the users
of changeset evolution.

This patch modifies rebase to skip obsolete commits if they are being rebased on
their successors.
It introduces a new rebase state 'revprecursor' for these revisions that are
being skipped and a new message to inform the user of what is happening.
This feature is gated behind the config flag experimental.rebaseskipobsolete

When an obsolete commit is skipped, the output is:
not rebasing 14:9ad579b4a5de "I", already in destination as 17:fc37a630c901 "K"
2015-09-14 17:31:48 -07:00
Pierre-Yves David
7b5d19b0d7 transplant: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:52:21 -07:00
Pierre-Yves David
4756d21a63 mq: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs. The
underlying function already handle "None" as an option value, so we do not need
to do anything else.
2015-09-24 00:50:06 -07:00
Pierre-Yves David
a551464cdd largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:49:02 -07:00
Pierre-Yves David
ffcbdf7cc8 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:48:24 -07:00
Pierre-Yves David
cdc21e7de4 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:48:02 -07:00
Pierre-Yves David
4838705431 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:46:37 -07:00
Pierre-Yves David
40bf417522 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:46:12 -07:00
Pierre-Yves David
ef62bb6e54 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:44:59 -07:00
Pierre-Yves David
4dc7b8ccac largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:44:32 -07:00
Pierre-Yves David
a7ba280694 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:41:43 -07:00
Pierre-Yves David
28f9483962 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:40:53 -07:00