Commit Graph

265 Commits

Author SHA1 Message Date
Yuya Nishihara
7701e518b5 pager: flush outputs before firing pager process
So that buffered outputs are always sent to the console.
2017-02-25 17:29:30 +09:00
Yuya Nishihara
21edd5907a patchbomb: use modern pager to display -n/--test result (BC)
This should provide more consistent UX, but is a BC because the pager will
no longer be fired up for each message.
2017-02-25 17:27:48 +09:00
Yuya Nishihara
5fab4a9d55 patchbomb: add config knob to generate flags by template (issue5354)
This can be used to flag patches by branch or topic automatically. Flags
optionally given by --flag option are exported as {flags} template keyword,
so you can add --flag V2.
2017-02-25 18:41:00 +09:00
Yuya Nishihara
7697dd4d5b patchbomb: pass around ui and revs that are needed for flag template
See the next patch for why.
2017-02-25 18:35:34 +09:00
Yuya Nishihara
cc7b1af6b2 patchbomb: build patch texts by _getpatchmsgs()
Now _getpatchmsgs() knows revision numbers, which allows us to generate flags
by applying a template to changectx objects.
2017-02-25 18:28:04 +09:00
Yuya Nishihara
2fae5e032d patchbomb: drop internal option for pbranch extension (API)
I want to move _getpatches() to _getpatchmsgs() to make sure each patch text
is tied with the corresponding revision number. This helps adding templater
support.

IIRC, the pbranch extension doesn't work with the recent Mercurial versions,
so the removal of this option wouldn't hurt.
2017-02-25 18:25:17 +09:00
Yuya Nishihara
be15dfae52 patchbomb: factor out function that builds a prefix string to patch subject
I'll add templating support.
2017-02-25 18:16:41 +09:00
Sean Farley
e145fc2df7 ui: rename tmpdir parameter to more specific repopath
This was requested by Augie and I agree that repopath is more
descriptive.
2017-01-18 18:25:51 -08:00
Sean Farley
934f476aec patchbomb: add tmpdir parameter to ui.edit call 2017-01-16 21:17:39 -08:00
Pulkit Goyal
1a4248666b py3: replace os.environ with encoding.environ (part 2 of 5) 2016-12-18 01:46:39 +05:30
Henning Schild
9ed7d6b8f2 patch: remove unused git parameter from patch.diffstat()
Since 5997ebdd67f0 the parameter is not used anymore.
2016-11-12 13:36:17 +01:00
Augie Fackler
4e1c384d0a extensions: change magic "shipped with hg" string
I've caught multiple extensions in the wild lying about being
'internal', so it's time to move the goalposts on people. Goalpost
moving will continue until third party extensions stop trying to
defeat the system.
2016-08-23 11:26:08 -04:00
Gregory Szorc
35166670e2 mail: unsupport smtp.verifycert (BC)
smtp.verifycert was accidentally broken by 799db3fe9866. And,
I believe the "loose" value has been broken for longer than that.
The current code refuses to talk to a remote server unless the
CA is trusted or the fingerprint is validated. In other words,
we lost the ability for smtp.verifycert to lower/disable security.

There are special considerations for smtp.verifycert in
sslutil.validatesocket() (the "strict" argument). This violates
the direction sslutil is evolving towards, which has all security
options determined at wrapsocket() time and a unified code path and
configs for determining security options.

Since smtp.verifycert is broken and since we'll soon have new
security defaults and new mechanisms for controlling host security,
this patch formally deprecates smtp.verifycert. With this patch,
the socket security code in mail.py now effectively mirrors code
in url.py and other places we're doing socket security.

For the record, removing smtp.verifycert because it was accidentally
broken is a poor excuse to remove it. However, I would have done this
anyway because smtp.verifycert is a one-off likely used by few people
(users of the patchbomb extension) and I don't think the existence
of this seldom-used one-off in security code can be justified,
especially when you consider that better mechanisms are right around
the corner.
2016-06-04 11:13:28 -07:00
Yuya Nishihara
a5c934df3c py3: move up symbol imports to enforce import-checker rules
Since (b) is banned, we should do the same for (a) for consistency.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 14:03:12 +09:00
timeless
85999ce49e patchbomb: use single quotes around command hint
Windows command lines use double quotes to quote arguments with spaces.
This change is in a series to unify around using single quotes around
commands, and double quotes around interior arguments.

This changeset is taken on stable for consistency with similar update done
before the freeze.
See dc90bb772edc, 675a0be03493, 518b94d8f911 and 149a699cfd98.
2016-04-14 15:15:49 +00:00
timeless
2778e2894f patchbomb: fix public-is-missing hint
Without this, there is no space between a hash and the -r preceding the next
line in the use hg push hint
2016-04-14 14:26:37 +00:00
timeless
f77cdcd3b1 pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
Anton Shestakov
adaa0d801e patchbomb: specify unit for ui.progress when sending emails 2016-03-11 22:30:43 +08:00
timeless
3d3cc1c01c patchbomb: use absolute_import 2016-03-02 21:42:42 +00:00
Bryan O'Sullivan
c490d3c96d patchbomb: replace file I/O with util.readfile 2016-01-12 15:57:18 -08:00
Bryan O'Sullivan
9fc5431d91 patchbomb: treat empty address list as no addresses
Previously it wasn't possible to use configuration to avoid
being prompted for e.g. a CC list when using patchbomb to send
emails.

We now make it possible to supply an empty value.
2016-01-07 20:02:47 -08:00
timeless
9b00c9388a patchbomb: rename email function
I see no reason for the function not to be email ...
2015-11-29 06:51:23 +00:00
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