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
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
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
Summary: This information may be quite useful.
Test Plan: Threw exception from license linter.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3764
Summary:
This code is much more readable to me.
It should also be faster as building the array at once should be faster than one by one.
Test Plan: Made license and XHPAST errors in PHP file, made spelling error in JS file.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3758
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
Summary:
Currently, ArcanisSingleLintEngine lints deleted paths and directories. These are sometimes appropriate, but SingleLintEngine is a less-sophisticated linter and should have more safe defaults.
Also fix an error where JSHint reported useless messages on failure.
Test Plan:
Reproduced the problem:
$ git show
commit d71efe2b13770c8861bcd3415c15503fc377339f
Author: epriestley <git@epriestley.com>
Date: Fri Oct 19 12:22:50 2012 -0700
WIP
diff --git a/test.js b/test.js
deleted file mode 100644
index 8bd6648..0000000
--- a/test.js
+++ /dev/null
@@ -1 +0,0 @@
-asdf
$ arc set-config --local lint.engine.single.linter ArcanistJSHintLinter
Set key 'lint.engine.single.linter' = "ArcanistJSHintLinter" in local config (was null).
$ arc lint --engine ArcanistSingleLintEngine --rev HEAD^
Usage Exception: JSHint returned output we can't parse. Check that your JSHint installation.
Output:
Applied the error message fix:
$ arc lint --engine ArcanistSingleLintEngine --rev HEAD^
Usage Exception: JSHint returned unparseable output.
stdout:
stderr:
node.js:181
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: ENOENT, No such file or directory '/INSECURE/repos/git-working-copy/test.js'
at Object.statSync (fs.js:400:18)
at _collect (/usr/lib/node_modules/jshint/lib/hint.js:77:12)
at /usr/lib/node_modules/jshint/lib/hint.js:93:13
at Array.forEach (native)
at Object.hint (/usr/lib/node_modules/jshint/lib/hint.js:92:17)
at Object.interpret (/usr/lib/node_modules/jshint/lib/cli.js:137:21)
at Object.<anonymous> (/usr/lib/node_modules/jshint/bin/hint:2:25)
at Module._compile (module.js:420:26)
at Object..js (module.js:426:10)
at Module.load (module.js:336:31)
Applied the remove paths fix:
$ arc lint --engine ArcanistSingleLintEngine --rev HEAD^
Usage Exception: No paths are lintable.
Reviewers: magazovski, btrahan, vrana
Reviewed By: btrahan
CC: aran, Korvin, vissi
Differential Revision: https://secure.phabricator.com/D3735
Summary:
When some linter throws then we don't print any result.
This is bad in case when the linter threw e.g. because of syntax error in some file which some other linter will tell us about.
Test Plan: Threw from a linter, made lint error in a file, saw error then exception.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3756
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
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
Summary:
This is horrible and git specific, but fixes a case where people are using "arc
patch --nobranch ..." when they're not currently on a branch.
The old code assumed you were on a branch and used getBranchName() to record
this, in order to return to that branch later and cherry-pick the patch.
When not on a branch, and using arc patch --nobranch, this was trying to return
to the branch '(no branch)'.
Now, I detect that we're not on a branch and just record what HEAD is instead.
Test Plan:
Checkout the SHA of master (so I'm on master, but not on a branch) then try to
patch it with a feature diff:
€ git checkout e7a3ec68159d6847372cab5ad913f2f15aa7c249
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
ac1ad39 Updating a-file
If you want to keep them by creating a new branch, this may be a good time
to do so with:
git branch new_branch_name ac1ad392350a51edd10343f12b9713f5e5b3707c
HEAD is now at e7a3ec6... Fix arcconfig
€ arc patch --nobranch D7
Created and checked out branch arcpatch-D7.
OKAY Successfully committed patch.
€ git branch
* (no branch)
feature
haddock
master
€ git log --oneline | head -2
38c0235 Updating a-file
e7a3ec6 Fix arcconfig
Reviewers: vrana, epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3743
Summary: This also changes how we treat `@generated` and `@nolint` - after this diff, we will still lint their path.
Test Plan:
Created directory `a.php` and symlink `b.php` pointing to directory.
`arc lint` previously printed:
> Requested path `/data/users/jakubv/devtools/arcanist/_.php' is not a file.
Now it prints:
> No lint warnings.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3737
Summary:
We need to run new Arcanist over old code in Perflab.
We also need to run new Arcanist over new code (with already deleted custom `buildAllWorkflows()`).
This will work because old code overwrites `buildAllWorkflows()`.
Test Plan:
$ arc help
$ arc help # after deleting getWorkflowName() from one workflow
Reviewers: edward, epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3741
Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.
Remove all the rules tying workflow names to class names through arcane incantations.
This has a very small performance cost in that we need to load every Workflow class every time now, but we don't hit __init__ and such anymore and it was pretty negligible on my machine (98ms vs 104ms or something).
Test Plan: Ran "arc help", "arc which", "arc diff", etc.
Reviewers: edward, vrana, btrahan
Reviewed By: edward
CC: aran, zeeg
Differential Revision: https://secure.phabricator.com/D3691
Summary:
This changes what --nobranch does, though not what it means. In git, the patch
is applied to the git commit it is based off where it will commit cleanly, and
if you specify --nobranch then arc-patch will then switch back to your original
branch and try to cherry-pick the commit there.
If this fails, you end up with merge-conflict markers in the file which can be
handy.
Test Plan: https://secure.phabricator.com/P572
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3712
Summary:
We currently pull message from Conduit twice in `arc diff` update.
Once in `buildCommitMessage()` and once in `buildRevisionFromCommitMessage()`.
Remeber that we already pulled it (and so it is authoritative) to save this call.
Even faster solution would be to not pull and update the message at all in common (non-`--edit`, non-`--verbatim` and such) update workflows but it's more involved.
Test Plan:
$ arc diff --trace
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3716
Summary: We want to use them in event.
Test Plan: Will use it in event.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3690
Summary:
I was thinking about creating a method `differential.setdiffproperties` updating all properties at once or adding 'properties' to `differential.creatediff` (better) but it will require bumping Conduit version.
This looks simpler and with similar effect.
We could postpone resolving properties more but I don't want to risk not resolving them after an error.
Test Plan:
This diff for that it works.
Benchmark: 0.55 s before, 0.25 s after (with three properties, the difference will be bigger with more).
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3689
Summary:
The 'review its own revision' check is now handled by Differential (bug T1879)
Previous behavior:
arc threw an "You can not be a reviewer for your own revision." exception
if an users adds itself as reviewer, even when this configuration is
allowed on the Differential remote install's configuration.
New behavior:
Arc doesn't check that anymore. It still will be checked by the server.
Test Plan: Tested locally pushing revisions with "arc diff" to a Phabricator server with differential.allow-self-accept at true or false with myself or not as reviewer.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Maniphest Tasks: T1879
Differential Revision: https://secure.phabricator.com/D3674
Test Plan: A lot of spew before. Not so much now.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3681
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
Summary: I use it more often without second parameter than with it.
Test Plan:
Lint of:
preg_quote('');
preg_quote('', '/');
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3647
Summary: cd && cmd won't work so use chdir; -m $multiline_message won't work so use -F $tmp_file
Test Plan: this is actually un-tested at the moment.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Maniphest Tasks: T1617
Differential Revision: https://secure.phabricator.com/D3592
Summary:
Currently, we run `runDiffSetupBasics()` //after// splitting off background lint and unit tests. However, this means `--base` and any explicit revision name (like "HEAD^") will not be parsed, so the call to `getRelativeCommit()` in order to generate `arc lint --rev XXX` will fail or not work as expected, because it will ignore any arguments.
Instead, parse `--base`, explicit revisions, and other repository API arguments before doing lint and unit tests.
Test Plan:
- Set global config for `base` to `arc:amended, git:branch-unique(origin/master)`.
- Created a commit on master.
- Ran `arc diff HEAD^`.
- Before this change, the command fails with "Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly." when it attempts to run lint, because the `HEAD^` argument is never parsed. After
- After this change, the command succeeds.
Reviewers: vrana
Reviewed By: vrana
CC: aran
Differential Revision: https://secure.phabricator.com/D3574
Summary:
We store the message to a scratch file.
But if I need to switch context, commit something else and then go back then I'll lose the message.
Amend the repository commit by it instead.
This also removes the annoying question "Do you want to use this message?".
Test Plan: Made an error in message, verified Git log.
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3561
Summary:
Currently, we print `arc tasks` in a console-agnostic and unicode-unaware way, so:
- Tasks with multibyte characters get aligned incorrectly (see T1831); and
- narrow terminals plus long task names results in a broken display.
Test Plan: Ran `arc tasks`. Will post screenshots.
Reviewers: btrahan, vrana, Korvin
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T749, T1831
Differential Revision: https://secure.phabricator.com/D3568
Summary:
See https://github.com/facebook/arcanist/pull/53
- Work correctly for directories with `%` in their name; this breaks under sprintf().
- Search for `src/` -> `tests/` style directories.
- Add coverage for search paths.
Test Plan:
Ran unit tests.
I don't have a working test case for PHPUnit tests, can one of you guys apply this and verify I didn't break your setups?
Reviewers: quard, aurelijus
Reviewed By: aurelijus
CC: aran
Differential Revision: https://secure.phabricator.com/D3558
Summary: `arc patch` currently warns about "This diff is against commit svn+ssh://... but the commit is nowhere in the working copy" in Git SVN repository.
Test Plan:
$ arc patch # in Git SVN repository
$ svn find-rev r121212112 # invalid revision
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3539
Summary: Patch created on Git contains 'unix:filemode' property which is useless in SVN.
Test Plan: Exported a bundle changing a file to executable in Git, applied it in SVN, verified that the file is executable.
Reviewers: epriestley
Reviewed By: epriestley
CC: ptarjan, aran, Korvin, digoangeline
Differential Revision: https://secure.phabricator.com/D3554
Summary:
Running `a.php` from command line doesn't work on Windows, we need to run `php a.php`.
This shouldn't break other OSes.
Test Plan:
$ arc diff --background 1
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3544
Summary:
I am using it for about a month.
It works even in Facebook www.
Test Plan:
$ arc diff --background 1 # hundreds of times
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3495
Summary: $param is null here. it should be $node.
Test Plan: arc lint no longer barfed on me!
Reviewers: vrana, epriestley
Reviewed By: vrana
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3540
Summary:
Adds a test which goes through a git repository commit by commit and applies them (in effect) via "arc patch", verifying that the results match the actual commit.
See D3439 for the fixture stuff.
The git repo archive has a couple of trivial commits in it:
$ ../libphutil/scripts/utils/directory_fixture.php src/parser/__tests__/bundle.git.tgz
Spawning an interactive shell. Exit when complete.
sh-3.2$ git log
commit f19fb9fa1385c01b53bdb6d8842dd154e47151ec
Author: epriestley <git@epriestley.com>
Date: Wed Sep 5 14:30:28 2012 -0700
Edit a text file.
commit 228d7be4840313ed805c25c15bba0f7b188af3e6
Author: epriestley <git@epriestley.com>
Date: Wed Sep 5 14:30:11 2012 -0700
Add a text file.
Test Plan: Ran tests.
Reviewers: edward
Reviewed By: edward
CC: aran
Maniphest Tasks: T866
Differential Revision: https://secure.phabricator.com/D3440