Commit Graph

616 Commits

Author SHA1 Message Date
Martin von Zweigbergk
06e8c1de95 trydiff: remove unused argument to diffline()
Now that diffline no longer knows about copies/renames, it only needs
one argument for the path.
2015-01-16 14:58:51 -08:00
Martin von Zweigbergk
2a62729249 trydiff: move git-header code out of diffline function
This collects more of the code for writing git headers in a single
place and makes diffline() close on a few variables less.
2015-01-16 14:58:06 -08:00
Martin von Zweigbergk
13e9d82723 trydiff: inline indexmeta()
The function is trivial and is only called in one place.
2015-01-16 15:40:59 -08:00
Martin von Zweigbergk
18e0f2df1e trydiff: order header-writing code in same order as output
Instead of inserting a line before the others header lines, move the
code that writes that line before the code that writes the other
lines.
2015-01-16 14:49:08 -08:00
Martin von Zweigbergk
e67ec1dc7b trydiff: inline sole addmodehdr() call
Now that there is only a single call to addmodehdr() left, and there
is other similar code (for new/deleted files) around that call site,
let's inline the function there. That also makes it clearer under what
circumstances the header is actually written (when modes differ).
2015-01-16 14:53:37 -08:00
Martin von Zweigbergk
26f9ad4736 trydiff: join filename with prefix only once 2015-01-16 14:46:03 -08:00
Martin von Zweigbergk
fa3ad9c66e trydiff: collect header-writing in one place
This is the first step towards simplifying the big loop in
trydiff(). This will make both the header code and the non-header code
clearer, and it prepares for further simplification of the many nested
if-statements in the body of the loop.
2015-01-22 17:00:54 -08:00
Martin von Zweigbergk
2cda80f871 trydiff: make variable names more consistent
Use '1' and '2' as suffix for names just like in the parameters
'ctx[12]':

to,tn -> content1,content2
a,b -> f1, f2
omode,mode -> mode1,mode2
omode,nmode -> mode1,mode2
onode,nnode -> node1,node2
oflag,nflag -> flag1,flag2
oindex,nindex -> index1,index2
2015-01-16 10:57:13 -08:00
Martin von Zweigbergk
20500e2442 trydiff: check only if added file is a copy target, not source
When creating a diff with copy/rename enabled, we consider added files
and check if they are either copy sources or targets. However, an
added file should never be a copy source. The test suite seems to
agree with this: all tests pass if we raise an exception when an added
file is a copy source. So, let's simplify the code by dropping the
conditions that are never true.

For those interested in the historical reasons:

Before commit c15c00e7afba (patch: separate reverse copy data
(issue1959), 2010-02-11), 'copy' seems to have been a bidirectional
map. Then that commit split it up into two unidirectional maps and
duplicated the logic to look in both maps. It was still needed at that
point to look in both maps, as the copy detection was poor and could
sometimes be reported in reverse.

A little later came 5a644704d5eb (copies: rewrite copy detection for
non-merge users, 2012-01-04). That commit fixed the copy detection to
be backwards when it should, and made the hacks in trydiff
unnecessary.
2015-01-16 17:01:58 -08:00
Martin von Zweigbergk
74a4151049 trydiff: remove unused variable 'modifiedset'
We started updating 'modifiedset' in e85e48ffb83e (trydiff: simplify
checking for additions, 2014-12-23) but in the same commit, we removed
the last use of the variable. Clean it up.
2015-01-29 21:12:35 -08:00
Martin von Zweigbergk
fc35342dbb diff: use binary diff when copy source is binary
When a binary source has been copied or renamed into a non-binary
file, we don't check whether the copy source was binary. There is a
code comment explaining that a git mode will be forced anyway in order
to capture the copy record (i.e. losedatafn() will be called). This is
true, but forcing git mode is not the only effect binary files have:
when git mode was already requested, we use the binary-ness to tell us
whether to use a regular unified diff or a git binary diff. The user
sees this as a "Binary file $file has changed" instead of the binary
2015-01-17 15:03:41 -08:00
Martin von Zweigbergk
f60106670d trydiff: replace dodiff=True/'binary' by binarydiff=False/True 2015-01-07 11:02:10 -08:00
Martin von Zweigbergk
4a8198a6db trydiff: replace 'dodiff = False' by 'continue'
The 'dodiff' variable is initialized to True and may later be set to
either False or "binary". When it's set to False, we skip everything
after that point, so we can simplify by instead continue-ing (the
loop). We can then also drop the 'if dodiff', since it will always be
true.
2015-01-07 10:59:40 -08:00
Martin von Zweigbergk
86561cd4f0 trydiff: make addindexmeta() unconditionally add index meta
The conditional-ness is not clear from the name and there is only one
caller, so it's clearer to check on the call site. Moving it also
makes addindexmeta() no longer close on the 'opts' variable.
2015-01-07 08:54:26 -08:00
Martin von Zweigbergk
590312deed trydiff: remove unused code for git index of "combined diff"
We only ever produce diffs with one pre- and one post-image, so remove
the code for displaying "index" lines for combined diffs.
2015-01-07 08:46:52 -08:00
Martin von Zweigbergk
a92bd0f094 diff: remove dead assignment 2015-01-06 22:55:01 -08:00
Martin von Zweigbergk
d21c241927 trydiff: use 'ctx1.flags()' for symmetry with 'ctx2.flags()' 2014-12-23 16:16:26 -08:00
Martin von Zweigbergk
0154ee1c3e trydiff: use 'not in addedset' for symmetry with 'not in removedset'
With the previous change in place, we can safely use 'addedset'.
2014-12-23 16:25:00 -08:00
Martin von Zweigbergk
a69f913d1d trydiff: simplify checking for additions
In the body of the loop in trydiff(), there are conditions like:

  addedset or (f in modifiedset and to is None)

The second half of that expression is to account for the fact that
merge-in additions appear as additions. By instead fixing up the sets
of modified and added files to compensate for this fact, we can
simplify the body of the loop. It also fixes one case where the
addedset was checked without the additional check (the "have we
already reported a copy above?" case in the code, also see fixed test
case).

The similar condition with 'removedset' in it seems to have served no
purpose even before this change, so it could have been simplified even
before.
2014-12-23 16:12:54 -08:00
Martin von Zweigbergk
12fa2d93ff trydiff: extract 'date2' variable like existing 'date1'
Note that there is a comment saying "ctx2 date may be dynamic". The
comment was introduced in 8ed3d2a60500 (patch: use contexts for diff,
2006-12-25), but it seems like it stopped being dynamic in that very
changeset -- before that changeset, the date seems to have been the
file's mtime, but after the changeset, it seems to be the changeset's
timestamp (current time for workingctx). Since no one seems to have
missed the "dynamicness", let's simplify and extract a date2 for
symmetry with date1.
2014-12-23 14:56:30 -08:00
Martin von Zweigbergk
c7f4a068b8 trydiff: use sets, not lists, for containment checks
This only has a noticeable effect on diffs touching A LOT of
files. For example, it takes

  hg diff -r FIREFOX_AURORA_30_BASE -r FIREFOX_AURORA_35_BASE

from 1m55.465s to 1m32.354s. That diff has over 50k files.
2014-12-23 10:41:45 -08:00
Siddharth Agarwal
113c428a6d patch.difffeatureopts: add a feature for format-changing diffopts
Typically, callers that are interested in this set are also interested in the
others. We still add it as a first-class flag for convenience.
2014-11-18 17:22:03 -08:00
Siddharth Agarwal
542813a378 patch.difffeatureopts: add a feature for whitespace diffopts
These aren't exactly format-breaking features -- just ones for which patches
applied to a repo will produce incorrect commits, In any case, some commands
like record and annotate only care about this feature.
2014-11-18 17:09:26 -08:00
Siddharth Agarwal
8c24c56a7e patch.difffeatureopts: add a feature for diff.git
This deserves to be its own feature -- indeed, this is often the only feature
several commands care about.
2014-11-18 17:10:14 -08:00
Siddharth Agarwal
3864c7a9bb patch: rename diffopts to diffallopts
This is meant to be used when all features are explicitly requested. diffopts
is kept as an alias for now -- it will go away soon.
2014-11-18 21:43:38 -08:00
Siddharth Agarwal
56b105c2c6 patch: add a new function to initialize diffopts by feature
Not all callers are interested in all diffopts -- for example, commands like
record (which use diff internally) break when diffopts like noprefix are
enabled. This function will allow us to add flags that callers can use to
enable only the features they're interested in.
2014-11-18 16:53:22 -08:00
Siddharth Agarwal
e42499560a patch.diffopts: use a dict for initialization
In upcoming patches we'll conditionally add to and remove from the dict.
2014-11-18 16:00:54 -08:00
Siddharth Agarwal
48ef0179c1 patch.trydiff: add support for noprefix 2014-11-12 23:50:21 -08:00
Siddharth Agarwal
37a8021dad patch.diffopts: add support for noprefix
In an upcoming patch we'll enable support as an option to 'hg diff' as well.

The tests reflect the current state of the world -- as we add support we'll see
changes in the test output.
2014-11-13 00:08:44 -08:00
Siddharth Agarwal
ccd6611ec9 patch.diffopts: allow a setting to be forced in plain mode
Upcoming patches will add an option that will almost certainly break diff
output parsers when enabled. Add support for forcing an option to something in
plain mode, as a fallback. Options passed in via the CLI are not affected,
though -- it is assumed that any script passing the option in explicitly knows
what it is doing.
2014-11-12 23:47:25 -08:00
Siddharth Agarwal
dabae3afed patch.diffopts: break get function into if statements
We're going to add another condition here, and with the current structure that
becomes just too confusing.
2014-11-12 23:44:17 -08:00
Jordi Gutiérrez Hermoso
60df7a50e9 patch: enable diff.tab markup for the color extension
The following patch splits up changed lines along tabs (using
re.findall), and gives them a "diff.tab" label. This can be used by
the color extension for colorising tabs, like it does right now with
trailing whitespace.

I also provide corresponding tests.
2014-08-20 15:15:50 -04:00
Mads Kiilerich
4dd236da3f convert: use None value for missing files instead of overloading IOError
The internal API used IOError to indicate that a file should be marked as
removed.

There is some correlation between IOError (especially with ENOENT) and files
that should be removed, but using IOErrors to represent file removal internally
required some hacks.

Instead, use the value None to indicate that the file not is present.

Before, spurious IO errors could cause commits that silently removed files.
They will now be reported like all other IO errors so the root cause can be
fixed.
2014-08-26 22:03:32 +02:00
Sean Farley
c813b41f60 patch: use ctx.node() instead of bare node variable
Future patches will allow patch.diff to take a basectx so node1 (and node2)
could make hexfunc error out. Instead, we'll call the node function on the
context object directly.
2013-08-14 13:10:27 -05:00
Stephen Lee
b831a97d01 diff: add nobinary config to suppress git-style binary diffs 2014-06-21 15:56:49 +10:00
Chinmay Joshi
b97e831462 patch: replace functions in fsbackend to use vfs
Several functions in fsbackend are replaced to use vfs functions.
vfs operations are applied on filename and path is joined by _join().
2014-06-05 15:24:29 +05:30
Pierre-Yves David
b7c330c46d import: add --partial flag to create a changeset despite failed hunks
The `hg import` command gains a `--partial` flag. When specified, a commit will
always be created from a patch import. Any hunk that fails to apply will
create .rej file, same as what `hg qimport` would do. This change is mainly
aimed at preserving changeset metadata when applying a patch, something very
important for reviewers.

In case of failure with `--partial`, `hg import` returns 1 and the following
message is displayed:

    patch applied partially
    (fix the .rej files and run `hg commit --amend`)

When multiple patches are imported, we stop at the first one with failed hunks.

In the future, someone may feel brave enough to tackle a --continue flag to
import.
2014-05-08 17:08:17 -07:00
Matt Mackall
34b49de789 diff: use second filename for --stat reporting on git patches (issue4221) 2014-04-11 16:38:55 -04:00
FUJIWARA Katsunori
0eed53de6c i18n: fix "% inside _()" problems
Before this patch, "contrib/check-code.py" can't detect these
problems, because the regexp pattern to detect "% inside _()" doesn't
suppose the case that format string consists of multiple string
components concatenated implicitly or explicitly,

This patch does below for that regexp pattern to detect "% inside _()"
problems in such case.

  - put "+" into separator part ("[ \t\n]") for explicit concatenation
    ("...." + "...." style)

  - enclose "component and separator" part by "(?:....)+" for
    concatenation itself ("...." "...." or "...." + "....")
2014-04-01 02:46:03 +09:00
Nicolas Vigier
a9bf6787d2 patch: add support for git delta hunks
When creating patches modifying binary files using "git format-patch",
git creates 'literal' and 'delta' hunks. Mercurial currently supports
'literal' hunks only, which makes it impossible to import patches with
'delta' hunks.

This changeset adds support for 'delta' hunks. It is a reimplementation
of patch-delta.c from git :
http://git.kernel.org/cgit/git/git.git/tree/patch-delta.c
2013-11-27 18:39:00 +01:00
Augie Fackler
fb91efd733 makememctx: move from patch to context to break import cycle 2013-11-06 22:09:15 -05:00
Johan Bjork
6055bcdec2 patch: ensure valid git diffs if source/destination file is missing (issue4046)
This is arguably a workaround, a better fix may be in the repo to
ensure that it won't list a file 'modified' unless there is a file
context for the previous version.
2013-10-13 08:38:30 -04:00
Augie Fackler
cdf1bbd9e1 merge with stable 2013-10-07 17:47:55 -04:00
Johan Bjork
bbce7855f8 patch: Fix nullid for binary git diffs (issue4054)
The index for an empty file in git is not 0, but sha-1("blobl 0\0").
2013-10-07 17:47:19 -04:00
Matt Mackall
aa456e3925 import: cut commit messages at --- unconditionally (issue2148)
We used to do this based on X-mailer: mentioning git, but git doesn't
put X-mailer in its git-format-patch output.
2013-07-27 19:31:14 -05: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
897a535360 patch: correct import of email module 2013-09-20 10:15:51 -04:00
Siddharth Agarwal
4340781945 patch: use scmutil.marktouched instead of scmutil.addremove
addremove required paths relative to the cwd, which meant a lot of extra code
that transformed paths into relative ones. That code is now gone as well.
2013-04-04 13:45:21 -07:00
Sean Farley
0a28dbdae7 patch: match 'diff --git a/' instead of 'diff --git'
This reduces the likelihood of a traceback when trying to email a
patch that happens to have 'diff --git' at the beginning of a line
in the description, as this patch did:

http://markmail.org/message/wxpgowxd7ucxygwe
2013-03-22 17:27:06 -05:00
Johan Bjork
7b64b304ec diff: fix binary file removals in git mode.
With the previous version, a binary file removal diff generated with
2013-03-04 22:34:11 +00:00
Mads Kiilerich
275333d6c9 util: fold ENOENT check into unlinkpath, controlled by new ignoremissing flag
Refactor a common pattern.
2012-12-28 11:55:57 +01:00
Mads Kiilerich
ac8e1fc147 check-code: there must also be whitespace between ')' and operator
The check pattern only checked for whitespace between keyword and operator.

Now it also warns:
 >     x = f(),7
 missing whitespace after ,
 >     x = f()+7
 missing whitespace in expression
2012-12-09 23:33:16 +01:00
Bryan O'Sullivan
0dc2115da0 subrepo: use posixpath when diffing, for consistent paths
This fixes a Windows failure in test-subrepo-recursion.t introduced
by c9345d017402.
2012-11-27 14:58:00 -08:00
Guillermo Pérez
2c1f380e8a diff: move index header generation to patch
In an upcoming patch, we will add index information to all git diffs, not
only binary diffs, so this code needs to be moved to a more appropriate
place.

Also, since this information is used for patch headers, it makes more
sense to be in the patch module, along with other patch-related metadata.
2012-11-15 15:16:41 -08:00
Guillermo Pérez
f655c9c8c8 patch: make _addmodehdr a function under trydiff
addmodehdr is a header helper, same as diffline, so it doesn't
need to be a top-level function and can be nested under trydiff.

In upcoming patches we will generalize this approach for
all headers.
2012-11-15 15:06:32 -08:00
Guillermo Pérez
e12d2e6289 diff: rewrite diffline
Make diffline more readable, using strings with placeholders
rather than appending to a list from many ifs that makes
difficult to understand the actual output format.
2012-11-15 13:57:03 -08:00
Guillermo Pérez
4339c3bf86 diff: swap and simplify diffline args
Args order swapped, since a, b are more important than revs
(which is only used on non-git format), and change to read opts
from context.
2012-11-15 13:52:51 -08:00
Guillermo Pérez
565ed512ac diff: change how quiet mode supresses diffline
Before, quiet mode produced no diffline header for mercurial as a
side effect of not populating "revs". This was a weird side effect,
and we will always need revs for git index header that will be added
in upcoming patches, so now we just check ui.quiet from diffline
directly.
2012-11-15 13:49:04 -08:00
Guillermo Pérez
33e8ab6c12 diff: move diffline to patch module
diffline is not part of diff computation, so it makes more sense
to place it with other header generation in patch module.

In upcoming patches we will generalize this approach for
all headers added in the patch, including the git index
header.
2012-11-15 12:19:03 -08:00
Guillermo Pérez
9482817c96 diff: unify calls to diffline
diffline was called from trydiff for binary diffs and from unidiff
for text diffs. In this patch we unify those calls into one.

diffline is also a header, not part of diff mechanisms, so it makes
sense to remove that responsibility from the mdiff module. In
upcoming patches we will move diffline to patch module and
keep grouping responsibilities.
2012-11-15 12:16:08 -08:00
Guillermo Pérez
d54d996bfb diff: move b85diff to mdiff module
b85diff generates a binary diff, so we move this code to mdiff module
along with unidiff for text diffs. All diffing mechanisms will be in the
same place.

In an upcoming patch we will remove the responsibility to print the
index header from b85diff and move it back to patch, since it's
a patch metadata header, not part of the diff generation.
2012-11-06 14:04:05 -08:00
Mads Kiilerich
688b9e2048 check-code: indent 4 spaces in py files 2012-07-31 03:30:42 +02:00
Bryan O'Sullivan
abdf4a8227 util: subclass deque for Python 2.4 backwards compatibility
It turns out that Python 2.4's deque type is lacking a remove method.
We can't implement remove in terms of find, because it doesn't have
find either.
2012-06-01 17:05:31 -07:00
Matt Mackall
da90115a02 merge with stable 2012-06-01 15:14:29 -05:00
Patrick Mezard
5315858d38 patch: keep patching after missing copy source (issue3480)
When applying a patch renaming/copying 'a' to 'b' on a revision where
'a' does not exist, the patching process would abort immediately,
without processing the remaining hunks and without reporting it. This
patch makes the patching no longer abort and possible hunks applied on
the copied/renamed file be written in reject files.
2012-06-01 17:37:56 +02:00
Bryan O'Sullivan
bef5b61512 cleanup: use the deque type where appropriate
There have been quite a few places where we pop elements off the
front of a list.  This can turn O(n) algorithms into something more
like O(n**2).  Python has provided a deque type that can do this
efficiently since at least 2.4.

As an example of the difference a deque can make, it improves
perfancestors performance on a Linux repo from 0.50 seconds to 0.36.
2012-05-15 10:46:23 -07:00
Brodie Rao
7f47d4e347 check-code: ignore naked excepts with a "re-raise" comment
This also promotes the naked except check from a warning to an error.
2012-05-13 13:18:06 +02:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Brodie Rao
a7ef0a0cc5 cleanup: "not x in y" -> "x not in y" 2012-05-12 16:00:57 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Matt Mackall
8420ca3aee merge with stable 2012-05-12 12:23:49 +02:00
Yuya Nishihara
9228db24a3 patch: fix segfault against unified diffs which start line is zero
Since f7e538c3b7ba, if a chunk starts with "@@ -0,1", oldstart turns into
a negative value. Because diffhelpers.testhunk() doesn't expect negative bstart,
it bypasses "alen > blen - bstart" condition and segfaults at
"PyList_GET_ITEM(b, i + bstart)".
2012-05-12 16:10:01 +09:00
Patrick Mezard
601035e58a patch: clarify binary hunk parsing loop 2012-04-29 11:19:51 +02:00
Patrick Mezard
816bc359f4 patch: be more tolerant with EOLs in binary diffs (issue2870)
The only place where an trailing CR could be meaningful is in the "diff --git"
line as part of a filename, and existing code already rule out this
possibility. Extend the CR/LF filtering to the whole binary hunk.
2012-04-26 21:44:02 +02:00
Patrick Mezard
293cc1e994 patch: include file name in binary patch error messages
$ hg import --no-commit ../mercurial_1915035238540490516.patch
 applying ../mercurial_1915035238540490516.patch
 abort: could not extract binary data

Becomes:

 abort: could not extract "binary2" binary data
2012-04-26 21:44:00 +02:00
Patrick Mezard
4076709ad5 patch: display a nice error for invalid base85 data
Before, import was terminating with a traceback. Now it says:

 $ hg import --no-commit ../bad.patch
 applying ../bad.patch
 abort: could not decode binary patch: bad base85 character at position 66
2012-04-21 19:58:18 +02:00
Patrick Mezard
b5270209ca patch: fix patch hunk/metdata synchronization (issue3384)
Git patches are parsed in two phases: 1) extract metadata, 2) parse actual
deltas and merge them with the previous metadata. We do this to avoid
dependency issues like "modify a; copy a to b", where "b" must be copied from
the unmodified "a".

Issue3384 is caused by flaky code I wrote to synchronize the patch metadata
with the emitted hunk:

 if (gitpatches and
     (gitpatches[-1][0] == afile or gitpatches[-1][1] == bfile)):
     gp = gitpatches.pop()[2]

With a patch like:

 diff --git a/a b/c
 copy from a
 copy to c
 --- a/a
 +++ b/c
 @@ -1,1 +1,2 @@
  a
 +a
 @@ -2,1 +2,2 @@
  a
 +a
 diff --git a/a b/a
 --- a/a
 +++ b/a
 @@ -1,1 +1,2 @@
  a
 +b

the first hunk of the first block is matched with the metadata for the block
"diff --git a/a b/c", then the second hunk of the first block is matched with
the metadata of the second block "diff --git a/a b/a", because of the "or" in
the code paste above. Turning the "or" into an "and" is not enough as we have
to deal with /dev/null cases for each file.

We I remove this broken piece of code:

 # copy/rename + modify should modify target, not source
 if gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') or gp.mode:
     afile = bfile

because "afile = bfile" set "afile" to stuff like "b/file" instead of "a/file",
and because this only happens for git patches, which afile/bfile are ignored
anyway by applydiff().

v2:
- Avoid a traceback on git metadata desynchronization
2012-04-21 21:40:25 +02:00
Patrick Mezard
41dcbfe34f patch: be more tolerant with "Parent" header (issue3356)
Here is how export and mq write the "Parent" header:

  mq:     # Parent XXXXX
  export: # Parent  XXXXX

then import expects exactly 2 spaces while mq tolerates one or more. So "hg
import --exact" truncates mq generated patches header by one character and
fails. This patch aligns import "Parent" header parsing on mq one. I do not
expect spaces in parent references anytime soon.

Reported by Stefan Ring <stefanrin@gmail.com>
2012-04-20 19:11:54 +02:00
Patrick Mezard
83515678f4 patch: remove useless variable assignment 2012-04-05 19:23:04 +02:00
Patrick Mezard
20e5c736c0 patch: fuzz more aggressively to match patch(1) behaviour
The previous code was assuming a default context of 3 lines. When fuzzing, it
would take this value in account to reduce the amount of removed line from
hunks top or bottom. For instance, if a hunk has only 2 lines of bottom
context, fuzzing with fuzz=1 would do nothing and with fuzz=2 it would remove
one of those lines. A hunk with one line of bottom context could not be fuzzed
at all.  patch(1) has apparently no such restrictions and takes the fuzz level
at face value.

- test-import.t: fuzz/offset changes at the beginning of file are explained by
  the new fuzzing behaviour and match patch(1) ones. Patching locations are
  different but those of my patch(1) do not make a lot of sense right now
  (patched output are the same)

- test-import-bypass.t: more agressive fuzzing makes a patching supposed to
  fail because of context, succeed. Change the diff to avoid this.

- test-mq-merge.t: more agressive fuzzing would allow the merged patch to apply
  with fuzz, but fortunately we disallow this behaviour. The new output is
  kept.

I have not enough experience with patch(1) fuzzing to know whether aligning our
implementation on it is a good or bad idea. Until now, it has been the
implementation reference. For instance, "qpush" tolerates fuzz (test-mq-merge.t
runs the special case of pushing merge revisions where fuzzing is forbidden).
2012-02-13 17:22:35 +01:00
Patrick Mezard
39da9af001 patch: fix fuzzing of hunks without previous lines (issue3264)
When applying hunks such as:

  @@ -2,1 +2,2 @@
   context
  +change

fuzzing would empty the "old" block and make patchfile.apply() traceback.
Instead, we apply the new block at specified location without testing.

The "bottom hunk" test was removed as patch(1) has no problem applying hunk
with no context in the middle of a file.
2012-02-13 16:47:31 +01:00
Patrick Mezard
1be0e99fa3 patch: make hunk.fuzzit() compute the fuzzed start locations
- It moves hunks processing weirdness where it belongs
- It helps reusing said weirdness whenever fuzzit() is called, like during the
  actual hunk fuzzing.
2012-02-13 13:51:38 +01:00
Patrick Mezard
e783da0202 patch: fuzz old and new lines at the same time
In theory, the fuzzed offsets for old and new lines should be exactly the same
as they are based on hunk parsing. Make it true in practice.
2012-02-13 13:21:00 +01:00
Patrick Mezard
a7eea871c8 import: handle git renames and --similarity (issue3187)
There is no reason to discard copy sources from the set of files considered by
addremove(). It was done to handle the case where a first patch would create
'a' and a second one would move 'a' to 'b'. If these patches were applied with
--no-commit, 'a' would first be marked as added, then unlinked and dropped from
the dirstate but still passed to addremove(). A better fix is thus to exclude
removed files which ends being dropped from the dirstate instead of removed.

Reported by Jason Harris <jason@jasonfharris.com>
2012-02-16 13:03:42 +01:00
Jesus Espino Garcia
9146d99b1d patch: a little bit more robust line counting on diff --stat (issue3183) 2012-01-21 23:50:58 +01:00
Matt Mackall
9bfa890ee6 copies: split the copies api for "normal" and merge cases (API) 2012-01-04 15:48:02 -06:00
Matt Mackall
3d60dfdd1c merge with stable 2011-11-30 17:15:39 -06:00
Benoit Allard
f3be9c5304 diff: '\ No newline at end of file' is also not part of the header
Diff containing '\ No newline at end of file' were colorized incorrectly.
2011-11-29 19:51:35 +01:00
Nicolas Venegas
2582d1e3d9 mdiff/patch: fix bad hunk handling for unified diffs with zero context
Prior to this patch "hg diff -U0", i.e., zero lines of context, would
output hunk headers with a start line one greater than what GNU patch
and git output. Guido van Rossum documents the unified diff format[1]
as having a start line value "one lower than one would expect" for
zero length hunks.

Comparing the behaviour of the three systems prior to this patch in
transforming

  c1
  c3

to

  c1
  c2
  c3

- GNU "diff -U0" reports the hunk as "@@ -1,0 +2 @@"
- "git diff -U0" reports the hunk as "@@ -1,0 +2 @@"
- "hg diff -U0" reports the hunk as "@@ -2,0 +2,1 @@"

After this patch, "hg diff -U0" reports "@@ -1,0 +2,1 @@".

Since "hg export --config diff.unified=0" outputs zero-context unified
diffs, "hg import" has also been updated to account for start lines
one less than expected for zero length hunk ranges.

[1]: http://www.artima.com/weblogs/viewpost.jsp?thread=164293
2011-11-09 16:55:59 -08:00
Patrick Mezard
cc3315778f annotate: support diff whitespace filtering flags (issue3030)
splitblock() was added to handle blocks returned by bdiff.blocks() which differ
only by blank lines but are not made only of blank lines. I do not know exactly
how it could happen but mdiff.blocks() threshold behaviour makes me think it
can if those blocks are made of very popular lines mixed with popular blank
lines. If it is proven to be wrong, the function can be dropped.

The first implementation made annotate share diff configuration entries. But it
looks like users will user -w/b for annotate but not for diff, on both the
command line and hgweb. Since the latter cannot use command line entries, we
introduce a new [annotate] section duplicating the diff whitespace options.
2011-11-18 12:04:31 +01:00
Patrick Mezard
31705153e3 patch: simplify hunk extents parsing
Do not capture unwanted groups in regexps
2011-11-14 18:16:01 +01:00
Patrick Mezard
1e1f58f358 diffstat: be more picky when marking file as 'binary' (issue2816)
The 'Bin' marker was added to every changed file for which we could not find
any diff changes. This included binary files but also copy/renames and mode
changes. Since Mercurial regular diff format emits a 'Binary file XXX has
changed' line when fed with binary files, we use that and the usual git marker
to tell them from other cases. In particular, new empty files are no longer
reported as binary.

Still, this fix is not complete since copy/renames/mode changes are now
reported as '0' lines changes, instead of 'Bin'.
2011-10-24 13:41:19 +02:00
Kirill Elagin
a331869573 diff: enhance highlighting with color (issue3034)
Now the highlighter knows whether it is in the header of the patch or not.
2011-10-05 09:20:38 +03:00
Matt Mackall
e538620d00 merge with stable 2011-09-27 18:50:18 -05:00
Steffen Daode Nurpmeso
f5ba5be1a8 patch: correctly handle non-tabular Subject: line
The line content of continued Subject: lines was yet joined via
str.replace('\n\t', ' '), which does not handle continuation via
spaces.  So expan the regular expression instead to
handle all allowed forms of mail header line continuation.
2011-09-27 18:41:09 -05:00
Dan Villiom Podlaski Christiansen
c5a1d45b09 patch: handle 'gitpatches' being empty, but not none 2011-09-11 18:49:41 +02:00
Matt Mackall
af293bcf51 merge with stable 2011-09-12 23:02:45 -05:00
Wagner Bruna
56657ac28b patch: fix parsing patch files containing CRs not followed by LFs
Since 75e6e3c16f9c , patch lines containing a CR not followed by a LF
would be incorrectly splitten, causing a failure to apply the patch.
2011-07-04 19:53:39 -03:00
Thomas Arendsen Hein
692a53d202 classes: fix class style problems found by 06e968819ac9
This makes test-wireprotocol.py work on Python 2.4
2011-06-29 15:00:00 +02:00
Peter Arrenbrecht
97a6442c24 patch: fix typo in variable name 2011-06-20 09:30:03 +02:00
Patrick Mezard
86e3700676 patch: make filestore store data in memory and fallback to fs 2011-06-17 20:33:02 +02:00
Patrick Mezard
fd8786d770 import: add --bypass option
This feature is more a way to test patching without a working directory than
something people asked about. Adding a --rev option to specify the parent patch
revision would make it a little more useful.

What this change introduces is patch.repobackend class which let patches be
applied against repository revisions. The caller must supply a filestore object
to receive patched content, which can be turned into a memctx with
patch.makememctx() helper.
2011-06-14 23:26:35 +02:00
Patrick Mezard
9a9794b348 patch: extend filtestore to store an optional copy source
This will help wrapping filestores in memctx.
2011-06-14 23:24:34 +02:00
Patrick Mezard
3680e66462 patch: generalize the use of patchmeta in applydiff()
- Add patchmeta.copy() and emit copies from iterhunks. Modifying patchmeta
  instances in applydiff() makes things simpler.
- Rename selectfile() into makepatchmeta(). It is responsible for creating
  patchmeta for regular patches.
- Pass patchmeta objects to patchfile() directly

patchmeta instances were associated with git patches, for regular patches we
had to pass additional variables to tell the patch intent to patchfile().
Instead, we generate patchmeta for regular patches and pass them. This will
also help with patch filtering by matcher objects.
2011-06-11 14:17:25 +02:00
Patrick Mezard
c72a5b0080 patch: stop updating changed files set in applydiff()
This information is more correctly returned by backends.

The extra updated file removed from test-mq-merge.t output came from changes
from git patches being counted before being really applied in some cases.
2011-06-11 14:14:13 +02:00
Patrick Mezard
6aaca90508 patch: turn patch() touched files dict into a set 2011-06-11 14:14:11 +02:00
Patrick Mezard
7acb34dda5 patch: dot not ignore hunk of files marked as 'deleted'
git 'deleted' flag was processed unconditionnally and the file removed even if
the related hunk was not matching.
2011-06-05 22:26:01 +02:00
Patrick Mezard
f3d2dd1ca2 patch: fix patchmeta/hunk synchronization in iterhunks()
Synchronizing on bfile does not work on file removal where bfile is /dev/null.
We match items on afile or bfile instead. The incorrect code makes iterhunks()
to emit patchmeta and hunks separately in some cases. This is currently hidden
by applydiff() being too tolerant when processing patchmeta, and will be fixed
later.
2011-06-05 22:24:19 +02:00
Patrick Mezard
fc7fde3949 patch: remove unnecessary exists() call in selectfile() 2011-06-05 22:24:11 +02:00
Patrick Mezard
62588fedca patch: remove redundant islink() call 2011-06-05 13:27:06 +02:00
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +02:00
Patrick Mezard
ab82a700d3 patch: do not patch unknown files (issue752) 2011-05-27 21:50:11 +02:00
Patrick Mezard
d4b7db6294 patch: use temporary files to handle intermediate copies
git patches may require copies to be handled out-of-order. For instance, take
the following sequence:

  * modify a
  * copy a into b

Here, we have to generate b from a before its modification. To do so,
applydiff() was scanning for copy metadata and performing the copies before
processing the other changes in-order. While smart and efficient, this approach
complicates things by handling file copies and file creations at different
places and times. While a new file must not exist before being patched a copied
file already exists before applying the first hunk.

Instead of copying the files at their final destination before patching, we
store them in a temporary file location and retrieve them when patching. The
filestore always stores file content in real files but nothing prevents adding
a cache layer. The filestore class was kept separate from fsbackend for at
least two reasons:

- This class is likely to be reused as a temporary result store for a future
  repository patching call (entries just have to be extended to contain copy
  sources).

- Delegating this role to backends might be more efficient in a repository
  backend case: the source files are already available in the repository itself
  and do not need to be copied again. It also means that third-parties backend
  would have to implement two other methods. If we ever decide to merge the
  filestore feature into backend, a minimalistic approach would be to compose
  with filestore directly. Keep in mind this copy overhead only applies for
  copy/rename sources, and may even be reduced to copy sources which have to
  handled ahead of time.
2011-05-27 21:50:10 +02:00
Patrick Mezard
e6f284be06 patch: refactor file creation/removal detection
The patcher has to know if a file is being created or removed to check if the
target already exists, or to actually unlink the file when a hunk emptying it
is applied. This was done by embedding the creation/removal information in the
first (and only) hunk attached to the file.

There are two problems with this approach:

- creation/removal is really a property of the file being patched and not its
  hunk.

- for regular patches, file creation cannot be deduced at parsing time: there
  are case where the *stripped* file paths must be compared. Modifying hunks
  after their creation is clumsy and prevent further refactorings related to
  copies handling.

Instead, we delegate this job to selectfile() which has all the relevant
information, and remove the hunk createfile() and rmfile() methods.
2011-05-27 21:50:09 +02:00
Steven Brown
b13eee65a4 patch: restore the previous output of 'diff --stat'
Restore the previous diffstat behaviour of scaling by the maximum number of
changes to a single file. Changeset 7bb0e22a7988 modified the diffstat to be
scaled by the total number of changes. This seems to have been unintentional.
2011-05-26 22:51:02 +08:00
Matt Mackall
c6e850b04b context: make forget work like commands.forget
Switch users of wctx.delete(..., False) to forget.
2011-05-26 17:15:35 -05:00
Patrick Mezard
32250cd067 patch: remove EOL support from linereader class
This was only used when reading patched files which is now done by backends.
2011-05-24 14:21:04 +02:00
Matt Mackall
6af03bc2e8 patch: use diffstatsum in diffstat 2011-05-21 15:06:38 -05:00
Matt Mackall
7560e9a576 patch: add diffstatsum helper 2011-05-21 15:06:36 -05:00
Matt Mackall
898e0ce783 diffstatdata: no longer a generator
This produces a smallish amount of data and all consumers needed to
buffer it anyway.
2011-05-21 15:01:28 -05:00
Patrick Mezard
272081b65d patch: fast-path git case in selectfile()
We avoid a lot of complicated heuristics in git cases, where these heurestics
may even be broken when copies are involved.
2011-05-19 22:55:13 +02:00
Patrick Mezard
a09607c9ee patch: unify backend file access interface
- Rename readlines() into getfile(), return data and mode
- Make setfile() write a data buffer instead of lines, make mode mandatory.
2011-05-19 22:49:43 +02:00
Patrick Mezard
701e9571f9 patch: merge backend setmode() into writelines()
Copy handling will be easier to handle in a single method.
2011-05-19 22:44:01 +02:00
Patrick Mezard
15861c0232 patch: stop modifying gitpatch objects
gitpatch objects emitted by iterhunks() were referencing file paths unmodified
from the input patch. _applydif() made them usable by modifying the gitpatch
objects in-place with specified path strip level. The same modified objects
were then reused by iterhunks() generator. _applydiff() now copies and update
the paths which completely decouples both routines.

As a side effect, the "git" event now receives only metadata about
copies/renames to perform the necessary copies ahead of time. Other actions are
handled in the "file" event.
2011-05-19 22:44:01 +02:00
Patrick Mezard
3246b5c773 patch: stop handling hunkless git blocks out of stream
Patch changes are emitted by iterhunks() in two separate events: 'file' when
hunks have to be applied and 'git' to describe other modifications like copies
or mode changes. Note that a file which mode is changed and which content is
modified by the same patch will be emitted in both events. It is more
convenient to handle all file modifications in a single event. This patch
"zips" git actions with regular changes so both kinds can be emitted at the
same place.
2011-05-19 22:44:01 +02:00
Patrick Mezard
ac0634bc33 patch: reindent code 2011-05-19 22:44:01 +02:00
Patrick Mezard
ac6f56515a patch: unify iterhunks() afile/bfile handling
git afile/bfile are extracted twice, once when reading a 'diff --git', and
again when reading a unified hunk. The problem is not all git blocks have
unified hunks (renames just have metadata) and they were not extracted the same
way. This is what this patch unifies.
2011-05-19 22:44:01 +02:00
Patrick Mezard
f8df1dcc42 patch: git metadata was ignored if strip > 1
gitpatch objects emitted by iterhunks() are modified in place by applydiff().
Processing them earlier improves iterhunks() isolation. applydiff() modifying
them should still be fixed though.
2011-05-19 22:44:01 +02:00
Patrick Mezard
68fd0dcbe7 patch: construct and parse binary hunks at the same time 2011-05-19 22:44:01 +02:00
Patrick Mezard
452fad17b8 patch: refactor iterhunks() regular and binary files emission 2011-05-19 22:44:01 +02:00
Patrick Mezard
78738c3822 patch: remove patch.patch() cwd argument 2011-05-19 22:44:01 +02:00
Patrick Mezard
6d4d079b0e patch: merge _updatedir() into externalpatch() 2011-05-19 22:44:01 +02:00
Patrick Mezard
2bda8cbde2 patch: add a workingbackend dirstate layer on top of fsbackend
_updatedir() is no longer used by internalpatch()

The change in test-mq-missingfiles.t comes from workingbackend not considering
the missing 'b' file as changed, thus not calling addremove() on it.
2011-05-18 23:48:17 +02:00
Patrick Mezard
34a629b9c0 patch: handle binary copies as regular ones
This introduces a performance regression for large files, as they will be
copied just to be clobbered afterwards since binary patching does not use
deltas.  But it simplifies the code and the previous optimization will be
reintroduced later in a better way.
2011-05-18 23:48:13 +02:00
Patrick Mezard
18202a57db patch: remove files while patching, not in updatedir()
At this point, updatedir() only reads the working directory and update the
dirstate.
2011-05-18 23:48:13 +02:00
Patrick Mezard
514ff73602 patch: set desired mode when patching, not in updatedir()
This patch and the following aim at merging _updatedir() actions into
_applydiff().
2011-05-18 23:48:13 +02:00
Patrick Mezard
e5afef2782 patch: stop changing current directory before patching
_applydiff() patcher argument was added to help hgsubversion like extension
monkeypatching the patching process. While it could be removed at this point, I
prefer to leave it until patch.py is completely refactored and there is a valid
and tested alternative.
2011-05-18 23:48:13 +02:00
Sune Foldager
3549e9b445 patch: remove unused variable to make pyflakes test happy 2011-05-18 09:05:18 +02:00
Patrick Mezard
42f681d4d9 patch: add lexists() to backends, use it in selectfile()
At this point, all applydiff() filesystem calls should pass through fsbackend.
2011-05-17 23:46:38 +02:00
Patrick Mezard
c3cc8c546a patch: move copyfile() into backends, abstract basedir 2011-05-17 23:46:38 +02:00
Patrick Mezard
6b9f641c33 patch: merge makerejlines() into write_rej() 2011-05-17 23:46:37 +02:00
Patrick Mezard
431a9d156a patch: extract fs access from patchfile into fsbackend
Most filesystem calls are already isolated in patchfile but this is not enough:
renames are performed before patchfile is available and some chmod calls are
even done outside of the applydiff call. Once all these calls are extracted
into a backend class, we can provide cleaner APIs to write to a working
directory context directly into the repository.
2011-05-17 23:46:15 +02:00
Patrick Mezard
45494955e5 mq: fix qpush changes detection of renamed files
patch.changedfile() was not considering renamed file source as changed.
2011-05-17 23:27:58 +02:00
Matt Mackall
ae22dd85a2 scmutil: drop some aliases in cmdutil 2011-05-13 14:48:48 -05:00
Augie Fackler
618d65243a patch: use safehasattr instead of hasattr 2011-07-25 16:02:27 -05:00
Patrick Mezard
e0378ee5bd patch: make patch()/internalpatch() always update the dirstate 2011-05-08 17:48:31 +02:00
Patrick Mezard
88e958194e patch: move updatedir() from cmdutil into patch
Also, create an artificial wdutil.py to avoid import cycles between patch.py
and cmdutil.py.
2011-05-08 17:48:30 +02:00
Idan Kamara
81a855bb70 patch: introduce changedfiles
returns the set of all changed files in a given patch
2011-05-06 19:03:41 +03:00
Idan Kamara
0cc88950bd patch: remove unused ui arg to iterhunks 2011-05-06 18:45:12 +03:00
Adrian Buehlmann
e94d06bb79 rename explain_exit to explainexit 2011-05-06 15:31:09 +02:00
Adrian Buehlmann
eb8027ea31 rename util.parse_patch_output to parsepatchoutput 2011-05-06 15:19:48 +02:00
Martin Geisler
23e62c55ea patch: fix clash between local variable and exception instance
The local err variable would be bound to PatchError thrown and it
keeps this value even after the except block is executed.

The whole thing worked anyway since the rejected variable is set in
the except block and this makes the function return -1 when a
PatchError is thrown.
2011-05-06 11:31:40 +02:00
Martin Geisler
c4c68cacee patchfile: use real Booleans instead of 0/1 2011-05-06 11:12:55 +02:00
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