Commit Graph

26343 Commits

Author SHA1 Message Date
Pierre-Yves David
ab23538b10 extract: simplify parents assignement
We move to the more standard style of:

  value = default
  if special:
      value = other

This is more consistent and compact.
2015-10-06 02:04:06 -07:00
Pierre-Yves David
ec1d4cc8b3 patch: move 'extract' return to a dictionnary
The final goal here is to be able to parse, return and process arbitrary data
from patch. This mirror the recently added ability to add arbitrary data to
patch headers.

The first step is to return something more flexible, so we return a dict without
changing any other logic.
2015-10-06 02:01:53 -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
Pierre-Yves David
d6432f70b8 export: introduce a generic way to add patch header on export
Extensions currently have no easy way to add data to exported
patch. This is now fixed using a generic mechanism in the same fashion
used by bundle2. Tests are coming in the next changeset with its first
user.
2015-10-05 23:17:01 -07:00
Pierre-Yves David
3ff87b1cf4 incoming: request a bundle2 when possible (BC)
Incoming was using bundle1 in all cases, as bundle1 is restricted to
changegroup1 and does not support general delta, this can lead to significant
CPU overhead if the server is using general delta storage. We now properly
request and store a bundle2 to disk.

If the server include any output or error in the bundle, they will be stored on
disk and replayed when the bundle is read. As 'hg incoming' is going to read the
bundle right away, we call that 'good' enough and go back to the bigger plan of
having general delta on by default.

This was tracked as 4864
2015-10-05 00:23:20 -07:00
Pierre-Yves David
1bff95dea7 bundlerepo: indent some code to prepare next patch
We are about to add a new condition. Code is indented in a separated patch for
readability.
2015-10-05 00:18:11 -07:00
Pierre-Yves David
84d5d1a440 bundle2: add a way to just forward the bundle2 stream to another user
There is use case for directly forward and bundle2 stream from the peer to a
file (eg: 'hg incoming --bundle'), However ssh peers have no way to know the
'getbundle' is over except for actually interpreting the bundle. So we need to
have the unbundle do the interpreting and forward job.

The function is marked as private to highlight that this is terrible and that we
are sorry.
2015-10-08 01:40:21 -07:00
Pierre-Yves David
9cadff52d0 bundle2: split parameter retrieval and processing
We want to introduce a simple way to forward the content of a bundle2 stream.
For this purpose, we will need to both yield the parameters block and process it
(to apply any behavior change it might indicate).
2015-10-05 01:10:49 -07:00
Pierre-Yves David
ad2caca390 changegroup: extract the file management part in its own function
The current writebundle function do two things:

- taking a changegroup-packer instance and storing it into a valid bundle with
  proper header.

- creating a temporary or requested file to store that bundle

We would like to make it easier to forward bundle stream directly from a remote
peer to a file, so we split the two logic to be able to skip the one about
building a valid bundle (the remote is already sending one).
2015-10-05 00:14:47 -07:00
Pierre-Yves David
96f8937e86 unbundle: properly read head modification result from bundle2
We were reading the wrong key...
2015-10-04 21:48:19 -07:00
Yuya Nishihara
e482010d79 revset: strip off "literal:" prefix from bookmark not found error
This is what branch() and tag() do.
2015-10-07 23:04:31 +09:00
Yuya Nishihara
af229fbc94 revset: do not fall through to revspec for literal: branch (issue4838)
If "literal:" is specified, it must not be a revset expression. It should
error out with a better message.
2015-10-07 23:00:29 +09:00
Gijs Kruitbosch
92cf6734a1 hgweb: ensure both foreground and background colors are specified (issue4872)
When users configure the default foreground or background color to
non-default (black on white) values, several hgweb styles lack
contrast for headers and table row items. This patch fixes that by
ensuring that where either foreground or background colors are
specified, both are specified.
2015-10-07 21:08:14 +01:00
Pierre-Yves David
24004c0b3e merge: drop special parent assignment in the obsolete case
We can safely drop this because the very same assignment is enforcement later in
the function. Dropping it will make it simpler to extract the default
destination logic in its own function.
2015-10-05 01:47:33 -07:00
Pierre-Yves David
232a6cb371 bundle: use bundle2 if repository uses general delta
As bundle1 does not support generaldelta, this would mean recomputing delta at
bundle time. This is similar to what we do for strip and shelve and was tracked
as issue4865.
2015-10-01 20:31:43 -07:00
Pierre-Yves David
f1e9601240 parsebundletype: add a comment for future generation 2015-10-01 20:21:16 -07:00
Pierre-Yves David
8f390ad0b6 bundle: extend the format of --type to support version and compression
We had some basic undocumented support for uncompressed bundle2 support. We now
have an official extensible syntax to specify both format type and compression
(eg: bzip2-v2).

In practice, this changeset introduce the 'v1' and 'v2' identifier to make it
possible to combine format and compression. The default format is still 'v1'.
We'll care about picking 'v1' or 'v2' in regard with general delta in the next
changesets.
2015-10-01 19:16:00 -07:00
Gijs Kruitbosch
5b5d0b9759 hgweb: fix border-radius for standards-based browsers
While here, remove an old gecko-specific property, as gecko has
supported the unprefixed version for many years.
2015-10-07 20:19:20 +01:00
Siddharth Agarwal
1f3c72862f filemerge: move precheck to before files are written out
This is much simpler, and also avoids unnecessary disk IO.
2015-10-07 21:28:43 -07:00
Siddharth Agarwal
545f983ef8 filemerge: move 'merging' output to before file creation
This has no visible impact but makes some future work simpler.
2015-10-07 22:58:52 -07:00
Siddharth Agarwal
7ea14fa915 filemerge.filemerge: make a tuple containing merge paths on disk
We're going to need this same tuple elsewhere.
2015-10-07 21:21:56 -07:00
Siddharth Agarwal
6b1725d26f filemerge: switch trymerge boolean to mergetype enum
trymerge = False becomes mergetype = nomerge, and trymerge = True becomes
mergetype = fullmerge or mergeonly, depending on whether a premerge happens.
2015-10-07 16:14:57 -07:00
Siddharth Agarwal
36f6f22a1e filemerge: add some merge types
We're going to turn the 'trymerge' boolean into a 'mergetype' enum with these
three possible values.
2015-10-07 15:13:41 -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
0602f8209b dirstate: split write to write changes into files other than .hg/dirstate
'_writedirstate()' is used mainly for "transactional dirstate". See
the wiki page below for detail about it.

    https://mercurial.selenic.com/wiki/DirstateTransactionPlan
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
Siddharth Agarwal
dbdf9ec262 filemerge: run symlink check for :merge3
Just like :merge, :merge3 doesn't support merging symlinks.
2015-10-07 00:27:23 -07:00
Siddharth Agarwal
bedfe886f8 filemerge: print correct name of tool for symlink checks
Earlier we'd print ':merge' even if the tool was something else like ':union'.
That's clearly a bug.
2015-10-07 00:24:44 -07:00
Siddharth Agarwal
30c73e4dd2 filemerge: normalize 'internal:foo' names to ':foo'
In upcoming patches we're going to present these names in the UI -- it would be
good not to present deprecated names.
2015-10-07 00:01:16 -07:00
Siddharth Agarwal
aef73939f9 filemerge: use symlinkcheck for :merge and :union
This exposes a couple of bugs, both of which will be fixed in upcoming patches.
2015-10-06 22:57:21 -07:00
Siddharth Agarwal
258f79e559 filemerge: add a precheck for symlinks
This will be used by internal merge tools.
2015-10-06 22:56:33 -07:00
Siddharth Agarwal
11ffaa85a2 filemerge: call precheck if available
In upcoming patches we'll define a precheck function for some merge tools.
2015-10-06 22:55:21 -07:00
Siddharth Agarwal
3226585b5b filemerge: add a before-merge callback to internal merge tools
We're going to separate the pre-merge and merge steps for merge tools. The
merge step will be specific to the tool, but the pre-merge step will be common
to all merge tools that need it.

However, some merge tools run checks *before* the pre-merge step. This callback
will allow that to continue to work.
2015-10-06 22:54:14 -07:00
Siddharth Agarwal
6e9048d788 filemerge: indent filemerge.filemerge
This will make upcoming patches much easier to review.
2015-10-06 17:39:13 -07:00
Pierre-Yves David
50e5ae9a7a test-bundle-type: replace unbundle with debugbundle
We now have a convenient command to look at bundle contents, let's use
it.
2015-10-01 20:15:00 -07:00
Pierre-Yves David
63b3b90838 bundle: extract the parsing of the bundle type in a function
We are going to introduce significant extensions of the bundle parsing code to
support creation of bundle2 through the bundle command. As an early step, we
extract the logic in its own function.
2015-10-01 18:01:24 -07:00
Pierre-Yves David
52f209c327 changegroup: add version argument to getchangegroup
For some obscure reasons (probably upsetting a Greek goddess),
getchangegroup did not had a 'version' argument to control the changegroup
version. We fixes this to allow cg02 to be used with 'hg bundle' in the future.
2015-10-01 19:14:47 -07:00
Pierre-Yves David
905bd41a77 changegroup: add version argument to getlocalchangegroup
For some obscure reasons (probably upsetting a Greek goddess),
getlocalchangegroup did not have a 'version' argument to control the
changegroup version. We fix this to allow cg02 to be used with 'hg
bundle' in the future.
2015-10-01 19:14:33 -07: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
Matt Harbison
16d4ee35c6 templater: protect word() from crashing on out of range negative value
The function isn't documented to work with negative values at all, but it does,
which can be useful.  However, the range check didn't account for this.
2015-10-05 12:37:26 -04:00
Siddharth Agarwal
39cdc4468e commands: add a new debug command to print merge state
We're going to be extending the merge state very soon, and this will give us a
way to test all that.
2015-10-02 13:00:47 -07:00
Matt Mackall
e190fd19b1 Added signature for changeset f41404cf41e2 2015-10-01 12:07:20 -05:00
Siddharth Agarwal
7c5424c31f merge.mergestate: factor out code to validate v1/v2 records
We're going to need this in another place in upcoming patches.
2015-09-30 21:22:31 -07:00
Siddharth Agarwal
b91b05d624 localrepo: prevent wlock from being inherited when a transaction is running
Review feedback from Pierre-Yves David. A separate line of work is working to
ensure that dirstate writes are written to a separate 'pending' file while a
transaction is active. Lock inheritance currently conflicts with that, so dodge
the issue by simply preventing inheritance while a transaction is running.

Custom merge drivers aren't going to run inside a transaction, so this doesn't
affect that.
2015-10-06 13:19:05 -07:00