1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-10-24 01:28:51 +02:00
Commit graph

125 commits

Author SHA1 Message Date
Joshua Spence
b1112e73c4 Minor linter fixes
Summary: Apply some linter autofixes.

Test Plan: `arc lint` and `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10568
2014-09-27 10:21:23 +10:00
epriestley
65b6e1bdac Don't parse separator tabs as part of the filename in Git diffs which affect files with spaces
Summary:
Fixes T5870. When a filename contains spaces, Git will add a "\t" at the end of the "---" and "+++" lines. We currently consume this and think we're reading a file called "blah blah\t".

Instead, parse it out as not part of the filename.

Test Plan: Added failing unit test and made it pass.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5870

Differential Revision: https://secure.phabricator.com/D10267
2014-08-14 12:13:02 -07:00
Evan Priestley
97501da164 Fix double file content in files in new subdirectories in Subversion
Summary:
Fixes T5555. Normally, when we `svn diff subdir/`, we use `--depth empty` to get only changes for the directory itself (usually, property changes).

However, this flag has no effect if the directory is newly added.

Adjust the diff parser so that if two sets of hunks are specified for a single file in a raw diff, we let the last one win instead of including both. This approach is a broadly more reasonable interpretation of these diffs.

Test Plan:
  - Added a new file in a new subdirectory in Subversion.
  - Ran `arc diff --only`.
  - No double file content in resulting diff.
  - Added unit test.
  - There's fairly comprehensive unit test coverage for this stuff.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5555

Differential Revision: https://secure.phabricator.com/D9921
2014-07-15 09:43:04 -07:00
Joshua Spence
9016207307 Fix various spelling mistakes
Summary: Minor change, self-explanatory.

Test Plan: Eye-ball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9910
2014-07-13 00:45:38 +10:00
Joshua Spence
d09beeb75c Remove @group annotations
Summary: I'm pretty sure that `@group` annotations are useless now... I believe that they were originally used by Diviner?

Test Plan: Eye-balled it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D9855
2014-07-09 09:12:13 +10:00
Joshua Spence
439dff5e09 Fix a spelling mistake and tidy up whitespace
Summary: Self-explanatory.

Test Plan: Eye-ball it.

Reviewers: epriestley, chad, #blessed_reviewers

Reviewed By: chad, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9705
2014-06-24 15:09:53 +10:00
Tal Shiri
6b192f3178 --range support for git
Summary:
This adds support for passing range of commits for arc diff. This is useful when you want to submit code reviews for past commits without mucking around with the working copy.

This will probably require changes :)

Test Plan: Tested locally, but totally need to add tests for this

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9369
2014-06-11 14:37:01 -07:00
Joshua Spence
ff1915ecff Apply various linter fixes.
Summary: Applied various linter fixes. Also make the `.editorconfig` file a bit more specific. Unfortunately, `arc lint --apply-patches` currently modifies some test data that it shouldn't, but this should be fixed after T5105.

Test Plan: Ran `arc unit` to make sure things weren't broken.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D9440
2014-06-10 11:02:42 -07:00
Joshua Spence
17820442da Change double quotes to single quotes.
Summary: Ran `arc lint --apply-patches --everything` over rARC, mainly to change double quotes to single quotes where appropriate. These changes also validate that the `ArcanistXHPASTLinter::LINT_DOUBLE_QUOTE` rule is working as expected.

Test Plan: Eyeballed //most// of the diff.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D9269
2014-05-23 13:53:05 -07:00
epriestley
a36969e58b Allow arc to parse svnlook diffs from moves/copies
Summary: Ref T4697. This is similar to the existing stuff, but `svnlook diff ...` can also produce a "Copied" header. Currently, we choke on it in Herald when running pre-commit rules.

Test Plan: Added and ran tests. In the next diff, used this in a real system.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4697

Differential Revision: https://secure.phabricator.com/D8653
2014-04-01 08:20:55 -07:00
epriestley
46fe94db9f Support git-format-patch format in diff parser
Summary:
Fixes T4063. The `git format-patch` command produces a special header
and footer which we need to detect, strip, and parse.

Test Plan:
  - Added and ran unit tests.
  - Submitted a diff with `git format-patch HEAD^ --stdout | arc diff --raw`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4063

Differential Revision: https://secure.phabricator.com/D8547
2014-03-15 11:25:49 -07:00
epriestley
06cfe0746e Utilize assertFalse and assertTrue methods.
Summary:
Ref D8460.

Use `$this->assertFalse(...)` and `$this->assertTrue(...)` instead of `$this->assertEqual(false, ...)` and `$this->assertEqual(true, ...)` respectively.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8461
2014-03-08 18:33:05 -08:00
Sergey Sharybin
2c2c5663cb Fix exception on diff parse on FreeBSD
FreeBSD 9.2 comes with diff tool version 2.8.7 which behaves
a bit different from how it is expected to. Namely for diff
between two binary files it says:

  Files A and B are differ

This was leading to an exception when browsing revisions with
changes in binary files.

Tweaked parse patterns in order to fix this issue. Now both
older and newer diff tools are supported.

See: <https://github.com/facebook/arcanist/pull/139>

Reviewed by: epriestley
2014-01-18 11:13:28 -08:00
epriestley
8e177c4db8 Parse the output of svnlook diff ...
Summary: Ref T4195. When figuring out changed content in SVN, the easiest approach is to use `svnlook diff`, but it has a slightly different header than we're used to. Adjust the parser for it and add some tests.

Test Plan: Clean unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4195

Differential Revision: https://secure.phabricator.com/D7790
2013-12-18 14:20:59 -08:00
Aviv Eyal
a2285b2b5a Extract configuration read/write methods out of BaseWorlkflow
Summary:
Create a new class for them, pass instance around as need.

This looks like it's mostly working, but I'd like to replace the various `new ArcanistConfigurationManager()`
calls with something more suitable.

And maybe get a better name for ArcanistConfigurationManager ("Configuration" is already taken).

Test Plan: arc unit --everything, and then some.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, chad

Differential Revision: https://secure.phabricator.com/D7271
2013-10-18 16:10:45 -07:00
epriestley
587addfd94 Strip comments from all diffs before parsing them
Summary:
See <https://github.com/facebook/phabricator/issues/400>. Since all of `patch`, `git apply` and `hg export` either accept or emit header comments, parse them unconditionally.

This is a tiny bit messy because we already had a less-general parser for `hg export` diffs, which have a large header section.

This is less permissive than GNU `patch`, which allows comments anywhere. We could do that, but `git apply` won't read them and they seem pretty crazy.

Test Plan: Added and ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7207
2013-10-03 15:06:35 -07:00
epriestley
3ad72195bf When converting a file to a binary, populate the binary's data
Summary:
Currently, we prompt the user to mark non-UTF8 files as binary, but don't actually attach the data to the change when they do. This means we don't upload the data, and can't patch it later.

A simple reproduction case is to build a test file (I used one with bytes from 1..255):

  $ # Don't include \0, since Git treats that specially.
  $ ./echo_every_byte_from_1_to_255_inclusive.erl > example.txt

Then add it:

  $ git add example.txt
  $ git commit -a -m derp
  $ arc diff --only HEAD^

You'll be prompted to convert the file to binary:

  Do you want to mark this file as binary and continue? [Y/n] y

Before this patch, that would be followed by:

  Uploading 0 files...

...which is incorrect; we need to upload the new data. After this patch, this shows:

  Uploading 1 files...

...which is also incorrect, but only grammatically. Diffs created after this patch apply back cleanly with `arc patch` and restore the file properly.

Test Plan: Followed instructions above, restoring a textual binary conversion by using `arc patch`.

Reviewers: zeeg, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6815
2013-08-27 09:34:30 -07:00
Bob Trahan
a45ef76a8f Arcanist changes related to T2784
Summary: These were in my sandbox, but I forgot about them. Without this things break post D5896. Ref T2784

Test Plan: my sandbox works and soon so shall others

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2784

Differential Revision: https://secure.phabricator.com/D5929
2013-05-14 15:24:20 -07:00
durham
f5c8430188 Change hg arc diff to detect up to the nearest parent with a diff
Summary:
Changes arc diff to choose the base commit as the first ancestor
that has a diff.  So if your tree looks like master->A->B->C->D, if you
have a diff on B (which will include A), when you run arc diff on D it will
only include C and D.

This makes the scenario for stacked diffs nicer.  A user can commit A, commit B,
arc diff, commit C, commit D, arc diff, arc land B, arc land D.

Test Plan:
Commit A on top of master
Commit B on top of A
arc diff
Commit C on top of B
Commit D on top of C
arc diff

Verify the second diff contains the changes in C and D, but not A and B.

hg up B
arc land --preview
Verify that arc land shows A and B

hg up D
arc land --preview
Verify that arc land shows A, B, C, and D
(arc land should be unaffected by this change.
It always tries to land the entire branch)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5639
2013-04-12 14:11:51 -07:00
Afaque Hussain
e0702d17c2 Parsing rcsdiff -u
Summary: Added some sample rcsdiffs for adding and deleting a line from a file. Wrote some test cases to be tested by ArcanistDiffParser.

Test Plan: By making all the test cases pass.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Differential Revision: https://secure.phabricator.com/D5324
2013-03-14 06:15:42 -07:00
durham
8412f7cfd7 Improve hg arc diff perf when image files are uploaded
Summary:
arc diff called 'hg cat' twice for every image binary in the diff.
This turns out to take 1 second per call on a large repo because mercurial
has to parse the manifest every time.

Now arc diff batches up all the files and does only two 'hg cat'
commands.  This makes the cost constant relative to the number of
images being uploaded.

Test Plan:
Ran arc diff on a diff with 30 images on both git and hg.
Verified that it was fast and that the images showed up in the web ui.

Reviewers: epriestley

Reviewed By: epriestley

CC: sid0, dschleimer, bos, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5144
2013-02-28 09:46:42 -08:00
epriestley
31a390a38c Fix issue with SVN property changes under Windows
Summary: We were incorrectly matching `$` in the regexp against a possible `\r\n`. I missed this earlier when trying to catch all of these.

Test Plan:
  - Added unit test and made it pass.
  - Did another search for `getLine()` to see if I could spot any more of these, but failed to identify any via inspection.

Reviewers: vrana, mbishopim3

Reviewed By: mbishopim3

CC: aran

Differential Revision: https://secure.phabricator.com/D5038
2013-02-20 13:24:14 -08:00
epriestley
7a67173b97 Apply new whitespace lint rules to arcanist/
Summary: Automated changes from `arc lint`.

Test Plan: Looked them over.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5017
2013-02-19 14:09:20 -08:00
epriestley
4e688b0e0e Parse property change diffs generated with old SVN (prior to 1.5)
Summary:
Fixes T2565. SVN from before June 2008 generates different looking property changes.

See http://subversion.tigris.org/issues/show_bug.cgi?id=3019 for the change.

Test Plan: Added a unit test derived from the report in T2565, made it pass.

Reviewers: chad, vrana

Reviewed By: chad

CC: aran

Maniphest Tasks: T2565

Differential Revision: https://secure.phabricator.com/D5009
2013-02-19 07:32:57 -08:00
epriestley
d952502f12 Make "arc patch" read authorName and authorEmail
Summary: If provided, have `arc patch` use `authorName` / `authorEmail`. This simplifies handling and makes patches more portable between version control systems (previously, information was generated in the diff's VCS, regardless of which VCS it was being applied to).

Test Plan: Created a diff with author `derp <derp@derp.com>`, ran `arc patch --diff x`, got a local commit with that author.

Reviewers: btrahan, edward, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4827
2013-02-05 20:11:39 -08:00
vrana
a9e316bf9c Fix dynamic string usage as safe input
Summary: This fixes some real issues.

Test Plan:
  $ arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, btrahan

Differential Revision: https://secure.phabricator.com/D4795
2013-02-02 16:28:15 -08:00
epriestley
51f32bdde7 Restore directory after executing ArcanistBundleTestCase
Summary:
This test currently chdir()'s into a directory which is later removed. If another test tries to run a shell script while the CWD is invalid, the shell may emit this to stderr:

  shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Among other things, this can cause the XHPAST test to fail, because it detects syntax errors by examining stderr.

Instead, retore the directory.

Test Plan: Ran "arc unit --everything", which could previously fail if XHPAST ran after Bundle.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4738
2013-01-30 11:24:41 -08:00
Asher Baker
087ad5f84a Added support for hg diffs generated in git mode
Summary: Fixes T2112. These are fairly common now, and are used as the storage format for `hg export` and mq in most installs.

Test Plan: Ran unit tests, used `arc patch --patch`, uploaded some diffs manually.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2112

Differential Revision: https://secure.phabricator.com/D4592
2013-01-22 18:14:14 -08:00
epriestley
38e2e1336f Generate Git patches with "\n" metadata line endings unconditionally
Summary:
Fixes T2175. Git generates patches which have "\n" line endings on every system. We currently generate patches with system-dependent line endings.

Git accepts system-dependent line endings in almost call cases, but part of the parser tests for "\n" explicitly. T2175 has an example of this.

Test Plan:
Ran `arc export --git --revision D4366 > export.git` on a Windows machine, verified "\n" line endings. Ran the same with `--unified`, verified "\r\n" line endings.

(I didn't add any unit tests for this because it's Windows-dependent and very difficult to test meaningfully right now -- i.e., test that appliable patches are generated -- since the git reconstitution test doesn't run on Windows either, because we can't yet untar things there.)

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2175

Differential Revision: https://secure.phabricator.com/D4373
2013-01-09 13:51:51 -08:00
epriestley
ea1585d7fa Fix "empty diff" error in arcanist
Summary: Ref T2296. This error is unreachable right now -- when I fixed all the "\r\n" stuff, we always end up with a nonempty first line for an empty input. Do this test earlier and more explicitly. This results in a less useful error: "expected (some junk) on line 1" instead of "can't parse an empty diff".

Test Plan: Tried to parse an empty diff, got a "you can't parse an empty diff" error.

Reviewers: btrahan, vrana, codeblock

Reviewed By: codeblock

CC: aran

Maniphest Tasks: T2296

Differential Revision: https://secure.phabricator.com/D4370
2013-01-09 08:15:53 -08:00
epriestley
2ae0cb797d Remove ArcanistRepositoryAPI::setDefaultBaseCommit()
Summary:
This method is used in three cases:

  # For unit tests, to set the range to 'HEAD^' or '.^' in an agnostic way.
  # For "amend", to set the range to the commit to be amended (also 'HEAD^' or '.^').
  # For "patch" and "upgrade" so we don't fail just because there's an invalid "base" rule somewhere in the config when doing clean-working-copy tests.

For cases (1) and (2), introduce an "arc:this" rule to mean "the current commit". For case (3), remove the call; it is no longer necessary to check the commit range in order to do tests for the working copy state after D4095.

Test Plan: Ran unit tests, "arc upgrade", "arc patch", "arc amend".

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4096
2012-12-17 12:53:38 -08:00
vrana
5025c06f3d Introduce arc lint --only-new 1
Test Plan:
  $ arc lint src/workflow/ArcanistLintWorkflow.php
  $ arc lint --only-new 1 src/workflow/ArcanistLintWorkflow.php

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2038

Differential Revision: https://secure.phabricator.com/D3934
2012-12-03 17:21:17 -08:00
epriestley
2d3d7be09a Allow ArcanistDiffParser to parse diff.suppress-blank-empty Git diffs
Summary: See D3963. Instead, parse these diffs so they'll work with `--raw`, etc.

Test Plan:
Generated a failing diff, added it as a test case. Fixed issue. Ran test suite. Ran `arc` against it:

  $ git -c diff.suppress-blank-empty=true diff HEAD | arc diff --raw --only --conduit-uri=http://local.aphront.com:8080/
  Reading diff from stdin...
  Created a new Differential diff:
          Diff URI: http://local.aphront.com:8080/differential/diff/103/

  Included changes:
    M       things

Reviewers: vrana, jiiix, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3969
2012-11-15 15:47:35 -08:00
Bob Trahan
827c1bc1c5 make arc patch workflow preserve author commit information
Summary: assumes D3917 (or something like it that populates 'author' value from conduit call) exists in production

Test Plan: stubbed out 'author' value and verified checkins as author worked

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T479

Differential Revision: https://secure.phabricator.com/D3918
2012-11-09 13:36:15 -08:00
Sergio Correia
02b185571f ArcanistBundle: fix attribution of $old_phid when building binary changes
Summary:
The variable $old_phid was not being set in a certain situation in
buildBinaryChange(), and that was causing the following error, during
`arc patch <revision>`:

"the patch applies to <file> (<hash>), which does not match the
current contents."

and hence it was failing to download/apply the patch.

Signed-off-by: Sergio Correia <sergio@correia.cc>

Test Plan:
I spotted the problem in a revision where I was renaming
some images, which are binary.

Reviewers: epriestley, vrana, btrahan

Reviewed By: btrahan

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3925
2012-11-08 11:34:22 -08:00
epriestley
c8409bb5b2 Fix an issue where arc diff would loop indefinitely for a property change
Summary:
When we hit a diff which is missing file context, we try to pull it synthetically later. This works for moves and copies, but currently fails for property changes. Since it failed, we didn't have context, so we'd try to pull it again...

The general problem this creates is that when you mark a file "+x" without changing it, we can't show you the content in Differential. Not a huge deal. In some future diff, I'll build the content synthetically.

Adds commits to cover this behavior:

  commit 1830a13adf764b55743f7edc6066451898d8ffa4
  Author: epriestley <git@epriestley.com>
  Date:   Tue Nov 6 17:11:18 2012 -0800

      Mark koan2 +x and edit it.

  commit 8ecc728bcc9b482a9a91527ea471b04fc1a025cf
  Author: epriestley <git@epriestley.com>
  Date:   Tue Nov 6 17:08:44 2012 -0800

      Move 'text' to 'executable' and mark it +x.

  commit 39c8e7dd3914edff087a6214f0cd996ad08e5b3d
  Author: epriestley <git@epriestley.com>
  Date:   Tue Nov 6 16:36:59 2012 -0800

      Mark koan as +x.

Test Plan: Ran unit tests. Previously, they looped indefinitely. Now, they pass.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3909
2012-11-06 17:46:55 -08:00
vrana
66d204be81 Delete license headers from files
Summary:
This commit doesn't change license of any file. It just makes the license implicit (inherited from LICENSE file in the root directory).

We are removing the headers for these reasons:

- It wastes space in editors, less code is visible in editor upon opening a file.
- It brings noise to diff of the first change of any file every year.
- It confuses Git file copy detection when creating small files.
- We don't have an explicit license header in other files (JS, CSS, images, documentation).
- Using license header in every file is not obligatory: http://www.apache.org/dev/apply-license.html#new.

This change is approved by Alma Chao (Lead Open Source and IP Counsel at Facebook).

Test Plan: Verified that the license survived only in unit tests and LICENSE file.

Reviewers: epriestley, btrahan, edward

Reviewed By: epriestley

CC: aran, Korvin, davidrecordon

Maniphest Tasks: T2035

Differential Revision: https://secure.phabricator.com/D3881
2012-11-05 11:16:24 -08:00
epriestley
d96eaed097 Partially revert D3748
Summary:
D3748 attempted to improve the behavior of `arc diff` when dealing with files merged from another branch, but had the side effect of marking all normal edits and deletes as adds. Revert this side effect, at least. This likely degrades the merging case, but it's comparatively rare, and editing/deleting files is very common.

I'll make an effort to fix this properly (and back it with DirectoryFixture tests) when I deal with T1947.

Test Plan: Ran `arc diff --preview` for a change that edits or removes files.

Reviewers: btrahan, vrana, svemir

Reviewed By: svemir

CC: aran

Differential Revision: https://secure.phabricator.com/D3836
2012-10-30 07:06:05 -07:00
epriestley
6be5cfd104 Split paths on "diff --git" lines correctly in more cases
Summary:
See T1973. In T1675, we addressed parsing of diffs with `--no-prefix` or custom `--src-prefix` and `--dst-prefix` flags. However, this inadvetently broke diffing of files with spaces in their names, which Git does not quote. They look like this normally:

  diff --git a/old file b/new file

Prior to D3744, we accidentally got this right by looking for the `a/` and `b/`. However, we no longer do, and instead produce nonsense results.

This problem is difficult because for files with spaces, `git diff --no-prefix` may generate an ambiguous line like:

  diff --git a b c d e f g

From this line, we have no way to deterine if this moves "a" to "b c d e f g", or "a b c d" to "e f g", or anything in between. In some diffs we have more information later on, but in some cases we do not, e.g. for binary diffs without `--binary`.

Try to get this right in as many cases as possible:

  - If there are quotes, we can unambiguously get it right. This only happens for filenames with quotes or unicode characters, however.
  - If there is exactly one space, we can unambiguously get it right.
  - Interpret the common case of `a/<anything> b/<anything>` in the most-likely-correct way again.
  - Interpret the rare case of `<anything> <that same thing>` in the most-likely-correct way.
  - Complain about any `a b c d e f g` garbage.

Test Plan: Ran unit tests. Created a diff of a file called "File With Spaces".

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran, ReturnZero

Maniphest Tasks: T1973

Differential Revision: https://secure.phabricator.com/D3818
2012-10-25 14:46:44 -07:00
epriestley
10653d7ff3 Fix some regexp issues for parsing SVN diffs with \r\n newlines
Summary: We need to tweak a few patterns to accommodate the possibility that lines end in "\r\n".

Test Plan: Added failing unit test and made it pass.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, mbishopim3

Maniphest Tasks: T1944

Differential Revision: https://secure.phabricator.com/D3772
2012-10-22 11:15:36 -07:00
epriestley
6114d7cf9c Add a large number of move/copy diff/patch tests
Summary: The way we represent some move/copy stuff is a bit messed up, but it mostly works, so add coverage before I mess with it.

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3752
2012-10-20 08:43:31 -07:00
epriestley
4b03a3fa0d Improve test coverage of diff/patch generation
Summary:
We have coverage for generating patches, applying them, and making sure they reproduce the original repository state. However:

  - The code uses simplified patch generation which omits some flags like `-M` and `-C`, and generally produces less rich patches than we really produce. Instead, produce patches the same way `arc diff` does.
  - We don't test the intermediate change representation. In theory it's not too important because if we get it wrong the output should be wrong, but in practice it makes it easier to nail down issues. We can also generate less-rich patches which still apply correctly, but would prefer not to.
  - Similarly, we don't test the intermediate patch representation. This is almost entirely redundant with simply applying the patch, but easier to visualize.

Add coverage for all that stuff and fix some bugs with `-M` / `-C` patch generation that weren't caught under the simpler patch generation.

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3751
2012-10-20 08:43:13 -07:00
epriestley
5981aa1df4 Make ArcanistDiffParser automatically load synthetic changes if the working copy is available
Summary: Make this harder to get wrong. Instead of requiring a separate call for synthetic data, automatically load it if we can.

Test Plan: Unit tests; `arc diff`.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3750
2012-10-20 08:42:16 -07:00
epriestley
7cb3551dc7 Fix two arc issues
Summary:
  - I caused $parser to be reused in D3732 which I belived was safe, but actually isn't. We end up writing to the same changes. We should make it safe but there's some mess in Phabricator that needs to be cleaned up first.
  - One minor error code thing, variable is undefined.

Test Plan: Ran `arc export --git` on a moved file, got a better result. Ran some command which made me hit the other case and didn't get a fatal anymore.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3749
2012-10-20 06:13:12 -07:00
Svemir Brkic
134e9e5b4d Treat a file merged from another svn branch as an addition
Summary:
After a reintegration merge, "Copied From URL" will be different and current approach will result in a wrong path. If the path does not match, just mark it as a new file.

moved the comment before if so lines stay at 80 chars

Test Plan: in trunk, svn merge --reintegrate ^/branches/foo and arc diff - without this change it will say "Copied from es/foo/..."

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3748
2012-10-19 15:55:42 -07:00
epriestley
f1bca1b7cb Make parser more flexible in the face of Git diff prefix flags
Summary: See T1675 for discussion. We currently strip `[abicwo12]/` from Git patches, but the user can provide arbitrary prefixes with `--src-prefix` and `--dst-prefix`, or strip prefixes entirely with `--no-prefix`. In these cases, trust they know what they're doing rather than rejecting the diff.

Test Plan: Added a bunch of tests. We have existing tests for `diff.mnemonicprefix` and normal prefixes.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1675

Differential Revision: https://secure.phabricator.com/D3744
2012-10-19 14:07:34 -07:00
epriestley
ffac8d5c4c Improve arc handling of various binary file operations in Git
Summary:
See T866, D3521. Additional things this fixes:

  - `arc export` now exports binary data correctly.
  - `ArcanistBundle` unit tests now load and apply binary data correctly.
  - `arc patch` no longer relies on `base` configuration.
  - Adds tests to the tarball:

  commit df340e88d8aba12e8f2b8827f01f0cd9f35eb758
  Author: epriestley <git@epriestley.com>
  Date:   Wed Oct 17 15:46:11 2012 -0700

      Remove binary image.

  commit 3f5c6d735e64c25a04f83be48ef184b25b5282f0
  Author: epriestley <git@epriestley.com>
  Date:   Wed Oct 17 15:45:58 2012 -0700

      Copy binary image.

  commit b454edb3bb29890ee5b3af5ef66ce6a24d15d882
  Author: epriestley <git@epriestley.com>
  Date:   Wed Oct 17 15:45:35 2012 -0700

      Move binary image.

  commit 5de5f3dfda1b7db2eb054e57699f05aaf1f4483e
  Author: epriestley <git@epriestley.com>
  Date:   Wed Oct 17 15:45:09 2012 -0700

      Add a binary image.

Test Plan: Ran unit tests, `arc patch`, `arc export`, `arc diff`, `arc upgrade`.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3732
2012-10-19 10:10:25 -07:00
vrana
c57ee8e564 Add missing newline in arc export
Summary:
Hunk may be missing newline at end of file. It produces exports like this:

  lang=diff
  --- a/third-party
  +++ b/third-party
  @@ -1 +1 @@
  -/mnt/gvfs/third-party/90cb1654197e56261b1733c704b387285f36208e
  \ No newline at end of file
  +/mnt/gvfs/third-party/7097083d10d37251218531da398545658872a47a
  \ No newline at end of filediff --git a/ti/proxygen/TARGETS b/ti/proxygen/TARGETS

Test Plan:
  $ arc export --git --diff 1

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, lesliepc16

Differential Revision: https://secure.phabricator.com/D3672
2012-10-10 13:43:59 -07:00
vrana
35f20154ae Fix typo in comment 2012-10-09 16:39:48 -07:00
vrana
da74127fec Write to STDERR instead of php://stderr
Summary: See D3661.

Test Plan:
  $ arc diff --raw

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1261

Differential Revision: https://secure.phabricator.com/D3662
2012-10-08 16:34:18 -07:00