Commit Graph

313 Commits

Author SHA1 Message Date
Patrick Mezard
be05d24d8e patch: remove redundant variable in iterhunks() 2011-04-26 21:22:14 +02:00
Adrian Buehlmann
f3e8eae526 move canonpath from util to scmutil 2011-04-20 21:41:41 +02:00
Adrian Buehlmann
cf126bb7dd move opener from util to scmutil 2011-04-20 19:54:57 +02:00
Matt Mackall
a8dd64dcb0 misc: replace .parents()[0] with p1() 2011-04-04 16:21:59 -05:00
Patrick Mezard
92074cd441 patch: deprecate ui.patch / external patcher feature
Why?
- Mercurial internal patcher works correctly for regular patches and git
  patches, is much faster at least on Windows and is more extensible.
- In theory, the external patcher can be used to handle exotic patch formats. I
  do not know any and have not heard about any such use in years.
- Most patch programs cannot handle git format patches, which makes the API
  caller to decide either to ignore ui.patch by calling patch.internalpatch()
  directly, or take the risk of random failures with valid inputs.
- One thing a patch program could do Mercurial patcher cannot is applying with
  --reverse. Apparently several shelve like extensions try to use that,
  including passing the "reverse" option to Mercurial patcher, which has been
  removed mid-2009. I never heard anybody complain about that, and would prefer
  reimplementing it anyway.

And from the technical perspective:
- The external patcher makes everything harder to maintain and implement. EOL
  normalization is not implemented, and I would bet file renames, if supported
  by the patcher, are not correctly recorded in the dirstate.
- No tests.

How?
- Remove related documentation
- Clearly mark patch.externalpatch() as private
- Remove the debuginstall check. This deprecation request was actually
  triggered by this last point. debuginstall is the only piece of code patching
  without a repository. When migrating to an integrated patch() + updatedir()
  call, this was really a showstopper, all workarounds were either ugly or
  uselessly complicated to implement. If we do not support external patcher
  anymore, the debuginstall check is not useful anymore.
- Remove patch.externalpatch() after 1.9 release.
2011-03-24 10:28:29 +01:00
Patrick Mezard
1597f620c9 patch: move closefile() into patchfile.close() 2011-03-20 00:22:47 +01:00
Patrick Mezard
189b71bbde patch: inline patchfile.hashlines() 2011-03-20 00:09:44 +01:00
Patrick Mezard
6a59fcba00 patch: fix hunk newlines when parsing hunks, not in iterhunks() 2011-03-20 00:08:44 +01:00
Gastón Kleiman
f4afcea9fa diffstat: fix parsing of filenames with spaces
The patch changes the output of "hg diff --stat" when one file whose filename
has spaces has changed, making it get the full filename instead of just the
substring between the last space and the end of the filename.

It also changes the diffstat generated by "hg email -d" when one of the commit
messages starts with "diff". Because of the regex used to parse the filename,
the diffstat generated by "hg email -d" will still be not correct if a commit
message starts with "diff -r ".

Before the patch Mercurial has the following behavior:

$ echo "foobar">"file with spaces"
$ hg add "file with spaces"
$ hg diff --stat
 spaces |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
$ hg diff --git --stat
 file with spaces |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

After the patch:

$ echo "foobar">"file with spaces"
$ hg add "file with spaces"
$ hg diff --stat
 file with spaces |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
$ hg diff --git --stat
 file with spaces |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Before the patch:

$ hg add mercurial/patch.py tests/tests-diffstat.t
$ hg commit -m "diffstat: fix parsing of filenames"

$ hg email -d --test tip
This patch series consists of 1 patches.

diffstat: fix parsing of filenames
[...]

 filenames             |    0
 mercurial/patch.py    |    6 ++++--
 tests/test-diffstat.t |   17 +++++++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
[...]

After the patch:

$ hg email -d --test tip
This patch series consists of 1 patches.

diffstat: fix parsing of filenames

[...]

 mercurial/patch.py    |    6 ++++--
 tests/test-diffstat.t |   17 +++++++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
[...]
2011-02-04 16:32:14 -03:00
Adrian Buehlmann
15eb1de134 opener: always reset flags on 'w'rite
only the patcher needs to preserve flags on write
2010-12-10 15:14:05 +01:00
Matt Mackall
6bcc439bb1 merge with stable 2010-12-08 13:12:12 -06:00
Patrick Mezard
744f417d4c patch: write .rej files without rewriting EOLs
Do not pass reject file content to patchfile.writelines() to:
- Avoid line endings transformations
- Avoid polluting overriding implementations with unrelated data. They should
  override write_rej() to deal or ignore reject files properly.

Bug report, analysis and original patch and test by
Shun-ichi GOTO <shunichi.goto@gmail.com>
2010-12-03 11:40:30 +09:00
Patrick Mezard
209debed48 patch: remove unused applydiff() sourcefile argument 2010-11-03 21:11:07 +01:00
Patrick Mezard
0f5ec5ba66 patch: remove unused gitworkdone variable from iterhunks() 2010-11-03 21:11:05 +01:00
Patrick Mezard
88ff8c9a1e Test applying context diffs 2010-10-24 12:56:38 +02:00
Mads Kiilerich
287d9de60b import: only the first hg patch marker should be processed (issue2417)
Proper use of the hgpatch state variable had been lost in the final edits of
6f45596f715c - now it works more like intended.
2010-10-14 01:28:29 +02:00
Patrick Mezard
01e8f53ff7 patch: fails immediately upon malformed hunk
patch(1) does silently ignore malformed hunks but this is not something we want
to copy.
2010-10-09 15:13:08 -05:00
Patrick Mezard
095f60fafa patch: always raise PatchError with a message, simplify handling 2010-10-09 15:13:08 -05:00
Patrick Mezard
b52c9228ba patch: simplify externalpatch() arguments 2010-10-09 15:13:08 -05:00
Patrick Mezard
61a67cb90e patch: remove internal patcher fallback and NoHunk error
By now the internal patcher is probably more reliable than anything we might
find on the command line.
2010-10-09 15:13:08 -05:00
Patrick Mezard
f0b64b2f9a patch: remove unused patchmeta.lineno 2010-10-09 15:13:08 -05:00
Patrick Mezard
3c601e6ebf patch: remove unused flags from readgitpatch() 2010-10-09 15:13:08 -05:00
Mads Kiilerich
227683e7b5 import: don't strip '#' lines from patch descriptions (issue 2417)
Previously no '# ' lines came through the parser.

Now only the first '# ' lines are processed, from '# HG changeset patch' and to
the first line not starting with '# '.
2010-10-08 23:39:44 -05:00
Patrick Mezard
df877501f1 Merge with stable 2010-09-28 01:11:24 +02:00
Patrick Mezard
a8f024ef25 patch: test and document a bit binary to regular file upgrade 2010-09-28 00:41:08 +02:00
Patrick Mezard
a9686ec545 patch: upgrade to git patch when removing binary file
Otherwise it may cause data loss when removing binary files in mq with
--git=auto.
2010-09-28 00:41:07 +02:00
Patrick Mezard
5468157807 patch: fix rename text to binary file (issue2400) 2010-09-27 22:47:10 +02:00
Patrick Mezard
979ccf4590 Use lexists() instead of exists() where appropriate 2010-09-20 21:46:56 +02:00
Patrick Mezard
21f3e10fb9 patch: do not overwrite broken untracked symlinks 2010-09-20 21:42:11 +02:00
Patrick Mezard
2d21e62e9b patch: fix target when patching broken symlinks (issue2368) 2010-09-20 21:42:11 +02:00
Martin Geisler
5f46f16fb7 Lowercase error messages 2010-08-29 22:37:58 +02:00
Patrick Mezard
614db673f4 Merge with stable 2010-09-20 22:29:13 +02:00
Martin Geisler
112ea7d5ed patch: break import cycle with cmdutil
The patch module imported cmdutil but used it only in updatedir.
2010-09-13 13:08:09 +02:00
Martin Geisler
e9c2a20771 diff: recurse into subrepositories with --subrepos/-S flag 2010-09-03 12:58:51 +02:00
Martin Geisler
c27c54faec clone, patch, convert: use hex(nullid) instead of '0'*40 2010-09-02 12:08:13 +02:00
Martin Geisler
cb36142754 Merge with stable 2010-08-29 22:55:37 +02:00
Martin Geisler
bfea979db3 util: remove lexists, Python 2.4 introduced os.path.lexists 2010-08-25 16:23:32 +02:00
Martin Geisler
d396293ec7 patch: fix typo in comment 2010-08-12 17:58:03 +02:00
Dan Drake
32aaa61ef2 patch: fix extract() docstring, it returns branch as well 2010-07-22 14:30:27 +09:00
FUJIWARA Katsunori
2f9dbb12f7 i18n: use encoding.colwidth() for correct column width
Some encoding and language combinations (e.g.: UTF-8 and Japanese)
cause encoding characters into sequence of bytes more than column
width of them.

So, encoding.colwidth() should be applied instread of len() on i18n
strings.

In addition to it, formatting by '%*s'/'%-*s' also uses "number of
bytes" to calculate space padding size, and should be fixed, too.
2010-07-18 01:06:50 +09:00
Dirkjan Ochtman
56aef99b57 patch: inline small, single-use 'write' function 2010-06-17 15:51:27 +02:00
Dirkjan Ochtman
12058a3e8e patch: inline small, single-use 'close' function 2010-06-17 15:50:35 +02:00
Dirkjan Ochtman
af6b696f0f move working dir/dirstate methods from localrepo to workingctx 2010-06-07 20:03:32 +02:00
Mads Kiilerich
865bdae0fa patch: strip paths in leaked git patchmeta objects 2010-04-26 13:21:03 +02:00
Mads Kiilerich
345145e804 patch: minor cleanup of _applydiff 2010-04-26 13:21:03 +02:00
Mads Kiilerich
63938a51f6 patch: git delete mode shouldn't be used at all 2010-04-26 13:21:02 +02:00
Mads Kiilerich
9f2ca1164a patch: make "unable to strip away" message less confusing 2010-04-26 13:21:02 +02:00
Mads Kiilerich
10fedd8d3d patch: descriptive patchmeta.__repr__ to help debugging 2010-04-26 13:21:02 +02:00
Augie Fackler
2556500e58 patch: refactor applydiff to allow for mempatching 2010-04-17 13:23:24 -05:00
Augie Fackler
4da02e74e7 patch: move mercurial-specific imports after stdlib imports 2010-04-17 13:13:57 -05:00