Commit Graph

558 Commits

Author SHA1 Message Date
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
Jun Wu
81bdbbebbd patch: migrate to util.iterfile 2016-11-14 23:14:06 +00:00
Ryan McElroy
eabf9d1003 import: abort instead of crashing when copy source does not exist (issue5375)
Previously, when a patch contained a move or copy from a source that did not
exist, `hg import` would crash. This patch changes import to raise a PatchError
with an explanantion of what is wrong with the patch to avoid the stack trace
and bad user experience.
2016-10-08 05:26:58 -07:00
Augie Fackler
3ab4799643 diffopts: notice a negated boolean flag in diffopts
This means that if you have git-diffs enabled by default (pretty
common) and you hit the rare (but real) case where a git-diff breaks
patch(1) or some other tool, you can easily disable it by just
specifying --no-git on the command line.

I feel a little bad about the isinstance() check, but some values in
diffopts are not booleans and so we need to preserve false iff the
flag is a boolean flag: failing to do this means we end up with empty
string defaults for flags clobbering meaningful values from the [diff]
section in hgrc.
2016-08-30 15:55:07 -04:00
liscju
088829b590 import: report directory-relative paths in error messages (issue5224)
Import uses paths relative to the root of the repository, so when
user imports patch with paths relative to the current working directory
import aborts with 'unable to find file for patching'.

This patch improves this situation by warning the user that paths are
relative to the root of repository when patching fails.
2016-08-26 12:48:20 +02:00
Augie Fackler
e02d5adf5a patch: use iter(callable, sentinel) instead of while True
This is functionally equivalent, but is a little more concise.
2016-08-05 14:00:14 -04:00
Henrik Stuart
40c8c53428 patch: allow copy information to be passed in
When displaying patches from graphical tools where you can browse through
individual files, with diff being called separately on each, recomputing the
limits of file copy history can become rather expensive on large repositories.
Instead, we can compute it once and pass it in for subsequent calls.
2016-06-27 12:11:18 +02:00
Augie Fackler
ad67b99d20 cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
All versions of Python we support or hope to support make the hash
functions available in the same way under the same name, so we may as
well drop the util forwards.
2016-06-10 00:12:33 -04:00
Denis Laxalde
259dd53d72 patch: define full messages for interactive record/revert
Followup 814eb5a11da4 to provide complete context for proper localization.

Also update cmdutil.recordfilter docstring to remove recommendation that
"operation" argument should be translated. Indeed, for record/revert, we
either go to patch.filterpatch or crecord.filterpatch (in curses mode) ; the
former now build the full ui message from the operation parameter and the
latter does not use this parameter (removing in a followup patch). For shelve,
operation is not specified and this thus falls back to "record".
2016-06-07 10:37:19 +02:00
Denis Laxalde
ae2b66dbed revert: use "discard"/"revert" verb when reverting interactively (issue5143)
Instead of "record this change to 'FILE'?" now prompt with:

* "discard this change to 'FILE'?" when reverting to the parent of working
  directory, and,
* "revert this change to 'FILE'?" otherwise.
2016-06-03 15:55:07 +02:00
FUJIWARA Katsunori
63611bb308 patch: show lower-ed translated message correctly
Before this patch, patch.filterpatch() shows meaningless translation
of help message for chunk selection in some encoding.

It applies str.lower() instead of encoding.lower(str) on translated
message, but some encoding uses 0x41(A) - 0x5a(Z) as the second or
later byte of multi-byte character (for example, ja_JP.cp932), and
str.lower() causes unexpected result.

To show lower-ed translated message correctly, this patch replaces
str.lower() by encoding.lower(str).
2016-05-13 07:19:59 +09:00
timeless
f77cdcd3b1 pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
Julien Cristau
1c82b3fc6d patch: when importing from email, RFC2047-decode From/Subject headers
Reported at https://bugs.debian.org/737498
2016-03-03 18:34:19 +01:00
Martin von Zweigbergk
216d0e41ef diff: don't crash when merged-in addition is copied
Similar to what was explained in the previous commit, the diff code
expected copy source to be in "ctx1", which is not always the case
during a merge. This has been broken since before hg 2.0.

Also similar to the previous commit, we fix the problem by fixing up
the copy dict.
2016-01-14 10:22:55 -08:00
Martin von Zweigbergk
0c3407d70e diff: don't crash when merged-in addition was removed (issue4786)
During a merge, if the user removes a file that came from parent 2 and
did not exist in parent 1, the file's status will be "removed". This
surprises the diff code, which crashes because it expects removed
files exist in parent 1. This has been broken since ff976121fb34
(trydiff: use 'not in addedset' for symmetry with 'not in removedset',
2014-12-23).

Fix by fixing up the list of removed file, similar to how we currently
fix up the list of modified and added files during a merge.
2016-01-14 10:14:24 -08:00
Martin von Zweigbergk
cf817770b1 diff: move status fixup earlier, out of _filepairs()
This prepares for future patches, and it also lets us remove the ugly
"ctx1" argument to _filepairs() (ugly because of its assymmetry --
there's no "ctx2" argument).
2016-01-14 10:02:34 -08:00
Bryan O'Sullivan
a33fafdc2a with: use context manager for I/O in changedfiles in patch 2016-01-15 13:14:50 -08:00
Gregory Szorc
090eb4dcbe patch: use absolute_import 2015-12-21 21:33:52 -08:00
timeless
b7d4dff7f3 record: fix hunk handling to remember the current function 2015-12-17 20:13:29 +00:00
Mateusz Kwapich
dcddc82bed patch: disable nobinary when HGPLAIN=1
The diff output without binaries is definitely great for interactive users - a
binary patch is not meaningful for them. Although setting diff.nobinary flag
can break the automation. Let's force full output for automation.
2015-12-17 11:00:06 -08:00
Laurent Charignon
1409af5e69 commit: add a way to return more information from the chunkselector
Before this patch, the chunkselector for record or crecord was used to return
the list of hunks that were selected by the user. The goal of this series is to
reintroduce the toggle amend feature for crecord. To do so, we need to be able
to return more than just the selected hunks from the chunkselector but also
the information: is amend mode toggled. This patch adds a new return value for
chunkselectors that will be used to implement the toggle amend feature in
crecord.
2015-11-30 16:35:21 -08:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02: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
240fce0b19 extract: parse 'nodeid' using the generic mechanism
Parsing 'nodeid' is very simple and a good first test.
2015-10-06 02:23:21 -07:00
Pierre-Yves David
6eaa931821 extract: parse 'branch' using the generic mechanism
Parsing 'branch' is very simple and a good first test.
2015-10-06 02:22:23 -07:00
Pierre-Yves David
2602f6923f extract: parse 'date' using the generic mechanism
Parsing 'date' is very simple and a good first test.
2015-10-07 01:13:36 -07:00
Pierre-Yves David
4ae623122e extract: add some facility for extensible header parsing
We need a way for extension to extend the header we can parse. We start with a
very simple mechanism that will be used in the next changeset.
2015-10-07 01:20:49 -07:00
Pierre-Yves David
b85c4695a2 extract: remove the 'user' variable
It is not heavily used enough to justify being something other than a
dictionary entry.
2015-10-06 02:16:24 -07:00
Pierre-Yves David
1f322a05ad extract: use a single return
The differences between both returns are now very thin, we factor out
that part.
2015-10-06 02:11:09 -07:00
Pierre-Yves David
159f2b3f21 extract: move 'nodeid' assignment where it is parsed
The is one setter and no consumer, we can move it there directly.
2015-10-07 00:50:53 -07:00
Pierre-Yves David
b6f2794f84 extract: move 'date' assignment where it is parsed
There is one setter and no consumer, we can move it there directly.
2015-10-06 02:08:32 -07:00
Pierre-Yves David
6386f9c739 extract: assign user to 'data' earlier
This is used in both case, we can assign it once.
2015-10-06 02:07:33 -07:00
Pierre-Yves David
cf6731af5a extract: move 'branch' assignment where it is parsed
There is one setter and no consumer, we can move it there directly.
2015-10-06 02:06:36 -07:00
Pierre-Yves David
43416c9684 extract: directly assign parent to data dictionary
The temporary variables are not adding anything.
2015-10-06 02:05:56 -07:00
Pierre-Yves David
3351bc88a4 extract: assign message only once
This return is shared between the two cases. We can move it earlier.
2015-10-06 02:04:46 -07:00
Pierre-Yves David
ab23538b10 extract: simplify parents assignement
We move to the more standard style of:

  value = default
  if special:
      value = other

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

The first step is to return something more flexible, so we return a dict without
changing any other logic.
2015-10-06 02:01:53 -07:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -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
Gregory Szorc
3aa1c73868 global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.

Mass rewrite all instances of the old octal syntax to the new syntax.

This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
2015-06-23 22:30:33 -07:00
Gregory Szorc
be5724ac71 patch: remove email import workaround for Python 2.4
Python 2.6 provides access to the sub-modules just fine. This workaround
is no longer needed since we no longer support Python 2.4.
2015-06-22 10:09:08 -07:00
Matt Mackall
7c6674833f patch: add fuzz config flag (issue4697) 2015-06-18 15:42:40 -05:00
Laurent Charignon
1ca77932d5 record: exiting editor with non-zero status should not stop recording session
Before this patch, exiting a hunk edit in record with a non-zero status lead
to the end of the recording session, losing previously-selected hunks to record.
This patch introduces the more desirable behavior of warning the user and
continuing the recording session.
2015-06-05 13:31:18 -07:00
Laurent Charignon
f9d447f8e4 revert: add an experimental config to use inverted selection
We had a discussion on the list about the interactive ui for revert. This patch
adds a flag to allow people to test the second alternative (referred to as
proposition 2 on the mailing list). It effectively inverts the signs in the
2015-05-29 13:11:52 -07:00
Laurent Charignon
9b866fafac record: add default value for operation argument
This patch is part of a series of patches to change the recording ui to reflect
the operation currently running (commit, shelve, revert ...).
This patch adds the default value of the operation argument for record's
standard and curses interface to match what is displayed in the interface
as of today.
2015-05-27 15:56:10 -07:00
Laurent Charignon
92c99cc1a7 record: add an operation arguments to customize recording ui
This patch is part of a series of patches to change the recording ui to reflect
the operation currently running (commit, shelve, revert ...).
This patch adds a new argument to the recording function to reflect in the UI
what operation we are running.
2015-05-27 15:49:24 -07:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04:00
Pierre-Yves David
27d9d4e153 patch: remove duplicated import of cStringIO
It is already imported a couple of line above.
2015-05-17 17:27:10 -07:00
Martin von Zweigbergk
4127f67694 util: drop alias for collections.deque
Now that util.deque is just an alias for collections.deque, let's just
remove it.
2015-05-16 11:28:04 -07:00
Laurent Charignon
6fc9e8be66 record: edit patch of newly added files (issue4304)
I tried to fix this issue in the past and had to revert the fix. This is a
second attempt without the regression we found with the first one.

record defines special headers (of file) as headers whose hunk are not shown
to the user for editing, they are used to represent deleted, moved and new
files. Since we want to authorize editing the patch of newly added file we
make the newly added file with some content not special anymore. This entails
that we have to save their content before applying the backup to be able to
revert it if the patch does not apply properly.
We reintroduce the test showing that newly added files can be edited and that
their content is shown to the user.
2015-04-23 14:27:26 -07:00