Commit Graph

11969 Commits

Author SHA1 Message Date
Mads Kiilerich
5d377a8588 cleanup: avoid local vars shadowing imports
This will mute some pyflakes "import ... shadowed by loop variable" warnings.
2014-08-15 16:20:47 +02:00
Mads Kiilerich
23da6c1d98 cleanup: avoid _ for local unused tmp variables - that is reserved for i18n
_ is usually used for i18n markup but we also used it for I-don't-care
variables.

Instead, name don't-care variables in a slightly descriptive way but use the _
prefix to designate unused variable.

This will mute some pyflakes "import '_' ... shadowed by loop variable"
warnings.
2014-08-15 16:20:47 +02:00
Yuya Nishihara
58cebc106d annotate: inline definition of decorate() functions 2014-08-15 14:33:19 +09:00
Yuya Nishihara
fa3165fc6e annotate: rewrite long short-circuit statement by if-elif-else 2014-08-15 14:29:30 +09:00
Pierre-Yves David
ff3290bfea revert: use modified information from both statuses
Using status information against the target ensures we are catching all
files with modifications that need reverting.

We still need to distinguish fresh modifications for backup purpose.

test-largefile is affected because it reverted a file that needs no content
change.
2014-06-24 17:27:18 +01:00
Pierre-Yves David
56e34a196a revert: drop special case handling for file unknown in parent
We had a special case for file not caught by any categories. It was
aimed at files missing in wc and wc's parent but existing in the target
revision. This is now properly handled using status information.
2014-06-24 16:57:16 +01:00
Pierre-Yves David
911e895e66 revert: use "remove" information from both statuses
Using status information against the target to make sure we are catching all
files that need to be re-added.

We still need to distinguish fresh removal because they use a different
message.
2014-06-24 16:53:22 +01:00
Pierre-Yves David
2cc3d88c5b revert: process removed files missing in target as clean
If a file does not exist in target and is marked as removed in the dirstate, we
can mark it as clean. There are no changes needed to revert it.
2014-08-01 18:27:47 -07:00
Pierre-Yves David
708550e527 revert: also track clean files
Tracking clean files is the simplest way to be able to reports files that need
no changes. So we explicitly retrieve them.

This fixes a couple of test outputs where the lack of changes was not reported.
2014-07-31 15:52:56 -07:00
Pierre-Yves David
df2c9033ac revert: triage "deleted" files into more appropriate categories
Status can return file as "deleted". This is only a special case
related to working directory state: file is recorded as tracked but no
file exists on disk. This will never be a state obtainable from
manifest comparisons.

"Deleted" files have another working directory status shadowed by the lack of
file. They will -alway- be touched by revert. The "lack of file" can be seen as
a modification. The file will never match the same "content" as in the revert
target. From there we have two options:

1. The file exists in the target and can be seen as "modified".
2. The file does not exist in the target and can be seen as "added".

So now we just dispatch elements from delete into appropriate categories.
2014-08-01 18:57:53 -07:00
Matt Mackall
7a0d67564b repoview: fix try/except/finally for py2.4 2014-08-14 16:39:02 -05:00
Matt Mackall
57de8037d2 merge with stable 2014-08-14 16:25:47 -05:00
Yuya Nishihara
ea70238e6f alias: exit from bad definition by Abort 2014-08-13 22:22:24 +09:00
Yuya Nishihara
2d19d347a0 alias: show one-line hint for command provided by disabled extension
It will be a hint of Abort exception.  "hg help <alias>" provides the detailed
version as before.
2014-08-13 22:18:28 +09:00
Yuya Nishihara
5ffa20b315 help: provide help of bad alias without executing aliascmd()
The output is slightly changed because of minirst formatting.  Previously,
ui.pushbuffer() had no effect because "badalias" message was written to stderr.

"if not unknowncmd" should no longer be needed because there's no call loop.
2014-08-13 19:38:47 +09:00
Yuya Nishihara
02fa6ed1f7 alias: provide "unknowncmd" flag to tell help to look for disabled command
This patch prepares for breaking the call loop: help.help_() -> cmdalias() ->
commands.help_() -> help.help_().
2014-08-13 19:28:42 +09:00
Yuya Nishihara
9f46c8b964 alias: keep error message in "badalias" so that help can see it
Upcoming patches will

 - change help_() to get badalias message without executing cmdalias()
 - raise Abort on bad alias
2014-05-17 21:13:31 +09:00
Siddharth Agarwal
4b5c9f694a alias: expand "$@" as list of parameters quoted individually (BC) (issue4200)
Before this patch, there was no way to pass in all the positional parameters as
separate words down to another command.

(1) $@ (without quotes) would expand to all the parameters separated by a space.
    This would work fine for arguments without spaces, but arguments with spaces
    in them would be split up by POSIX shells into separate words.
(2) '$@' (in single quotes) would expand to all the parameters within a pair of
    single quotes. POSIX shells would then treat the entire list of arguments
    as one word.
(3) "$@" (in double quotes) would expand similarly to (2).

With this patch, we expand "$@" (in double quotes) as all positional
parameters, quoted individually with util.shellquote, and separated by spaces.
Under standard field-splitting conditions, POSIX shells will tokenize each
argument into exactly one word.

This is a backwards-incompatible change, but the old behavior was arguably a
bug: Bourne-derived shells have expanded "$@" as a tokenized list of positional
parameters for a very long time. I could find this behavior specified in IEEE
Std 1003.1-2001, and this probably goes back to much further before that.
2014-08-13 23:21:52 -07:00
Pierre-Yves David
5b7e70a4d0 revert: issue "no changes needed" message for files missing on both side
When a file was marked as removed in the working copy and did not existed in the
target of the revert, we did not issued any message pointing that no change was
needed to the file (implicitly saying that revert had changed the file).

We now properly issue a message in this situation. Tests change in and handful
of case where the message was documented as missing.
2014-07-31 16:03:26 -07:00
Pierre-Yves David
b18e801dd3 revert: call status against revert target too
We now call status against the target (and possibly against the working
directory parent is different). We do not use the information from the two
sources yet, but this is coming soon.

We need the status information aganst the dirstate in all case because we need
to be able to backup local modification.
2014-06-24 15:47:12 +01:00
Pierre-Yves David
b263ff2b09 revert: prefix variable names for dirstate status with "ds"
As we are going to introduce status again other revision we needs to distinguish
between data from dirstate status and the other one. We prefix the existing data
with "ds" to highlight this.
2014-06-24 15:35:43 +01:00
Pierre-Yves David
50ccb74146 revert: move manifest membership condition outside of the loop
Currently, revset is using information from dirstate status and alter its
behavior whenever the file exist in the target manifest or not. This tests are
done a big for loop. We move this member ship testing outside of the loop and
simplifies associates data structure.

This is a step toward a cleaner implementation of revert based on status.
2014-06-24 15:28:22 +01:00
David Soria Parra
698eea6e2b repoview: cache hidden changesets
Use the introduced caching infrastructure to cache hidden
changesets. We crosscheck if the content of the cache unless
experimental.verifyhiddencache is set to False. This will be removed
in the future. Without crosschecking the caches speed ups hg status and
other commands:

without caching:
$ time hg status
hg status  0.72s user 0.20s system 100% cpu 0.917 total

with caching
$ time hg status
hg status  0.49s user 0.15s system 100% cpu 0.645 total
2014-08-12 09:39:14 -07:00
David Soria Parra
75f779a75d repoview: add caching bits
Add a caching infrastructure to cache hidden changesets. The cache tries to read
the cache lazily and falls back to recomputing if no wlock can be obtain.
To validate the cache we store a sha of the obstore content and repo heads in
the beginning of the cache which we check every request.
2014-08-12 16:48:54 -07:00
David Soria Parra
c878b027dc repoview: split _gethiddenblockers
Split up _gethiddenblockers into two categories: (1) "static' blockers
that solely rely on the contents of obstore and are visible children of
hidden changsets. (2) "dynamic" blockers, appearing by having wd parents,
bookmarks or tags pointing to hidden changesets.

We assume that (1) doesn't change often and can be easily cached with a good
invalidation strategy. (2) change often, but barely produce blockers, so we
can recompute them if necessary.
2014-08-06 13:26:04 -07:00
David Soria Parra
70d1fce0ac repoview: use set for blockers
Blockers should be unique but tags and bookmarks could point to the same rev,
therefore use a set to ensure that we don't have duplicates.
2014-08-12 16:42:24 -07:00
Matt Mackall
390a8e52ce merge with stable 2014-08-12 04:50:58 -05:00
Matt Mackall
d2e240d48e help: normalize helplist hints 2014-08-12 04:11:32 -05:00
Matt Mackall
68762ac0d2 help: fold repeatable option message into option table header
This will hopefully conserve some limited user attention.
2014-08-12 04:00:42 -05:00
Matt Mackall
0ba980d3fa help: roll option list header into option formatter 2014-08-12 03:53:33 -05:00
Matt Mackall
ddad209d92 help: refactor helplist optlist mess
No output changes
2014-08-12 03:42:09 -05:00
Matt Mackall
fef3609a90 help: normalize topic and extension verbose hints 2014-08-12 03:25:51 -05:00
Matt Mackall
e6f86f6aa5 help: normalize hint about enabling extensions 2014-08-12 03:18:50 -05:00
Matt Mackall
c6e73a8a42 help: normalize extension shadow hint 2014-08-12 03:12:24 -05:00
Matt Mackall
106c32f507 help: improve command summary hint
This adds our normal hint parentheses, corrects the command syntax
(consider config), and corrects the fullness of help you'll get.
2014-08-12 03:09:26 -05:00
Matt Mackall
540b8eb745 help: tweak --verbose command help hint
We used to have two slightly different message which people wouldn't read...
and then complain that they couldn't find the global options or examples.

So we unify them into one message that's upfront that STUFF IS
INTENTIONALLY HIDDEN and that looks more like our normal hint style.
2014-08-12 03:01:37 -05:00
Matt Mackall
3326a5431e merge with stable 2014-08-11 11:24:05 -05:00
Matt Mackall
93db32d337 merge with stable 2014-08-10 14:30:30 -05:00
Pierre-Yves David
db81cffcdc phase: attach phase to the transaction instead of the lock
The phase cache file is no longer written on lock release, it is now handled by
the transaction (as changesets and obsolescence markers are).

(Hooray)

As we stop relying on the lock to write phase, repos with no existing phase
information will need to wait for a phase move or a strip to happen in order to
get the first write in the `phaseroots` file. This explain the change in
test-inherit-mode.t.

This should not have any side effects but in very obscure cases where
people interact with pre-2.1 and post-2.1 versions of Mercurial on the
same repo while having MQ patches applied but the MQ extension
disabled from time to time. A case unlikely enough to not be worth
preserving the old behavior with awful hacks.
2014-08-07 14:11:36 -07:00
Pierre-Yves David
60e760ea53 phase: extract the phaseroots serialization in a dedicated method
In most case, the file creation logic will be handled by the
transaction itself. The write method has to stay around for the case
where the repository is modified outside a transaction (strip).
2014-08-07 14:41:00 -07:00
Pierre-Yves David
3f8b890149 transaction: add a file generation mechanism
A new `transaction.addfilegenerator` function is added. It allows external code
to register files to be generated. See inline documentation for details.

It is important to gather all file creation logic on the transaction
as at some point we'll want to mimic the "pre-transaction-commit"
logic that we use for revlog. I'm refering to the logic that lets
hooks see the result of the transaction before it actually gets
committed.
2014-08-07 14:40:02 -07:00
Pierre-Yves David
98693f71e9 transaction: backup file in a dedicated "namespace"
File backup may conflict with other "journal.*" file. We add a fixed part in the
backup name file to prevent it.
2014-08-07 10:54:17 -07:00
Pierre-Yves David
c81f99d5f9 transaction: use self.journal to create backup file
Transaction journal name is "journal" in most case, but it can be something else.
We use the appropriate attribute to create the file.
2014-08-07 11:56:32 -07:00
Sean Farley
2c7a940b62 memctx: add note about p2 2014-06-17 20:55:06 -07:00
Sean Farley
f810468c76 memfilectx: add remove and write methods
Similar to the previous patch for workingfilectx, this patch will allow
abstracting localrepo.remove / write method to refactor working directory code
but instead operate on files in memory.
2014-07-25 20:20:26 -05:00
Sean Farley
a94ef7041a workingfilectx: add remove and write methods
This patch will allow abstracting localrepo.remove / write method to refactor
working directory code.
2014-07-02 14:01:01 -05:00
Sean Farley
2909941bb0 memctx: create a filectxfn if it is not callable
This will allow future patches to construct a memctx based on another context
or any other store-type object.
2014-07-25 19:36:01 -05: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
aaed9a0813 pull: pre-filter remote phases before moving local ones
We were relying on the phase internals to filter out redundant phase
information from remove. However as we plan to integrate phase
movement inside the transaction, we want to avoid useless transaction
creation on no-op pulls.

Therefore we filter out all the information that already matches the current
repository state. This will let us create a transaction only when there is
actual phase movement needed.
2014-08-06 00:54:37 -07:00
Matt Mackall
7cba48bf37 whitespace: nuke triple blank lines in **.py 2014-08-07 14:58:12 -05:00
Jordi Gutiérrez Hermoso
465e05be10 strip: remove -b/--backup codepaths
cset 21b4faf3787e has removed this option. This commit just tidies the
code that was associated to it. It also fixes the internal calls to
the strip() function.

Before this change, any function that thought it would want as a final
safety to keep a partial backup bundle (bundling changes not linearly
related to the current change being stripped), had to explicitly pass
a backup="strip" option. With this change, these backups are always
kept in case of an exception and always removed if there is no
exception. Only full backups can be specified with backup=True or no
full backups with backup=False.
2014-07-24 15:06:08 -04:00
Jordi Gutiérrez Hermoso
0ee68cc094 simplemerge: remove dead code
The following functions in simplemerge are dead code. I reran "make
test-merge*" after this change, and it passed. Looks like cruft that
we've been carrying since we nabbed this code from bzr.
2014-08-07 12:51:45 -04:00
Sean Farley
a9b7ae9555 basectx: add missing, merge, and branch args to dirty method
This fixes a discrepency for basectx and classes that inherit from it. Now
callers can pass these arguments to any context without an exception being
raised.
2014-06-17 20:26:51 -07:00
Sean Farley
760faddb4c basefilectx: move isexec and islink from memfilectx
This will be used in the future for creating memctx objects from other
store-type objects, such as a patch store or even another context.
2014-07-25 20:11:47 -05:00
Pierre-Yves David
4d38b093fd pushkey: wrap pushkey phase movement in a transaction
Phases are not yet inside the transaction, but we need to prepare for it. So we
wrap the phase movement inside a transaction.
2014-08-06 00:54:58 -07:00
Pierre-Yves David
322ec1b757 push: wrap local phase movement in a transaction
Phases are not yet inside the transaction, but we need to prepare for it. So we
wrap the phase movement inside a transaction.
2014-08-06 00:54:15 -07:00
Pierre-Yves David
f2b6946a89 phase: wrap hg phases phase movement in a transaction
Phases are not yet inside the transaction, but we need to prepare for it. So we
wrap the phase movement inside a transaction.
2014-08-06 00:50:53 -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
Pierre-Yves David
7e05742434 commit: update the --secret code to use backupconfig and restoreconfig
Those dedicated methods also preserve all associated data (eg:
sources, lack of value).
2014-08-05 18:53:05 -07:00
Pierre-Yves David
c79537766d config: fix restoreconfig of non existing config
When the section, but no value existed, the `del` call raised a key error.
2014-08-05 21:16:24 -07:00
Pierre-Yves David
cc9f66eab2 push: use stepsdone for obsmarkers push
We do not have infrastructure to include obsolescence markers in the bundle2
push from core. But extensions may so we make sure it would not be sent twice.
2014-07-31 13:51:17 -07:00
Pierre-Yves David
8ac50232a0 push: introduce a discovery step for obsmarker
The discovery step is still not doing anything smart. But this will allow
extension to wrap it.
2014-07-05 19:32:20 +02:00
Pierre-Yves David
1a0b1222c5 push: move the list of obsmarker to push into the push operation
The list is now carried in the push operation, this will let
extensions override it.
2014-07-05 19:17:09 +02:00
Pierre-Yves David
c3d4f292a8 push: explicitly encode a list of obsmarkers to push
Sending obsmarkers through pushkey requires extra encoding (since pushkey can't
take binary content) and slicing (since we can hit http header limit). As we
send all obsolescences markers that exists in the repo for each push, we used to
just look at the content of the "obsolete" pushkey namespace (already encoded
and sliced) and send its
content.

However, future changeset will make it possible to push only parts of the
obsmarkers. To prepare this we now explicitly encode a list of markers. The list
of markers is still "all of them" but future changeset will takes care
of that.

The new code uses a "_protected" method but that seems reasonable to keep it
private as this is the is the only external user of it and this whole pushing
obsmarker through pushkey things in fairly hacky already)
2014-07-04 19:31:49 +02:00
Pierre-Yves David
bbc45b832a merge-tools: add a premerge=keep-merge3 config option
This value leaves premerge markers that includes the merge base too. This is a
the same as what `internal:merge3` would do.
2014-08-04 16:32:41 -07:00
Pierre-Yves David
eab8e275dd merge-tools: make premerge valid values extensible
We want to introduce a version leaving merge3 style markers.
2014-08-04 16:58:39 -07:00
Pierre-Yves David
16c46d5926 merge: add an internal:merge3 tool
This variant gives access to a feature already present in ``internal:merge``:
displaying merge base content.

In the basic merge (calling ``hg merge``) case, including more context to the
merge markers is an interesting addition.

But this extra information is the only viable option in case conflict from
grafting (, rebase, etc…).

When grafting ``source`` on ``destination``, the parent of ``source`` is
used as the ``base``. When all three changesets add content in the same
location, the marker for ``source`` will contains both ``base`` and ``source``
content. Without the content of base exposed, there is no way for the user
to discriminate content coming from ``base`` and content commit from ``source``.

Practical example (all addition are in the same place):

* ``destination`` adds ``Dest-Content``
* ``base``        adds ``Base-Content``
* ``source``      adds ``Src-Content``

Grafting ``source`` on ``destination`` will produce the following conflict:

  <<<<<<< destination
  Dest-Content
  =======
  Base-Content
  Src-Content
  >>>>>>> source

This that case there is no way to distinct ``base`` from ``source``. As a result
content from ``base`` are likely to slip in the resolution result.

However, adding the base make the situation very clear:

  <<<<<<< destination
  Dest-Content
  ||||||| base
  Base-Content
  ======= base
  Base-Content
  Src-Content
  >>>>>>> source

Once the base is added, the addition from the grafted changeset is made clear.
User can compare the content from ``base`` and ``source`` to make an enlightened
decision during merge resolution.
2014-08-05 14:58:45 -07:00
Pierre-Yves David
0ddace5f8c internal:merge: update documentation
Highlight the fact there are two regions in the markers and what their contents
are. This prepares for the arrival of merge3.
2014-08-05 15:09:54 -07:00
Pierre-Yves David
6120cff637 filemerge: allow the formatting of three labels instead of two
When a third label is provided (to included the base content) it is properly
processed as the two others. Nothing changes if only two labels are provided.
2014-08-05 15:17:38 -07:00
Pierre-Yves David
2fc8f16378 filemerge: drop extra white space
There should be no white space around the brace.
2014-08-05 15:12:22 -07:00
Pierre-Yves David
72d8ebecb8 simplemerge: support three labels when merging
If a third label is provided it will be used for the "base" content:

  <<<<<<< local
  content
  from
  local
  ||||||| base
  former
  common
  =======
  other
  conflicting
  >>>>>>> other
2014-08-05 15:10:50 -07:00
Pierre-Yves David
2017698ec4 simplemerge: burn "minimal" feature to the ground
Matt Mackall said:

  The goal of simplemerge should have always been to be a drop-in
  replacement for RCS merge. Please nuke this minimization thing entirely.

This whole things is now dead.
2014-08-05 14:56:25 -07:00
Pierre-Yves David
0fe23d7392 merge: use no-minimal for premerge too
fade484cb8f6 disabled minimal for `internal:merge` but forgot to also disabled
it for premerge. This is now done.

This gives me an occasion to shamelessly includes my explanation of why this
minimisation feature must disappear:

[this is why it's pointless to reject patches with misspellings in the
description - mpm]

Detailled explanation
=====================


The ``simplemerge`` code use in ``internal:merge`` has a feature called
"minimization". It reprocess conflicting chunks to find common changes
inside them and excludes such common sections from the marker.

This approach seems a significant win at first glance but produces very
confusing results in some other cases.

Simple example
--------------

A simple example is enough to show the benefit of this feature.  In this merge,
both sides change all numbers from letters to digits, but one side is also
changing some values.

  $ cat << EOF > base
  > Small Mathematical Series.
  > One
  > Two
  > Three
  > Four
  > Five
  > Hop we are done.
  > EOF

  $ cat << EOF > local
  > Small Mathematical Series.
  > 1
  > 2
  > 3
  > 4
  > 5
  > Hop we are done.
  > EOF

  $ cat << EOF > other
  > Small Mathematical Series.
  > 1
  > 2
  > 3
  > 6
  > 8
  > Hop we are done.
  > EOF

In the minimalists case, the markers focus on the disagreement between the two
sides.

  $ $TESTDIR/../contrib/simplemerge --print local base other
  Small Mathematical Series.
  1
  2
  3
  <<<<<<< local
  4
  5
  =======
  6
  8
  >>>>>>> other
  Hop we are done.
  warning: conflicts during merge.
  [1]

In the non minimalist case, the whole chunk is included in the conflict marker.
Making it harder spot actual differences.

  $ $TESTDIR/../contrib/simplemerge --print --no-minimal local base other
  Small Mathematical Series.
  <<<<<<< local
  1
  2
  3
  4
  5
  =======
  1
  2
  3
  6
  8
  >>>>>>> other
  Hop we are done.
  warning: conflicts during merge.
  [1]

Practical Advantages of minimalisation: merge of grafted change
---------------------------------------------------------------

This feature can be very useful when a change have been grafted in another
branch and then some change have been made to the grafted code.

  $ cat << EOF > base
  > # empty file
  > EOF

  $ cat << EOF > local
  > def somefunction(one, two):
  >     some = one
  >     stuff = two
  >     are(happening)
  >     here()
  > EOF

  $ cat << EOF > other
  > def somefunction(one, two):
  >     some = one
  >     change = two
  >     are(happening)
  >     here()
  > EOF

The minimalist case recognises the grafted content as similar and highlight the
actual change.


  $ $TESTDIR/../contrib/simplemerge --print local base other
  def somefunction(one, two):
      some = one
  <<<<<<< local
      stuff = two
  =======
      change = two
  >>>>>>> other
      are(happening)
      here()
  warning: conflicts during merge.
  [1]

Again, the non-minimalist case produces a larger conflict. Making it harder to
spot the actual conflict.

  $ $TESTDIR/../contrib/simplemerge --print --no-minimal local base other
  <<<<<<< local
  def somefunction(one, two):
      some = one
      stuff = two
      are(happening)
      here()
  =======
  def somefunction(one, two):
      some = one
      change = two
      are(happening)
      here()
  >>>>>>> other
  warning: conflicts during merge.
  [1]


Practical disadvantage: multiple functions on each side
---------------------------------------------------------------

So, if this "minimalist" help so much, why introduce a setting to disable it?

The issue is that this minimisation will grab any common lines for breaking
chunks. This may result in partial context when solving a merge. The most
simple example is a merge where both side added some (different) functions
separated by blank lines. The "minimalist" approach will recognise the blank
line as "common" and over slice the chunks, turning a simple conflict case into
multiple pairs of conflicting functions.

  $ cat << EOF > base
  > # empty file
  > EOF

  $ cat << EOF > local
  > def function1():
  >     bla()
  >     bla()
  >     bla()
  >
  > def function2():
  >     ble()
  >     ble()
  >     ble()
  > EOF

  $ cat << EOF > other
  > def function3():
  >     bli()
  >     bli()
  >     bli()
  >
  > def function4():
  >     blo()
  >     blo()
  >     blo()
  > EOF

The minimal case presents each function as a separated context.

  $ $TESTDIR/../contrib/simplemerge --print local base other
  <<<<<<< local
  def function1():
      bla()
      bla()
      bla()
  =======
  def function3():
      bli()
      bli()
      bli()
  >>>>>>> other

  <<<<<<< local
  def function2():
      ble()
      ble()
      ble()
  =======
  def function4():
      blo()
      blo()
      blo()
  >>>>>>> other
  warning: conflicts during merge.
  [1]

The non-minimalist approach produces a simpler version with more context in
each block. Solving such conflicts is usually as simple as dropping the 3 lines
dedicated to markers.

  $ $TESTDIR/../contrib/simplemerge --prin --no-minimal local base other
  <<<<<<< local
  def function1():
      bla()
      bla()
      bla()

  def function2():
      ble()
      ble()
      ble()
  =======
  def function3():
      bli()
      bli()
      bli()

  def function4():
      blo()
      blo()
      blo()
  >>>>>>> other
  warning: conflicts during merge.
  [1]

Practical disaster: programing language have a lot of common line
=================================================================

If only blank lines between function where the only frequent content of a code
file. But programming language tend to repeat them self much more often. In that
case, the minimalist approach turns a simple conflict into a massive mess.

Consider this example where two unrelated functions are added on each side.
Those function shares common programming constructs by chance.

  $ cat << EOF > base
  > # empty file
  > EOF

  $ cat << EOF > local
  > def longfunction():
  >     if bla:
  >        foo
  >     else:
  >        bar
  >     try:
  >        ret = some stuff
  >     except Exception:
  >        ret = None
  >     if ret is not None:
  >         return ret
  >     return 0
  >
  > def shortfunction(foo):
  >     goo()
  >     ret = foo + 5
  >     return ret
  > EOF

  $ cat << EOF > other
  > def otherlongfunction():
  >     for x in xxx:
  >        if coin:
  >            break
  >        tutu
  >     else:
  >        bar()
  >     baz()
  >     ret = week()
  >     try:
  >        groumpf = tutu
  >        fool()
  >     except Exception:
  >        zoo()
  >     pool()
  >     if cond:
  >         return ret
  >
  >     # some big block
  >     ret ** 6
  >     koin()
  >     return ret
  > EOF

The minimalist approach will hash the whole conflict into small chunks that
does not match any meaningful semantic and are impossible to solve.

  $ $TESTDIR/../contrib/simplemerge --print local base other
  <<<<<<< local
  def longfunction():
      if bla:
         foo
  =======
  def otherlongfunction():
      for x in xxx:
         if coin:
             break
         tutu
  >>>>>>> other
      else:
  <<<<<<< local
         bar
  =======
         bar()
      baz()
      ret = week()
  >>>>>>> other
      try:
  <<<<<<< local
         ret = some stuff
  =======
         groumpf = tutu
         fool()
  >>>>>>> other
      except Exception:
  <<<<<<< local
         ret = None
      if ret is not None:
  =======
         zoo()
      pool()
      if cond:
  >>>>>>> other
          return ret
  <<<<<<< local
      return 0
  =======
  >>>>>>> other

  <<<<<<< local
  def shortfunction(foo):
      goo()
      ret = foo + 5
  =======
      # some big block
      ret ** 6
      koin()
  >>>>>>> other
      return ret
  warning: conflicts during merge.
  [1]

The non minimalist approach will properly produce a single set of conflict
markers. Highlighting that the two chunk are unrelated. Such conflict from
unrelated content added at the same place is usually solved by dropping the
marker an keeping both content. Something impossible with minimised markers.


  $ $TESTDIR/../contrib/simplemerge --prin --no-minimal local base other
  <<<<<<< local
  def longfunction():
      if bla:
         foo
      else:
         bar
      try:
         ret = some stuff
      except Exception:
         ret = None
      if ret is not None:
          return ret
      return 0

  def shortfunction(foo):
      goo()
      ret = foo + 5
      return ret
  =======
  def otherlongfunction():
      for x in xxx:
         if coin:
             break
         tutu
      else:
         bar()
      baz()
      ret = week()
      try:
         groumpf = tutu
         fool()
      except Exception:
         zoo()
      pool()
      if cond:
          return ret

      # some big block
      ret ** 6
      koin()
      return ret
  >>>>>>> other
  warning: conflicts during merge.
  [1]
2014-07-29 11:55:01 -07:00
Pierre-Yves David
b9d14448be merge: refactor labels selection code
The code is simplified to prepare the future introduction of a third labels for
the merge base.
2014-06-09 23:37:36 -07:00
Pierre-Yves David
4d68940dba push: include phase push in the unified bundle2 push
Phase push is now included in the same bundle2 push as changesets. We use
multiple pushkey parts to transmit the information. Note that phase moves are
still not part of the repository "transaction".
2014-07-01 23:08:17 +02:00
Pierre-Yves David
bee675a073 push: perform phases discovery before the push
This will allow including phase information in the same bundle2 as the
changesets.
2014-07-30 19:26:47 -07:00
Pierre-Yves David
ce9f85e2a8 push: make discovery extensible
We need to gather all discovery before the unified bundle2 push. We
use the same pattern as bundle2 parts generation.
2014-07-01 17:06:02 +02:00
Pierre-Yves David
421f86b4d6 push: rework the bundle2partsgenerators logic
Instead of a single list of functions, we now have a list of names and
a mapping of names to functions. This simplifies wrapping of steps
from extensions. In the same move, declaration becomes decorator-based
(syntax sugar, nom nom nom!).
2014-07-30 19:04:50 -07:00
Pierre-Yves David
77a2e846ed push: move common heads computation into pushop
Now that both options (push succeed or fall back) live in pushop, we
can move the common heads computation there too. It is a very commonly
accessed attribute so it makes a lot of sense to have it in pushop.
2014-07-01 17:27:22 +02:00
Pierre-Yves David
95a8ba3038 push: extract fallback heads computation into pushop
Similar motivation to `futureheads`, we extract the computation into pushop
to make it available early to all possibly interested parties.
2014-07-01 17:20:47 +02:00
Pierre-Yves David
b3209a1336 push: extract future heads computation into pushop
Bundle2 will allow pushing all different parts of the push in a single bundle.
This mean that the discovery for each part needs to be done before trying to
push. Currently we may have different behaviors for phases and obsolescence markers
when the push of changesets fails. For example, information may still be
exchanged for a part of the history where changesets are common but where
phases mismatch. So the preparation of the push need to determine what
information need to be pushed in both situations. And it needs a different set of
heads for this. Therefore we are moving heads computation within pushop for easy
access by all parties. We start with the simplest set of heads.
2014-07-01 17:20:31 +02:00
FUJIWARA Katsunori
28e199eab5 cmdutil: use '[committemplate]' section like as map file for style definition
Before this patch, each template definitions for 'changeset*' in
'[committemplate]' section have to be written fully from scratch,
even though many parts of them may be common.

This patch uses '[committemplate]' section like as the map file for
the style definition. All items other than 'changeset' can be referred
from others.

This can reduce total cost of template customization in
 '[committemplate]' section.

When the commit template other than '[committemplate] changeset'
is chosen by 'editform', putting '[committemplate] changeset'
value into the cache of the templater causes unexpected result,
because the templater stores the specified (= chosen) template
definition into own cache as 'changeset' at construction time.

This is the reason why '[committemplate] changeset' can't be referred
from others.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
ec97822d35 cmdutil: look commit template definition up by specified 'editform'
Before this patch, '[committemplate] changeset' definition is shared
between all actions invoking 'commitforceeditor()'.

This prevents template definition from showing action specific
messages: for example, 'hg tag --remove' may need specific
message to call attention, but showing it may be redundant for
other actions.

This patch looks commit template definition up by specified
'editform' introduced by prior patches. 'editform' are
dot-separated list of names, and treated as hierarchical one.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
7b50947677 import: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  COMMAND[.ROUTE]

  - ROUTE: name of route, if there are two or more routes in COMMAND

In this patch, 'normal' and 'bypass' are used as ROUTE.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
4de8382c53 commit: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  COMMAND[.ROUTE]

  - ROUTE: name of route, if there are two or more routes in COMMAND

In this patch, 'normal' and 'amend' are used as ROUTE.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
69635163b7 tag: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  COMMAND[.ROUTE]

  - ROUTE: name of route, if there are two or more routes in COMMAND

In this patch, 'add' and 'remove' are used as ROUTE
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
c911495421 graft: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  COMMAND[.ROUTE]

  - ROUTE: name of route, if there are two or more routes in COMMAND

In this patch, ROUTE is omitted.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
70a66564d9 backout: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  COMMAND[.ROUTE]

  - ROUTE: name of route, if there are two or more routes in COMMAND

In this patch, ROUTE is omitted..
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
83c808bc5a cmdutil: introduce 'editform' to distinguish the purpose of commit text editing
This information will be used to switch '[committemplate] changeset'
definition according to its purpose in the subsequent patch.

This information also makes it easier to hook commit text editing only
in the specific cases.
2014-08-02 21:46:26 +09:00
Durham Goode
4bf8cd87a5 log: allow patterns with -f
It's not uncommon for a user to want to run log with a pattern or directory name
on the history of their current commit.  Currently we prevent that, but
I can't think of any reason to continue blocking that.

This commit removes the restriction and allows 'hg log -f <dir/pat>'
2014-07-22 22:40:16 -07:00
Matt Mackall
fbb6a8c166 merge with stable 2014-08-04 14:32:34 -05:00
Pierre-Yves David
3d5f179a17 getbundle: add a `cg` boolean argument to control changegroup inclusion
The ``getbundle`` function was initially design to return a changegroup bundle.
However, bundle2 allows transmitting a wide range of data. Some bundle2
requests may not include a changegroup at all.

Before this changeset, the client would request a changegroup for
``heads=[nullid]`` and receive an empty changegroup.

We introduce an official boolean parameter, ``cg``, that can be set
to false to disable changegroup generation on getbundle. A new bundle2
capability is introduced to let the client know.
2014-05-31 16:48:29 -07:00
Pierre-Yves David
18d1ed009e wireproto: add a `boolean` type for getbundle parameters
This will be used to control inclusion of some parts in a bundle2.
2014-05-22 17:20:52 -07:00
Yuya Nishihara
cc6b6f4d1b i18n: detect UI language without POSIX-style locale variable on Windows (BC)
On Windows, it isn't common to set LANG environment variable. This patch makes
gettext honor Windows-style UI language [1] if no locale variables are set.

Because of this change, LANG=C or HGPLAIN must be set in order to disable
translation on non-English Windows.

 [1]: http://msdn.microsoft.com/en-us/library/dd374098(v=VS.85).aspx
2014-08-03 19:19:23 +09:00
Siddharth Agarwal
670a39c654 locate: use ctx.matches instead of ctx.walk
On mozilla-central, which is around 100,000 files, best of 5:

$ hg --time locate > /dev/null
before: real 1.460 secs (user 1.140+0.000 sys 0.320+0.000)
after:  real 0.620 secs (user 0.610+0.000 sys 0.020+0.000)

$ hg --time locate README > /dev/null
before: real 0.630 secs (user 0.330+0.000 sys 0.290+0.000)
after:  real 0.120 secs (user 0.110+0.000 sys 0.020+0.000)

Larger repositories see correspondingly larger performance gains.
2014-08-01 22:16:54 -07:00
Siddharth Agarwal
8d983aad7b context: add a method to efficiently filter by match if possible
For non-working contexts, walk and matches do the same thing. For working
contexts, walk stats all the files and looks for unknown files, while matches
just filters the dirstate by match.
2014-08-01 22:07:29 -07:00
Siddharth Agarwal
e621257516 dirstate: add a method to efficiently filter by match
Current callers that require just this data call workingctx.walk, which calls
dirstate.walk, which stats all the files. Even worse, workingctx.walk looks for
unknown files, significantly slowing things down, even though callers might not
be interested in them at all.
2014-08-01 22:05:16 -07:00
Siddharth Agarwal
3b1a83f9de graft: make --force apply across continues (issue3220)
Since --force determines the list of revisions to be grafted, it doesn't really
make sense for users to have to keep typing --force --continue as they continue
grafting.
2014-07-26 14:54:36 -07:00
Siddharth Agarwal
871030a1ab graft: allow regrafting ancestors with --force (issue3220) 2014-07-25 18:21:16 -07:00
Siddharth Agarwal
712df54e55 match: use util.re.escape instead of re.escape
For a pathological .hgignore with over 2500 glob lines and over 200000 calls to
re.escape, and with re2 available, this speeds up parsing the .hgignore from
0.75 seconds to 0.20 seconds. This causes e.g. 'hg status' with hgwatchman
enabled to go from 1.02 seconds to 0.47 seconds.
2014-07-15 15:34:50 -07:00
Siddharth Agarwal
2b459094e1 util.re: add an escape method
The escape method in at least one of the modules called 're2' is in C. This
means it is significantly faster than the Python code written in 're'.

An upcoming patch will have benchmarks.
2014-07-15 15:14:45 -07:00
Siddharth Agarwal
dd9e1b721a util.re: move check for re2 into a separate method
We're going to use the same check for another method in an upcoming patch.
2014-07-15 15:01:52 -07:00
Siddharth Agarwal
fe4e13633a util: remove no longer used compilere 2014-07-15 14:52:40 -07:00
Siddharth Agarwal
b33f19d949 commands: use util.re.compile instead of util.compilere 2014-07-15 14:52:22 -07:00
Siddharth Agarwal
f1a50f9fee config: use util.re.compile instead of util.compilere 2014-07-15 14:50:58 -07:00
Siddharth Agarwal
5e38818cf4 match: use util.re.compile instead of util.compilere 2014-07-15 14:49:45 -07:00
Siddharth Agarwal
d0cd5cb8c7 util: move compilere to a class
We do this to allow us to use descriptors for other related methods.

For now, util.compilere does the same thing. Upcoming patches will remove it.
2014-07-15 14:40:43 -07:00
Siddharth Agarwal
04ca7a05ee util: rename 're' to 'remod'
Upcoming patches will introduce a binding called 're'.
2014-07-15 14:35:19 -07:00
Pierre-Yves David
c58559c32a bundle2-push: drop _pushbundle2extraparts
All core user are now using the new way. We drop the old way.
2014-07-02 15:47:39 +02:00
Pierre-Yves David
1df43f3299 bundle2-push: introduce a list of part generating functions
Instead of explicitly calling a few function to generate part in the bundle, we
now have a list of all part generators. This should make it easier for
extensions to adds new part in the bundle.

This new way to extend the push deprecates the old `_pushbundle2extraparts` way.
2014-07-02 15:26:04 +02:00
Pierre-Yves David
2418b3778f bundle2-push: move changegroup push validation inside _pushb2ctx
When bundle2 push includes more than just changesets, we may have no
changegroup to push yet still have other data to push.

So we now try to performs a bundle2 push in all cases. The check for changegroup
inclusion is moved into the ``_pushb2ctx`` function in charge of creating the
changegroup part.

The bundle2 part is aborted if no actual payload part have been added to the
bundle2.
2014-07-02 12:55:09 +02:00
Pierre-Yves David
9163633b35 push: use stepsdone to control changegroup push through bundle10 or bundle20
We use the newly introduced `pushop.stepsdone` attribute to inform
older methods than changegroup have already been pushed using a newer
method.
2014-07-07 12:30:31 +02:00
Pierre-Yves David
0b263a85d2 push: add a `pushop.stepsdone` attribute
This attribute will record what steps were performed during the bundle2 push.
This will control whenever the old way push must be performed or skipped. This
will ultimately be used by changegroup, phases, obsmarkers, bookmarks and any
other kind of data ones may want to exchange even when bundle2 support is
missing.
2014-07-02 12:48:54 +02:00
Pierre-Yves David
4be695cccc bundle2: add a `bundle20.nbparts` property
This property can be used to know how much parts have been added to the bundle2.
This will be useful to check if any part have been generated for a push.
2014-07-02 16:17:54 +02:00
Pierre-Yves David
5403bb5287 bundle2-push: extract changegroup logic in its own function
We extract the creation of changegroup related parts into its own function.
This precludes the inclusion of more diverse data during the bundle2 push.

We use a closure to carry the logic that need to be perform when processing the
server reply.
2014-07-02 11:42:35 +02:00
Pierre-Yves David
3c5524525e bundle2: call _pushbundle2extraparts a bit sooner
This is the first step of a refactoring that will ease the inclusion of new part
in the bundle2 push and includes more information (like phases) in this push

We need to move the function a bit sooner to be able to group the generation of
`b2x:check:heads` and `b2x:changegroup` part in an external function. We move it
sooner to preserve parts creation order bundle2 tests rely on. At the ends of this
refactoring the `_pushbundle2extraparts` will be replaced by another mechanism
anyway.
2014-07-02 14:09:24 +02:00
FUJIWARA Katsunori
f09e7bc4c8 templatekw: add 'subrepos' keyword to show updated subrepositories
'subrepos' template keyword newly added by this patch shows updated
subrepositories.

For the compatibility with the list of subrepositories shown in the
editor at commit:

  - 'subrepos' is empty, at revisions removing '.hgsub' itself

  - 'subrepos' is calculated between the revision and the first parent
    of it, at merge revisions

To avoid silent regression, this patch also confirms "hg diff" of
".hgsubstate" and parents for each target revisions in the test.
2014-07-15 23:34:13 +09:00
FUJIWARA Katsunori
843d08c987 templatekw: add 'currentbookmark' keyword to show current bookmark easily
Before this patch, complicated template expression below is required
to show current active bookmark if it is associated with the
changeset.

    "{bookmarks % '{ifeq(bookmark, current, \"{bookmark}\")}'}"

This patch add 'currentbookmark' keyword to show current bookmark
easily.
2014-07-15 23:34:13 +09:00
Siddharth Agarwal
869ee24c8b context: extend efficient manifest filtering to when all paths are files
On a repository with over 250,000 files and 700,000 commits, this improves
cases like

hg status --rev <rev> -- <file>  # rev is not .

from 2.1 seconds to 1.4 seconds.

There is further scope for improvement here: for a single file or a small set
of files, it is probably more efficient to use filelog linkrevs when possible.
However there will always be cases where that will fail (multiple commits
pointing to the same file revision, removed files...), so this is independently
useful.
2014-07-16 14:53:03 -07:00
Siddharth Agarwal
5801040e81 revset: remove no longer used _missingancestors revset
This was undocumented.
2014-07-12 00:37:08 -07:00
Siddharth Agarwal
9ea47f6848 revset: replace _missingancestors optimization with only revset
(::a - ::b) is equivalent to only(a, b).
2014-07-12 00:31:36 -07:00
Angel Ezquerra
e362f81ce1 tags: introduce _readtaghist function
The existing _readtags function has been modified a little and renamed
_readtaghist. A new _readtaghist function has been added, which is a wrappger
around _readtaghist. Its output is the same as the old _readtaghist.

The purpose of this change is to make it possible to automatically merge tag
files. In order to do so we will need to get the line numbers for each of the
tag-node pairs on the first merge parent.

This is not used yet, but will be used on a follow up patch that will introduce
an automatic tag merge algorithm.

I performed some tests to compare the effect of this change. I used timeit to
run the test-tags.t test a 9 times with and without this patch. The results
were:

- without this patch: 3 loops, best of 3: 8.55 sec per loop
- with this patch:    3 loops, best of 3: 8.49 sec per loop

The the test was on average was slightly faster with this patch (although the
difference was probably not statistically significant).
2014-06-28 01:42:39 +02:00
FUJIWARA Katsunori
bf65909194 subrepo: ensure "close()" execution at the end of "_initrepo()"
Before this patch, "close()" for the file object opened in
"_initrepo()" may not be executed, if unexpected exception is raised,
because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of "_initrepo()" by
moving it into "finally" clause.

This patch puts configuration lines into "lines" array and write them
out at once, to narrow the scope of "try"/"finally" for review-ability.

This patch doesn't use "vfs.write()", because:

  - current "vfs.write()" implementation doesn't take "mode" argument
    to open file in "text" mode

  - writing hgrc file out in binary mode may break backward compatibility
2014-06-20 00:42:35 +09:00
FUJIWARA Katsunori
a467af4f30 subrepo: ensure "close()" execution at the end of "_cachestorehash()"
Before this patch, "close()" for the file object opened in
"_cachestorehash()" may not be executed, if unexpected exception is
raised, because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of
"_cachestorehash()" by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
7a254d1245 subrepo: ensure "close()" execution at the end of "_readstorehashcache()"
Before this patch, "close()" for the file object opened in
"_readstorehashcache()" may not be executed, if unexpected exception
is raised, because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of
"_readstorehashcache()" by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
9848086908 subrepo: ensure "close()" execution at the end of "_calcfilehash()"
Before this patch, "close()" for the file object opened in
"_calcfilehash()" may not be executed, if unexpected exception is
raised, because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of "_calcfilehash()"
by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
690c2c3f1b subrepo: ensure "lock.release()" execution at the end of "_cachestorehash()"
Before this patch, "lock.release()" for "self._repo" in
"_cachestorehash()" of "hgsubrepo" may not be executed, if unexpected
exception is raised, because it isn't executed in "finally" clause.

This patch ensures "lock.release()" execution at the end of
"_cachestorehash()" by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
05e68ce418 subrepo: ensure "lock.release()" execution at the end of "storeclean()"
Before this patch, "lock.release()" for "self._repo" in "storeclean()"
of "hgsubrepo" may not be executed, if unexpected exception is raised,
because it isn't executed in "finally" clause.

This patch ensures "lock.release()" execution at the end of
"storeclean()" by moving it into "finally" clause.

This patch chooses moving almost all lines in "storeclean()" into
"_storeclean()" instead of indenting them for "try/finally" clauses,
to keep diff simple for review-ability.
2014-06-20 00:21:19 +09:00
Siddharth Agarwal
b89cfab942 context: generate filtered manifest efficiently for exact matchers
When the matcher is exact, there's no reason to iterate over the entire
manifest. It's much more efficient to iterate over the list of files instead.

For a repository with approximately 300,000 files, this speeds up
hg log -l10 --patch --follow for a frequently modified file from 16.5 seconds
to 10.5 seconds.
2014-07-12 17:59:03 -07:00
Siddharth Agarwal
021a1bd81c manifestdict: add a new method to intersect with a set of files
This is meant to be used when the set of files is known in advance, e.g. with a
match object with no patterns.
2014-07-12 17:57:25 -07:00
Siddharth Agarwal
1fe4080620 log: use an exact matcher for --patch --follow
The arguments to log --patch --follow are expected to be exact paths.

This will be used to make manifest filtering for these cases more efficient in
upcoming patches.
2014-07-12 18:31:18 -07:00
Matt Mackall
809fa98620 merge with stable 2014-07-16 17:35:04 -05:00
Siddharth Agarwal
67dffae77b log: make --patch --follow work inside a subdirectory
Previously, the 'patch' code for hg log --patch --follow would try to resolve
patterns relative to the repository root rather than the current working
directory. Fix that by using match.files instead of pats, as done elsewhere
nearby.
2014-07-12 02:23:17 -07:00
Matt Mackall
de2b99d87c templates: escape NUL bytes in jsonescape (issue4303)
It's currently possible for various fields to contain NUL bytes, which
are disallowed in JSON.
2014-07-14 12:44:45 -05:00
Matt Mackall
5fc8526562 merge with stable 2014-07-14 18:53:03 -05:00
Siddharth Agarwal
9d5c80b2c5 log: allow revset for --follow to be lazily evaluated
It is unclear to me why evaluation was forced.

For a repository with over 700,000 commits, 'hg log -f' drops from 1.2 seconds
to 0.2 seconds.
2014-07-12 20:44:00 -07:00
Siddharth Agarwal
b06eb2e341 parsers: remove unused getintat function
Warning detected by clang.
2014-07-14 15:42:31 -07:00
Matt Mackall
5157edb3f5 revset: maintain ordering when subtracting from a baseset (issue4289) 2014-07-14 17:55:31 -05:00
FUJIWARA Katsunori
ccb0dfc103 cmdutil: separate building commit text from 'commitforceeditor'
This separation makes it easier to extend/hook building commit text
from the specified context.

This patch uses 'committext' instead of 'edittext' for names of newly
added variable and function, because the former is more purpose
specific than the latter, even though 'edittext' in 'buildcommittext'
is left as it is to reduce amount of diff.
2014-07-15 00:59:09 +09:00
Gregory Szorc
ad5c0552ce localrepo: document localrepo.hook() 2014-07-12 10:52:58 -07:00
FUJIWARA Katsunori
872be90f3b filemerge: use 'util.ellipsis' to trim custom conflict markers correctly
Before this patch, filemerge slices byte sequence directly to trim
conflict markers, but this may cause:

  - splitting at intermediate multi-byte sequence

  - incorrect calculation of column width (length of byte sequence is
    different from columns in display in many cases)

This patch uses 'util.ellipsis' to trim custom conflict markers
correctly, even if multi-byte characters are used in them.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
31bba09810 filemerge: use only the first line of the generated conflict marker for safety
Before this patch, with careless configuration (missing '|firstline'
filtering for '{desc}' keyword, for example), '[ui]
mergemarkertemplate' can make conflict markers multiple lines.

For ordinary users, advantage of allowing '[ui] mergemarkertemplate'
to generate multiple lines for customizing seems to be less than
advantage of disallowing it for safety.

This patch uses only the first line of the conflict marker generated
from '[ui] mergemarkertemplate' configuration for safety.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
b34bd803eb encoding: add 'leftside' argument into 'trim' to switch trimming side 2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
5206a6fd25 util: replace 'ellipsis' implementation by 'encoding.trim'
Before this patch, 'util.ellipsis' tried to avoid splitting at
intermediate multi-byte sequence, but its implementation was incorrect.

Internal function '_ellipsis' trims specified unicode sequence not at
most maxlength 'columns in display', but at most maxlength number of
'unicode characters'.

    def _ellipsis(text, maxlength):
        if len(text) <= maxlength:
            return text, False
        else:
            return "%s..." % (text[:maxlength - 3]), True

In many encodings, number of unicode characters can be different from
columns in display.

This patch replaces 'ellipsis' implementation by 'encoding.trim',
which can trim string at most maxlength columns in display correctly,
even though specified string contains multi-byte characters.

'_ellipsis' is removed in this patch, because it is referred only from
'ellipsis'.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
71717db270 encoding: add 'trim' to trim multi-byte characters at most specified columns
Newly added 'trim' is used to trim multi-byte characters at most
specified columns correctly: directly slicing byte sequence should be
replaced with 'encoding.trim', because the former may split at
intermediate multi-byte sequence.

Slicing unicode sequence ('uslice') and concatenation with ellipsis
('concat') are defined as function, to make enhancement in subsequent
patch easier.
2014-07-06 02:56:41 +09:00
Matt Mackall
ffa85c3a41 bookmarks: avoid deleting primary bookmarks on rebase
Prior to this, doing "hg rebase -s @foo -d @" would delete @, which is
obviously wrong: a primary bookmark should never be automatically deleted.

This change blocks the deletion, but doesn't yet properly clean up the
divergence: @ should replace @foo.
2014-07-08 14:45:55 -05:00
Augie Fackler
23d3b7a1e7 cmdutil: add copy-filtering support to duplicatecopies
In order to fix issue 4192 we need to be able to skip some copies
while doing duplicatecopies.
2014-06-07 15:14:36 -04:00
Angel Ezquerra
870dfdf91c repoview: do not crash when localtags refers to non existing revisions
This fixes a crash that may happen when using mercurial 3.0.x.

The _gethiddenblockers function assumed that the output of tags.readlocaltags()
was a dict mapping tags to of valid nodes. However this was not necessarily the
case. When a repository had obsolete revisions and had local tag pointing to a
non existing revision was found, many mercurial commands would crash.

This revision fixes the problem by removing any tags from the output of
tags.readlocaltags() which point to invalid nodes.

We may want to add a warning when this happens (although it might be
annoying to get that warning for every command, possibly even more than once per
command).

A test for this problem has been added to test-obsolete.t. Without this fix the
test would output:

  $ hg tags
  abort: 00changelog.i@3816541e5485: no node!
  [255]

Instead of:

  $ hg tags
  tiptag                             2:3816541e5485
  tip                                2:3816541e5485
  visible                            0:193e9254ce7e
2014-06-29 13:52:35 +02:00
Siddharth Agarwal
1aa951751f match: make glob '**/' match the empty string
Previously, a glob pattern of the form 'foo/**/bar' would match 'foo/a/bar' but
not 'foo/bar'. That was because the '**' in 'foo/**/bar' would be translated to
'.*', making the final regex pattern 'foo/.*/bar'. That pattern doesn't match
the string 'foo/bar'.

This is a bug because the '**/' glob matches the empty string in standard Unix
shells like bash and zsh.

Fix that by making the ending '/' optional if an empty string can be matched.
2014-06-25 14:50:48 -07:00
Matt Mackall
831df5027c push: restore contents of HG_URL for hooks (issue4268) 2014-06-18 19:46:18 -05:00
Matt Mackall
0257c423ac hgweb: avoid initialization race (issue4280) 2014-06-16 13:30:46 -05:00
Matt Mackall
dad18b6446 revlog: fix check-code error 2014-06-14 11:49:02 -05:00
Matt Mackall
6faaeed973 revlog: hold a private reference to self._cache
This keeps other threads from modifying self._cache out from under us.
With this and the previous fix, 'hg serve' survives 100k hits with siege.
2014-06-13 14:17:14 -05:00
Matt Mackall
6c57e49897 revlog: make _chunkcache access atomic
With this and related fixes, 'hg serve' survived 100000 hits with
siege.
2014-06-13 14:16:03 -05:00
Danek Duvall
7280554540 parsers.c: fix a couple of memory leaks 2014-06-11 15:31:04 -07:00
Mads Kiilerich
8a80de42d5 resolve: keep wlock while resolving
This will make resolve use correct locking and thus make it more safe.

Resolve is usually a long running command spending a lot of time waiting for
user input on hard problems. It is thus a real world scenario to start multiple
resolves at once or run other commands (such as up -C and merge) while resolve
is running. Proper locking prevents that.
2014-05-26 19:02:11 +02:00
Gregory Szorc
103656d473 localrepo: prevent leak of transaction object (issue4258)
The onclose() closure added in 5264dbb2d4ee held a regular reference to
the transaction object. This was causing the transaction to not gc and
a leak to occur.

The closure now holds a reference to the weakref instance and the leak
goes away.
2014-05-21 18:02:35 -07:00
Pierre-Yves David
5877b7bbef wireproto: expose the list of getbundle arguments to extensions
For now, getbundle accepts a fixed number of arguments: ``heads``, ``common``
and ``bundlecaps``. We make this list exposed at the module level to let
extensions add content there. This is important for extensions that wish to use
bundle2 for other contents than changegroup.
2014-05-22 01:49:12 -07:00
Durham Goode
e18e8b3005 bundle2: fix bundle2 pulling all revs on empty pulls
When bundle2 was enabled, if hg pull had no commits to pull, it would print
'no changes found' and then download the entire repository from the server. This
was caused by heads and common being set to None, which gets treated as
heads=cl.heads() and common=[nullid], which means download the entire repo.

Pulling bundles without a changegroup is a valid use case (like if we're just
updating bookmarks), so this modifes the bundle code to allow not adding
changegroups.

This is backport of 26ad3517a3a2.
2014-05-07 17:24:19 -07:00
Pierre-Yves David
d55202b92c exchange: fix bad indentation
Those two lines where double indented for no good reasons.

This is backport of d889859ccef0.
2014-05-07 19:26:15 -07:00
Pierre-Yves David
d4684c05ab exchange: propagate arguments to the _getbundleextrapart function
The arguments was wrongly propagated (again).

This a backport of 1c1da5990b8c
2014-05-07 19:28:17 -07:00
Durham Goode
f8ebc64925 bundle2: fix configuration name mismatch
During pulls bundle2 was checking server.bundle2, but during pushes it was
checking experimental.bundle2. This makes them both experimental.bundle2.

This is a backport of a9334b37b19a
2014-05-07 17:20:38 -07:00
Yuya Nishihara
bc04e2c6cd alias: change return code of bad definition to 255
We use 255 for general command error.

It can't raise util.Abort because help module executes badalias command to get
error message.
2014-05-17 15:14:18 +09:00
Matt Mackall
10039fb244 bookmarks: properly align multi-byte characters 2014-05-27 15:16:52 -07:00
Yuya Nishihara
2827ff321c alias: handle shlex error in command aliases
No command should fail with ValueError just because there is unparseable
alias definition.

It returns 1 like other badalias handlers, but should be changed to 255 in
a later version because we use 255 for general command error.
2014-05-17 13:06:16 +09:00
FUJIWARA Katsunori
85d651396d subrepo: normalize path in the specific way for problematic encodings
Before this patch, "reporelpath()" uses "rstrip(os.sep)" to trim
"os.sep" at the end of "parent.root" path.

But it doesn't work correctly with some problematic encodings on
Windows, because some multi-byte characters in such encodings contain
'\\' (0x5c) as the tail byte of them.

In such cases, "reporelpath()" leaves unexpected '\\' at the beginning
of the path returned to callers.

"lcalrepository.root" seems not to have tail "os.sep", because it is
always normalized by "os.path.realpath()" in "vfs.__init__()", but in
fact it has tail "os.sep", if it is a root (of the drive): path
normalization trims tail "os.sep" off "/foo/bar/", but doesn't trim
one off "/".

So, just avoiding "rstrip(os.sep)" in "reporelpath()" causes
regression around issue3033 fixed by e3dfde137fa5.

This patch introduces "pathutil.normasprefix" to normalize specified
path in the specific way for problematic encodings without regression
around issue3033.
2014-05-08 19:03:00 +09:00
FUJIWARA Katsunori
f2a51c0956 subrepo: avoid sanitizing ".hg/hgrc" in meta data area for non-hg subrepos
Before this patch, sanitizing ".hg/hgrc" scans directories and files
also in meta data area for non-hg subrepos: under ".svn" for
Subversion subrepo, for example.

This may cause not only performance impact (especially in large scale
subrepos) but also unexpected removing meta data files.

This patch avoids sanitizing ".hg/hgrc" in meta data area for non-hg
subrepos.

This patch stops checking "ignore" target at the first
(case-insensitive) appearance of it, because continuation of scanning
is meaningless in almost all cases.
2014-05-08 19:03:00 +09:00
FUJIWARA Katsunori
8aea0c13e6 subrepo: make "_sanitize()" take absolute path to the root of subrepo
Before this patch, "hg update" doesn't sanitize ".hg/hgrc" in non-hg
subrepos correctly, if "hg update" is executed not at the root of the
parent repository.

"_sanitize()" takes relative path to subrepo from the root of the
parent repository, and passes it to "os.walk()". In this case,
"os.walk()" expects CWD to be equal to the root of the parent
repository.

So, "os.walk()" can't find specified path (or may scan unexpected
path), if CWD isn't equal to the root of the parent repository.

Non-hg subrepo under nested hg-subrepos may cause same problem, too:
CWD may be equal to the root of the outer most repository, or so.

This patch makes "_sanitize()" take absolute path to the root of
subrepo to sanitize correctly in such cases.

This patch doesn't normalize the path to hostile files as the one
relative to CWD (or the root of the outer most repository), to fix the
problem in the simple way suitable for "stable".

Normalizing should be done in the future: maybe as a part of the
migration to vfs.
2014-05-08 19:03:00 +09:00
FUJIWARA Katsunori
a8f723b6c7 subrepo: invoke "_sanitize()" also after "git merge --ff"
Before this patch, sanitizing ".hg/hgrc" in git subrepo doesn't work,
when the working directory is updated by "git merge --ff".

"_sanitize()" is not invoked after checking target revision out into
the working directory in this case, even though it is invoked
indirectly via "checkout" (or "rawcheckout") in other cases.

This patch invokes "_sanitize()" explicitly also after "git merge
--ff" execution.
2014-05-08 19:03:00 +09:00
FUJIWARA Katsunori
78cdb35351 subrepo: make "_sanitize()" work
"_sanitize()" was introduced by 5131f2755f60 on "stable" branch, but
it has done nothing for sanitizing since 5131f2755f60.

"_sanitize()" assumes "Visitor" design pattern:

    "os.walk()" should invoke specified function ("v" in this case)
    for each directory elements under specified path

but "os.walk()" assumes "Iterator" design pattern:

    callers of it should drive loop to scan each directory elements
    under specified path by themselves with the returned generator
    object

Because of this mismatching, "_sanitize()" just discards the generator
object returned by "os.walk()" and does nothing for sanitizing.

This patch makes "_sanitize()" work.

This patch also changes the format of warning message to show each
unlinked files, for multiple appearances of "potentially hostile
.hg/hgrc".
2014-05-08 19:03:00 +09:00
Yuya Nishihara
c5b2af81b6 alias: fix loss of non-zero return code in command aliases
This also includes test for shell aliases.  It avoid using "false" command
because "man false" does not say "exit with 1" but "exit with a status code
indicating failure."
2014-05-17 14:43:06 +09:00
Pierre-Yves David
0203860e23 changelog: ensure changelog._delaybuf is initialized
The ``localrepo.writepending`` method is using the ``changelog._delaybuff``
attribute to know if it has anything to do. However the ``changelog._delaybuff``
is never initialised at ``__init__`` time. This can lead to crash when using
bundle2 for part that never touch the changelog.

We simply initialize it to its base value. This is scheduled for stable as it
both trivial and blocking for experimenting with bundle2.
2014-05-20 13:55:08 -07:00
Yuya Nishihara
1cdd3cec9a proxy: remove unneeded _set_hostport for compatibility with Python 2.7.7rc1
With Python 2.7.7rc1, "hg pull" through HTTP CONNECT tunnel fails due to the
removal of _set_hostport [1].

      ...
      File "mercurial/url.py", line 372, in https_open
        return self.do_open(self._makeconnection, req)
      ...
      File "mercurial/url.py", line 342, in connect
        _generic_proxytunnel(self)
      File "mercurial/url.py", line 228, in _generic_proxytunnel
        self._set_hostport(self.host, self.port)
    AttributeError: httpsconnection instance has no attribute '_set_hostport'

self._set_hostport(self.host, self.port) should be noop and can be removed
because:

 - _set_hostport() [2] was the function to parse "host:port" string and
   set them to self.host and self.port,
 - and (self.host, self.port) pair should be valid since connect() is called
   prior to _generic_proxytunnel().

 [1]: http://hg.python.org/cpython/rev/568041fd8090
 [2]: http://hg.python.org/cpython/file/3a1db0d2747e/Lib/httplib.py#l721
2014-05-22 22:05:26 +09:00
Durham Goode
63d5c92a11 templates: fix ifcontains against sets with length > 1 (issue4259)
Previously the ifcontains revset was checking against the set using a pure
__contains__ check.  It turns out the set was actually a list of
formatted strings meant for ui output, which meant the contains check failed if
the formatted string wasn't significantly different from the raw value.

This change makes it check against the raw data, prior to it being formatted.
2014-05-23 16:25:55 -07:00
Thomas Arendsen Hein
aedd3b060c setup.py, make: avoid problems with outdated, existing hgext/__index__.py*
"make clean" already removed __index__.py[cdo], but not the __index__.py
(automatically generated by "python setup.py build_hgextindex").

"setup.py build_hgextindex" did not generate a new index if file
__index__.py[cdo] already existed, because if __index__.py was removed,
the compiled file containing the old information was imported and used.
Generate an empty file (with a new timestamp to generate a new .py[cdo])
instead and make mercurial.extensions ignore the unset docs attribute.

One of the problems was a failed test-help.t, to reproduce:

$ rm hgext/__index__.py*
$ echo 'docs = {"mq": "dummy"}' > hgext/__index__.py
$ make test-help.t

With this a "make clean" or "python setup.py build_hgextindex" helps.
2014-05-05 16:54:15 +02:00
Steve Borho
bb09f925ca win32: backout 6891e5c66508
This change conflicted with TortoiseHg's use of QFileSystemWatcher. Files which
were being monitored (for file-system events) were unable to be reliably updated
using util.atomictempfile.  Often the update would error out in the middle of
the process leaving neither the old or the new file in place.

My guess is that _kernel32.CreateFileA() is triggering an exception that is
not handled correctly within unlink()
2014-05-03 10:33:54 +02:00
Pierre-Yves David
e654410fbc revset: directly use __contains__ instead of a lambda
We get rid of lambda in a bunch of other place. This is equivalent and much
faster. (no new timing as this is the same change as three other changesets)
2014-05-01 14:07:04 -07:00
Pierre-Yves David
b3f19fad6e orderedlazyset: directly use __contains__ instead of a lambda
We apply the same speedup as in spanset, getting rid of the useless lambda.
(No new timing, as this is the very same change)
2014-05-01 12:15:28 -07:00
Pierre-Yves David
68eca34f8d lazyset: directly use __contains__ instead of a lambda
We apply the same speedup as in spanset, getting rid of the useless lambda.
(No new timing, as this is the very same change)
2014-05-01 12:15:00 -07:00
Pierre-Yves David
7a5b8cbf4b spanset: directly use __contains__ instead of a lambda
Spanset are massively used in revset. First because the initial subset itself is
a repo wide spanset. We speed up the __and__ operation by getting rid of a
gratuitous lambda call. A more long terms solution would be to:

1. speed up operation between spansets,
2. have a special smartset for `all` revisions.

In the mean time, this is a very simple fix that buyback some of the performance
regression.

Below is performance benchmark for trival `and` operation between two spansets.
(Run on an unspecified fairly large repository.)

revset tip:0
2.9.2)  wall 0.282543 comb 0.280000 user 0.260000 sys 0.020000 (best of 35)
before) wall 0.819181 comb 0.820000 user 0.820000 sys 0.000000 (best of 12)
after)  wall 0.645358 comb 0.650000 user 0.650000 sys 0.000000 (best of 16)

Proof of concept implementation of an `all` smartset brings this to 0.10 but it's
too invasive for stable.
2014-04-26 00:38:02 -07:00
Durham Goode
340117ecce transaction: fix file descriptor leak for journal.backupfiles
The journal.backupfiles descriptor wasn't being closed. This resulted in
hgsubversion test runs having a bagillion descriptors open, which crashed on
platforms with low open file limits (like OSX).
2014-04-30 15:36:38 -07:00
Pierre-Yves David
a4f88556f4 revset: also inline spanset._contained in __len__
For consistency with what happen in `__contains__`, we inline the range test
into `__len__` too.
2014-04-25 18:00:07 -07:00
Pierre-Yves David
b42c62324c revset: inline spanset containment check (fix perf regression)
Calling a function is super expensive in python. We inline the trivial range
comparison to get back to more sensible performance on common revset operation.

Benchmark result below:

Revision mapping:
0) bced32a3fd6c 2.9.2 release
1) 2ab64f462d81 current @
2) This revision


revset #0: public()
0) wall 0.010890 comb 0.010000 user 0.010000 sys 0.000000 (best of 201)
1) wall 0.012109 comb 0.010000 user 0.010000 sys 0.000000 (best of 199)
2) wall 0.012211 comb 0.020000 user 0.020000 sys 0.000000 (best of 197)

revset #1: :10000 and public()
0) wall 0.007141 comb 0.010000 user 0.010000 sys 0.000000 (best of 361)
1) wall 0.014139 comb 0.010000 user 0.010000 sys 0.000000 (best of 186)
2) wall 0.008334 comb 0.010000 user 0.010000 sys 0.000000 (best of 308)

revset #2: draft()
0) wall 0.009610 comb 0.010000 user 0.010000 sys 0.000000 (best of 279)
1) wall 0.010942 comb 0.010000 user 0.010000 sys 0.000000 (best of 243)
2) wall 0.011036 comb 0.010000 user 0.010000 sys 0.000000 (best of 239)

revset #3: :10000 and draft()
0) wall 0.006852 comb 0.010000 user 0.010000 sys 0.000000 (best of 383)
1) wall 0.014641 comb 0.010000 user 0.010000 sys 0.000000 (best of 183)
2) wall 0.008314 comb 0.010000 user 0.010000 sys 0.000000 (best of 299)

We can see this changeset gains back the regression for `and` operation on
spanset.  We are still a bit slowerfor the `public()` and `draft()`. Predicates
not touched by this changeset.
2014-04-28 15:15:36 -07:00
Matt Mackall
8ba0348c31 ancestor: silence multiple ancestor warning outside of merge (issue4234)
The current situation is a bit of a layering violation as
merge-specific knowledge is pushed down to lower layers and leaks
merge assumptions into other code paths.

Here, we simply silence the warning with a hack. Both the warning and
the hack will probably go away in the near future when bid merge is
made the default.
2014-04-30 14:19:01 -05:00
Pierre-Yves David
4274fa0b04 revset: fix revision filtering in spanset.contains (regression)
The argument is `x` but the variable tested for filtering is `rev`. `rev`
happens to be a revset methods, ... never part of the filtered revs. This
method is now using `rev` for everything.
2014-04-28 16:28:52 -07:00
Pierre-Yves David
7bcfb6a103 graft: do not use .remove on a smart set (regression)
Revset calls use to return a list. Graft use to mutate that list. We cannot do
this anymore leading to a crash when grafting multiple changeset with a revset.

    File ".../mercurial/commands.py", line 3117, in graft
      revs.remove(rev)
    AttributeError: '_addset' object has no attribute 'remove'

We are late in code-freeze so we make the shortest possible fix by turning it
back to a list.
2014-04-28 17:25:36 -07:00
Greg Hurrell
89c96d28b3 help: clarify distinction among contains/file/filelog
For a Mercurial new-comer, the distinction between `contains(x)`,
`file(x)`, and `filelog(x)` in the "revsets" help page may not be
obvious. This commit tries to make things more obvious (text based on
an explanation from Matt in an FB group thread).
2014-04-28 15:09:23 -07:00
Mads Kiilerich
bdb0a37b31 discovery: don't report all "unsynced" remote heads (issue4230)
49e52fbb2acd made discovery more helpful - too helpful for some extreme use
cases.

Instead, we arbitrarily limit the list it at 4 and add 'or more'.
2014-04-24 16:47:22 +02:00
Yuya Nishihara
96a8ea56df cmdserver: forcibly use L channel to read password input (issue3161)
Command server is designed to use the channel protocol even if the server
process is accessible to tty, whereas vanilla hg should be able to read
password from tty in that case.  So it isn't enough to swap sys.stdin:

    # works only if the server process is detached from the console
    sys.stdin = self.fin
    getpass.getpass('')
    sys.stdin = oldin

or test isatty:

    # vanilla hg can't talk to tty if stdin is redirected
    if self._isatty(self.fin):
        return getpass.getpass('')
    else:
        ...

Since ui.nontty flag is undocumented and command-server channels don't provide
isatty(), this change won't affect the other uses of ui._isatty().

issue3161 also suggests to provide some context of messages.  I think it can
be implemented by using the generic templating function.
2014-04-26 18:13:06 +09:00
Yuya Nishihara
80dbd234d4 win32: add missing definition of _ERROR_NO_MORE_FILES caught by pyflakes 2014-04-29 12:35:50 +09:00
Yuya Nishihara
621a878ba5 exchange: fix invalid reference to bundle2.UnknownPartError caught by pyflakes 2014-04-29 12:35:02 +09:00
Yuya Nishihara
2e030eb020 match: fix NameError 'pat' on overflow of regex pattern length
'pat' was renamed to 'regex' in 25907f42ff54.
2014-04-29 11:02:40 +09:00
Javi Merino
8411a4f8e5 hgweb: replace excanvas.js with a newer version
The current version of excanvas is unknown.  Substitute it with the
latest version from the excanvas website:

http://code.google.com/p/explorercanvas/

Instead of using the "compiled" version, just use the readable one.
2014-04-23 20:23:30 +01:00
Mads Kiilerich
8b72c846ed httppeer: reintroduce _abort that accidentally was removed in fc14a1cf743e
Including the missing test coverage that would have caught it.
2014-04-23 23:29:55 +02:00
Pierre-Yves David
cb0ccbf8af bundle2: gracefully handle hook abort
We make sure any exceptions raised during the whole span of handling bundle2
processing are decorated. This let us catch exceptions raised by hooks prior to
transaction commit.
2014-04-21 16:13:15 -07:00
Pierre-Yves David
b4b66836e8 bundle2: gracefully handle PushRaced error during unbundle
Same drill again. We catch the PushRaced error, check if it cames from
a bundle2 processing, if so we turn it into a bundle2 with a part
transporting error information to be reraised client side.
2014-04-21 17:51:58 -07:00
Pierre-Yves David
eb0866dfad bundle2: add an error message to push race error
Errors with no explanations makes my uncle Bob sad.
2014-04-21 20:04:54 -07:00
Pierre-Yves David
716843e5d3 bundle2: fix raising errors during heads checking
If the heads on the server differ from the ones reported seen by the client at
bundle time, we raise a PushRaced exception. However, the part raising the
exception was broken.

To fix it, we move the PushRaced class in the error module so it can be
accessible everywhere without an import cycle.

A test is also added to prevent regression.
2014-04-21 18:59:09 -07:00
Pierre-Yves David
f5bff0c11f bundle2: gracefully handle UnknownPartError during unbundle
Same as for Abort error, we catch the error, encode it into a bundle2 reply
(expected by the client) and stream this reply. The client processing of the
error will raise the exception again.
2014-04-21 16:02:03 -07:00
Pierre-Yves David
d27dff342a bundle2: catch UnknownPartError during local push
When doing local push, UnknownPartError from the server will be raised directly
to the client. We need to catch them too.
2014-04-22 11:41:34 -07:00
Pierre-Yves David
7eb6e3f27d bundle2: catch UnknownPartError during pull
We narrow the exception catching while pulling.
2014-04-21 19:43:01 -07:00
Pierre-Yves David
dc21483bc8 bundle2: catch UnknownPartError during push
We narrow the exception catching while unbundling the push reply.
2014-04-21 19:42:51 -07:00
Pierre-Yves David
8265035568 bundle2: use a more specific UnknownPartError when no handler is found
KeyError is very generic, we need something more specific for proper error
handling.
2014-04-21 19:42:40 -07:00
Pierre-Yves David
3085949133 bundle2: gracefully handle abort during unbundle
Clients expect a bundle2 reply to their bundle2 submission. So we
catch the Abort error and turn it into a bundle2 containing a part
transporting the exception data. The unbundling of this reply will
raise the error again.
2014-04-21 15:48:52 -07:00
Pierre-Yves David
3385347d38 bundle2: decorate exception raised during bundle processing
This is a small hack to help us do some graceful error handling in bundle2
without major refactoring. See embedded comment for details.
2014-04-22 11:22:41 -07:00
Wagner Bruna
359de9734a commands: fix typo in --graph description 2014-04-22 10:12:21 -03:00
Wagner Bruna
0db6df4ed7 revset, i18n: add translator comment to "only" 2014-04-22 10:12:13 -03:00
Mads Kiilerich
134cd15f9a merge: improve notes for listing the bids for ambiguous merges 2014-04-21 20:24:54 +02:00
Mads Kiilerich
a37cc358ef merge: tell the user when we are using bid merge
Bid merge is a new rarely used feature that the user explicitly enabled - we
should tell/warn when the user actually is using it, just like we tell when we
not are using it.

Give a message like
  note: merging 3b08d01b0ab5+ and adfe50279922 using bids from ancestors 0f6b37dbe527 and 40663881a6dd
2014-04-18 13:33:20 +02:00
Mads Kiilerich
019c70c1d0 merge: fix stray character in bid merge message 2014-04-21 20:22:14 +02:00
Mads Kiilerich
6112ed888f merge: fix wrong number of arguments for bid merge message 2014-04-21 19:53:19 +02:00
Matt Mackall
4c8937e91e merge: fix test failures with new merge code on OS X
The case collision checker was missing a op entry for 'k'eep.
2014-04-21 15:08:39 -05:00
Martin Geisler
df032a1bc2 obsolete: fix one-element tuple in module docstring 2014-04-19 20:12:53 +02:00
Martin Geisler
010f4026c6 obsolete: let N denote number of obsoleted changestes in a marker
The number of obsoleted changesets is referred to as N later in the
docstring.
2014-04-19 19:53:46 +02:00
Martin Geisler
3b1788aa56 obsolete: fix language and grammar in module docstring 2014-04-19 19:52:09 +02:00
Pierre-Yves David
f63734b94b bundle2: allow extensions to extend the getbundle request
We want extensions to be able to request extra parts.
2014-04-17 16:56:15 -04:00
Pierre-Yves David
bc1c360f82 bundle2: add a way to add parts during a getbundle request
We add a hook function to let extensions add parts to the bundle.
2014-04-17 17:32:34 -04:00
Pierre-Yves David
9761757d1d getbundle: pass arbitrary arguments all along the call chain
The wireprotocol command accepts arbitrary arguments, we are now passing such
arguments down the call chain.
2014-04-17 17:25:50 -04:00
Pierre-Yves David
3f4bc7b0ce bundle2: call a hook after the transaction is closed
We call a dedicated hook right after closing the transaction. This will let
people react to the transaction with all the information in hand. This hook is
experimental and will not survive in future versions.
2014-04-17 17:59:28 -04:00
Pierre-Yves David
e6db4922df bundle2: call a hook prior to closing the transaction
We call a dedicated hook right before closing the transaction. This will let
people abort unbundling with all the information in hand. This hook is
experimental and will not survive in future versions.
2014-04-17 17:21:39 -04:00
Pierre-Yves David
7bbaf30f57 bundle2: inform transaction that we are in a bundle2 unbundle
That way, hooks called during the unbundle process are aware that a bigger picture
is going on.
2014-04-17 17:16:21 -04:00
Pierre-Yves David
d9e2c653ca changegroup: use tr.hookargs when calling changegroup hooks
So that other parties using the transaction can put information in our hook
calls.
2014-04-17 17:46:26 -04:00
Pierre-Yves David
140d78d745 changegroup: use tr.hookargs when calling pretxnchangegroup hooks
So that other parties using the transaction can put information in our hook
calls.
2014-04-17 17:15:02 -04:00
Pierre-Yves David
1e7dd6937e addchangegroup: register data in tr.hookargs
We are registering data related to the process into the transaction hook data.
This lets other parties using the same transaction get informed of the
addchangegroup result.
2014-04-17 17:09:20 -04:00
Pierre-Yves David
18d2864e3c transaction: add a notion of hook arguments
It is now possible to register parameters to be used when invoking hooks in this
transaction. This will cope with the fact that bundle2 adds multiple data types
in a single transaction.

Do not expect any wide and consistent usages of this in the next release. This
will be used by bundle2 experiments first. It will be made better for the release
after.
2014-04-17 17:04:59 -04:00
Pierre-Yves David
1d48078897 bundle2: allow extensions to plug into the push process
Extensions are offered functions to add parts and process their results.
2014-04-17 16:54:15 -04:00
Pierre-Yves David
9ab32b965e bundle2: require both client and server to opt in
Even if the server is bundle2-enabled, the client now has to opt-in in the
config too.
2014-04-17 16:04:58 -04:00
Pierre-Yves David
953b10a36c bundle2: move bundle2 config option to section "experimental"
We highlight the fact that this is experimental by moving it to an "experimental"
section, and we match the config name with the server capability name
`bundle2-exp`.
2014-04-17 16:01:58 -04:00
Pierre-Yves David
fd614e4d04 bundle2: move all parts into a bx2 namespace
All currently core parts are moved to a `bx2` namespace (for "bundle 2
experimental"). This should avoid conflicts between the final stable
format and the one about to be released.
2014-04-17 15:45:12 -04:00
Pierre-Yves David
005c745f17 bundle2: rename server capability to bundle2-exp
For the same reason, we advertise this bundle2 implementation and format as
experimental. This will leave room for field testing in 3.0 but won't conflict
with a stable implementation in 3.1.
2014-04-17 15:33:17 -04:00
Pierre-Yves David
7e653a9c0f bundle2: use HG2X in the header
The current implementation of bundle2 is still very experimental and the 3.0
freeze is yesterday. The current bundle2 format has never been field-tested, so
we rename the header to HG2X. This leaves the HG20 header available for real
usage as a stable format in Mercurial 3.1.

We won't guarantee that future mercurial versions will keep supporting this
`HG2X` format.
2014-04-17 15:27:54 -04:00
Pierre-Yves David
8495126170 bundle2: transmit capabilities to getbundle during pull
Bundle2 capabilities of the client are sent to the server in the bundlecaps
argument of `getbundle`.
2014-04-17 02:01:38 -04:00
Pierre-Yves David
30d2504741 bundle2: include client capabilities in the pushed bundle
The necessary data is now included in the `replycaps` part.
2014-04-17 14:37:24 -04:00
Pierre-Yves David
9992968890 bundle2: advertise bundle2 caps in server capabilities
We can now retrieve them from the server during push. The capabilities are
encoded the same way as in `replycaps` part (with an extra layer of urlquoting
to escape separators).
2014-04-17 01:49:20 -04:00
Pierre-Yves David
0eec02877e bundle2: add bundle2caps dict on localrepo object
This dictionary will hold bundle2-related capabilities.
2014-04-17 01:50:28 -04:00
Pierre-Yves David
9bb9dc1703 bundle2: capabilities encoding 2014-04-17 01:44:53 -04:00
Pierre-Yves David
211041404c bundle2: extract capabilities decoding
We'll need to reuse this in more places (at least pull and push).
2014-04-17 01:09:05 -04:00
Pierre-Yves David
f2ead829c7 bundle2: protect capabilities name and values with url quoting
This lift limitations of the text based encoding.
2014-04-17 01:03:33 -04:00
Pierre-Yves David
f48478a77f bundle2: support for capabilities with values
The capabilities attributes of `bundle20` is now a dictionary and the reply caps
can encode capabilities with values.
2014-04-17 11:44:49 -04:00
Pierre-Yves David
b4784becd2 bundle2: add capabilities support in replycaps part
This part now contains a list of supported capabilities.
2014-04-17 11:32:30 -04:00
Pierre-Yves David
e273dad6f6 bundle2: adds a capabilities attribute on bundler20
This attribute conveys the capabilities supported by the destination of the
bundle. It is used to decide which parts to include in the bundle.

This is currently a set but will probably be turned into a dictionary to allow
capabilities with values.
2014-04-16 23:55:59 -04:00
Pierre-Yves David
1c2cd8594e bundle2: include stderr when capturing handlers output
We do not discriminate between stdout and stderr yet. But this will do for now.
2014-04-16 23:18:27 -04:00
Pierre-Yves David
2feab6f005 ui: pushbuffer can now also capture stderr
We need an easy way to capture both stderr and stdout during bundle2 processing
of a remote bundle. This changeset adds simple changes to the `ui` class to make
this possible.

I expect the interface to change in future releases as bundle2 will probably want to
distinguish stdout and stderr. The current change will, however, do for now.
2014-04-16 23:36:57 -04:00
Pierre-Yves David
53ffee95a2 bundle2: capture remote stdout while unbundling
When a reply is built, the bundle processing will capture the output of each
handler and sends it to the client in a dedicated part.

As a side effect, this add a "remote: " prefix to destination output on local
push. This is considered okay for now as:

1. bundle2 is still experimental,
2. Matt said he could be okay to change output for bundle2,
3. This keeps the implementation simple.

This changeset does it for stdout only. stderr will be done in a future changeset.
2014-04-16 14:22:24 -04:00
Pierre-Yves David
f7d4dc294b bundle2: introduce replycaps part for on-demand reply
The bundle2 processing does not create a bundle2 reply by default anymore.  It
is only done if the client requests it with a `replycaps` part. This part is
called `replycaps` as it will eventually contain data about which bundle2
capabilities are supported by the client.

We have to add a flag to the test command to control whether a reply is
generated or not.
2014-04-16 14:09:35 -04:00
Pierre-Yves David
88fa4f238f bundle2: use an official iterparts method to unbundle parts
Explicit is better than implicit.
2014-04-16 18:41:48 -04:00
Mads Kiilerich
5a1f9b25aa merge: with merge.preferancestor=*, run an auction with bids from ancestors
The basic idea is to do the merge planning with all the available ancestors,
consider the resulting actions as "bids", make an "auction" and
automatically pick the most favourable action for each file.

This implements the basic functionality and will only consider "keep" and
"get" actions. The heuristics for picking the best action can be tweaked later
on.

By default it will only pass ctx.ancestor as the single ancestor to
calculateupdates. The code path for merging with a single ancestor is not
changed.
2014-02-28 02:52:32 +01:00
Lucas Moscovicz
2794920df6 log: changed implementation to use graphlog code
Now that revsets work in a lazy way, log code can be changed to parse every
option into a revset and then evaluate it lazily.

Now expressions like

  "hg log -b default -b ."

are converted into a revset using the same code as graphlog.
2014-02-28 15:10:56 -08:00
Mads Kiilerich
cdb11ac02d context: introduce merge.preferancestor for controlling which ancestor to pick
Multiple revisions can be specified in merge.preferancestor, separated by
whitespace. First match wins.

This makes it possible to overrule the default of picking the common ancestor
with the lowest hash value among the "best" (introduced in f19507e1bcf2).

This can for instance help with some merges where the 'wrong' ancestor is used.
There will thus be some overlap between this and the problems that can be
solved with a future 'consensus merge'.

Mercurial will show a note like
  note: using 40663881a6dd as ancestor of 3b08d01b0ab5 and adfe50279922
        alternatively, use --config merge.preferancestor=0f6b37dbe527
when the option is available, listing all the alternative ancestors.
2014-02-24 22:42:14 +01:00