]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
13 years agoArcanist - make Patch workflow automagically apply dependencies
Bob Trahan [Thu, 17 Oct 2013 21:59:04 +0000 (14:59 -0700)]
Arcanist - make Patch workflow automagically apply dependencies

Summary: Nice title. Ref T479.

Test Plan:
Actually, help on that? I want to make sure I properly build up the "depends" on data. Is it as simple as

  -- observe at some commit hash RAZZMATAZZ
  -- git checkout -B "foo"
  -- <work>
  -- git commit -m "stash"
  -- arc diff -> yields DX
  -- git checkout -B "foo_prime"
  -- <work>
  -- git commit -m "stash"
  -- arc diff -> yield DY
  -- git checkout RAZZMATAZZ
  -- arc patch DY
  -- get prompted in workflow, agree
  -- git log and observe DX and DY applied

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran, davidressman
Maniphest Tasks: T479

Differential Revision: https://secure.phabricator.com/D6790

13 years agoWrite ARCANIST into the environment while running arc
epriestley [Thu, 10 Oct 2013 13:18:37 +0000 (06:18 -0700)]
Write ARCANIST into the environment while running arc

Summary:
Addresses a request to let Git commit hooks react differently when run via `arc`. While executing an `arc` command, write ARCANIST into the environment.

(I wrote the actual command as the value since it seemed like it could plausibly be more useful than `true` or `1`.)

Test Plan: Added `pre-commit` to `.git/hooks` which did `echo $ARCANIST`, verified the envvar was accessible when running via arc.

Reviewers: btrahan, frgtn

Reviewed By: frgtn

CC: aran
Differential Revision: https://secure.phabricator.com/D7281

13 years agoRemove spurious +x from arcanist
epriestley [Sat, 5 Oct 2013 12:20:05 +0000 (05:20 -0700)]
Remove spurious +x from arcanist

Summary: A few files here have +x, but should not. Also correct a
spelling mistake.

13 years agoKeep Arcanist from mistaking paths that look like svn:externals as svn:externals
root [Sat, 5 Oct 2013 00:31:18 +0000 (17:31 -0700)]
Keep Arcanist from mistaking paths that look like svn:externals as svn:externals

Summary: Fixes T3920. Added a slash to the path and external name so that "public" and "publicnotexternal" won't appear to be the same root.

Test Plan:
We've had this issue in one of our projects for some time, just ran into it again today. Ran the patched arc against the same directory structure and the troublesome file was added to the diff. Confirmed that files
modified in the "public" (svn external) folder are still caught as external modifications.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T3920

Differential Revision: https://secure.phabricator.com/D7226

13 years agoget jshint error codes
Tal Shiri [Fri, 4 Oct 2013 13:29:47 +0000 (06:29 -0700)]
get jshint error codes

Summary:
makes jshint slightly more useful by printing out error numbers. I love memorizing numbers.
Sorry about the crappy getLintMessageName(). There was no list of error names, just the long descriptions that are already rendered as 'reason'.

Test Plan: Verify that the numbers are mezmorizing. Been tested on OSX with jshint v2.1.11

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D7213

13 years agoStrip comments from all diffs before parsing them
epriestley [Thu, 3 Oct 2013 22:06:35 +0000 (15:06 -0700)]
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

13 years agoadded getLinterConfigurationName() to ArcanistJSHintLinter.
Tal Shiri [Thu, 3 Oct 2013 02:02:40 +0000 (19:02 -0700)]
added getLinterConfigurationName() to ArcanistJSHintLinter.

Summary: Needed for it to be usable from ArcanistConfigurationDrivenLintEngine, which is pretty ok.

Test Plan: put jshint in your .arclint and feel the electricity in the air.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D7200

13 years agoAdd C# linter for Arcanist.
James Rhodes [Tue, 1 Oct 2013 18:37:26 +0000 (11:37 -0700)]
Add C# linter for Arcanist.

Summary:
Completes T3859.  This implements a C# linter for Arcanist, which in turn uses `cslint` from `cstools` to actually perform the linting.  `cslint` internally uses StyleCop in addition to it's own lint rules.

Unlike other linters, C# is a compiled language, which means that the StyleCop integration must be aware of the full project.  To this end, there is the `discovery` setting in `.arclint`.  This allows users to define mappings between C# files and the projects they belong to.  Here is an configuration for `.arclint` (and is the one we use):

```
{
  "linters": {
    "csharp": {
      "type": "csharp",
      "include": "(\\.cs$)",
      "binary": "cstools/cslint/bin/Debug/cslint.exe",
      "discovery": {
        "([^/]+)/(.*?)\\.cs": [
          "$1/$1.Linux.csproj"
        ],
        "([^\\\\]+)\\\\(.*?)\\.cs": [
          "$1\\$1.Windows.csproj"
        ]
      }
    }
  }
}
```

Test Plan: Tested under both Linux and Windows.  Changed some files, ran `arc lint` and it all worked correctly.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran, jamesr
Maniphest Tasks: T3859

Differential Revision: https://secure.phabricator.com/D7170

13 years agoFix coverage for NoseTestEngine
Aviv Eyal [Mon, 30 Sep 2013 17:44:38 +0000 (10:44 -0700)]
Fix coverage for NoseTestEngine

Summary:
In case that the $source_path is `.` or empty, it produces filenames that
look like `./foo.py`, which differential doesn't like.

Test Plan: arc diff, see coverage data.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D7181

13 years agoExtract xUnit test results parser
Aviv Eyal [Mon, 30 Sep 2013 17:43:08 +0000 (10:43 -0700)]
Extract xUnit test results parser

Summary:
Many test frameworks can format their output in xUnit-like format.

Test Plan: Tested the Nose engine with a Nose one, and the pytest with a demo project.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D7011

Conflicts:
src/__phutil_library_map__.php

13 years agoFix a stiring issue in the External linter
epriestley [Sun, 29 Sep 2013 14:44:33 +0000 (07:44 -0700)]
Fix a stiring issue in the External linter

Summary: See error message in D7170 --  this should be a `.`, not a `,`.

Test Plan:
Faked interprerter and got reasonable error message:

> Unable to locate interpreter "TESTpython2.6" to run linter ArcanistPEP8Linter. You may need to install the intepreter, or adjust your linter configuration.
> TO INSTALL: Install PEP8 using `easy_install pep8`.

This doesn't fix the //real// error, which is that the test should skip if you don't have the interpreter/binary, but that's a little more involved.

Reviewers: hach-que, chad, btrahan

Reviewed By: chad

CC: aran
Differential Revision: https://secure.phabricator.com/D7172

13 years agoSet the CWD before applying a git patch
Gareth Evans [Sat, 28 Sep 2013 13:53:15 +0000 (06:53 -0700)]
Set the CWD before applying a git patch

Summary:
If in a subdirectory, any changes made in a different location
is missed from the patch with no errors from git. The other
option was to run some logic to compare the files being changed.

Test Plan:
Run arc patch from a subdirectory that would miss some files
previously.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Maniphest Tasks: T3733

Differential Revision: https://secure.phabricator.com/D7167

13 years agoAdding arc lint flag that will show lint only on changed lines - even when paths...
Chris Dentel [Fri, 20 Sep 2013 23:08:59 +0000 (16:08 -0700)]
Adding arc lint flag that will show lint only on changed lines - even when paths are specified

Summary:
The existing lint configurations do not allow for linting only the lines that have
changed when paths are added.  --lintall has a default behavior of true when paths are specified,
and false when paths are not specified.  Because of this (and because it does not take a boolean
param) it is not possible to lint a path for only the errors on changed lines - only-new is not
working presently.

Test Plan: play around with the linter

Reviewers: lifeihuang

Reviewed By: lifeihuang

CC: epriestley, aran
Differential Revision: https://secure.phabricator.com/D7055

13 years agoAdd `https.blindly-trust-domains` to Arcanist
epriestley [Wed, 25 Sep 2013 22:26:38 +0000 (15:26 -0700)]
Add `https.blindly-trust-domains` to Arcanist

Summary:
This allows users to specify that they want to implicitly trust their weird self-signed certificate without verification.

This can either be specified per user (which will make it apply every time the user runs `arc`, in any project):

  arc set-config https.blindly-trust-domains '["example.mycompany.com"]'

...or added to a `.arcconfig` file (which will make it apply to every user who runs `arc` in that project):

  "https.blindly-trust-domains" : ["example.mycompany.com"]

Depends on D7130.

Test Plan: Tweaked config and verified this setting sends HTTPSFuture down the right branch.

Reviewers: btrahan

Reviewed By: btrahan

CC: hlau, aran
Differential Revision: https://secure.phabricator.com/D7131

13 years agoFix an issue where method prototypes have different signatures
epriestley [Mon, 23 Sep 2013 15:34:28 +0000 (08:34 -0700)]
Fix an issue where method prototypes have different signatures

Summary: PHP whines about this:

> [2013-09-23 08:09:22] ERROR 2048: Declaration of CSharpToolsTestEngine::loadEnvironment() should be compatible with XUnitTestEngine::loadEnvironment($config_item = 'unit.xunit...') at [/INSECURE/devtools/arcanist/src/unit/engine/CSharpToolsTestEngine.php:13]

Auditors: jamesr, btrahan

13 years agoAdd C# tools and xUnit unit test engines.
James Rhodes [Mon, 23 Sep 2013 12:32:34 +0000 (05:32 -0700)]
Add C# tools and xUnit unit test engines.

Summary:
This implements Arcanist support for the xUnit testing framework.  It also supports code coverage by way of `cstools` (which is something I've written).

The unit test support works under both Linux and Windows, while the code coverage support has only been tested under Linux (one would assume it would also work under Windows given that Windows has a super-set of functionality in the C# world).

The Arcanist support assumes that the directory layout will be something like:

  * MyProject
  * MyProject.Tests

When files are changed in either MyProject or MyProject.Tests, it causes MyProject.Tests to be built and the xUnit runner to be executed on the resulting binary.

Test Plan: I guess if really wanted to, you could create a C# project in MonoDevelop, set up `.arcconfig` to point to this unit test engine, and download and build xUnit and cstools.  Run `arc unit --coverage` to see the results of your unit test coverage.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Maniphest Tasks: T3859

Differential Revision: https://secure.phabricator.com/D7058

13 years agoPrevent detailed code coverage from accessing missing report.
James Rhodes [Fri, 20 Sep 2013 16:18:02 +0000 (09:18 -0700)]
Prevent detailed code coverage from accessing missing report.

Summary:
Fixes T3856.

Detailed code coverage iterates over all of the files with changes in the current repository, however the code coverage tool might not generate a report for all changed files in the repository, and this would result in an undefined index error.

As an additional bonus, since changes to binary files won't be reported by code coverage tools, this also prevents binary data from being outputted to the console.

Test Plan:
Change a binary file in a repository and run a code coverage tool.  The binary file should be reported as 0% code coverage, but the file contents should not be rendered to the console.

Change a code file that is not covered by a code coverage tool and run code coverage.  The file should be reported as 0% code coverage, and the file contents should not be displayed.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Maniphest Tasks: T3856

Differential Revision: https://secure.phabricator.com/D7051

13 years agoPerform case-insensitive check for PHPUnit test finder to not return original file
Eric Stern [Thu, 19 Sep 2013 22:14:44 +0000 (15:14 -0700)]
Perform case-insensitive check for PHPUnit test finder to not return original file

Summary: PhpunitTestEngine incorrectly included some source files as tests when run on a case-insensive fiesystem. This fixes that behavior. It could introduce problems for case-sensive users, but it's extremely unlikely to be an issue in practice (who would put a file in both Tests/ and tests/ and expect different results for the two?)

Test Plan: arc unit before and after change on OS X. Stubs and autoloaders in .../tests/... directories are no longer picked up.

Reviewers: epriestley

Reviewed By: epriestley

CC: aurelijus, Korvin, aran
Differential Revision: https://secure.phabricator.com/D7048

13 years agoPluralize add files questions
Jakub Vrana [Sat, 14 Sep 2013 15:06:50 +0000 (08:06 -0700)]
Pluralize add files questions

Test Plan: Saw 'Do you want to add these files to the commit?'

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D6991

13 years agoCorrect capitalization of "new" in lint
epriestley [Thu, 12 Sep 2013 20:01:25 +0000 (13:01 -0700)]
Correct capitalization of "new" in lint

Summary: Automatically correct `New` to `new` in lint.

Test Plan: Ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D6948

13 years agoIgnore errors from "svn upgrade" in unit tests
epriestley [Thu, 12 Sep 2013 04:23:30 +0000 (21:23 -0700)]
Ignore errors from "svn upgrade" in unit tests

Summary: See discussion in D6893. Different versions of `svn` do different stuff, just ignore any possible error here.

Test Plan: Ran unit tests.

Reviewers: andrewjcg, btrahan

Reviewed By: andrewjcg

CC: aran
Differential Revision: https://secure.phabricator.com/D6946

13 years agoparse ls-tree with git-submodule correctly
Aviv Eyal [Wed, 11 Sep 2013 17:36:23 +0000 (10:36 -0700)]
parse ls-tree with git-submodule correctly

Summary:
git ls-tree gives type 'commit' for submodules.

This code-path is only used when a binary file is present in the diff.

Test Plan: arc diff with a binary file

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D6943

13 years agoFix an issue with PHPCS output formatting
epriestley [Tue, 10 Sep 2013 22:10:34 +0000 (15:10 -0700)]
Fix an issue with PHPCS output formatting

Summary:
See <https://github.com/facebook/arcanist/issues/102>. PHPCS changed its output format sometime between 1.4.6 (stable) and 1.5.0RC3.

Add a "no errors" test and make the linter work on both versions.

Test Plan: Ran `arc unit` on PHPCS 1.5.0RC3.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D6926

13 years ago[lint][spelling] delimeter -> delimiter
katherine [Mon, 9 Sep 2013 19:16:22 +0000 (12:16 -0700)]
[lint][spelling] delimeter -> delimiter

Summary:
I got bit by this one earlier (I swear I thought it was delimeter),
so I figured I would add it to the spelling data lint rule.

Test Plan:
changed an instance of delimiter to delimeter, ran `arc lint` fixed the
typo.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D6936

13 years agoMerge pull request #90 from dcramer/pytest
Evan Priestley [Fri, 6 Sep 2013 18:49:56 +0000 (11:49 -0700)]
Merge pull request #90 from dcramer/pytest

Add PytestTestEngine

13 years agoList all DOM extension classes as extension classes for static analysis purposes
epriestley [Fri, 6 Sep 2013 00:28:19 +0000 (17:28 -0700)]
List all DOM extension classes as extension classes for static analysis purposes

Summary: See D6895. We currenty whitelist one of the DOM classes, but should whitelist them all. Classes not in this whitelist raise warnings when users who don't have the corresponding extensions installed lint code. We don't want to require you to install every extension just to send diffs, so we whitelist stuff that we know would exist if you did install everything.

Test Plan: bwahaha

Reviewers: btrahan, Firehed

Reviewed By: Firehed

CC: aran
Differential Revision: https://secure.phabricator.com/D6896

13 years agoFix arc + svn + delted binary file with properties + image heuristic
epriestley [Thu, 5 Sep 2013 22:05:26 +0000 (15:05 -0700)]
Fix arc + svn + delted binary file with properties + image heuristic

Summary:
See IRC. This fixes an issue when deleting an SVN file that ends with one of the extensions in the regexp, which may only affect newer versions of SVN.

Possibly we shouldn't have this heuristic, or should move it elsewhere or make it more explicit, but at least stop it from being broken for now.

Test Plan: Ran `arc diff --only` in a working copy with a deleted binary file ending in ".jpg".

Reviewers: btrahan, nh

Reviewed By: nh

CC: aran, mbishopim3
Differential Revision: https://secure.phabricator.com/D6893

13 years agoTighten up "arc land"
Bob Trahan [Thu, 5 Sep 2013 19:45:59 +0000 (12:45 -0700)]
Tighten up "arc land"

Summary:
Make sure on failure (restoreBranch()) we call `git submodule update --init --recursive` to handle all those purdy submodules. For the pushing step, wrap the push commands in the try / catch block so everything gets cleaned up nice if there's failure. BONUS - add --recursive to arc patch workflow to so nested submodules work correctly. (Crazy git users)

Fixes T3407, T2945.

Test Plan: I wasn't sure how to simulate a good "push" failure but I think this should work.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Maniphest Tasks: T2945, T3407

Differential Revision: https://secure.phabricator.com/D6885

13 years agoDon't error on first run of arc diff
Nick Harper [Sat, 31 Aug 2013 21:57:10 +0000 (14:57 -0700)]
Don't error on first run of arc diff

Summary:
When running arc diff in a repository that supports commit ranges, it is
possible that the setting for the default relative commit hasn't been set.
If this is the case, the user will be prompted. This change makes sure that
the prompt happens (and thus the setting is set) before we run the
background lint and unit runs.

Test Plan:
```
rm .git/arc/default-relative-commit
arc diff
```

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Maniphest Tasks: T2351

Differential Revision: https://secure.phabricator.com/D6854

13 years agoFixup lint testing for changes in D6798
Wez Furlong [Thu, 29 Aug 2013 16:55:30 +0000 (09:55 -0700)]
Fixup lint testing for changes in D6798

Summary:
We have some linters that trigger based on the path name
in the tree (some rules apply in some dirs and not others).
The changes in D6798 caused all the paths to appear to be outside
the tree, so allow for passing a fake through from those test cases
that are sensitive to this.

We also have a test for the copyright linter, and that needs to read
settings from the .arcconfig file.  The change to faking a working
copy meant that this config option was effectively unset, so add a way
to pass the entire arcconfig through from the tests that need it.

Lastly, the logic to skip deleted files needs to be special cased
when we're faking paths like this: if we've added data for a file
in the testable engine, we should also consider that file as existing.

Test Plan:
`arc unit --everything` here, and passing our tests in
our repo over there.

Reviewers: epriestley, mareksapota

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D6841

13 years agoSupport PHPCS as a `.arclint` linter
epriestley [Thu, 29 Aug 2013 13:47:27 +0000 (06:47 -0700)]
Support PHPCS as a `.arclint` linter

Summary:
Ref T3186. Ref T2039. Ref T3771. A few effects here:

  # Expose PHPCS as a `.arclint` linter.
  # Turn PHPCS into an ArcanistExternalLinter linter.
  # Add test coverage for PHPCS.
  # Add a `severity.rules` option to `.arclint`. Some linters have very explicit builtin severities ("error", "warning") but their meanings are different from how arc interprets these terms. For example, PHPCS raises "wrong indentation level" as an "error". You can already use the "severity" map to adjust individual rules, but if you want to adjust an entire linter it's currently difficult. This rule map makes it easy. There's substantial precedent for this in other linters, notably all the Python linters.

For `severity.rules`, for example, this will turn all PHPCS "errors" into warnings, and all of its warnings into advice:

      "severity.rules" : {
        "(^PHPCS\\.E\\.)" : "warning",
        "(^PHPCS\\.W\\.)" : "advice"
      }

The user can use `severity` (or more rules) to get additional granularity adjustments if they desire.

Test Plan: https://github.com/epriestley/arclint-examples/commit/5bb919bc3a684d6654dcc28622de9a29ec08307d

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, ajtrichards
Maniphest Tasks: T2039, T3186, T3771

Differential Revision: https://secure.phabricator.com/D6830

13 years agoMake arc patch slightly better about submodules
Bob Trahan [Wed, 28 Aug 2013 23:47:30 +0000 (16:47 -0700)]
Make arc patch slightly better about submodules

Summary:
Ref T3776, Ref T479. Say you have some DN, with a submodule X@Y. Later, X@Z in your working copy / repo. If you run arc patch DN, you'd end up with a dirty working copy claiming that X@Z was wrong and it should be X@Y.

To fix, basically run 'submodule init' and 'submodule update'. This makes it so after "arc patch" if you run "git status" it looks clean.

Gross part though now is if you then "git checkout master" you'll have a dirty checkout the other way. I think this is better though.

Test Plan: made a new repository where I added libphutil @ X, did some work (DX), then made libphutil @ y. When I arc patch'd DX, things looked good!

Reviewers: epriestley

Reviewed By: epriestley

CC: csilvers, Korvin, aran
Maniphest Tasks: T479, T3776

Differential Revision: https://secure.phabricator.com/D6837

13 years agoWhen converting a file to a binary, populate the binary's data
epriestley [Tue, 27 Aug 2013 16:34:30 +0000 (09:34 -0700)]
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

13 years agoAdd support for 'phpunit_binary' config setting
Eric Stern [Mon, 26 Aug 2013 16:59:51 +0000 (09:59 -0700)]
Add support for 'phpunit_binary' config setting

Summary:
If present, this will override the default phpunit path. Allows easy
integration of Composer-provided installs of phpunit (ex. set phpunit_binary to
vendor/bin/phpunit). If the path provided doesn't resolve to an executable it
will assume the path is relative to the project root.

fix line length issue

Test Plan:
Added phpunit_binary to .arcconfig in a simple project using Composer with
phpunit/phpunit package as part of require-dev (installed to
$ROOT/vendor/bin/phpunit). Phpunit not otherwise installed on the system. Set
unit.engine to PhpunitTestEngine. Confirmed that 'arc unit' used the specified
binary, both at project root and from subdirectories.

Reviewers: epriestley

CC: aurelijus, Korvin, aran
Differential Revision: https://secure.phabricator.com/D6791

13 years agoAutomatically answer excuse prompts if stdin is not a TTY
epriestley [Mon, 26 Aug 2013 12:41:32 +0000 (05:41 -0700)]
Automatically answer excuse prompts if stdin is not a TTY

Summary: Fixes T3696. Currently, we abort. If stdin is not a TTY, we should just continue. A script which cares could conceivably run `arc lint` and `arc unit` separately, but it seems unlikely that any script would ever want to fail here.

Test Plan: Ran `echo -n '' | arc diff --create --verbatim` with a lint error and got a revision (D6720).

Reviewers: Firehed, btrahan, vrana

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T3696

Differential Revision: https://secure.phabricator.com/D6721

13 years agoReady more linters and linter functions for .arclint
epriestley [Mon, 26 Aug 2013 12:37:10 +0000 (05:37 -0700)]
Ready more linters and linter functions for .arclint

Summary:
Ref T3186. Ref T2039. Continues work on readying linters for `.arclint`.

  - **Ruby**: Make this an ExternalLinter.
  - **Priority**: Currently, linters have an implicit "correct" order (notably, the "NoLint" linter needs to run before other linters). Make this explicit by introducing `getLinterPriority()`.
  - **Binaries**: Currently, linters manually reject binary files. Instead, reject binary files by default (linters can override this if they do want to lint binary files).
  - **Deleted Files**: Currently, linters manually reject deleted files (usually in engines). Instead, reject deleted files by default (linters can override this).
  - **Severity**: Move this `.arclint` config option up to top level.
  - **willLintPaths()**: This method is abstract, but almost all linters provide a trivial implementation. Provide a trivial implementation in the base class.
  - **getLintSeverityMap()/getLintNameMap()**: A bunch of linters have empty implementations; these are redundant. Remove them.
  - **Spelling**: clean up some dead / test-only / unconventional code.
  - **`.arclint`**: Allow the filename, generated, nolint, text, spelling and ruby linters to be configured via `.arclint`.

Test Plan:
https://github.com/epriestley/arclint-examples/commit/458beca3d65b64d52ed612904ae66eb837118b94

Ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: Firehed, aran
Maniphest Tasks: T2039, T3186

Differential Revision: https://secure.phabricator.com/D6805

13 years agoBetter heuristic for checking for hgsubversion
durham [Fri, 23 Aug 2013 23:40:15 +0000 (16:40 -0700)]
Better heuristic for checking for hgsubversion

Summary:
The existing heuristic checks for the existence of .hg/svn, but it
turns out that this directory can exist in a non-svn hg repo if the user or a
script ever runs a 'hg svn' command.

Now we check for a file inside .hg/svn.  The hgsubversion maintainer said this
particular file will always be present in hgsubversion repos.

Test Plan:
arc land --trace
Verified it used 'hg push' and not 'hg push -r ...'. This indicates it
considered the repo to be an hgsubversion repo.

Reviewers: epriestley

Reviewed By: epriestley

CC: dschleimer, sid0, Korvin, aran
Differential Revision: https://secure.phabricator.com/D6807

13 years agoExpose PEP8, Flake8 and CSSLint engines to .arclint
epriestley [Fri, 23 Aug 2013 18:58:07 +0000 (11:58 -0700)]
Expose PEP8, Flake8 and CSSLint engines to .arclint

Summary:
Ref T3186. Ref T2039. Allow these linters to be selected with `.arclint`.

Also allow severities to be set.

Also fix some other minor bugs.

Test Plan:
https://github.com/epriestley/arclint-examples
https://github.com/epriestley/arclint-examples/blob/master/.arclint

Reviewers: btrahan

Reviewed By: btrahan

CC: chad, aran
Maniphest Tasks: T2039, T3186

Differential Revision: https://secure.phabricator.com/D6803

13 years agoPort flake8 to ArcanistExternalLinter
epriestley [Fri, 23 Aug 2013 18:52:54 +0000 (11:52 -0700)]
Port flake8 to ArcanistExternalLinter

Summary:
Ref T3186. Brings another linter onboard. This one uses the stdin stuff.

The unit test was ostensibly broken so I fixed it, but that might just be some kind of version issue.

Test Plan: Unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T3186

Differential Revision: https://secure.phabricator.com/D6802

13 years agoIntroduce a rough abstract base class for "linters which run programs and read the...
epriestley [Fri, 23 Aug 2013 18:52:44 +0000 (11:52 -0700)]
Introduce a rough abstract base class for "linters which run programs and read the results"

Summary:
Ref T3186. We have about 50 linters which run programs and read the results, all of which have ad-hoc one-off custom config that isn't formalized anywhere.

Consolidate all this stuff into `ArcanistExternalLinter`, which is configurable through `.arclint` (although nothing supports this quite yet).

Extend CSSLint and Pep8Lint from `ArcanistExternalLinter`.

Add unit tests for both.

There are still some rough edges here, but it mostly seems to work pretty well.

Test Plan: Ran unit tests, hit some (most?) of the error cases.

Reviewers: btrahan

Reviewed By: btrahan

CC: chad, aran, Firehed
Maniphest Tasks: T3186

Differential Revision: https://secure.phabricator.com/D6800

13 years agoRebuild map
Chad Little [Fri, 23 Aug 2013 12:29:40 +0000 (05:29 -0700)]
Rebuild map

Summary: rebuild arc map

Test Plan: run phabricator

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: Korvin, aran
Maniphest Tasks: T3748

Differential Revision: https://secure.phabricator.com/D6804

13 years agoSimplify and demuck some of the linter test cases
epriestley [Thu, 22 Aug 2013 23:02:41 +0000 (16:02 -0700)]
Simplify and demuck some of the linter test cases

Summary:
Ref T3186.

  - Every linter builds a WorkingCopyIdentity in the same way, with no specialized data. Don't do that.
  - Linters get passed a goofy hardcoded ".php" path. Don't do that.
  - Linters generally run on an imaginary path, which might not work. Just give them a real path by building a tiny working copy in `/tmp`.
  - Fix a TODO now that we have better typechecking.

Test Plan: `arc unit --everything`, intentionally broke a test to make sure that still works.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T3186

Differential Revision: https://secure.phabricator.com/D6798

13 years agoLay groundwork for configuration-driven linters
epriestley [Thu, 22 Aug 2013 23:02:16 +0000 (16:02 -0700)]
Lay groundwork for configuration-driven linters

Summary:
Ref T2039. That task has a bunch of discussion, but basically we do a poor job of serving the midrange of lint configuration right now.

If you have something simple, the default linters work.

If you have something complex, building your own engine lets you do whatever you want.

But many users want something in between, which isn't really well accommodated. The idea is to let you write a `.arclint` file, which looks something like this:

  {
   "linters" : {
      "css" : {
        "type" : "csslint",
        "include" : "(\.css$)",
        "exclude" : "(^externals/)",
        "bin" : "/usr/local/bin/csslint"
      },
      "js" : {
        "type" : "jshint",
        "include" : "(\.js$)",
        "exclude" : "(^externals/)",
        "bin" : "support/bin/jshint",
        "interpreter" : "/usr/local/bin/node"
      }
   }
  }

...which will provide a bunch of common options around lint severity, interpreter and binary locaitons, included and excluded files, etc.

This implements some basics, and very rough support in the Filename linter.

Test Plan:
Generated a `.arclint` file and saw it apply filename lint correctly. Used `debug` mode and tried invalid regexps.

  {
    "debug" : true,
    "linters" : {
      "filename" : {
        "type" : "filename",
        "exclude" : ["@^externals/@"]
      }
    }
  }

Next steps include:

  - Provide an external linter archetype (T3186) and expose a common set of configuration here ("bin", "interpreter", "flags", "severity").
  - Provide a `.arcunit` file which works similarly (it can probably be simpler).

Reviewers: btrahan, Firehed

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D6797

13 years agofix issue where multi-line dataproviders in phpunit were parsed incorrectly when...
Firehed [Tue, 20 Aug 2013 13:58:02 +0000 (06:58 -0700)]
fix issue where multi-line dataproviders in phpunit were parsed incorrectly when displaying results

Summary: Found an issue where if arc unit runs phpunit and the datasets included a dataprovider which spanned multiple lines, it wasn't filtered out correctly in the result parser, this fixes it

Test Plan: accidentally ran tests against phpunit itself which exhibits this problem. no longer a problem after this fix, nothing else breaks.

Reviewers: epriestley

Reviewed By: epriestley

CC: aurelijus, epriestley, aran
Differential Revision: https://secure.phabricator.com/D6773

13 years agoFix arc land for mercurial on windows
durham [Thu, 15 Aug 2013 01:00:51 +0000 (18:00 -0700)]
Fix arc land for mercurial on windows

Summary:
arc for mercurial on windows was broken in several way.
Executing a command via passthru failed because passthru on windows
skips the shell so 'set HGPLAIN=1 & ...' was an invalid command. The
fix was to just not set HGPLAIN for passthru commands on windows.

Also removed hardcoded '' quotes in mercurial commands since windows
doesn't support single quots.

Test Plan: arc land --hold on a windows machine

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D6763

13 years agofixes local svn branch name detection
Firehed [Tue, 13 Aug 2013 21:16:14 +0000 (14:16 -0700)]
fixes local svn branch name detection

Summary: Corrects relative vs absolute branch name when using 'arc commit'

Test Plan: 'arc commit' on a release branch gave an error before making the change (change was generated from 'branches/yyy' but working copy root is 'https://xxx/branches/yyy', now it does not.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D6743

13 years agoFix 'arc lint --everything' when svn has uncommitted changes
Eric Stern [Mon, 12 Aug 2013 20:47:33 +0000 (13:47 -0700)]
Fix 'arc lint --everything' when svn has uncommitted changes

Summary: My recent change adding --everything to arc lint could sometimes cause a "diff is empty" error, this patch fixes it.

Test Plan: Ran "arc lint --everything" before and after patch. No longer errors out. Only appeared to originally happen when there were uncommited changes in an svn repo.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Differential Revision: https://secure.phabricator.com/D6732

13 years agoUse underscores instead of hyphens as bookmark suffixes.
Mehdi Mulani [Wed, 7 Aug 2013 21:56:03 +0000 (14:56 -0700)]
Use underscores instead of hyphens as bookmark suffixes.

Summary:
When trying to find an unused bookmark we append hyphened suffixes to the end of the bookmark name. In Mercurial, these are treated the same as the bookmark name without the suffix, here's the output from hg log -r:

```
[mehdi] HGPLAIN=1 hg log -r "arcpatch-1"
abort: unknown revision 'arcpatch'!
[mehdi] HGPLAIN=1 hg log -r "arcpatch_1"
abort: unknown revision 'arcpatch_1'!
```

Test Plan: None.

Reviewers: epriestley, dschleimer

Reviewed By: dschleimer

CC: aran, Korvin, DurhamGoode, dschleimer
Differential Revision: https://secure.phabricator.com/D6698

13 years agoImprove arc commit with SVN branches
Eric Stern [Sun, 4 Aug 2013 16:01:22 +0000 (09:01 -0700)]
Improve arc commit with SVN branches

Summary:
If you are trying to commit someone else's diff, arc commit gives warnings about path mismatch. This changes the path comparison to be based on the repo url rather than the local working directory. E.g. if both the author and committer are working in branches/release/2013_08_07 despite being checked out in ~/dev/2013_08_07 (system user being different, of course) it no longer warns that the WC path is different

Original behavior:

eric@Eric-MBP ~/dev/2013_07_31: arc commit --revision 21
You are not the author of 'D21: WeMerge Automatic Request'. Commit this
revision anyway? [y/N] y

Revision 'D21: WeMerge Automatic Request' was generated from '', but
current working copy root is '/Users/eric/dev/2013_07_31/'. Commit this
revision anyway? [y/N] y

Committing 'D21: WeMerge Automatic Request'...
Adding         test
Transmitting file data .
Committed revision 52676.
Closing revision D21 'WeMerge Automatic Request'...
Exception
ERR-CONDUIT-CORE: You can not mark a revision you don't own as closed.
(Run with --trace for a full exception trace.)

New behavior:

eric@Eric-MBP ~/dev/2013_07_31: arc commit --revision 24

You are not the author of 'D24: WeMerge Automatic Request'. Commit this
revision anyway? [y/N] y

Committing 'D24: WeMerge Automatic Request'...
Adding         test
Transmitting file data .
Committed revision 52679.
Closing revision D24 'WeMerge Automatic Request'...
Exception
ERR-CONDUIT-CORE: You can not mark a revision you don't own as closed.
(Run with --trace for a full exception trace.)

Test Plan: 'arc diff' changes with one user. 'arc patch Dxx' on a different working copy by a different user to review and test changes. accept review. 'arc commit --revision xx' as reviewer to land the patch. complaint goes away.

Reviewers: epriestley, ghostwriter78

Reviewed By: epriestley

CC: aran, epriestley, Korvin
Differential Revision: https://secure.phabricator.com/D6665

13 years agoPass global CA bundle to HTTPSFuture, T3668
Eric Stern [Sun, 4 Aug 2013 15:21:35 +0000 (08:21 -0700)]
Pass global CA bundle to HTTPSFuture, T3668

Summary: Update and clarify precedence of CA bundles

Test Plan:
tested with "arc call-conduit user.whoami" from project root
Same from other subdirectory in project
Repeated tests with both https.cabundle and https.cacert settings, both in
.arcconfig and ~/.arcrc

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T3668

Differential Revision: https://secure.phabricator.com/D6647

13 years agoAdd CSSLint linter to Arcanist
Lajos Veres [Fri, 2 Aug 2013 12:13:23 +0000 (05:13 -0700)]
Add CSSLint linter to Arcanist

See: https://github.com/facebook/arcanist/pull/93

Reviewed by: epriestley

13 years agoarc unit --output none
Aviv Eyal [Thu, 1 Aug 2013 19:07:11 +0000 (12:07 -0700)]
arc unit --output none

Summary:
Support for no output from arc unit (For scripts, etc).
Also include --output param, analogous to arc lint --output.

Test Plan: run all 6 variants + `--output bad-value`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6642

13 years agoRemove hard coded single quotes in arc feature
durham [Thu, 1 Aug 2013 17:14:38 +0000 (10:14 -0700)]
Remove hard coded single quotes in arc feature

Summary:
Single quotes aren't valid in the windows cmd prompt, so arc feature
didn't work in mercurial when it got to this line.

I have no idea why %C was used before.  Nothing in that string should be
broken by the escaping.

Test Plan:
Ran arc feature --trace on my mac. Verified the command was escaped correctly
and the correct feature results were printed.

I don't have a windows machine to try it on, but the builtin escaping should
now account for windows machines.

Reviewers: epriestley

Reviewed By: epriestley

CC: sid0, aran, Korvin
Differential Revision: https://secure.phabricator.com/D6637

13 years agoRemove warning about deprecated phutil_render_tag()
Jakub Vrana [Sun, 28 Jul 2013 18:00:00 +0000 (11:00 -0700)]
Remove warning about deprecated phutil_render_tag()

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6567

13 years agoAdd --everything support to 'arc lint'
Eric Stern [Sun, 28 Jul 2013 01:29:20 +0000 (18:29 -0700)]
Add --everything support to 'arc lint'

Summary:
When adding arcanist support to a new project or adding a new linter,
it's helpful to be able to run new linters against the entire codebase. This
patch adds support for this with an '--everything' option, similar to 'arc unit
--everything'

Test Plan:
Run 'arc lint --everything' and check out the code. Optionally dump
the paths to test in the current lint engine's buildLinters() function to
demonstrate that it's receiving all files in the project rather than just the
changed and/or specified ones

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin
Differential Revision: https://secure.phabricator.com/D6592

13 years agoPass correct filename into PHPUnitTestEngine coverage
Eric Stern [Sat, 27 Jul 2013 02:09:09 +0000 (19:09 -0700)]
Pass correct filename into PHPUnitTestEngine coverage

Summary: The test result parser in PhpunitTestEngine was receiving $test_path from the previous loop instead of $path from the current one. The variable isn't actually used in the PhpunitResultParser object (it exists for strict compatibility with the parent class) so it didn't cause any problems, but who knows if that could change in the future

Test Plan: Review diff. No changes to the output of running 'arc unit' when using the Phpunit engine, as expected

Reviewers: epriestley

CC: aran, epriestley, aurelijus, chad
Differential Revision: https://secure.phabricator.com/D6587

13 years agoRevert "Merge pull request #93 from vlajos/csslint"
epriestley [Mon, 22 Jul 2013 13:51:48 +0000 (06:51 -0700)]
Revert "Merge pull request #93 from vlajos/csslint"

This reverts commit 2852a965e3308dcb81d1d7154e1a25aa72d74139, reversing
changes made to 46bb3dbc361729ba589c73ddd550f7d570f5d26f.

See: https://github.com/facebook/arcanist/pull/93

13 years agoMerge pull request #93 from vlajos/csslint
Jeff Ferland [Mon, 22 Jul 2013 13:44:22 +0000 (06:44 -0700)]
Merge pull request #93 from vlajos/csslint

CSS lint support for arcanist using csslint.

13 years agoarc browse: Support line number and reduce conduit call
Aviv Eyal [Mon, 15 Jul 2013 02:14:34 +0000 (19:14 -0700)]
arc browse: Support line number and reduce conduit call

Summary:
support common "filename:line number" format.
Also, remove redundent conduit call.

Test Plan: arc browse with and without :33 suffix.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6451

13 years agoDisplay line number with assertion for failed test cases
Jakub Vrana [Wed, 10 Jul 2013 15:42:49 +0000 (08:42 -0700)]
Display line number with assertion for failed test cases

Summary: We use custom `assert*` functions here and there. Remove them from backtrace.

Test Plan: Ran `XHPASTTreeTestCase`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6411

13 years agoLint undeclared variables in strings
Jakub Vrana [Wed, 10 Jul 2013 15:26:11 +0000 (08:26 -0700)]
Lint undeclared variables in strings

Summary: Depends on D6405.

Test Plan:
New unit test.
Linted libphutil, Arcanist, Phabricator.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6406

13 years agocomment typo fix
Lajos Veres [Tue, 9 Jul 2013 13:11:21 +0000 (14:11 +0100)]
comment typo fix

13 years agoupdate __phutil_library_map__
Lajos Veres [Tue, 9 Jul 2013 11:48:07 +0000 (12:48 +0100)]
update __phutil_library_map__

13 years agoadd css lint
Lajos Veres [Tue, 9 Jul 2013 11:46:59 +0000 (12:46 +0100)]
add css lint

13 years agoUpdate spelling replacement rule for 'algorithmical'
epriestley [Mon, 8 Jul 2013 16:46:24 +0000 (09:46 -0700)]
Update spelling replacement rule for 'algorithmical'

Summary:
I suspect that when people use 'algorithmical', they mean it as an adjective and not an adverb.

'algorithmic' = adjective
'algorithmically' = adverb

Test Plan: Add the word 'algorithmical' to a file. Run `arc lint` on the file. See suggestion to correct it to 'algorithmic'.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6373

13 years agoStop using deprecated Conduit methods in `arc`
epriestley [Tue, 2 Jul 2013 12:47:52 +0000 (05:47 -0700)]
Stop using deprecated Conduit methods in `arc`

Summary:
  - Replace `maniphest.find` with `maniphest.query`. These calls are nearly identical, it was just a rename for consistency.
  - Replace `differential.find` with `differential.query`.

Test Plan:
  - Ran `arc tasks`.
  - Ran `arc close-revision` on valid, nonexistent, and existent-but-invalid revisions.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D6336

13 years agoDon't instantiate abstract classes in ArcanistConfiguration::buildAllWorkflows
Miorel-Lucian Palii [Sat, 29 Jun 2013 01:24:30 +0000 (18:24 -0700)]
Don't instantiate abstract classes in ArcanistConfiguration::buildAllWorkflows

Summary:
I wanted to write a couple of workflows that shared some code in an abstract superclass, but ##arc## would fail trying to instantiate the abstract class.

As it turns out, we can modernize the ##buildAllWorkflows## function a bit, and it will only load concrete objects.

Test Plan:
1. Define an abstract subclass of ##ArcanistBaseWorkflow##.
2. ##arc liberate## the source directory that contains it.
3. Try any ##arc## operation without this diff, and see it fail.
4. Patch this diff and see that ##arc## operations work now.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6324

13 years agoUpdate some output based on flag being set
Gareth Evans [Tue, 25 Jun 2013 22:26:14 +0000 (15:26 -0700)]
Update some output based on flag being set

Summary: Makes sense now

Test Plan: Get someone else to test it

Reviewers: epriestley

CC: aran, Korvin
Maniphest Tasks: T3342

Differential Revision: https://secure.phabricator.com/D6307

13 years agoAllow passing library name with flag
Gareth Evans [Tue, 25 Jun 2013 22:19:23 +0000 (15:19 -0700)]
Allow passing library name with flag

Summary: Enables the process to pass the user input for library name. Fixes T3342

Test Plan: Little help... `arc liberate` doesn't run on windows. Though I saw the flag :)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T3342

Differential Revision: https://secure.phabricator.com/D6306

13 years agoAdd Delete Flag to Paths ignore mask
Gareth Evans [Thu, 20 Jun 2013 14:35:18 +0000 (07:35 -0700)]
Add Delete Flag to Paths ignore mask

Summary:
When `arc diff` runs unit tests it uses all of the affected files as the base array of paths. These files may have been deleted. If the deleted file fits the test criteria `unit` will try and run the test and in some cases fail.

An example of this fataling is with PHPUnit;

> Fatal error: Uncaught exception 'Exception' with message 'JSON report file is em
pty, it probably means that phpunit failed to run tests. Try running arc unit wi
th --trace option and then run generated phpunit command yourself, you might get
 the answer.' in C:\Websites\facebook\arcanist\src\unit\engine\PhpunitResultPars
er.php on line 156

Test Plan: Re-ran the tests that were causing issues with `arc unit --rev HEAD^ --trace`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, aurelijus
Differential Revision: https://secure.phabricator.com/D6246

13 years agoDon't prepopulate update message in hg amend diff workflow
durham [Mon, 17 Jun 2013 18:40:58 +0000 (11:40 -0700)]
Don't prepopulate update message in hg amend diff workflow

Summary:
Previously, updating a commit via arc diff in mercurial would
prepopulate the update message with part of the commit message.  In an
amend workflow this doesn't make sense, so I disabled it. Git already
does this, so now mercurial matches git in this scenario.

We had users complain that new users would often submit diffs with the
default update message, and it wasn't useful since they were using a
amend flow.

Test Plan:
arc diff on a commit that already had a diff
Verified the editor did not have a update message
arc diff on a stack of commits where the bottom one had a diff
Verified the editor provided a default update message

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6215

13 years agoAdd PytestTestEngine
David Cramer [Thu, 13 Jun 2013 21:23:45 +0000 (14:23 -0700)]
Add PytestTestEngine

13 years agoWhen a file upload fails during "arc diff", show why
epriestley [Wed, 12 Jun 2013 12:50:08 +0000 (05:50 -0700)]
When a file upload fails during "arc diff", show why

Summary: We currently swallow the exception message, but this isn't useful. Fixes T3354.

Test Plan:
  $ arc diff HEAD^ --conduit-uri=http://local.aphront.com:8080/ --only
  Uploading 1 files...
  Failed to upload new binary 'large.png'.

  [HTTP/500] Internal Server Error
  As received by the server, this request had a nonzero content length but no POST data.

  Normally, this indicates that it exceeds the 'post_max_size' setting in the PHP configuration on the server. Increase the 'post_max_size' setting or reduce the size of the request.

  Request size according to 'Content-Length' was '2093052', 'post_max_size' is set to '100K'.

      Continue? [Y/n]

Reviewers: jamesr, chad

Reviewed By: chad

CC: aran
Maniphest Tasks: T3354

Differential Revision: https://secure.phabricator.com/D6186

13 years agoFix a `catch` class name
epriestley [Tue, 11 Jun 2013 13:26:42 +0000 (06:26 -0700)]
Fix a `catch` class name

Summary: Now that we examine these in lint, this came up. There is no `ConduitException`; the class is `ConduitClientException`.

Test Plan: Lint.

Reviewers: vrana, chad

Reviewed By: chad

CC: aran
Differential Revision: https://secure.phabricator.com/D6158

13 years agoSupport for lint messages which are always shown
Omer Strulovich [Sun, 9 Jun 2013 15:37:40 +0000 (08:37 -0700)]
Support for lint messages which are always shown

Summary: If one wishes to implement a linter which finds unused resources or variables the current scheme does not work as the lint engine filters all changes from lines which were not introduced in a diff. To solve that, I've added an "always show" configuration for a lint message allowing creation of such linters.

Test Plan:
1. Created a custom linter for finding unused Android resources in a project
2. Ran arc lint with linter added and received warnings as expected

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6119

13 years agoFind needed classes in catch, instanceof and newv()
Jakub Vrana [Thu, 6 Jun 2013 01:08:20 +0000 (18:08 -0700)]
Find needed classes in catch, instanceof and newv()

Test Plan:
  try {} catch (X $ex) {}
  $a instanceof X;
  newv('X');

Linted Phabricator.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6143

13 years agoFind classes used in call_user_func()
Jakub Vrana [Wed, 5 Jun 2013 21:38:15 +0000 (14:38 -0700)]
Find classes used in call_user_func()

Summary:
Also fix false positive for call_user_func('C::f').
Also fix false positive for call_user_func("$f").
Also centralize handling of magic classes.

Test Plan:
  call_user_func("$f");
  call_user_func('C::f');
  call_user_func(array('C', 'f'));
  call_user_func(array(1 => 'f', 0 => 'C'));

Linted Phabricator.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6137

13 years agoVerify classes used in typehints
Jakub Vrana [Wed, 5 Jun 2013 18:41:39 +0000 (11:41 -0700)]
Verify classes used in typehints

Summary: Also support `SomeInterface::CONSTANT`.

Test Plan:
  interface I {
    const A = 1;
  }
  I::A;

  function f(stdClass $a, array $b, Iterator $c) {
  }

Linted Phabricator.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6135

13 years agoFix some Arcanist lint warnings
epriestley [Tue, 4 Jun 2013 22:29:39 +0000 (15:29 -0700)]
Fix some Arcanist lint warnings

Summary: Lint. See https://github.com/facebook/phabricator/pull/332

Test Plan: Lint.

Reviewers: chad

Reviewed By: chad

CC: aran
Differential Revision: https://secure.phabricator.com/D6126

13 years agoUse a temporary file to execute `arc patch`
epriestley [Fri, 31 May 2013 04:03:21 +0000 (21:03 -0700)]
Use a temporary file to execute `arc patch`

Summary:
Piping data around on Windows doesn't work well when it contains zany characters like "null" and "newline". Fixes T3266.

Instead of piping data into `git apply`, write to a temporary file.

Test Plan:
Ran `arc patch`, got good results.

  >>> [17] <exec> $ git apply --index --reject -- '/private/var/folders/8k/c3vkmjy5335gcxdzxkhwq82w0000gn/T/7z9iea6srikoo0sc/4266-ZEyvz9'

Reviewers: btrahan, hach-que

Reviewed By: hach-que

CC: aran
Maniphest Tasks: T3266

Differential Revision: https://secure.phabricator.com/D6070

13 years agoFixing the star on unit tests for Windows consoles
James Rhodes [Fri, 31 May 2013 03:56:16 +0000 (20:56 -0700)]
Fixing the star on unit tests for Windows consoles

Summary: On Windows consoles, the star on the unit tests (I'm assuming it's a Unicode character of some kind), doesn't render correctly and you just get garbage.  This fixes it so that on Windows, it falls back to just using an ASCII asterisk.

Test Plan: On Windows run some unit tests, the star should now be a plain asterisk.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6087

13 years agoPrint --conduit-uri in install-certificate instructions
Jakub Vrana [Sat, 25 May 2013 03:20:20 +0000 (20:20 -0700)]
Print --conduit-uri in install-certificate instructions

Test Plan:
  $ arc diff # without certificate
  $ arc --conduit-uri=http://phabricator.local/ diff # without certificate

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6037

13 years agoCompute UTF8 string differences correctly, accounting for combining characters
epriestley [Thu, 23 May 2013 21:38:09 +0000 (14:38 -0700)]
Compute UTF8 string differences correctly, accounting for combining characters

Summary:
@Afaque_Hussain has done a bunch of utf8 work here; combined with PhutilEditDistanceMatrix we can now do utf8 diffs correctly, in a general way, without a significant performance impact.

Use PhutilEditDistanceMatrix and `phutil_utf8v_combined()` to compute accurate diffs for all (or, at least, most) UTF8 text.

The only thing this doesn't handle completely correctly is lines beginning with combining characters. This is messy/expensive to handle and will probably never actually happen, so I'm punting for now. Nothing should actually break.

The utf8 stuff will be slow, but we only pay for it when we need it.

Test Plan:
Ran unit tests. I changed a few unit tests to use a non-combining character (snowman) for clarity, and some results are different now (since we get combining characters right).

{F44064}

Reviewers: btrahan, Afaque_Hussain

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T2379

Differential Revision: https://secure.phabricator.com/D6019

13 years agoUse PhutilEditDistanceMatrix in ArcanistDiffUtils
epriestley [Thu, 23 May 2013 21:36:42 +0000 (14:36 -0700)]
Use PhutilEditDistanceMatrix in ArcanistDiffUtils

Summary: Replace this old hard-coded implementation with the new vector-based, unicode-capable one.

Test Plan: Ran unit tests. Looked at revisions in Differential, using whitespace modes to bypass cache.

Reviewers: btrahan, Afaque_Hussain

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T2379

Differential Revision: https://secure.phabricator.com/D6016

13 years agoAllow an unassigned flag to be passed to `arc tasks`
Gareth Evans [Thu, 23 May 2013 17:32:41 +0000 (10:32 -0700)]
Allow an unassigned flag to be passed to `arc tasks`

Summary: Returns unassigned tasks

Test Plan: Run `arc tasks`, `arc tasks --unassigned`, make sure I get the correct results

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T3201

Differential Revision: https://secure.phabricator.com/D6009

13 years agoUpdate PHP compat info
Jakub Vrana [Wed, 22 May 2013 18:36:41 +0000 (11:36 -0700)]
Update PHP compat info

Summary: Also warn against functions not available on Windows at all.

Test Plan: Compared old and new file.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5975

13 years agoImplementing prefix and suffix diffing for multi-byte unicode characters.
Afaque Hussain [Tue, 21 May 2013 20:06:14 +0000 (13:06 -0700)]
Implementing prefix and suffix diffing for multi-byte unicode characters.

Summary: Prefix and suffix diffing for multi-byte unicode characters.

Test Plan:
Test diff:
------------------------------------------------------------
diff --git a/test b/test
index 252ad2f..a5bad3b 100644
--- a/test
+++ b/test
@@ -1 +1 @@
-This file contains this and this stuff.
+This file contains žžžž and this stuff.
--------------------------------------------------------------

{F43738}
--------------------------------------------------------------

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan
Maniphest Tasks: T2379

Differential Revision: https://secure.phabricator.com/D5925

13 years agoLint for PHP 5.3 on Windows
Jakub Vrana [Sun, 19 May 2013 18:00:08 +0000 (11:00 -0700)]
Lint for PHP 5.3 on Windows

Test Plan: Linted `FileFinder`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5972

13 years agoArcanist changes related to T2784
Bob Trahan [Tue, 14 May 2013 22:24:20 +0000 (15:24 -0700)]
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

13 years agoRemove "--allow-empty-message"
epriestley [Tue, 14 May 2013 20:35:42 +0000 (13:35 -0700)]
Remove "--allow-empty-message"

Summary: @alex has git 1.7.0.4 which doesn't have this flag. We don't actually need it: we always provide a commit message when calling this method. Remove the flag for compatibility, leaving a note in case we bump into this in the future.

Test Plan: N/A

Reviewers: btrahan, vrana, alex

Reviewed By: alex

CC: aran
Differential Revision: https://secure.phabricator.com/D5926

13 years agoAdding arc revert command[]
Howard Chan [Tue, 14 May 2013 18:00:56 +0000 (11:00 -0700)]
Adding arc revert command[]

Summary:
Arc Revert does the following:
1. Git revert
2. Go to the differential of the rev you are reverting and either repoen it or set it to a reverted state
3. File a hipri task to orig author

[Preview] Creating Arc Revert workflow

Porting arc revert from FB4A to phabricator for general usage. This is my first stab,
so totally appreciate feedback and assistance. I'm currently focused
on making this work for git. However, I built out the functions through the GitAPI so this
could be easily extendable to Mercurial later on.

Stuck on the following (help):
1. Creating a task for FB internal. I tried building on top of existing arc listeners
but getting errors on failures to load the TaskCreator (and other) tasks.

2. I'm using a hacky way to grab the diff revision id from the newly created
revert diff. (see line 204) I'm looking for a way to just fetch the diff ID
from arc after the diff is created; is this possible?

Test Plan:
 -

1. Ran arc revert on a www and fbcode diff
2. Confirmed that revert was run on the diffs and a proper diff filed
 -

Reviewers: royw, sdwilsh, nh, epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin, pti, keir
Maniphest Tasks: T1751

Differential Revision: https://secure.phabricator.com/D5553

13 years agomore reusable nosetest engine
Aviv Eyal [Tue, 14 May 2013 13:38:22 +0000 (06:38 -0700)]
more reusable nosetest engine

Summary:
The NoseTestEngine class has some usefull code for parsing nosetest, but it assumes a very specific code/test
layout. I've pulled this logic abit apart, which lets me reuse the nose-related parts with my existing
project layout, by having my custom engine just call runTests() with the relevant paths.

Test Plan: Run on a customized project with coverage, see coverage results.

Reviewers: epriestley, roman.barzyczak

Reviewed By: epriestley

CC: seporaitis, aran, Korvin, zeeg
Differential Revision: https://secure.phabricator.com/D5921

13 years agoAdded missing space between words in messages.
Martin Kralik [Fri, 3 May 2013 23:12:16 +0000 (16:12 -0700)]
Added missing space between words in messages.

Summary:
During my attept to `arc land master` on `master` branch
I have discovered that error message is missing few spaces between words.

I have added them and used this ugly readonly command:

  pcregrep --include="\.php$" -M -r '(?<!\\n| )("|'"'"')\.\n\s*\1(?!\\n| )' ~/arc/arcanist/src

to detect other instances of this serious bug.

Two more were found.
This time they were probably introduced in order to abide
to the draconian lint rule about number of columns.

Since I want to be a good citizen,
I have added this missing space to the begining of the next line in both cases.
It is an ugly hack, but I think user should not suffer due to missing spaces.

Another solution could be preserving no leading spaces and splitting long lines.
Or just providing excuse to lint.

Test Plan: Ran `arc land master` on `master` branch.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T3008

Differential Revision: https://secure.phabricator.com/D5827

13 years agoMake the behavior of "--load-phutil-library" more explicit
epriestley [Mon, 29 Apr 2013 19:19:15 +0000 (12:19 -0700)]
Make the behavior of "--load-phutil-library" more explicit

Summary:
This flag disables normal libraries to make it easier to test library changes. Print that out explicitly.

Also update `.arcconfig` to use the modern configuration format.

Test Plan: Ran `arc list --trace`, `arc list --load-phutil-library=src --trace`.

Reviewers: zeeg, btrahan, vrana

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D5768

13 years agoDon't use cache in svn-hook-pre-commit
Nick Harper [Wed, 24 Apr 2013 22:10:27 +0000 (15:10 -0700)]
Don't use cache in svn-hook-pre-commit

Test Plan: arc lint

Reviewers: epriestley, wez

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5779

13 years agoDisable lint cache by default
epriestley [Tue, 23 Apr 2013 18:26:28 +0000 (11:26 -0700)]
Disable lint cache by default

Summary:
Fixes T2266. Motivation:

  - The lint cache does not always invalidate correctly. Because of the nature of the cache, this is a hard problem (right after "naming things").
    - We already have a fair amount of complexity in trying to invalidate it, and are still discovering new places where it doesn't work (e.g., Windows with "/" vs "\" paths).
    - One invalidation failure is when linter code changes, which seems unresolvable in the general case (e.g., changes to external linters).
  - It's not obvious what's happening when the lint cache causes some kind of issue.
    - Particularly while developing or debugging linters, your changes often won't be reflected in the lint output. Some of this is theoretically tractable but the external linter case probably isn't.
  - When someone reports a problem with the lint cache in IRC or elsewhere, there is essentially never a way for me to fix it. The lint cache can't be debugged effectively without access to a working copy where the problem reproduces.
  - The cache provides limited benefit outside of Facebook's install.

To remedy these issues:

  - Introduce configuration which controls cache usage.
  - Default it off.
  - Print a message when the cache is in use.

(I'd tentatively support removing the cache entirely, but I don't know how @vrana and Facebook feel about that.)

Test Plan: Ran `arc set-config --show`, `arc lint --cache 0`, `arc lint --cache 1`.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, mbishopim3, nh, edward, wez
Maniphest Tasks: T2266

Differential Revision: https://secure.phabricator.com/D5766

13 years agoAdding `--` to the end of git log so can `arc land` when the branch is
san [Mon, 22 Apr 2013 03:54:51 +0000 (20:54 -0700)]
Adding `--` to the end of git log so can `arc land` when the branch is
named the same as a file path.

Summary: (In fbcode and www at least, the only places I tried) if a
branch happens to be named the same as a file path (from root) (like if
a branch is called `spec` and there is a directory in `www` called
`spec`) then `arc land` will fail with git complaining that the argument
(to `git log ...`) is ambiguous as it could refer to both a path and a
revision; so this diff adds a `--` to the end so that git knows that
both are revisions and not paths.

Test Plan: Try and land something from www (I did, see D752219) where
the branch is named `spec`.

Reviewed by: epriestley

13 years agoChanges to Arcanist for libphutil "extensions/"
epriestley [Mon, 22 Apr 2013 21:38:49 +0000 (14:38 -0700)]
Changes to Arcanist for libphutil "extensions/"

Summary: See D5714. Ref T2971.

Test Plan: Built a library map for libphutil's test library.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T2971

Differential Revision: https://secure.phabricator.com/D5715

13 years agoMove Arcanist machine config location on Windows
Jakub Vrana [Sat, 20 Apr 2013 05:12:02 +0000 (22:12 -0700)]
Move Arcanist machine config location on Windows

Test Plan:
  $ set # on Windows

Reviewers: epriestley, dschleimer

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5733

13 years agoFix arc lint amend for git to not add untracked files
durham [Fri, 19 Apr 2013 03:03:26 +0000 (20:03 -0700)]
Fix arc lint amend for git to not add untracked files

Summary:
Arc lint for git is currently adding all untracked files when it
amends the commit with lint fixes. This changes the git add -A to be
git add -u. This only adds files that were already tracked. -A was adding
untracked files as well which was not the desired behavior here.

Test Plan:
Create an untracked file.
Commit a lint failure another file.

arc diff and choose to amend the lint patches.

Verify that the untracked file was not added but the tracked file was amended.

Reviewers: epriestley, wez, chad

Reviewed By: chad

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5731