Commit Graph

243 Commits

Author SHA1 Message Date
Pierre-Yves David
53ed633b94 patchbomb: check that targets exist at the publicurl
Advertising that the patch are available to be pulled requires that to be true.
So we check revision availability on the remote before sending any email.
2015-10-11 22:13:03 -07:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Pierre-Yves David
70ea75bfe7 patchbomb: add a 'bundletype' config under 'patchbomb'
patchbomb relies on the 'hg bundle' command to generate an attached bundle using
--bundle. However, while 'hg bundle' has a --type option, patchbomb did not.
This is becoming very relevant since we are about to issue bundle2 for
general-delta repository.

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

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

As all this is experimental, bike shedding can happily happens before we remove
the experimental flag.
2015-10-06 01:49:04 -07:00
Matt Mackall
e8ae5150ee patchbomb: make sure all users of smtp.verifycert agree on the default 2015-07-17 13:41:07 -05:00
Matt Mackall
65f1e11a48 patchbomb: mark ancient option deprecated
This just exists for backwards compatibility with the earliest
versions of patchbomb.
2015-06-25 17:38:14 -05:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Pierre-Yves David
5796899530 patchbomb: stop explicit import required by Python 2.4
Ding Dong, the witch is dead!
2015-05-18 16:22:15 -05:00
Augie Fackler
f95a6caba1 extensions: document that testedwith = 'internal' is special
Extension authors (notably at companies using hg) have been
cargo-culting the `testedwith = 'internal'` bit from hg's own
extensions, which then defeats our "file bugs over here" logic in
dispatch. Let's be more aggressive about trying to give extension
authors a hint about what testedwith should say.
2015-04-28 16:44:37 -04:00
Yuya Nishihara
b3d3bd2695 patchbomb: factor out scmutil.revrange() calls
This allows us to access the calculated revs in patchbomb() function.
2015-03-30 23:25:55 +09:00
Yuya Nishihara
93cd317fe5 patchbomb: return outgoing revs as a smartset
This helps to factor out scmutil.revrange() calls from _getpatches() and
_getoutgoing(). In future patches, a smartset will be passed to _getpatches().
2015-03-31 00:52:17 +09:00
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Angel Ezquerra
88cbab7845 localrepo: remove all external users of localrepo.opener
This change touches every module in which repository.opener was being used, and
changes it for the equivalent repository.vfs. This is meant to make it easier
to split the repository.vfs into several separate vfs.

It should now be possible to remove localrepo.opener.
2015-01-15 23:17:12 +01:00
Pierre-Yves David
9b6b5b5d44 patchbomb: introduce a 'patchbomb.confirm' option
When set to true, this option will make patchbomb always ask for confirmation
before sending the email. Confirmation is a powerful way to prevent stupid
mistakes when the sending patches.

This should let me get rid of my global alias adding
--confirm to hg email.

I know that some people may get bitten when moving from a machine with confirm
configured to a machine where it is not, but I think it is worth the risk.
2014-12-02 17:35:21 -08:00
Pierre-Yves David
d7f199fab2 patchbomb: add a 'patchbomb.intro' option
This option allows the user to control the default behavior for
including an introduction message. This avoids having to tirelessly
skip the intro for people contributing to Mercurial.

The three possibles values are:
- always,
- auto (default, current behavior),
- never.

I was thinking of ("true", "false", "") (empty value being auto) but I ruled it
out as too confusing.

This new config option reuses the pre-existing 'patchbomb' section.
2014-12-02 17:24:52 -08:00
Pierre-Yves David
25a25d14e1 patchbomb: extract 'getoutgoing' closure into its own function
This continues my crusade against closure complication.
2014-12-02 16:51:32 -08:00
Siddharth Agarwal
1c8311a9c0 patchbomb: don't honor whitespace and format-changing diffopts (BC)
The whitespace diffopts break lossless transmission, and the format-changing
ones make import harder. We expect parsers to be able to read git-style diffs,
though.
2014-11-18 17:36:24 -08:00
Pierre-Yves David
8589ffc464 patchbomb: extract 'getpatchmsgs' closure into its own function
Keep marching toward the promised land of simplification!
2014-11-06 11:55:37 +00:00
Pierre-Yves David
68144cbf2d patchbomb: extract 'makeintro' closure into its own function
Keep marching toward the promised land of simplification!
2014-11-06 11:57:48 +00:00
Pierre-Yves David
5e7ba55699 patchbomb: extract 'getbundlemsgs' closure in its own function
Keep marching toward the promised land of simplification!
2014-11-04 21:48:23 +00:00
Pierre-Yves David
a4e022483b patchbomb: extract 'getdescription' closure in its own function
Keep marching toward the promised land of simplification!
2014-11-04 21:41:35 +00:00
Pierre-Yves David
db7363e36c patchbomb: extract 'getbundle' closure in its own function
Keep marching toward the promised land of simplification!
2014-11-04 21:33:57 +00:00
Pierre-Yves David
bc9c7c072f patchbomb: extract 'getpatches' closure in its own function
Keep marching toward the promised land of simplification!
2014-11-04 21:28:57 +00:00
Pierre-Yves David
e8f7207454 patchbomb: add label and color to the confirm output
The current output is mostly a wall of text. This makes it hard to
actually check something for people with lazy eyes. We use labels and
colors to make it more joyful (and get the patch summaries to stand
out). The colors have been arbitrarily choosen. They can be changed
later if someone has a more scientific choice.
2014-11-04 13:38:33 +00:00
Augie Fackler
f2d5956439 patchbomb: reorder header insertions to clarify code
This is done as its own change to make the changes to test-patchbomb.t
easier to review.
2014-06-07 11:32:37 -04:00
Augie Fackler
b8c9c1134c patchbomb: always use message-id of first patch for series-id
This currently has the side effect that the 0 of N message has no
series-id. This won't matter for Mercurial's own use, but may be
undesirable for other projects depending on their workflow.

The way the header is inserted is intentionally a little funny to make
the test expectation diff easier to review.
2014-06-07 11:06:15 -04:00
Pierre-Yves David
1437d7ae17 patchbomb: includes a unique series ID in email header
Now that we have patch index and series size information, having a unique series
identifier will helps tool to glue all email back together without any
additional logic.
2014-05-05 22:51:20 -07:00
Pierre-Yves David
02a943dbb1 patchbomb: includes series information in the header
We includes information about the series being patch bombed in all email. Two
new headers are added:

* X-Mercurial-Series-Index: index of the patches in the series (starts at 1)
* X-Mercurial-Series-Total: The total number of patches in the series

This information is available in the email subject line, but having them
formalized in the header will helps automated tools to process patches send with
modern mercurial.
2014-05-05 22:47:14 -07:00
Mads Kiilerich
6c7f6f30ff patchbomb: warn when emailing a dirty working directory parent 2014-04-07 23:10:20 +02:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
Augie Fackler
67877b90cc python2.4: fix imports of sub-packages of the email package
These all have an obvious comment so if/when we finally ditch Python
2.4 we can eradicate them easily.
2013-09-24 15:10:32 -04:00
Augie Fackler
5621af34e7 patchbomb: correct import of email module 2013-09-20 10:16:35 -04:00
Matt Mackall
13d2a13ea6 ui: merge prompt text components into a singe string
This will help avoid problems with partial or mismatched translation
of the components.
2013-05-22 17:31:43 -05:00
FUJIWARA Katsunori
3a3aca3c72 smtp: verify the certificate of the SMTP server for STARTTLS/SMTPS
Before this patch, the certificate of the SMTP server for STARTTLS or
SMTPS isn't verified.

This may cause man-in-the-middle security problem (stealing
authentication information), even though SMTP channel itself is
encrypted by SSL.

When "[smtp] tls" is configured as "smtps" or "starttls", this patch:

  - uses classes introduced by preceding patches instead of "SMTP" or
    "SMTP_SSL" of smtplib, and

  - verifies the certificate of the SMTP server, if "[smtp]
    verifycert" is configured as other than False

"[smtp] verifycert" can be configured in 3 levels:

  - "strict":

    This verifies peer certificate, and aborts if:

      - peer certification is not valid, or
      - no configuration in "[hostfingerprints]" and "[web] cacerts"

    This is default value of "[smtp] verifycert" for security.

  - "loose":

    This verifies peer certificate, and aborts if peer certification is
    not valid.

    This just shows warning message ("certificate not verified"), if
    there is no configuration in "[hostfingerprints]" and "[web]
    cacerts".

    This is as same as verification for HTTPS connection.

  - False(no verification):

    Peer certificate is not verified.

    This is as same as the behavior before this patch series.

"hg email --insecure" uses "loose" level, and ignores "[web] cacerts"
as same as push/pull/etc... with --insecure.

Ignoring "[web] cacerts" configuration for "hg email --insecure" is
already done in "dispatch._dispatch()" by looking "insecure" up in the
table of command options.
2013-03-26 02:28:10 +09:00
Matt Mackall
fd58e8703f i18n: wrap false positives for translation detection 2012-11-25 13:53:47 -06:00
Julian Cowley
af02d686b4 patchbomb: -c is not an alias for the --confirm option
The help text shows "-c/--confirm", which implies that -c is an alias
for --confirm.  Actually, it is an alias for --cc.  Correct the text
by removing -c.
2012-10-28 05:44:50 -10:00
Thomas Arendsen Hein
bf24be2a41 patchbomb: respect --in-reply-to for all mails if no intro message is sent
Before this change, the thread hierarchy looked like this:

PARENT
  PATCH1/x
    PATCH2/x
    PATCH3/x
    ...

Now it is:

PARENT
  PATCH1/x
  PATCH2/x
  PATCH3/x
  ...

With an introductory message the behaviour is unchanged:

PARENT
  INTRO
    PATCH1/x
    PATCH2/x
    PATCH3/x
    ...
2012-10-24 09:53:10 +02:00
Patrick Mezard
f1c5b9a95f patchbomb: rewrite getoutgoing() with revsets
Another version could have returned a revset expression from
getoutgoing(), but we do not know how many times it will be resolved, so
better do it once explicitely.
2012-06-24 18:11:52 +02:00
Patrick Mezard
3743817d12 patchbomb: support --outgoing and revsets
With --outgoing, input revisions were passed to getoutgoing() before
being resolved.
2012-06-24 17:39:27 +02:00
Patrick Mezard
10fef3c556 patchbomb: make --outgoing ignore secret changesets
getoutgoing() is just rewritten almost like revset.outgoing(), a
follow-up will make it use revsets after the tests are adjusted.
2012-07-14 19:21:31 +02:00
Martin Geisler
cae2421779 patchbomb: lowercase status messages 2012-06-12 14:18:18 +02:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Brodie Rao
c577fac135 cleanup: replace naked excepts with more specific ones 2012-05-12 16:02:45 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Angel Ezquerra
2da9b90b7f patchbomb: add --body flag to send patches as inline message body text
There is currently no way to make patchbomb include patches both as attachments
and as inline text. This would be quite convenient when sending patches to
people who use web email clients (e.g. gmail) which often mangle the patches,
making them hard to apply.

The default behavior of the email command is unchanged. However it is now
possible to use the --body flag _in addition_ to the -i or -a flags, in which
case the patchbomb emails will contain the patch as inline body text and as an
attachment.

A new test has been added to test-patchbomb.t ("test attach for single
patch"), based on the existing test called "test attach for single patch" test.
2012-03-21 06:45:07 +01:00
Matt Mackall
bd8479209b patchbomb: add (optional) note to 0 of 0 prompt 2012-03-08 15:59:41 -06:00
Mads Kiilerich
c30004d07d mail: mbox handling as a part of mail handling, refactored from patchbomb 2011-11-23 02:11:24 +01:00
Mads Kiilerich
6127ae9b6d patchbomb: minor refactoring of mbox functionality, preparing for move
This allows reuse of the mbox functionality but causes minor changes in the
patchbomb console output when writing to a mbox.
2011-11-23 02:09:38 +01:00
Matt Mackall
bd2e2796ed patchbomb: drop loop in prompt
There are no longer any prompts that insist on being answered, so the
loop is no longer needed, nor is most of the other logic.
2011-09-28 14:49:00 -05:00
Matt Mackall
46b745f857 patchbomb: use prompt even in non-interactive mode
This matches our pre-existing behavior from:

changeset:   12197:0a3b85866451
user:        Christian Ebert <blacktrash@gmx.net>
files:       hgext/patchbomb.py tests/test-patchbomb.t
description:
patchbomb: show prompt and selection in non-interactive mode
changeset:   8940:023d1310d8a4
user:        Mads Kiilerich <mads@kiilerich.com>
date:        Sun Jun 21 03:13:38 2009 +0200
files:       mercurial/ui.py tests/test-merge-prompt.out tests/test-merge-tools.out
description:
ui.prompt: Show prompt and selection in non-interactive mode
2010-09-08 08:31:07 +02:00