Commit Graph

280 Commits

Author SHA1 Message Date
Boris Feld
21b0f2024e configitems: register the 'patchbomb.publicurl' config 2017-06-30 03:43:43 +02:00
Boris Feld
b7f48a76b1 configitems: register the 'patchbomb.intro' config 2017-06-30 03:43:41 +02:00
Boris Feld
9eb3cb7909 configitems: register the 'patchbomb.from' config 2017-06-30 03:43:40 +02:00
Boris Feld
a72f2bfb21 configitems: register the 'patchbomb.flagtemplate' config 2017-06-30 03:43:39 +02:00
Boris Feld
956178d827 configitems: register the 'patchbomb.confirm' config 2017-06-30 03:43:38 +02:00
Boris Feld
b7bafc583d configitems: register the 'patchbomb.bundletype' config 2017-06-30 03:43:37 +02:00
Michael Bolin
094c271fff editor: use an unambiguous path suffix for editor files
Changes the API of `ui.edit()` to take an optional `action` argument,
which is used when constructing the suffix of the temp file.
Previously, it was possible to set the suffix by specifying a `suffix` to the
optional `extra` dict that was passed to `ui.edit()`, but the goal is to
drop support for `extra.suffix` and make `action` a required argument.
To this end, `ui.edit()` now yields a `develwarn()` if `action` is not set
or if `extra.suffix` is set.

I updated all calls to `ui.edit()` I could find in `hg-crew` to specify the
appropriate `action`. This means that when creating a commit, instead
of the path to the editor file being something like:

`/tmp/hg-editor-XXXXXX.txt`

it is now something like:

`/tmp/hg-editor-XXXXXX.commit.hg.txt`

Some editors (such as Atom) make it possible to statically define a [TextMate]
grammar for files with a particular suffix. For example, because Git reliably
uses `.git/COMMIT_EDITMSG` and `.git/MERGE_MSG` as the paths for commit-type
messages, it is trivial to define a grammar that is applied when files of
either name are opened in Atom:

https://github.com/atom/language-git/blob/v0.19.1/grammars/git%20commit%20message.cson#L4-L5

Because Hg historically used a generic `.txt` suffix, it was much harder to
disambiguate whether a file was an arbitrary text file as opposed to one
created for the specific purpose of authoring an Hg commit message.

This also makes it easier to add special support for `histedit`, as it has its own
suffix that is distinct from a commit:

`/tmp/hg-histedit-XXXXXX.histedit.hg.txt`

Test Plan:
Added an integration test: `test-editor-filename.t`.

Manually tested: ran `hg ci --amend` for this change and saw that it
used `/tmp/hg-editor-ZZjcz0.commit.hg.txt` as the path instead of
`/tmp/hg-editor-ZZjcz0.txt` as the path.

Verified `make tests` passes.

Differential Revision: https://phab.mercurial-scm.org/D464
2017-08-30 20:25:56 +00:00
Boris Feld
c9fe43d98b repovfs: add a ward to check if locks are properly taken
When the appropriate developer warnings are enabled, We wrap 'repo.vfs.audit' to
check for locks when accessing file in '.hg' for writing. Another changeset will
add a 'ward' for the store vfs (svfs).

This check system has caught a handful of locking issues that have been fixed
in previous series (mostly in 4.0). I expect another batch to be caught in third
party extensions.

We introduce two real exceptions from extensions 'blackbox.log' (because a lot of
read-only operations add entry to it), and 'last-email.txt' (because 'hg email'
is currently a read only operation and there is value to keep it this way).

In addition we are currently allowing bisect to operate outside of the lock
because the current code is a bit hard to get properly locked for now. Multiple
clean up have been made but there is still a couple of them to do and the freeze
is coming.
2017-07-11 12:38:17 +02:00
Augie Fackler
e6a918f63a patchbomb: make getaddrs function easier to work with
Prior to this the return value was potentially None, a string, or a
list of strings. It now always returns a list of strings where each
string is always only one email address
2017-06-13 17:43:33 -04:00
Augie Fackler
1250a2693f patchbomb: look for non-empty publicurl, not a non-None one
Otherwise it's impossible to turn this feature back off, which is
making writing of tests awkward.
2017-06-13 16:30:50 -04:00
Augie Fackler
88445b135f patchbomb: make variable name for publicurl always be publicurl 2017-06-13 16:30:11 -04:00
David Demelier
cdeab8bd8c patchbomb: avoid -r and -B options at the same time 2017-06-06 08:52:51 +02:00
David Demelier
d3c7997560 patchbomb: add -B option to select a bookmark
Add the -B/--bookmark option to select a bookmark whose changesets
and its ancestors will be selected unless a new bookmark/head is
found.

This is inspired by hg strip -B option.
2017-02-03 15:02:27 +01:00
Yuya Nishihara
6c2103bc71 commands: move templates of common command options to cmdutil (API)
The goal is to get rid of the debugcommands -> commands dependency.

Since globalopts is the property of the commands, it's kept in the commands
module.
2017-05-14 16:19:47 +09:00
Yuya Nishihara
3e663dde68 registrar: move cmdutil.command to registrar module (API)
cmdutil.command wasn't a member of the registrar framework only for a
historical reason. Let's make that happen. This patch keeps cmdutil.command
as an alias for extension compatibility.
2016-01-09 23:07:20 +09:00
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