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

1367 commits

Author SHA1 Message Date
James Rhodes
00d5eb2f21 Update C# tools unit test engine to work
Summary: This updates the C# tools unit test engine (the derived version of xUnit.NET test engine that supports code coverage) to work after the updates in D7594.

Test Plan:
Switched the test engine from 'XUnitTestEngine' to 'CSharpToolsTestEngine' and ran `arc unit --everything`.  The results were identical except that code coverage was provided.

Tested on Linux; will update or comment based on whether it works on Windows as well.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7640
2013-11-26 18:00:44 +11:00
Chris Dentel
d30c77d0a8 Add output-json option to arc feature
Summary:
The current format of arc feature is not very friendly to parsing.  This adds a json output
format.

Test Plan: Run the command and ensure output is valid

Reviewers: lifeihuang, #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: epriestley, aran, Korvin

Differential Revision: https://secure.phabricator.com/D7647
2013-11-25 11:50:11 -08:00
James Rhodes
799841a0d8 Remove debugging output from xUnit.NET test engine
Summary: This just removes the `print "Discovered test .."` code in the xUnit.NET unit test engine.  If users need to diagnose what tests are being debugged, it can be found out with `--trace` and observing what build commands are invoked.

Test Plan: Ran `arc unit --everything` and didn't see the message any more.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7639
2013-11-24 11:36:45 +11:00
James Rhodes
bd191c2860 Fix issues in C# unit test engine
Summary: This fixes a few issues in the C# unit test engine.  It fixes tests sitting in subdirectories not being tested correctly (the location of both the test assembly and the results file would be wrong).  It also fixes a very strange issue where xUnit.NET seems to not output the resulting XML file when it executes; in this case we just retry running the test until the XML file appears after completion (and eventually it works).

Test Plan: Ran `arc unit --everything` and `arc unit --everything --no-coverage` and verified that it's all reliably working.

Reviewers: epriestley, #blessed_reviewers, hach-que

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7594
2013-11-22 14:32:48 -08:00
Ramkumar Ramachandra
6033f14221 ArcanistGitAPI: replace 'ls-files -m' with diff-files
As documented,

  $ git ls-files -m

fails to exclude ignored submodules. Replace it with an equivalent:

  $ git diff-files --name-only

which does not suffer from this defect.

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

Reviewed by: epriestley
2013-11-22 08:39:20 -08:00
Ramkumar Ramachandra
e62b23e67d ArcanistGitAPI: document a git ls-files bug
When a submodule is ignored (ignore=all in .gitconfig),

  $ git ls-files -m

fails to exclude the submodule from the listing. Other commands like

  $ git diff-index --name-only HEAD

exclude it just fine.

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

Reviewed by: epriestley
2013-11-22 05:35:37 -08:00
Ramkumar Ramachandra
86eae809e0 ArcanistGitAPI: remove a bogus comment
See: <628de7d7a1 (commitcomment-4675543)>

This comment is indecipherable even if it originally meant something.

Reviewed by: epriestley
2013-11-22 05:28:37 -08:00
James Rhodes
fb8a0d32ae Set limit for execution in C# linter
Summary: This sets the limit for future execution in the C# linter to 8.  See D7606 for more information.

Test Plan:
Ran

```
arc lint --everything --trace --never-apply-patches --output json
```

and saw it only run 8 commands at once.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7607
2013-11-19 13:36:27 -08:00
James Rhodes
61753b6770 Upgrade C# linter to support linting multiple files at a time
Summary:
This upgrades `cslint` to support linting multiple files at a time.  As this required a backwards-incompatible to `cslint`, I've added a SUPPORTED_VERSION constant which can be used to detect these kinds of breaking changes in the future (and prompt users to upgrade the `cslint` they have in their repository).

The reason for this upgrade is mainly around running `arc lint --everything`, where there are significant performance benefits gained when bulk linting lots of files per command execution.

Test Plan: Upgraded `cslint` in the Tychaia repository and ran `arc lint --everything --trace`.  Saw a substantially less number of executions happening for linting and all of the results came through as expected.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, waynea

Differential Revision: https://secure.phabricator.com/D7599
2013-11-18 11:32:58 -08:00
Burak Yigit Kaya
19edbbb46e Make ScriptAndRegexLinter available to ConfigurationDrivenLintEngine
See: <https://github.com/facebook/arcanist/pull/118>

Reviewed by: epriestley
2013-11-18 10:08:19 -08:00
Anirudh Sanjeev
17e4e9e651 Fix markup in documentation for arcanist lint engine
Summary: Fixed wrong markup which was 1 space instead of 2

Test Plan: I couldn't test it as I don't know how to build documentation

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7587
2013-11-14 10:19:08 -08:00
epriestley
9310df9615 Handle empty output from hg --debug branches in the parser
Summary: Ref T1493. Also consolidate this a bit more.

Test Plan: Unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1493

Differential Revision: https://secure.phabricator.com/D7481
2013-11-04 12:15:12 -08:00
Sven Axelsson
aabbdbd2ab Filter out messages from included files
Summary:
CppCheck shows lint messages from included files as well as the current
file. Filter out those, since they don't make much sense in the context
of `arc lint`.

Test Plan:
Before this patch, `arc lint` using `ArcanistCppcheckLinter`. Note that lint messages
from included files appear pointing to a line in the active file.
After this patch, only messages from the active file are included.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7444
2013-10-30 13:46:30 -07:00
Aviv Eyal
6dc04af6e8 Specify custom arcrc filename
Summary: allow specifing an replacement .arcrc file, for the odd cases.

Test Plan: `echo {} | arc call-conduit user.whoami` with and without `--arcrc-file=`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7208
2013-10-25 15:57:38 -07:00
Aviv Eyal
0d212ccf5a rename getConfig -> getProjectConfig, make all linters use getConfigFromAnySource
Summary:
Lingers on from D7271; Rename `ArcanistWorkingCopyIdentity.getConfig()`.

Changed all linters (Except one) to use `getConfigFromAnySource()`, because it seems to make sense.

Test Plan: arc unit --everything; arc lint in github.com:epriestley/arclint-examples.git (Except for phpcs, flake8, cpplint and csslint which I don't have installed).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: chad, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7382
2013-10-22 15:34:06 -07:00
Aviv Eyal
4103bc423c get Config Manager to Unit engine and use getConfigFromAnySource
Summary:
somewhat related to D7271 and D7377.
Not actually broken right now, but might be worth it for completeness.

Test Plan: arc unit invokes PHPUnit; Can't test Csharp/XUnit on my end.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: aurelijus, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7381
2013-10-22 13:58:32 -07:00
epriestley
ddbc14ade1 Provide ConfigurationManager to LintEngine in Arcanist
Summary: Unbreaks ArcanistSingleLintEngine / ArcanistScriptAndRegexLinter from recent config churn.

Test Plan: `arc lint --engine ArcanistSingleLintEngine --rev HEAD^`

Reviewers: btrahan

Reviewed By: btrahan

CC: csilvers, aran

Differential Revision: https://secure.phabricator.com/D7377
2013-10-21 16:57:22 -07:00
epriestley
5c2f7b2abd Autocomplete branch names in arc feature
Summary: SPOOKY

Test Plan: `arc feature <tab>`

Reviewers: cpojer, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7376
2013-10-21 16:29:08 -07:00
Pascal Borreli
831fc9a92b Fixed typos
See: https://github.com/facebook/arcanist/pull/110

Reviewed by: epriestley
2013-10-20 07:53:23 -07:00
epriestley
2c64f1b072 Minor, fix a missing config source change. 2013-10-19 13:32:59 -07:00
Aviv Eyal
359e1c2803 Couple of fixes from refactor
Test Plan: arc set-<tab> <enter> from a not-workspace.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7354
2013-10-18 16:41:50 -07:00
epriestley
d85f7bee66 Minor, fix a typo. 2013-10-18 16:19:22 -07: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
Bob Trahan
b2021586d4 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
2013-10-17 14:59:04 -07:00
epriestley
13e422e123 Remove spurious +x from arcanist
Summary: A few files here have +x, but should not. Also correct a
spelling mistake.
2013-10-05 05:20:05 -07:00
root
10a9bb1e99 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
2013-10-04 17:31:18 -07:00
Tal Shiri
4e892e7269 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
2013-10-04 06:29:47 -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
Tal Shiri
0ece525d6c 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
2013-10-02 19:02:40 -07:00
James Rhodes
02e4a690dd 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
2013-10-01 11:37:26 -07:00
Aviv Eyal
0b8ea973ae 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
2013-09-30 10:44:38 -07:00
Aviv Eyal
aebcd7a985 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
2013-09-30 10:44:13 -07:00
epriestley
9bae517a38 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
2013-09-29 07:44:33 -07:00
Gareth Evans
1ead3cc307 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
2013-09-28 06:53:20 -07:00
Chris Dentel
08536d8917 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
2013-09-27 10:13:31 -07:00
epriestley
6270dd0de5 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
2013-09-25 15:26:38 -07:00
epriestley
0d0333d50a 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
2013-09-23 08:34:28 -07:00
James Rhodes
4ba895c30d 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
2013-09-23 05:32:34 -07:00
James Rhodes
75737c6d89 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
2013-09-20 09:18:02 -07:00
Eric Stern
bfcb3cfcd0 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
2013-09-19 15:14:58 -07:00
Jakub Vrana
bfbb16f322 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
2013-09-14 08:06:50 -07:00
epriestley
c00d8c551c 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
2013-09-12 13:01:25 -07:00
epriestley
ba3c8e3356 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
2013-09-11 21:23:30 -07:00
Aviv Eyal
1fa8e861b2 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
2013-09-11 10:36:23 -07:00
epriestley
699f3b3c05 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
2013-09-10 15:10:34 -07:00
katherine
5fd07856c0 [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
2013-09-10 11:36:17 -07:00
Evan Priestley
70567e48ae Merge pull request #90 from dcramer/pytest
Add PytestTestEngine
2013-09-06 11:49:56 -07:00
epriestley
5b869c2349 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
2013-09-05 15:05:26 -07:00
Bob Trahan
67061480f9 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
2013-09-05 12:45:59 -07:00
Nick Harper
db3581b8fa 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
2013-08-31 14:57:10 -07:00
Wez Furlong
4a3d829223 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
2013-08-29 09:55:30 -07:00
epriestley
2c5c9815c0 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: 5bb919bc3a

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, ajtrichards

Maniphest Tasks: T2039, T3186, T3771

Differential Revision: https://secure.phabricator.com/D6830
2013-08-29 06:47:27 -07:00
Bob Trahan
96a47759ae 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
2013-08-28 16:47:30 -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
Eric Stern
a28d4ff3e4 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
2013-08-26 09:59:51 -07:00
epriestley
65c19ff0c0 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
2013-08-26 05:41:32 -07:00
epriestley
0f30aca626 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:
458beca3d6

Ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: Firehed, aran

Maniphest Tasks: T2039, T3186

Differential Revision: https://secure.phabricator.com/D6805
2013-08-26 05:37:10 -07:00
durham
57bc582ad2 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
2013-08-23 16:40:15 -07:00
epriestley
1f3cb63db2 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
2013-08-23 11:58:07 -07:00
epriestley
6e5be59ad6 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
2013-08-23 11:52:54 -07:00
epriestley
e23fc30c19 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
2013-08-23 11:52:44 -07:00
Chad Little
c882877f50 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
2013-08-23 05:29:40 -07:00
epriestley
f18130a6aa 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
2013-08-22 16:02:41 -07:00
epriestley
97ad54ed00 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
2013-08-22 16:02:16 -07:00
Firehed
5eb82c8e7d 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
2013-08-20 06:58:14 -07:00
durham
8465c4dd53 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
2013-08-14 18:00:51 -07:00
Firehed
acb90fd9e7 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
2013-08-13 14:16:14 -07:00
Eric Stern
c11b9e1af9 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
2013-08-12 13:47:43 -07:00
Mehdi Mulani
857b754c7e 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
2013-08-07 14:56:03 -07:00
Eric Stern
dccc8571d7 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
2013-08-04 09:01:22 -07:00
Eric Stern
5e3b436099 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
2013-08-04 08:21:35 -07:00
Lajos Veres
a680c55670 Add CSSLint linter to Arcanist
See: https://github.com/facebook/arcanist/pull/93

Reviewed by: epriestley
2013-08-02 05:14:00 -07:00
Aviv Eyal
d54f0f69d4 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
2013-08-01 12:07:21 -07:00
durham
5b69749812 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
2013-08-01 10:14:38 -07:00
Jakub Vrana
19181fb3e8 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
2013-07-28 11:00:00 -07:00
Eric Stern
12f2175da1 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
2013-07-27 18:29:20 -07:00
Eric Stern
b56634ad27 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
2013-07-26 19:10:17 -07:00
epriestley
490984936b Revert "Merge pull request #93 from vlajos/csslint"
This reverts commit 2852a965e3, reversing
changes made to 46bb3dbc36.

See: https://github.com/facebook/arcanist/pull/93
2013-07-22 06:52:08 -07:00
Jeff Ferland
2852a965e3 Merge pull request #93 from vlajos/csslint
CSS lint support for arcanist using csslint.
2013-07-22 06:44:22 -07:00
Aviv Eyal
46bb3dbc36 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
2013-07-14 19:17:02 -07:00
Jakub Vrana
ad9cb418c4 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
2013-07-10 08:42:49 -07:00
Jakub Vrana
f5ceceea87 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
2013-07-10 08:26:11 -07:00
Lajos Veres
2e30c97ade comment typo fix 2013-07-09 14:11:21 +01:00
Lajos Veres
2b07f22e08 update __phutil_library_map__ 2013-07-09 12:48:07 +01:00
Lajos Veres
395c15e630 add css lint 2013-07-09 12:46:59 +01:00
epriestley
fbcd686e18 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
2013-07-08 09:46:24 -07:00
epriestley
910df64d31 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
2013-07-02 05:47:52 -07:00
Miorel-Lucian Palii
7130004015 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
2013-06-28 18:24:30 -07:00
Gareth Evans
a746ad8757 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
2013-06-25 15:26:14 -07:00
Gareth Evans
4f3dee80e5 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
2013-06-25 15:20:30 -07:00
Gareth Evans
1d5ee03fdb 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
2013-06-20 07:35:30 -07:00
durham
b713eb51c9 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
2013-06-17 11:40:58 -07:00
David Cramer
81a1c09148 Add PytestTestEngine 2013-06-13 14:23:45 -07:00
epriestley
c38bc4376c 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
2013-06-12 05:50:08 -07:00
epriestley
2e61b1a3df 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
2013-06-11 06:26:42 -07:00
Omer Strulovich
9a46ba7ea1 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
2013-06-09 08:38:30 -07:00
Jakub Vrana
5336f4bcf0 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
2013-06-05 13:53:43 -07:00
epriestley
e93726cb3b 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
2013-06-04 15:29:39 -07:00
epriestley
ae66d4caa9 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
2013-05-30 21:03:21 -07:00
James Rhodes
50419e584d 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
2013-05-30 20:57:00 -07:00
epriestley
1fcf7bac4e 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
2013-05-23 14:38:09 -07:00
epriestley
24d54a5fbd 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
2013-05-23 14:36:42 -07:00
Gareth Evans
4c37e6ff4a 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
2013-05-23 10:36:40 -07:00
Jakub Vrana
eb449a40b4 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
2013-05-22 11:36:41 -07:00
Afaque Hussain
0b8e9823fa 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
2013-05-21 13:06:14 -07:00
Jakub Vrana
a1c0ba785d 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
2013-05-19 11:00:08 -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
epriestley
592172c775 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
2013-05-14 13:35:42 -07:00
Howard Chan
3116d3656a 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
2013-05-14 11:00:56 -07:00
Aviv Eyal
0476bf8f4a 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
2013-05-14 06:38:22 -07:00
Martin Kralik
3401b2a5d2 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
2013-05-03 16:12:17 -07:00
Nick Harper
28df67963b 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
2013-04-24 15:10:27 -07:00
epriestley
957249f56c 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
2013-04-23 11:26:28 -07:00
san
410ea5dc32 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
2013-04-23 06:37:38 -07:00
epriestley
904740855c 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
2013-04-22 14:38:49 -07:00
Jakub Vrana
c0ff9852af 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
2013-04-19 22:12:02 -07:00
durham
07fba2a49b 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
2013-04-18 20:03:26 -07:00
Phil Dibowitz
fb88bb9da6 Add a configuration for python path
Test Plan: not a clue

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5717
2013-04-16 15:10:34 -07:00
durham
b3108661bb Enable lint amending commits in mercurial
Summary:
arc lint was hardcoded for git for amending commits with lint
patches. This enables the same functionality for mercurial.

Test Plan:
Made some changes that would result in a lint patch.
arc diff

Verify that the patches it produces were amended into the commit.

Verified it still works in git as well.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5716
2013-04-16 13:32:12 -07:00
durham
bfc1eeba07 Fix hg amend during arc diff
Summary:
When doing an arc diff with pending changes in your working copy
it was creating a new commit with the pending changes instead of amending
the existing one.  The problem was the author comparison was comparing
values like "John Smith <john@foo.com>" with "John Smith". The fix changes
$api->getAuthor() to return "John Smith" instead of the full string. This
matches the behavior (and implementation) found in the git api.

Test Plan:
hg book foo
touch a && hg commit -Ama
touch b && hg add b
arc diff
When prompted, amend the pending changes to the existing commit.

Verified that the changes were amended instead of making a new commit.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5706
2013-04-16 10:22:00 -07:00
epriestley
b0a0414766 Construct a diganostic parser in BaseWorkflow::getChange()
Summary:
@ender is reporting a parsing issue in SVN, but we don't build a parser with setWriteDiffOnFailure() set in this workflow right now so I can't get the raw file to fix the issue.

Use the onboard mechanism to build a parser with `setWriteDiffOnFailure()` set, so it will write the diff, so I can get a copy so I can fix the problem.

Test Plan: Ran `arc diff --preview` in an SVN repo with a linter.

Reviewers: ender, btrahan

Reviewed By: ender

CC: aran

Differential Revision: https://secure.phabricator.com/D5699
2013-04-15 12:30:56 -07:00
epriestley
2df40b5445 Lint TRUE, nUlL, etc., for Phabricator conventions
Summary: Detect and fix unconventional spellings of `true`, `false`, `null` and `array` (these are the only keywords I've seen spelled unconventionally in the wild).

Test Plan: Unit tests.

Reviewers: DurhamGoode, btrahan, vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2985

Differential Revision: https://secure.phabricator.com/D5686
2013-04-15 10:22:56 -07:00
durham
e573610ce4 Add arc.land.update.default config for setting the default strategy
Summary:
This adds a arcconfig setting to allow specifying whether to use the merge
or rebase strategy when doing the feature branch update.
arc.land.update.default can be set to either 'rebase' or 'merge'.  The command
line flags will override this setting.

We have had trouble with arc land producing merge commits (introduced
with D4080) in git. They usually appear when arc land fails, and our users
are confused by the presence of a merge commit afterwards. Today it got even
worse since a user managed to get arc land to push the merge commit to the
server. This setting will allow us to turn it off for our uses.

Test Plan:
Verified the following combinations:
update.default not set + arc land (saw git merge in the trace)
update.default = 'rebase' + arc land (saw git rebase)
update.default = 'merge' + arc land (saw git merge)
update.default = 'rebase' + arc land --update-with-merge (saw git merge)
update.default = 'merge' + arc land --update-with-rebase (saw git rebase)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5683
2013-04-14 11:48:22 -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
Nick Harper
b1fe436cfc [svn] Fix removing a binary file without svn:mime-type set
Summary:
If we're removing a binary file that didn't have svn:mime-type set properly,
we can't propset it (because the file doesn't exist locally). Instead, just
return a synthetic diff for the removed file.

Test Plan:
run arc diff in an svn working copy where I ran svn rm on a binary file that
doesn't have svn:mime-type set, and the diff correctly gets uploaded to
phabricator instead of erroring when trying to set properties.

Reviewers: epriestley, wez

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5655
2013-04-10 15:22:58 -07:00
durham
7c22017562 Allow 'arc diff .^' for hg repos
Summary:
Previously arc diff for hg only allowed bookmark names, rev numbers,
and commit hashes as the input base commit. This was because it escaped all
inputs and treated them as raw identifiers.

This change makes it treat the input as a revset if the escaped version fails.
This allows users to do things like "arc diff .^" when they only want to diff
the top commit.

Test Plan:
Created a stack of commits, master->A->B.
hg up B
arc diff .^
Verified the diff message only showed B as part of the diff.

arc diff .^~
Verified an error occurred ("Commit '.^~' is not a valid Mercurial commit id.")

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2888

Differential Revision: https://secure.phabricator.com/D5638
2013-04-09 17:00:34 -07:00
Shayne Sweeney
cf76d2fc1c Add py/pl files to $text_paths (remove l/y files?!)
Summary:
I'm guessing this was refactored somewhere down the line and it meant
that Python and Perl files were no longer considered text files.

I'm imagining the old regex was: p(hp|y|l). Therefore I blame CSS.

Test Plan:
Perform an arc lint on a Python or Perl file that has trailing whitespace
on a line. It should prompt you for an autocorrecting lint.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5637
2013-04-09 15:07:05 -07:00
Jakub Vrana
dbe0f7dc09 Invalidate SVN status cache after adding files
Summary: Cache invalidation is really one of the two hardest computer science problems.

Test Plan:
  lang=sh
  # in Subversion repository
  $ arc diff .arcconfig # untracked

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Differential Revision: https://secure.phabricator.com/D5600
2013-04-06 09:25:35 -07:00
Jakub Vrana
3af36c6a4e Hide Git merge stats in arc land
Test Plan:
  $ arc land # in Git repo

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5599
2013-04-06 09:23:41 -07:00
Jakub Vrana
c77ec2bdc6 Escape ^ on command line (significant on Windows) 2013-04-05 23:17:40 -07:00
Jakub Vrana
576c47aaa1 Don't use command output as formatted string in arc land 2013-04-05 23:09:35 -07:00
epriestley
ac0aa330f5 Don't use emailuser in Mercurial
Summary:
The `emailuser` template is a relatively recent addition to Mercurial, and a few users have complained about it. It also doesn't actually do what I thought it did, e.g. in an address like this:

  "Abraham Lincoln" <alincoln@whitehouse.gov>
   ^^^^^^^^^^^^^^^   ^^^^^^^^
         (1)            (2)

                     ^^^^^^^^^^^^^^^^^^^^^^^
                              (3)

...I want (1), but `emailuser` means (2). Instead, extract (1) with `getDisplayName()` and (3) with `getAddress()` using PhutilEmailAddress.

The implementation in Mercurial is not particularly sophisticated or magical (it just looks for "@" and "<") so we aren't really missing anything by doing this ourselves, at least today.

Also fix some issues in `arc export`, which literally no one uses, but which is occasionally useful for testing (as here).

Test Plan:
  - Ran `arc diff --only` in an `hg` repo, checked DB to see that name/email were correctly extracted.
  - Ran `arc export --git` in an `hg` repo, didn't get a long series of fatals.

Reviewers: btrahan, DurhamGoode

Reviewed By: DurhamGoode

CC: aran

Maniphest Tasks: T2866, T2858

Differential Revision: https://secure.phabricator.com/D5539
2013-04-02 14:06:46 -07:00
durham
3f2c6b629f Add hook for runtime config settings.
Summary:
This adds a hook to allow external parties to provide config settings at runtime.
The hook is technically for when a RepositoryAPI is created, but that moment can
be used to set new config settings using the new setRuntimeConfig() api.

For example you could have a external hook that looks for keys like 'git:foo.bar'
or 'hg:foo.bar' and writes the value of 'foo.bar' based on whether the repo is a
git or a hg repo.

Test Plan:
Created a hook that looks for hg/git prefix versions of config keys.
Set hg:arc.feature.start.default to be "master" and set arc.feature.start.default
to be "trunk".
Ran arc feature in the hg repo.  It made a bookmark on master.
Ran arc feature in the git repo.  It made a branch on trunk.

Did it again, but with git:arc.feature... set instead.

Reviewers: epriestley

Reviewed By: epriestley

CC: nh, wez, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5357
2013-04-01 11:26:17 -07:00
durham
b7a2766130 Make arc land list the commits being landed.
Summary:
Arc land is a bit magical and some users have gotten bitten by
the fact that it collapses and lands every commit on the branch. To make
it explicit what is being landed, it now shows a list of the commits
that are being landed.  I also added a --preview flag that will just
print the commits that would be landed, but does nothing else.

Hopefully this make arc land a little less magical for people.

Test Plan:
arc land in the following scenarios:
- Landing one change
- Landing no changes
- Landing a stack of changes

Did it with hg and git.

Reviewers: epriestley

Reviewed By: epriestley

CC: nh, sid0, dschleimer, bos, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5460
2013-03-29 10:08:23 -07:00
Jakub Vrana
d1027c186c Add missing image functions to PHP extension functions list
Summary:
Copied from PHP Manual.

Also fix missing cache key for implicitly linted file.

Test Plan:
  phabricator/ $ arc lint src/applications/files/PhabricatorImageTransformer.php # without GD2

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Differential Revision: https://secure.phabricator.com/D5457
2013-03-28 05:04:37 +00:00
Jakub Vrana
50b4f0af65 Don't connect to Conduit in arc feature name
Summary: There's no need for having an Internet connection in creating a branch.

Test Plan:
  $ arc feature name # with disabled Internet
  $ arc feature
  [cURL/6] (https://secure.phabricator.com/api/conduit.connect)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5430
2013-03-22 17:33:07 -07:00
durham
ba78000b38 Make arc patch create a bookmark by default in hg
Summary:
Previously, arc patch would create a new commit under the existing
current bookmark in mercurial. There have been two discussions about what the
right behavior should be (D3334 and D3658). One side wants no commit at all,
and one side wants a commit under a new bookmark. The current implementation is
the worst of both worlds :(

This change makes it create a new bookmark at the revision's base before commiting,
same as the --bookmark flag used to do (which is now obsolete). That way the
existing bookmark doesn't move (in mercurial >=1.8). This is the same behavior
git has, which is convienent for groups migrating between the two.

Also makes hg's getCanonicalRevision handle svn revisions just like git. This way
arc patch will try to apply the patch to the appropriate revision in the history.

Test Plan:
Ran:
arc patch - Verified it created a new bookmark and commited on top of the
revision's base commit.

arc patch --nobranch - Verified it put the new commit on top of the current
bookmark without a new bookmark.

arc patch --nocommit - Verified it left all the changes in the working copy.

Also verified arc patch still works with git.

Reviewers: epriestley

Reviewed By: epriestley

CC: sid0, bos, dschleimer, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5408
2013-03-21 17:52:07 -07:00
James Rhodes
2900ab6abd Added automatic stash / unstash support for Git in arc diff.
Summary:
- Added arc.autostash option to have this behaviour off by
default (but configurable on a per-project basis).
- Automatic stashing of changes now informs the user of how
to restore their working directory if Arcanist unexpectedly
terminates.
- Fixed an issue with finalizeWorkingCopy when the workflow
didn't require a clean working copy.

Test Plan:
Test `arc diff` when there are changes in the working
directory; by default it should tell you to stash or commit.
Turn on the arc.autostash option and try again; it should
automatically stash with a message on how to recover, and
it should restore the working directory automatically under
almost any circumstances (other than an unrecoverable error).

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5385
2013-03-21 16:00:05 -07:00
durham
9963323b91 Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial.  Previously it would often leave the repo in a confusing state
if something failed.

- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.

Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land

In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.

Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.

Reviewers: epriestley, dschleimer, sid0

Reviewed By: epriestley

CC: nh, wez, bos, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 15:06:10 -07:00
durham
b6e83c7b35 Fix arc patch adding unnecessary files for hg repos
Summary:
Arc patch was committing with -A (--addremove) which meant any random
files that were sitting around in the repo (like conflict .orig files) were
added to the commit.  The -A isn't even necessary since the hg import
adds and removes all the appropriate files for you.

Test Plan:
touch foo
arc patch --diff some-diff-id
Verified that foo was not added to the commit

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: dschleimer, bos, sid0, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5396
2013-03-20 14:40:28 -07:00
Nick Harper
30e12a0c9a Improve error if python can't run pep8
Summary:
On systems with an ancient version of python, the pep8 linter won't run.
Instead of blowing up in the user's face, we should display a nice error
message.

Test Plan:
Put /usr/bin (where the ancient version of python is) at the beginning of
my path and tried to lint some python. I got a nice error instead of a
stack trace.

Reviewers: epriestley, wez

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5356
2013-03-19 11:44:49 -07:00
Jakub Vrana
337f7f83ea Don't use absolute path in ArcanistDiffUtils
Summary: Improves Windows compatibility.

Test Plan: Ran failing unit test on Windows.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5344
2013-03-14 09:14:50 -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
b06237cb2d Change arc feature to use it's own config key for the start default
Summary:
Changes arc feature to read 'arc.feature.start.default' instead
of 'arc.land.onto.default'.  In our usage we actually need to fork off
a different branch than we land to, so separating these is useful.

Test Plan:
Set arc.land.onto.default = master
Set arc.feature.start.default = bar
arc feature foo
cat .git/config
Verified the foo branch tracked bar

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: wez, dschleimer, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5336
2013-03-13 17:01:23 -07:00
Jakub Vrana
4fd8b88833 Compute lint cache key before linting
Summary: If user changes the file contents during linting (usually when prompted to apply a patch) then we save the old messages to the new file contents. Fix that by computing the hash before linting (or after applying patch).

Test Plan: Changed the file during linting, verified that the file hash didn't change.

Reviewers: epriestley

Reviewed By: epriestley

CC: ptarjan, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5320
2013-03-10 22:31:13 -07:00
Jakub Vrana
a925ef9dc1 Improve Windows compatibility
Test Plan:
  $ arc liberate
  $ arc lint

Reviewers: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5319
2013-03-10 18:08:41 -07:00
Alok Menghrajani
7bf26484fb Dispatch an event in arc land right before pushing a revision
Summary: I looked at the pros & cons at adding hooks in git/hg vs arc land and I prefer arc land.

Test Plan:
* added an event listener and made sure I could handle the event.
* made sure things get reverted when the event handler throws an exception.

Reviewers: vrana, epriestley, pieter

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5268
2013-03-08 18:32:36 -08:00
vrana
955bfb5581 Initialize variable in lint patch output 2013-03-08 15:25:33 -08:00
vrana
c4773c87ba Improve the description of using arc land --revision
Summary: The message suggests that only one revision would land.

Test Plan: Read it.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5277
2013-03-07 21:28:04 -08:00
epriestley
42235d9f1f Minor, fix arc land for the case of no dependencies.
Auditors: Afaque_Hussain
2013-03-07 17:22:24 -08:00
vrana
91154c9cdf Ignore remote errors in parsing Mercurial log
Summary:
This probably indicates some none fatal error, e.g.:

> remote: Certificate invalid: name is not a listed principal

The best thing here would be to avoid the error but we shouldn't explode even if it is there.
I tried to mute the error from the output but didn't find a switch or config option to do it.

Test Plan:
  $ hg outgoing --branch default --style default

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5267
2013-03-07 11:14:49 -08:00
Afaque Hussain
dd3d33c610 If a revision depends on another revision which has not yet been closed, warn the developer
Summary: Have arc land inspect the revision if it depends on some other revisions which haven't been closed yet. If yes, then warn users.

Test Plan: Will test them locally.

Reviewers: epriestley, AnhNhan

CC: aran, Korvin, AnhNhan

Differential Revision: https://secure.phabricator.com/D5262
2013-03-07 09:02:51 -08:00
epriestley
d31385912f Document parameters
Summary: unlike the hooks I copy/pasted, these hooks have parameters

Test Plan: read it

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5264
2013-03-06 13:47:05 -08:00
epriestley
c827490708 Add willRunTestCases / didRunTestCases hooks
Summary: These hooks allow test cases to build shared resources -- notably, database fixtures.

Test Plan: See next diff.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5258
2013-03-06 13:40:07 -08:00
epriestley
5296bf529f Fix bug with arc unit --everything when coverage is available
Summary: We don't set $paths when running --everything.

Test Plan: Ran `arc unit --everything` with coverage.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5260
2013-03-06 13:39:31 -08:00
durham
64bbcda431 Add arcconfig setting for default arc feature start
Summary:
Adds arc.feature.start.default arcconfig setting to specify
a default value for 'start' in 'arc feature name start'. This lets
users always branch from origin/master (or whatever the main branch is).

Also cleaned up the 'feature' help text a little. The stuff about sorting
and closed/abandoned revisions is explained via the options list already.

Test Plan:
Ran arc feature with/without a start and with/without the config
setting set.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: bos, sid0, dschleimer, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5184
2013-03-05 12:48:53 -08:00
Andrew Chen
263cf9a95f Complain about Reuse of By-ref Iterators
Summary:
Added a lint rule that warns about reusing iterator reference
variables.

Test Plan:
- Add a file with examples found in with https://secure.phabricator.com/T2536
- Did not make a unit test yet

Reviewers: vrana, bill, epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin

Maniphest Tasks: T2536

Differential Revision: https://secure.phabricator.com/D5179
2013-03-05 07:45:02 -08:00
Ryan Patterson
eed7e70bb1 arc feature set up git tracking branch
Summary:
When using arc feature, it should set up the tracking branch to be
master.

Test Plan:
  ./bin/arc feature tracking

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5169
2013-03-03 21:43:59 -08:00
vrana
ebe464b6f0 Respect British spelling also in arguments
Summary: These are the errors I really do.

Test Plan:
  $ arc diff --no-lint
  (Assuming '--no-lint' is the British spelling of '--nolint'.)
  $ arc diff --reviewer a
  (Assuming '--reviewer' is the British spelling of '--reviewers'.)

New unit test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5185
2013-03-01 16:53:26 -08:00
durham
4af7c865aa Use hg phases to detect outgoing when phases are supported
Summary:
There was an accidental ! in the phase vs outgoing condition
which caused it to use 'hg outgoing' when it should have used the draft()
phase.  Fixing this shaves 4.5 seconds off 'arc diff' on large repos.

Test Plan:
Ran arc diff --trace.  Noted that the draft() was used and that the diff
contained the correct files and commit.

Reviewers: epriestley

Reviewed By: epriestley

CC: sid0, bos, dschleimer, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5182
2013-03-01 14:10:25 -08:00
mconnor
0e254f769d Use bookmark terminology if arc land on hg bookmark
Summary: Changes message for `arc land` that displays current branch or bookmark (if none is specified) to appropriately use the term 'bookmark' when on a bookmark in an hg repository.

Test Plan:
Ran `arc land` on new git and hg repositories, checking for correct identification of 'branch' or 'bookmark'.

~/test$ mkdir hg-test
~/test$ mkdir git-test
~/test$ cd hg-test
~/test/hg-test$ hg init
~/test/hg-test$ hg branch
default
~/test/hg-test$ hg bookmarks
no bookmarks set
~/test/hg-test$ arc land
Landing current branch 'default'.
Usage Exception: You can not land a branch onto itself -- you are trying to land 'default' onto 'default'. For more information on how to push changes, see 'Pushing and Closing Revisions' in 'Arcanist User Guide: arc diff' in the documentation. You may be able to 'arc amend' instead.
~/test/hg-test$ hg bookmark testmark
~/test/hg-test$ hg bookmarks
 * testmark                  -1:000000000000
~/test/hg-test$ hg branch
default
~/test/hg-test$ arc land
Landing current bookmark 'testmark'.
Usage Exception: Source testmark is a bookmark but destination default is not a bookmark. When landing a bookmark, the destination must also be a bookmark. Use --onto to specify a bookmark, or set arc.land.onto.default in .arcconfig.

Confirm still works on a git branch:

~/test/hg-test$ cd ../git-test/
~/test/git-test$ ls
~/test/git-test$ git init
Initialized empty Git repository in ~/test/git-test/.git/
~/test/git-test$ touch testfile
~/test/git-test$ git commit -am 'Test file'
~/test/git-test$ git branch
* master
~/test/git-test$ arc land
Landing current branch 'master'.
Usage Exception: You can not land a branch onto itself -- you are trying to land 'master' onto 'master'. For more information on how to push changes, see 'Pushing and Closing Revisions' in 'Arcanist User Guide: arc diff' in the documentation. You may be able to 'arc amend' instead.

Reviewers: DurhamGoode, epriestley

Reviewed By: DurhamGoode

CC: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D5163
2013-03-01 14:04:05 -08:00
vrana
2e87419c7b Render unit results progressively
Summary:
Some tests take longer (fixtures usually around 1 second for me) and also FB runs all tests on deploy.
I want to see all results immediately.

Test Plan:
Added `usleep(200000)` to `resultTest()`, then:

  $ arc unit
  Saw results printed one by one.

Also didn't pass `$renderer` to `ArcanistPhutilTestCase` and saw empty output.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5141
2013-02-28 15:33:21 -08: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
durham
0cb1b7efad Fix arc lint on working copy changes in mercurial repos
Summary:
Previously, running arc lint on a set of changes that only
existed in your working copy threw an exception in mercurial repos.
It was trying to use the revset "...." (i.e. the range from . to .),
which didn't parse. Even if I fix that it still doesn't work because
getRawDiffText did not include the working copy changes (which it does
in git).  I removed the check so the function now acts the same as in
git and arc lint works on working copy changes. I've seen this error before
in other places so hopefully this change will also fix any other areas,
that depended on getRawDiffText working the same as git.

The logic I removed was added in D1954 to support diffing against
uncommited changes.  That workflow should be unchanged.  arc diff will
still prompt the user if there are uncommited changes, and the user can
still choose to abort or continue.

Let me know if I missed something important which makes this a bad idea.

Test Plan:
Edited a file in the working directory of a hg repo.
arc lint
Verified lint ran successfully.

Also ran arc diff and land with and without working copy changes to make sure
they still work.  I'd kill for some tests in this area...

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: dschleimer, bos, sid0, aran, Korvin

Maniphest Tasks: T1631

Differential Revision: https://secure.phabricator.com/D5130
2013-02-26 16:15:29 -08:00
vrana
2f09de2e79 Include linter class MD5 in linter version
Summary:
People constantly forget to bump the linter version and I don't see a way how to stop it.
This may bump the version even if it wouldn't be required but let's rather undercache than overcache.

Test Plan: `var_dump($version)`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5129
2013-02-26 16:01:25 -08:00
vrana
266a4f4c75 Catch exceptions in didRunLinters()
Test Plan: Threw in `didRunLinters()` of one linter, still saw the result of other linters and "Some linters failed" at the end.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5124
2013-02-26 15:00:58 -08:00
vrana
2464f54ecf Initialize used variable in lint console renderer 2013-02-25 16:23:27 -08:00
vrana
9d92253903 Support arc lint --output none
Summary:
I want to run lint on background and I'm interested only in side effect of caching (and maybe exit status).
This is better than discarding stdout later because we don't do unnecessary work and error conditions are still printed.

Test Plan:
  $ arc lint --output none # with error
  $ echo $?
  $ arc lint --output none # with no lintable paths
  $ arc lint --output none # witout errors

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5106
2013-02-25 14:55:57 -08:00
vrana
0b120bd04b Add unit tests for implicit fallthrough lint rule
Summary:
The perf fix actually catches some real problems.
I didn't find anything in libphutil, Arcanist and Phabricator though.

Also bump version.

Also allow configuring the hook.

Test Plan:
Added a test, saw it fail with the old code.
Repeat for hook.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5097
2013-02-23 09:07:28 -08:00
vrana
8ec038291a Fix intraline lint patch rendering
Summary: `,` -> `, ` is currently highlighted wrong.

Test Plan:
Looked at patches of these errors:

- License linter
- `0+0`
- `0,0`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5093
2013-02-22 17:03:47 -08:00
vrana
21a4574922 Change ArcanistLintRenderer to class
Summary: Renderers **are** renderers not **can** render.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5092
2013-02-22 16:15:43 -08:00
vrana
5d47682f3b Don't amend existing revision with arc diff --create
Summary: If there's other revision in last commit message and I said `--create` then it is clear that I want to create a new commit.

Test Plan:
  $ arc diff --create # in dirty working copy on top of my open revision

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5078
2013-02-22 14:16:32 -08:00
vrana
aadaf9a795 Speedup implicit fallthrough lint rule by 99.5 %
Summary: At least on my sample file.

Test Plan: Saw time 0.073 s instead of 12.606 s.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5086
2013-02-22 14:16:03 -08:00
vrana
4d28d91d98 Fix arc diff --verbatim 2013-02-22 12:33:31 -08:00
vrana
47a823ac6d Declare that amend and land are supported by Mercurial
Test Plan: Read it.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5080
2013-02-22 10:15:33 -08:00
vrana
6a7a92cdcc Create a new diff if the user says so
Summary: If I have //Differential Revision// in my commit message then `arc diff --create` updates that revision instead of creating a new one.

Test Plan:
  $ arc diff --create # on top of commit message with Differential Revision

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5077
2013-02-22 09:59:57 -08:00
vrana
b758e3737c Log two times per linter instead of N
Summary: This number seems more interesting and it includes time for resolving futures which is the main part of some linters.

Test Plan:
  $ arc --trace lint

Reviewers: fdeliege, epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D5075
2013-02-22 09:54:43 -08:00
epriestley
e33bd82c42 Add hgsprintf() and jsprintf() to dynamic string lint warning
Summary: Soon all functions will accept only static parameters! glorious!

Test Plan: Added a couple tests.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4811
2013-02-21 16:44:34 -08:00
epriestley
3e3ea378ed Remove hgsprintf() from arcanist
Summary: Moving to libphutil.

Test Plan: unit

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5058
2013-02-21 16:44:19 -08:00
vrana
7a415e7e0c Make ArcanistLintWorkflow final
Summary: FB doesn't extend it.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5050
2013-02-21 14:44:59 -08:00
vrana
459251a8d0 Call willLintPath() in future linter
Summary: Also simplify creating futures.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, s.o.butler

Differential Revision: https://secure.phabricator.com/D5042
2013-02-21 11:57:38 -08:00
epriestley
3136edf9de Use Damerau-Levenshtein to improve british spellings
Summary: Price transpositions very cheaply. We might need to edit these weights a bit, but this covers the two previous cases ("test", "alnd") and gets them right.

Test Plan: Unit tests, various `arc x` tests.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5034
2013-02-21 10:16:02 -08:00
epriestley
e96db54125 Fix filter/sort order of operations for british spellings
Summary: Currently, if we match "alnd" to "land" and "amend" equally (distance 2), we drop "land" with the other part of the rule. Stop doing that.

Test Plan:
Unit tests. Also:

```
$ arc alnd
Usage Exception: Unknown command 'alnd'. Try 'arc help'.

Did you mean:
    amend
    land
```

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5033
2013-02-21 10:15:20 -08:00
vrana
5e7a458053 Use full message if XHPAST fails to parse the file
Summary:
The message is too defensive.

Test Plan: Tested in the fork.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin, s.o.butler

Differential Revision: https://secure.phabricator.com/D5043
2013-02-21 09:14:49 -08:00
vrana
df013f6282 Resolve XHPAST linter futures on background
Summary: This is a little bit tricky - if both XHPAST and PhutilXHPAST linters lint the same path then they get the same future wrapped in two different Future iterators.

Test Plan:
  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5015
2013-02-21 00:58:23 -08:00
vrana
a3e0c26ea8 Delete newLintAtLine()
Summary: Nobody needs it because `raiseLintAtLine()` returns the message.

Test Plan:
  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4870
2013-02-21 00:56:08 -08:00
durham
7f81058ead fix 'arc feature' not creating bookmarks on mercurial
Summary:
The arc feature command wasn't actually creating bookmarks
on mercurial. It needs to call 'hg bookmark' instead of 'hg update'

Also removed an unnecessary hgsprintf since there were no arguments.

Test Plan:
Ran 'arc feature foo' and 'arc feature bar tip^'.
The former created a bookmark at my current location.
The latter created a bookmark at tip^ and moved me to that revision.

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: sid0, bos, dschleimer, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5023
2013-02-20 20:06:16 -08:00
epriestley
01ec103297 Remove dead class from library map. 2013-02-20 15:10:34 -08:00
epriestley
652472d059 Undumb other generic text linters
Summary:
Make all the broad-spectrum text linters use the new binary check.

I didn't touch `ComprehensiveLintEngine` because it's a nest of vipers and no one has complained; see T2039.

Test Plan: Ran `arc lint` on text files and binaries in a libphutil project (arcanist).

Reviewers: lisp

Reviewed By: lisp

CC: aran

Differential Revision: https://secure.phabricator.com/D5040
2013-02-20 14:36:53 -08:00
Robert Smith
92a5803d30 Add linting for syntax brought in by unresolved merge conflicts.
Summary:
Add linting capability for detecting files which contain
syntax introduced by unresolved merge conflicts. The detection is
file-type-agnostic (the only requirement is that the file is a text
file).

Test Plan:
Tested in three ways.

The first way is to add all three forms of syntax to a file to
indicate a merge conflict. HPHP will pick this up as a syntax error
before this linter reaches it.

The second way is to add the syntax in a comment. In that case, this
linter will show three warnings. For example:

    $ arc lint ArcanistMergeConflictLinter.php
    >>> Lint for arcanist/src/lint/linter/ArcanistMergeConflictLinter.php:

       Warning  (MERGECONFLICT1) Unresolved merge conflict
        This syntax indicates there is still an unresolved merge conflict.

                  20
                  21     foreach ($lines as $lineno => $line) {
                  22 /*
        >>>       23 >>>>>>>
                  24
                  25 =======

       Warning  (MERGECONFLICT1) Unresolved merge conflict
        This syntax indicates there is still an unresolved merge conflict.

                  22 /*
                  23 >>>>>>>
                  24
        >>>       25 =======
                  26
                  27 <<<<<<<

       Warning  (MERGECONFLICT1) Unresolved merge conflict
        This syntax indicates there is still an unresolved merge conflict.

                  24
                  25 =======
                  26
        >>>       27 <<<<<<<
                  28
                  29 */

The last test was to test on various different file types, including
JavaScript, PHP, an animated GIF, a PNG, and a Bash file to make sure
the file type detection worked. Each of the aforementioned tests
passed.

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin

Maniphest Tasks: T2547

Differential Revision: https://secure.phabricator.com/D4966
2013-02-20 14:19:55 -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
ba560159d4 Simplify (?) arc upload code and make it more future-oriented
Summary: See discussion in D4968. This makes us run `file.uploadhash` calls in parallel, to slightly improve performance.

Test Plan:
Created a binary change in a commit:

  $ head -c65535 /dev/urandom > a_random_file
  $ git add .
  $ git commit -m .
  [master 32e4c0a] .
   1 files changed, 0 insertions(+), 0 deletions(-)
   create mode 100644 a_random_file

Verified `arc diff` called `conduit.query`, then `file.uploadhash` (which we expect to fail; the file is new), then `file.upload`:

  $ arc diff HEAD^ --only --trace
  ...
  Uploading 1 files...
  >>> [15] <conduit> conduit.query() <bytes = 157>
  >>> [16] <http> http://local.aphront.com/api/conduit.query
  <<< [16] <http> 111,500 us
  <<< [15] <conduit> 112,169 us
  >>> [17] <conduit> file.uploadhash() <bytes = 254>
  >>> [18] <http> http://local.aphront.com/api/file.uploadhash
  <<< [18] <http> 85,386 us
  <<< [17] <conduit> 85,798 us
  >>> [19] <conduit> file.upload() <bytes = 97009>
  >>> [20] <http> http://local.aphront.com/api/file.upload
  <<< [20] <http> 144,098 us
  <<< [19] <conduit> 144,550 us
  Uploaded 'a_random_file' (new).
  Upload complete.
  ...
  Created a new Differential diff:
          Diff URI: http://local.aphront.com:8080/differential/diff/202/

  Included changes:
    A (bin) a_random_file

Created the same diff again, verified that we skip the data transfer this time:

  $ arc diff HEAD^ --only --trace
  ...
  Uploading 1 files...
  >>> [15] <conduit> conduit.query() <bytes = 157>
  >>> [16] <http> http://local.aphront.com/api/conduit.query
  <<< [16] <http> 112,717 us
  <<< [15] <conduit> 113,374 us
  >>> [17] <conduit> file.uploadhash() <bytes = 254>
  >>> [18] <http> http://local.aphront.com/api/file.uploadhash
  <<< [18] <http> 95,545 us
  <<< [17] <conduit> 95,921 us
  Uploaded 'a_random_file' (new).
  Upload complete.
  ...
  Created a new Differential diff:
          Diff URI: http://local.aphront.com:8080/differential/diff/203/

  Included changes:
    A (bin) a_random_file

Created a new commit which adds a new file and updates the exiting file:

  $ head -c65535 /dev/urandom > another_file
  $ head -c65535 /dev/urandom >> a_random_file
  $ git add .
  $ git commit -m .
  [master 28f4fbd] .
   2 files changed, 0 insertions(+), 0 deletions(-)
   create mode 100644 another_file

Verified `arc diff` transfers one file by hash (old version of the first file) and two by data (new first file, new second file):

  $ arc diff HEAD^ --only --trace
  ...
  Uploading 3 files...
  >>> [19] <conduit> conduit.query() <bytes = 157>
  >>> [20] <http> http://local.aphront.com/api/conduit.query
  <<< [20] <http> 114,825 us
  <<< [19] <conduit> 115,517 us
  >>> [21] <conduit> file.uploadhash() <bytes = 254>
  >>> [22] <http> http://local.aphront.com/api/file.uploadhash
  >>> [23] <conduit> file.uploadhash() <bytes = 254>
  >>> [24] <http> http://local.aphront.com/api/file.uploadhash
  >>> [25] <conduit> file.uploadhash() <bytes = 253>
  >>> [26] <http> http://local.aphront.com/api/file.uploadhash
  <<< [24] <http> 104,310 us
  <<< [26] <http> 105,211 us
  <<< [25] <conduit> 105,587 us
  <<< [22] <http> 112,631 us
  <<< [25] <conduit> 111,437 us
  Uploaded 'a_random_file' (old).
  <<< [25] <conduit> 111,678 us
  >>> [27] <conduit> file.upload() <bytes = 193912>
  >>> [28] <http> http://local.aphront.com/api/file.upload
  >>> [29] <conduit> file.upload() <bytes = 97379>
  >>> [30] <http> http://local.aphront.com/api/file.upload
  <<< [28] <http> 153,126 us
  <<< [29] <conduit> 161,180 us
  Uploaded 'a_random_file' (new).
  <<< [30] <http> 678,739 us
  <<< [29] <conduit> 679,121 us
  Uploaded 'another_file' (new).
  Upload complete.
  ...
  Created a new Differential diff:
          Diff URI: http://local.aphront.com:8080/differential/diff/204/

  Included changes:
    M (bin) a_random_file
    A (bin) another_file

Ran the same command again, verified three uploads by hash:

  $ arc diff HEAD^ --only --trace
  ...
  Uploading 3 files...
  >>> [19] <conduit> conduit.query() <bytes = 157>
  >>> [20] <http> http://local.aphront.com/api/conduit.query
  <<< [20] <http> 117,058 us
  <<< [19] <conduit> 117,792 us
  >>> [21] <conduit> file.uploadhash() <bytes = 254>
  >>> [22] <http> http://local.aphront.com/api/file.uploadhash
  >>> [23] <conduit> file.uploadhash() <bytes = 254>
  >>> [24] <http> http://local.aphront.com/api/file.uploadhash
  >>> [25] <conduit> file.uploadhash() <bytes = 253>
  >>> [26] <http> http://local.aphront.com/api/file.uploadhash
  <<< [22] <http> 103,373 us
  <<< [24] <http> 105,418 us
  <<< [26] <http> 105,251 us
  <<< [25] <conduit> 105,604 us
  Uploaded 'a_random_file' (old).
  <<< [25] <conduit> 105,844 us
  Uploaded 'a_random_file' (new).
  <<< [25] <conduit> 106,053 us
  Uploaded 'another_file' (new).
  Upload complete.
  ...
  Created a new Differential diff:
          Diff URI: http://local.aphront.com:8080/differential/diff/205/

  Included changes:
    M (bin) a_random_file
    A (bin) another_file
  $

Reviewers: kwadwon

Reviewed By: kwadwon

CC: aran

Maniphest Tasks: T2456

Differential Revision: https://secure.phabricator.com/D4993
2013-02-20 12:24:32 -08:00
François Deliège
8be64ec4c6 Log slow linters using service call
Summary:
Following @epriestley suggestion to use PhutilServiceProfiler to log lint as a service call

Test Plan: arc lint

Reviewers: vrana

CC: phunt, aran, epriestley

Differential Revision: https://secure.phabricator.com/D4820
2013-02-20 11:43:51 -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
157184e01d Add a lint rule for spaces before the closing paren of a function/method call
Summary: This is technically documented, but not currently enforced and we aren't consistent about it in the codebase.

Test Plan: See D5002.

Reviewers: chad, vrana

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D5003
2013-02-19 13:50:13 -08:00
durham
eda3fc2ab4 Improve mercurial 'arc land' perf by avoiding updates
Summary:
Mercurial 'arc land --hold' was taking 90+ seconds on our large
repository.  Since most of arc land doesn't require any particular working
directory, I've changed the mercurial logic to avoid all updates except for
two: the one prior to finding the revision (only applies if the user specified
--branch), and the one at the end to leave the user in a good state.

Also got rid of a 'hg outgoing' call when phases are supported. Also changed
the hg-subversion detection to just look for .hg/svn instead of running 'hg
svn info', which was taking 4 seconds.

Now arc land takes about 50 seconds. Still much worse than git's 25 seconds.
One big hot spot is in the two 'hg rebase' calls, which account for 25 seconds
(versus 11 seconds of git).

Test Plan:
Tested arc land with mercurial and git. Tested with and without the --branch
options.

Reviewers: epriestley, bos, sid0, dschleimer

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5014
2013-02-19 13:36:02 -08:00
vrana
688e159319 Fix visibility of future linter methods 2013-02-19 13:09:34 -08:00
vrana
81171ca39d Run PEP8 linter on background
Test Plan:
  $ arc lint pep8.py --cache 0 --engine ComprehensiveLintEngine --trace

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4967
2013-02-19 12:56:57 -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
1e612eebc3 Fix another SVN issue with "@" files
Summary: This chunk of code is kind of iffy and not really correct, but make it not fail, at least.

Test Plan:
  - Added a file named `swamp@2x.jpg` to a working copy.
  - Used `svn propedit svn:mime-type swamp@2x.jpg@` to incorrectly set its mime type to `text/plain`.
  - Ran `arc diff`.
  - Saw `arc diff` "correctly" change its mime-type to a binary mime type. This isn't really correct, but doing it successfully is better than throwing an exception.

Reviewers: mbishopim3, chad

Reviewed By: mbishopim3

CC: aran

Differential Revision: https://secure.phabricator.com/D4998
2013-02-18 08:24:47 -08:00
kwadwo
8692587921 Arc diff tries to upload files it knows about using a content hash rather than transfering data.
Summary:
Arc diff will hash file data and try to upload the file using upload by hash rather than transferring data. If it is unable, it defaults to its normal behavior

Attempts to upload file by hash, use regular upload method otherwise

Test Plan: Figure out how to arc diff to my local install and look at the behavior

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, mehrapulkit

Differential Revision: https://secure.phabricator.com/D4968
2013-02-17 14:30:43 -08:00
epriestley
aba9d49449 Fix "none" in SVN XML summary
Summary: The `svn diff --xml --summarize` command reports a bunch of item statuses, which may include "none" if you make property changes to a directory (this is fairly rare).

Test Plan: Created property changes, saw "none" status.

Reviewers: chad, mbishopim3

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D4978
2013-02-15 14:53:31 -08:00
epriestley
0f57b8d2de Fix various SVN escaping issues in arc patch
Summary: Followup to D4703. When we give paths to `svn`, we need to escape them if they contain an `@`.

Test Plan:
Created a patch full of modifications to files with `@` in their names, and applied it:

  $ arc patch --diff 192
  A         A@2xcopy2
  A         A@2xcopy
  D         A@2x
   OKAY  Successfully applied patch to the working copy.

Reviewers: chad, mbishopim3

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D4977
2013-02-15 14:53:25 -08:00
vrana
cd50b0884e Don't run disabled lint rules in other linters.
Summary: D4963 for other linters.

Test Plan: Saw time 0.001 instead of 0.113 in spellcheck linter.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4965
2013-02-14 15:54:10 -08:00
vrana
eb8b414cc7 Don't run disabled lint rules
Summary:
We always generate all messages and then filter them out based on minimum severity.
It's lots of useless work, especially in commit hook mode where we are interested only in errors.

Test Plan:
  $ arc lint --cache 0 --severity error ArcanistXHPASTLinter.php
  0.406 s before, 0.074 after

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4963
2013-02-14 15:31:10 -08:00
epriestley
39704f1e49 Fix "arc:this" and "arc:amended" base rules after D4838
Summary:
After D4383, we escape the base commit when constructing a command like this:

  hg log --rev (base::. - base)

However, if the base commit is a revset like ".^", we now escape it and Mercurial looks for a commit named ".^" (a valid mercurial branch name) instead.

Fix this by returning nodes for these rules instead of revsets. The "arc:this" rule is automatically used in some operations, like "arc amend", so users can hit this during normal workflows, not just with weird `--base` rules.

Test Plan: Ran "arc amend" in a Mercurial repository, didn't fatal out.

Reviewers: DurhamGoode, sid0

Reviewed By: DurhamGoode

CC: tido, aran

Differential Revision: https://secure.phabricator.com/D4949
2013-02-14 13:57:34 -08:00
Jakub Vrana
7803b7da27 Decide whether to commit or amend with arc diff -a
Test Plan:
  $ arc diff -a
  $ arc diff -a # saw amend instead of a new commit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4947
2013-02-14 11:56:53 -08:00
vrana
619dd62f31 Respect granularity in reading cached lint messages
Summary:
We save repository version to lint cache but ignore it when reading the cache.
Fix it.

Test Plan: Made an error for linter with repo granularity, deleted the error from the cache. Relinted, didn't see the error. Changed another file and relinted, saw the error.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4841
2013-02-14 11:45:38 -08:00
durham
0795edfe1a Fix hg 'arc land' when the mq extension is not enabled
Summary:
Mercurial 'arc land' uses the 'hg strip' command to clean up after
itself, but this command isn't available unless the mq extension is enabled.
The fix is to enable it for that particular command only.

Test Plan: Ran 'arc land' with the mq extension disabled.  It worked.

Reviewers: epriestley, bos, sid0, dschleimer

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4955
2013-02-14 11:37:49 -08:00
vrana
299b9c4c6b Support arc bookmark in Mercurial
Summary:
Branch in Mercurial means something else.
Hopefully users wouldn't be too confused.

Test Plan:
  $ arc help
  $ arc help branch
  $ arc help feature
  $ arc feature
  $ arc bookmark
  $ arc branch
  # In hg repo:
  $ arc feature
  $ arc feature new
  $ arc feature new

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2332

Differential Revision: https://secure.phabricator.com/D4753
2013-02-13 13:58:07 -08:00
vrana
980889f1ba Handle safe HTML in intraline renderer
Test Plan: Used it in Phabricator.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2432

Differential Revision: https://secure.phabricator.com/D4928
2013-02-13 12:30:27 -08:00
epriestley
42ae7cd92f Add lint warning for $o->m()[0], not just f()[0]
Summary: We only caught half of this.

Test Plan: Unit test.

Reviewers: edward

Reviewed By: edward

CC: aran

Maniphest Tasks: T1261

Differential Revision: https://secure.phabricator.com/D4920
2013-02-12 07:07:35 -08:00
vrana
2419718593 Merge PHT into dynamic string linter
Test Plan: Existing unit test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4914
2013-02-11 18:59:53 -08:00
epriestley
446e5c4599 Apply rtrim() to arc:upstream
Summary: Git spits these out with \n at the end.

Test Plan:
```
>>> orbital ~/devtools/arcanist $ git branch --set-upstream trim master
Branch trim set up to track local branch master.
>>> orbital ~/devtools/arcanist $ arc which --base arc:upstream
RELATIVE COMMIT
If you run 'arc diff', changes between the commit:

    acf7600e6e  Temporarily restore apache/license linters

...and the current working copy state will be sent to Differential, because
it is the merge-base of the upstream of the current branch and HEAD, and
matched the rule 'arc:upstream' in your args 'base' configuration.

You can see the exact changes that will be sent by running this command:

    $ git diff acf7600e6e728395..HEAD

These commits will be included in the diff:

    3580555e4b30598f  WIP

MATCHING REVISIONS
These Differential revisions match the changes in this working copy:

    (No revisions match.)

Since there are no revisions in Differential which match this working copy, a
new revision will be created if you run 'arc diff'.
```

Reviewers: brennantaylor

Reviewed By: brennantaylor

CC: aran

Differential Revision: https://secure.phabricator.com/D4913
2013-02-11 15:58:47 -08:00
epriestley
acf7600e6e Temporarily restore apache/license linters
Summary:
Restores linters only, without unit tests or entry in ComprehensiveLinter. Marks them deprecated.

If use at Facebook isn't widespread I'd prefer to simply delete them.

Test Plan: none

Reviewers: vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2274

Differential Revision: https://secure.phabricator.com/D4906
2013-02-11 14:12:10 -08:00
vrana
8f0b0d379f Support short version of arc diff --add-all
Summary: Like `git commit -a`.

Test Plan:
  $ arc diff -a

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4903
2013-02-11 10:53:57 -08:00
vrana
f32b6aa6c5 Support short version of arc diff --add-all
Summary: Like `git commit -a`.

Test Plan:
  $ arc diff -a

Reviewers: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4903
2013-02-11 10:48:40 -08:00
vrana
e1d906ea18 Allow configuring PhutilXHPAST linter
Summary: Also move Phabricator stuff outside.

Test Plan: Updated unit test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4894
2013-02-11 10:41:26 -08:00
Bryan Cuccioli
8b1215ffcf Delete license linters.
Summary: Remove all references to ArcanistLicenseLinter and ArcanistApacheLicenseLinter.

Test Plan: Rerun the linter and ensure nothing is broken.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4901
2013-02-11 09:04:19 -08:00
epriestley
84254f111a Minor, fix an exception variable.
Auditors: DurhamGoode
2013-02-11 04:54:20 -08:00
vrana
6a70964a40 Deprecate phutil_escape_html()
Summary:
My original idea was to return safe HTML from this function.
But we are down to 20 occurrences in Phabricator and you shouldn't need this function in safe HTML world at all.

Test Plan:
  $ arc lint src/applications/audit/controller/PhabricatorAuditListController.php

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4890
2013-02-09 15:18:19 -08:00
Nick Pellegrino
f10f2ffb9c Support arc diff --edit under hg
Summary: T1571

Test Plan: epriestley says it works

Reviewers: epriestley

Reviewed By: epriestley

CC: kwadwon, aran, Korvin

Differential Revision: https://secure.phabricator.com/D4883
2013-02-09 11:24:54 -08:00
epriestley
38d23516d1 Add lint warnings about use of phutil_render_tag and javelin_render_tag
Summary: Raise deprecation warnings for these methods. I won't commit this until the phutil_tag branch merges.

Test Plan: Unit tests.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2432

Differential Revision: https://secure.phabricator.com/D4770
2013-02-08 17:38:56 -08:00
vrana
ca37bfb2ab Display other locations of Reused lint errors
Summary: It's not trivial to find them inside 700+ lines long functions.

Test Plan:
Linted `reused-iterators.lint-test` renamed to `_.php`, saw other locations.
Repeated for `reused-local.lint-test`.
Repeated for `duplicate-key-in-array.lint-test`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4871
2013-02-08 15:49:50 -08:00
durham
4c35af9283 Make 'arc diff X' in mercurial match git by using the GCA of X as the base
Summary:
Previously 'arc diff X' with mercurial meant to use X as the base
to diff against.  Now it means use gca(X,working directory) as the base to
diff against.  This matches the git behavior.

Test Plan:
Ran 'arc diff master' on a repo where master was ahead of the feature branch.
Verified that the diff result included only the diffs in the feature branch.

Reviewers: epriestley, sid0, bos, dschleimer

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4865
2013-02-08 07:09:30 -08:00
durham
db053e1eb7 Improve performance of mercurial arc diff
Summary:
arc diff on large mercurial repos was taking 14 seconds just to get
to the commit message prompt.  With these optimizations it takes 4.

- "ancestor(.) - ancestor(XYZ)" is expensive because it has to build the
entire 400000+ revision history for both.  "XYZ::. - XYZ" is much cheaper
because it only looks at the revisions between XYZ and the working directory.

- "hg outgoing" has to talk to the server, which is slow.  "hg log -r draft()"
gives us the same information and is much cheaper.  We fall back to 'outgoing'
on older versions of mercurial.

Of the remaining 4 seconds, 2.5 are spent in 'hg status', which is a bit harder
improve.

Test Plan: Ran arc diff on our hg repo. Verified it ran faster and the diff was created.

Reviewers: epriestley, sid0, bos, dschleimer

Reviewed By: epriestley

CC: aran, Korvin, tido

Differential Revision: https://secure.phabricator.com/D4838
2013-02-08 05:54:32 -08:00
vrana
7f9c286338 Upload binary files diffs in parallel
Summary: Makes sense after D2471.

Test Plan:
Swapped two binary files, ran `arc diff --only`.
Saw time 3.797 s instead of 4.361 s.

Changed `file.upload` to `file.uploa`, saw proper error.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4847
2013-02-07 17:27:36 -08:00
vrana
46dfc64337 Restore kept branch after landing
Test Plan: Ran it separately.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4846
2013-02-07 17:27:34 -08:00
epriestley
2c2cb3b78a Improve error message for phutil missing symbols
Summary: This is fairly confusing. Make the error message suggest the common remedy (update libphutil).

Test Plan: Eyeballed it.

Reviewers: Afaque_Hussain, btrahan, vrana

Reviewed By: Afaque_Hussain

CC: aran

Differential Revision: https://secure.phabricator.com/D4834
2013-02-06 19:11:06 -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
epriestley
99feb5c28e Record commit email information from arc
Summary:
Record author email information in `arc diff`, so we can recreate it in `arc patch` and elsewhere without creating any kind of email exposure issues.

In Mercurial, we currently store the whole string ("username <email@domain.com>"). Make this consistent with Git.

Test Plan: Created git and hg diffs, saw authorEmail populated.

Reviewers: btrahan, edward, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4825
2013-02-05 20:11:20 -08:00
vrana
bd71ba675e Implement hook for checking switch lint
Summary:
We want to use it for `yield` and `invariant_violation()` which throws.
Having node instead of token would be better but this would be enough.

Test Plan: Implemented a hook in FB repo and added a test case there.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4821
2013-02-05 11:46:59 -08:00
epriestley
be73bd8716 Allow arc diff and similar to run on systems with no git
Summary:
We assume `git` is available now, but should not. Specifically, if a user runs a working copy operation like `arc list` in an SVN working copy without `git` available, they get this error: P707

We interpret git errors very narrowly; be more liberal in how we interpret them. This assumes users working with `git` will have a functional `git`, but this seems like a reasonable assumption and lets us remove some error text matching code.

Test Plan: Changed `git` to `girt`, ran `arc list`, saw a reasonable exception. Changed back to `git`, saw git detected.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: svemir, aran

Differential Revision: https://secure.phabricator.com/D4804
2013-02-04 11:34:53 -08:00
vrana
8e34e2bd03 Fix dynamic string usage as safe input
Test Plan: Copied the code in a script, changed `phutil_passthru()` to `echo csprintf()` and ran it.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4805
2013-02-04 11:34:32 -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
vrana
03199df925 Lint dynamic string usage in parameters treated as safe
Summary:
This disallows code like this:

  $cmd = 'ls';
  execx($cmd);

But I guess it's not that big deal?

Test Plan: Linted whole Arcanist and Phabricator codebases, most parts looks fixable.

Reviewers: epriestley

CC: nh, aran, Korvin

Differential Revision: https://secure.phabricator.com/D4794
2013-02-02 16:26:52 -08:00
vrana
39cef6cb99 Dispatch event after collecting changes in diff
Summary:
FB currently starts Sandcastle push before starting the diff workflow.
If `arc diff` commits something then we need to restart the push.
I want to avoid this by starting the push after commit.

Test Plan: Will test after implementing the listener.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4785
2013-02-02 12:45:19 -08:00
vrana
5d7c77da72 Add typehint to setting workflow configuration
Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4784
2013-02-01 11:56:56 -08:00
vrana
8374dbc4e3 Handle $var::method() in XHPAST linter
Test Plan: Didn't see a fatal in new test case.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4783
2013-02-01 11:21:06 -08:00
vrana
cdb01f23a7 Make British spelling stricter
Summary: This is pretty lame but I didn't have a better idea.

Test Plan:
  $ arc test # previously translated as list
  $ arc lst
  $ arc brnach

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4773
2013-01-31 17:14:08 -08:00
vrana
6cd3d8e995 Fix getting changed files in SVN
Summary:
This is pretty awkward but I don't have anything better.

Also don't compute cache key if caching is disabled.

Test Plan:
  $ svn diff --xml --summarize '' -r 701319:HEAD
  $ svn diff --xml --summarize svn+ssh://tubbs/svnroot/projects/lolbunny -r 701319:HEAD

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4771
2013-01-31 13:47:59 -08:00
vrana
6d521f3b3f Disable pull stat in arc land
Test Plan:
  $ git pull --no-stat

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4754
2013-01-31 11:54:38 -08:00
Nick Harper
dff1342efc Add --skip-arcconfig option
Summary:
Continuation of D4732 - when we don't care about loading an arcconfig,
allow that to be specified.

Test Plan: chmod -r .arcconfig; bin/arc help --skip-arcconfig

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4750
2013-01-30 16:26:41 -08:00
vrana
3f747be644 Move isConstantString() to base class
Summary: This can be useful by itself, we want to use it in FB linter.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4744
2013-01-30 12:56:59 -08:00
vrana
98e8d0c9c4 Split php-tags-bad.lint-test to two tests
Summary: D1818 effectivelly disabled this test case.

Test Plan: This diff.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4746
2013-01-30 12:46:30 -08:00
epriestley
3acbf9f3fa Expose --coverage and --no-coverage flags from arc diff
Summary: Currently, we don't expose these at top level, so you can't disable coverage if your coverage is explosively broken. Expose them as passthrough arguments.

Test Plan:

  - Touched a file in `arc` which triggered unit tests.
  - Without `xdebug` installed:
    - Ran `arc diff --preview`, `arc diff --preview --no-coverage` (both fine).
    - Ran `arc diff --preview --coverage`, got exception about coverage not being available.
  - Installed `xdebug`.
    - Ran `arc diff --preview`, got coverage.
    - Ran `arc diff --preview --coverage`, got coverage.
    - Ran `arc diff --preview --no-coverage`, no coverage.

Reviewers: indiefan, btrahan, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4745
2013-01-30 12:35:30 -08:00
vrana
9746d2b2a1 Use all changed files since base revision in repository cache key
Test Plan: Added debug output for repository version, linted, committed, linted again, saw the same version, changed file, saw different version.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4731
2013-01-30 11:25:16 -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
vrana
c45053da4c Reset master after unsuccessful push
Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4717
2013-01-29 12:12:31 -08:00
vrana
5aa3bc6ec0 Separate Phutil specific lint rules from XHPAST
Summary: Also provides an example how to build custom linter using XHPAST.

Test Plan: Added debug output to `willLintPaths()`, verified that each path is parsed only once.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4718
2013-01-29 10:54:40 -08:00
vrana
0586b12d2f Allow running arc land after git svn rebase
Summary: `git pull` may fail in git-svn after rebasing (which is a side effect of dcommit).

Test Plan:
  $ git svn rebase
  $ git log trunk..master
  $ git pull --ff-only; echo $?

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4716
2013-01-28 17:47:17 -08:00
epriestley
410b58a2e2 Correct a bunch of mercurial revset construction
Summary: Possibly improves T2387 state of the world?

Test Plan: not yet

Reviewers: bos, DurhamGoode

Reviewed By: DurhamGoode

CC: aran

Maniphest Tasks: T2387

Differential Revision: https://secure.phabricator.com/D4712
2013-01-28 16:28:14 -08:00
epriestley
2613ea196f Provide hgsprintf() for building hg revsets
Summary: I guess this is correct? See T2387 for discussion.

Test Plan: Unit tests.

Reviewers: bos, DurhamGoode

Reviewed By: DurhamGoode

CC: aran

Maniphest Tasks: T2387

Differential Revision: https://secure.phabricator.com/D4711
2013-01-28 16:27:47 -08:00
vrana
fd909479d0 Ignore untracked files in lint repository cache key
Summary: Some people have 2GB+ untracked files in repo which significantly slows down this or even crashes it.

Test Plan: Added a debug output here and linted repo with untracked path.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, arudolph

Differential Revision: https://secure.phabricator.com/D4713
2013-01-28 15:40:47 -08:00
vrana
edd585a3d7 lint_untracked 2013-01-28 15:15:18 -08:00
epriestley
53691cdcf9 Fix an escaping issue with "svn commit"
Summary: Fixes T2438. We currently escape everything with '@', but SVN rejects that for '.'

Test Plan:
Unit tests. Performed this commit:

  $ svn st
   M      .
  A       x@123
  $ arc commit --conduit-uri=http://local.aphront.com:8080/ --revision 53

      Revision 'D53: asdf' has not been accepted. Commit this revision anyway?
      [y/N] y

  Committing 'D53: asdf'...
  Sending        .
  Adding         x@123
  Transmitting file data .
  Committed revision 37.
  Done.

I grepped for more '@' adding but couldn't find any. It's a bit tricky to grep for though, so it's possible I missed some.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran, mbishopim3

Maniphest Tasks: T2438

Differential Revision: https://secure.phabricator.com/D4703
2013-01-28 14:11:31 -08:00
indiefan
ce0a491bcd Added base test result parser class. Implemented Go test result parser based on Go's built in test utility output.
Test Plan: Ran PhpunitTestEngine unit test and used both test result parsers to generate test results.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D4676
2013-01-27 17:17:09 -08:00
Jesse Mullan
c49997a6e8 Added paths to search for python linters
Summary: Added paths to search for python linters

Test Plan: Linted in ubuntu

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2414

Differential Revision: https://secure.phabricator.com/D4648
2013-01-26 05:32:26 -08:00
Aurelijus
df04c79a90 Support PHPUnit 3.7 message changes
Summary: PHPUnit 3.7 now includes user message as well.

Test Plan: Ran phpunit tests

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4662
2013-01-25 17:19:41 -08:00
epriestley
44e25495ca Raise a lint warning on array_combine(x, x)
Summary: Suggest array_fuse().

Test Plan:
Unit tests, and:

  $ arc lint --lintall src/unit/engine/phutil/ArcanistPhutilTestCase.php
  >>> Lint for src/unit/engine/phutil/ArcanistPhutilTestCase.php:

     Warning  (XHP37) array_combine() Unreliable
      Prior to PHP 5.4, array_combine() fails when given empty arrays. Prefer
      to write array_combine(x, x) as array_fuse(x).

               252     $callable,
               253     $exception_class = 'Exception') {
               254     return $this->tryTestCases(
      >>>      255       array_combine(array_keys($map), array_keys($map)),
               256       array_values($map),
               257       $callable,
               258       $exception_class);

Reviewers: btrahan, vrana, chad

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4659
2013-01-25 17:06:49 -08:00
indiefan
9946e23f9e Decoupling phpunit test parsing from running and gathering. Should enable third party test engines to reuse common business logic around phpunit without requiring common logic for the typically application-specific running and gathering.
Test Plan: Ran PhpunitTestEngine unit test. Also used refactored PhpunitTestEngine to run phpunit tests.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D4651
2013-01-25 17:06:38 -08:00
durham
c8efb41811 Fix hg arc land on hg-svn repos
Summary:
arc land on a hg-svn repository would fail because arc land
uses 'hg push -r' to specify which revs to push which is not supported
by hg-svn. Now we just use 'hg push' which, when used against svn, only
pushes the current branch (which happens to be the branch we're trying to land).

We can't use standard 'hg push' for non-svn repos though because when used
against a vanilla hg repo 'hg push' pushes all branches.

Also remove --new-branch from 'hg push' because it's extremely
unlikely that a person wants to create a new branch on the server via
arc land.

Test Plan:
Ran arc land on a normal hg repo, verified it used 'hg push -r'.
Ran arc land on a hg-svn repo, verified it used 'hg push' and it pushed the
correct changes.

Reviewers: epriestley, sid0, dschleimer

Reviewed By: epriestley

CC: bos, aran, Korvin

Maniphest Tasks: T2403

Differential Revision: https://secure.phabricator.com/D4653
2013-01-25 14:00:52 -08:00
vrana
93ebde0d12 Revert "Delete useless code in ArcanistBaseWorkflow"
This reverts commit rARC501e2b7.
We call this method from FB workflow.
I'll commit it again in two weeks.
2013-01-24 16:33:32 -08:00
vrana
a1b902b190 Cache results of repository linters
Summary:
The cache key is repository base revision and hash of all modified files.
It isn't perfect in SVN where every file might have a different revision.
It's also suboptimal as just committing or amending changes the cache key even if the files contents weren't modified.
We can improve it later, perhaps by using previous revision and files modified since it.

Test Plan:
Changed granularity of XHPAST linter to repository.
Linted the same repo twice, verified that it was read from cache the second file.
Changed a single file, verified that all files were re-linted.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4608
2013-01-24 16:15:55 -08:00
vrana
e56f47aed5 Don't bail on no effect exception
Summary: The main reason for this is to not exit with 1 when no paths are lintable (which is more success than failure).

Test Plan:
Returned empty array from `buildLinters()`, then:

  $ arc lint
  $ echo $? # 0

Reviewers: epriestley

Reviewed By: epriestley

CC: wez, aran, Korvin

Differential Revision: https://secure.phabricator.com/D4625
2013-01-24 16:07:50 -08:00
epriestley
aec212069e Fix arc diff --no-ansi
Summary: Currently, we get an exception on empty %Ls for `arc diff --no-ansi` or similar (see P698).

Test Plan: Ran `arc diff --no-ansi`.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4624
2013-01-24 14:28:28 -08:00
vrana
d3a6e456a6 Mark deleted paths as removed in committing
Test Plan: Deleted file in Git, ran `arc diff`, confirmed the question, saw the file as deleted.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4603
2013-01-23 14:42:49 -08:00
vrana
501e2b7e1d Delete useless code in ArcanistBaseWorkflow
Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4601
2013-01-23 13:22:33 -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
7f93b7de02 Don't use xhpast binary to compute xhpastlinter cache version if the binary doesn't exist
Summary: The binary may not be built, in which case this raises a warning.

Test Plan: Will make @zeeg test.

Reviewers: zeeg, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4569
2013-01-22 17:16:37 -08:00
durham
880964af83 Allow hg arc land when no rebase is necessary
Summary:
Previously, trying to arc land in a mercurial repo would
fail if the local branch was already at the tip of the onto branch
(since hg rebase exited with code 1).  This change makes it check
if a rebase is needed before executing the rebase.

Test Plan:
hg init foo
cd foo
hg bookmark master
touch a && hg add a && hg commit -ma
// setup your .arcconfig
cd ..
hg clone foo foo2
cd foo2
hg bookmark mybook
touch b && hg add b && hg commit -mb
arc land --onto master --revision <your rev number>

Arc land should succeed.  I also tried landing when a rebase was
necessary and it still worked.

Reviewers: epriestley, dschleimer, bos

Reviewed By: epriestley

CC: sid0, aran, Korvin

Differential Revision: https://secure.phabricator.com/D4588
2013-01-22 15:20:10 -08:00
vrana
98fec27752 Fix PHT linter
Summary: Variables in strings and concatenation lists.

Test Plan:
New unit tests.

  preg_match('/^((?>[^$\\\\]*)|\\\\.)*$/s', str_repeat('a', 1e6));

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4540
2013-01-19 11:48:17 -08:00
vrana
78017033bd Warn against usage of nowdoc
Summary: Also include binary hash in the version.

Test Plan: New unit test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4535
2013-01-19 09:23:17 -08:00
vrana
85c0ed13d9 Set used variable 2013-01-18 13:32:48 -08:00
Nick Harper
40102252bf Fix arc diff when run from a git submodule
Summary:
A git submodule looks a lot like a normal git repo, but the .git
directory is replaced with a file that git reads to find the real
location of the git directory. When arcanist tries to write a file into
a directory inside of there, it was failing silently, and then crashing
silently when it couldn't read results back out. Instead of assuming the
git directory is a directory named .git at the toplevel of the tree, we
use the appropriate git command to get the correct git directory.

Test Plan: submit a diff from a submodule

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4482
2013-01-17 11:28:13 -08:00
epriestley
a39b591c95 Allow pht(<<<HEREDOC ... HEREDOC)
Summary: Don't raise lint on heredoc literals.

Test Plan: Linted pht() + heredoc in D4477.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4478
2013-01-16 14:57:10 -08:00
vrana
90129c5432 Include real PEP8 version and options in lint cache key
Summary: This should be done for all external and configurable linters.

Test Plan: Linted file with lint problems, changed options, relinted.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4475
2013-01-16 12:17:11 -08:00
vrana
8142aab9d3 Fix whitespace around else 2013-01-16 12:15:46 -08:00
vrana
f25c01606b Cache stopped paths in lint
Summary:
If linter with file cache granularity stops linting then we don't run it on the same path next time.
But we still run linters with non-file cache granularity causing that they run even on the paths that would be stopped otherwise.

Test Plan:
Put global granularity linter after Generated linter.
Caused an error from this linter but in ignored path.
Verified that 'stopped' is saved in `lint-cache.json`.
Linted the same files second time, verified that the path is still skipped (wasn't before).

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4446
2013-01-15 17:58:32 -08:00
vrana
d4359a838a Use assert_instances_of(, 'array')
Summary: To have at least one real callsite.

Test Plan:
  $message = new ArcanistLintMessage();
  $message->setOtherLocations(array());
  $message->setOtherLocations(array(array()));
  $message->setOtherLocations(array(1));

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4419
2013-01-14 11:36:29 -08:00
vrana
e8decd2062 Display other locations of lint errors in console renderer
Test Plan: Created function named `f_a`, manually set other location.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4412
2013-01-11 15:25:58 -08:00
vrana
ff73a90482 Add hook after running linters
Summary: This resolves D4380#7 by reverting https://secure.phabricator.com/D4380?vs=9112&id=9123.

Test Plan: Used it in our linters.

Reviewers: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4409
2013-01-11 14:15:04 -08:00
vrana
5c5d347544 Format whitespace in XHPAST linter
Test Plan: Linted a method named `f_a`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4405
2013-01-11 13:23:21 -08:00
vrana
a82493a84d Allow specifying multiple locations of the same lint error
Summary:
Some errors (duplicate declaration, invalid number of arguments) have more related places.
We need to notify user if he changes any related place.
This could be currently achieved by triggering errors instead of warnings or by including both files in the range (impossible if the locations are in different files) or by issuing multiple errors.
All options are too aggressive.

Test Plan: Issued error on unmodified line with other location on modified line.

Reviewers: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4392
2013-01-10 15:35:11 -08:00
vrana
80cd881fb1 Fix checking for lint binary paths
Summary: Like D4379.

Test Plan:
  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4391
2013-01-10 15:34:42 -08:00
Gregor Stocks
767f9457c1 Add some new misspellings of "hierarchy"
Summary: turns out people really like misspelling "hierarchy"

Test Plan: hope
2013-01-10 14:32:23 -08:00
vrana
35de4a5d1f Run all willLintPaths() before any lintPath()
Summary:
FB runs some linters on background and it's a magnificent hack using `ParallelLinter` (two instances), `BackgroundLinter` and `FutureLinter`.
I want to simplify this by resolving the futures in engine instead of in some virtual linter.
It also seems like a better place to do it.
It should also fix caching problems I have with them (because the virtual linters don't know about the cache at all).

Test Plan: None yet.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4380
2013-01-09 17:15:31 -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
vrana
983537e620 Fix checking for flake8 path
Test Plan:
  $ arc unit # without flake8 in path

Reviewers: zeeg

Reviewed By: zeeg

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D4379
2013-01-09 13:41:10 -08:00
epriestley
d399354822 Normalize Windows directory separators in SVN
Summary: Fixes T1946.

Test Plan: Ran `arc diff --only` with added paths inside directories. Saw only "/" entries in the diff.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran, mbishopim3

Maniphest Tasks: T1946

Differential Revision: https://secure.phabricator.com/D4374
2013-01-09 12:34:37 -08:00
epriestley
57ec5a026d Fix arc diff x y in SVN
Summary:
D4186 added an "svn status --xml x y" form to getSVNStatus(), but the parser doesn't work for multiple files, since we get multiple <target /> elements in the XML output. So, curently, `arc diff` works (one target, all files) and `arc diff x` works (one target, x) but `arc diff x y` does not (more than one target, hits the exception).

  $ arc diff QUACK2 QUACK3
  Exception
  Expected exactly one XML status target.

Test Plan: Ran `arc diff QUACK2 QUACK3` in a working copy with modified QUACK2, QUACK3. Ran `arc diff`; `arc diff QUACK2`.

Reviewers: vrana, btrahan, codeblock, JThramer

Reviewed By: codeblock

CC: aran

Differential Revision: https://secure.phabricator.com/D4372
2013-01-09 09:11:26 -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
Ricky Elrod
a5ddd7ebc0 Add a comma.
Summary: Add a comma because it was going to annoy the crap out of me.

Test Plan: See the comma. :)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4365
2013-01-08 15:51:36 -08:00
Roy Williams
7547ef7e96 Pass the constructed message to the TYPE_DIFF_DIDBUILDMESSAGE event.
Summary: We want to use TYPE_DIFF_DIDBUILDMESSAGE to abort arc diff when a message doesn't fit some

Test Plan: Created an EventListener subscribed to TYPE_DIFF_DIDBUILDMESSAGE, validated the 'message' field was filled in

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D4361
2013-01-08 15:06:46 -08:00
Jack Lindamood
48f5ecb05c Fix cppcheck path finding
Summary: This fix lets you run arc lint from any directory in the repository

Test Plan: Ran arc lint from any directory

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4356
2013-01-07 12:47:00 -08:00
epriestley
72b2b7b22c Limit arc branch to 16 concurrent processes
Summary:
Currently, this spawns 125 concurrent processes on my machine, which overflows some limit and gives me an error:

  PHP Warning:  proc_open(): unable to create pipe Too many open files in /INSECURE/devtools/libphutil/src/future/exec/ExecFuture.php on line 491

Instead, limit parallelism to 16. The runtime is approximately the same for me, and dominated by other concerns (conduit calls).

Test Plan: Ran `arc branch` successfully. Ran `arc branch --trace`, observed behavior.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4336
2013-01-07 08:44:55 -08:00
Jack Lindamood
cf8d445c9f CppCheck linter
Summary:
Lints cpp code using the cppcheck static linter.  This linter needs to
be downloaded and built from http://cppcheck.sourceforge.net/

Test Plan: Used it on a few files.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4353
2013-01-07 08:18:33 -08:00
Jack Lindamood
854c1b67b1 Add cpplint.py engine
Summary: Adds arc lint support for cpp files with Google's cpplint.py lint checking.

Test Plan: ran it on some cpp files. Added unit tests

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4344
2013-01-07 08:16:34 -08:00
Bob Trahan
0c8fa90040 make arc install-certificate <uri> work if uri is specified
Summary: see title

Test Plan: ran arc install-certificate <uri> in a directory without an .arcconfig and it worked! ran arc install-certificate in a directory with an .arcconfig and it worked! ran arc install-certificate <uri> in a directory with an .arcconfig and noted it correctly overrode the .arcconfig

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2251

Differential Revision: https://secure.phabricator.com/D4332
2013-01-03 09:23:20 -08:00
epriestley
59e13f666f Correct spelling for "arc" commands
Summary:
I type "arc brnach" about 300 times per day.

  - Allow arc commands to be specified by unique prefix ("exp" for "export", "lib" for "liberate").
  - Allow arc commands to be specified by unique levenshtein edit distance <= 2 ("brnach" for "branch", "halp" for "help", "ptach" for "patch").
  - Reorganize code out of "arcanist.php".

I think this will be uncontentious because arc commands are rarely destructive, but if people complain we can either require certain commands be typed exactly (maybe "land"?) or allow this feature to be disabled in configuration.

Test Plan:
  $ arc br
  Usage Exception: Unknown command 'br'. Try 'arc help'.

  Did you mean:
      branch
      browse

  $ arc brnachh
  Usage Exception: Unknown command 'brnachh'. Try 'arc help'.
  $ arc brnach
  (Assuming 'brnach' is the British spelling of 'branch'.)
     doc-security        No Revision      security
     sms                 Needs Revision   D319: Add SMS support to Phabricator
     phxtag              No Revision      derp
     arantag             No Revision      derp
  ...

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4305
2012-12-30 16:01:59 -08:00
David Cramer
0b833c2f02 Correct description and severity on Flake8 linter
Test Plan: do it live

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4274
2012-12-21 16:13:33 -08:00
David Cramer
4ca70d4e48 Add a flake8 linter
Summary: flake8 is the better maintained combination of pep8 and pyflakes

Test Plan: There's a test!

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, jack

Differential Revision: https://secure.phabricator.com/D4082
2012-12-21 15:28:26 -08:00
epriestley
cffe1942ec Improve arc land recovery from issues with the remote.
Summary:
Fixes T2138.

  - When a pull fails, restore the original branch.
  - When a push fails, complain about it really loudly.

NOTE: No test plan for push yet since I'm not sure this is the right remedy, see T2138 for discsusion.

Test Plan:
  - Tested pull by changing "git pull" to "git xxpull" and running "arc land". Saw the pull fail and my original branch restored.

Reviewers: vrana, aran

Reviewed By: vrana

Maniphest Tasks: T2138

Differential Revision: https://secure.phabricator.com/D4265
2012-12-21 14:18:07 -08:00
vrana
f830b3bf3f Don't require clean working copy for arc diff path in SVN
Summary: If you are explicit then there is no need to ask you.

Test Plan:
  $ touch a
  $ arc diff
  $ arc diff a
  $ arc diff existing

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4186
2012-12-21 12:34:06 -08:00
vrana
c7c3f6a7f1 Update PEP8 to 1.3.4
Summary: Primarily to avoid false positives: http://pypi.python.org/pypi/pep8#id1

Test Plan:
  $ arc lint --engine ComprehensiveLintEngine externals/pep8/pep8.py # after uncommenting externals/ check

Saw 9 errors, haha.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4260
2012-12-21 11:34:40 -08:00
vrana
940d91d7b5 Speed up SVN discovery
Summary: `svn info` takes up to 10 seconds.

Test Plan: `arc diff` inside SVN repo and outside any repo.

Reviewers: nh, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4256
2012-12-20 18:10:37 -08:00
vrana
3f05751724 Don't amend commit with the same message in arc diff
Summary: It makes reflog ugly

Test Plan:
# `arc diff`, made error, saw "Message saved to".
# `arc diff`, didn't edit, didn't see "Message saved to".
# `arc diff`, edited, saw "Message saved to".

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4243
2012-12-20 12:18:05 -08:00
vrana
2d63d080df Make caching lint default
Summary: I use it couple of weeks without troubles.

Test Plan:
Added debug output and:

  $ arc lint
  $ arc lint --cache 0

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2036

Differential Revision: https://secure.phabricator.com/D4242
2012-12-20 12:16:19 -08:00
epriestley
ffdf44e298 Fix arc diff in SVN with paths
Summary:
Recently, in D4097 or one of the precursors I refactored this. However, when $rev is null parseBaseCommitArgument() throws ("This VCS does not support commit ranges."). Shield the call so it only happens if if $rev is nonempty (we still want to make the call, so "arc lint --rev x" on SVN will throw and inform the user that "--rev" is incorrect usage).

(@vrana, this was reported by FB and might be worth pushing.)

Test Plan: Ran "arc diff --preview <path>". Grepped for other parseBaseCommitArgument() callsites and verified they don't have similar issues.

Reviewers: vrana, btrahan, chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D4241
2012-12-20 11:12:30 -08:00
vrana
219dbe2374 Refuse writing to undeclared properties in workflows
Summary: I don't know how to not be strict here plus we (Arcanist developers) don't have access to user's error log.

Test Plan:
Undeclared `ArcanistDiffWorkflow::$console`, then:

  $ arc diff

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3607
2012-12-18 16:15:32 -08:00
vrana
2871d00f96 Allow checking out branches in arc branch
Summary:
The main added value is loading the branch name from revision.
Sometimes I know the revision ID but I don't know the branch name.

The missing piece is the starting point of the branch.
I was thinking about using `arc.land.onto.default` but we also need to get 'origin'.

This is also the last step of a simple workflow where underlying VCS is not abstracted away.
In future, we can implement this for other APIs.

Test Plan:
  $ arc branch new_branch
  $ arc branch new_branch
  $ arc branch D4168

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4170
2012-12-18 16:13:22 -08:00
bonneval
551d036a89 Bugfixed undefined variable $commit. 2012-12-18 14:31:48 +01:00
Brennan Taylor
b5b1fd62dc Support http basic auth and related configuration
This adds the http basic auth username and password if found in the
configuration to the ConduitClient.

Reviewed by: epriestley
2012-12-17 18:06:54 -08:00
epriestley
6823706c76 Stop passsing bogus 'user' parameter to differential.createrevision
Summary: After D4191 this is a fatal.

Test Plan: Created this revision.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4219
2012-12-17 14:41:27 -08:00
epriestley
716ce2482c Implement --everything, --json and --ugly flags for arc unit
Summary: Adds "arc unit --everything", which runs every available test, provided the test engine supports it. Also add JSON output.

Test Plan: Ran `arc unit --everything` in arcanist/, libphutil/ and phabricator/. Saw all tests run.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2065

Differential Revision: https://secure.phabricator.com/D4214
2012-12-17 12:56:41 -08:00
epriestley
0bf5c3603c Refactor commit ranges and base commit handling
Summary:
See D4049, D4096.

  - Move commit range storage from Mercurial and Git APIs to the base API.
  - Move caching up to the base level.
    - Store symbolic name and resolved name separately, so we can re-resolve the correct commit from the symbolic name after dirtying caches.
  - Rename `supportsRelativeLocalCommit()` to `supportsCommitRanges()` (old name wasn't very good, and not consistent with new terminology like the `--base` flag).
  - Rename `getRelativeCommit()` and `setRelativeCommit()` to `getBaseCommit()` and `setBaseCommit()`.
  - Introduce `reloadCommitRange()` and call it from `reloadWorkingCopy()`.

I think this fixes the problem in D4049, and provides a general solution for the class of problems we're running into here, with D4096. Specifically:

  - We no longer get dirty caches, as long as you call reloadWorkingCopy() after changing the working copy (or call a method which calls it for you).
  - We no longer get order-of-parsing-things problems, because setBaseCommit() reloads the appropriate caches.
  - We no longer get nasty effects from calling `requireCleanWorkingCopy()` too early.

Test Plan: This is pretty far-reaching and hard to test. Unit tests; ran various arc commands. :/

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4097
2012-12-17 12:54:08 -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
epriestley
0e27dbfd17 Refactor getWorkingCopyStatus() into getUncommittedStatus() and getCommitRangeStatus()
Summary:
See discussion in D4049.

The getWorkingCopyStatus() method gets called from requireCleanWorkingCopy() in a lot of places, which triggers resolution of the base of the commit range. This is unnecessary; we do not need to examine the base commit in order to determine whether the working copy is dirty or not. This causes problems, in D4049 and elsewhere (we currently have a lot of fluff calls to setDefaultBaseCommit() in workflows which need to call requireCleanWorkingCopy() but do not ever use commit ranges, such as `arc patch`). This is mostly an artifact of SVN, where the "commit range" and "uncommitted stuff in the working copy" are always the same.

  - Split the method into two status methods: getUncommittedStatus() (uncommitted stuff in the working copy, required by requireCleanWorkingCopy()) and getCommitRangeStatus() (committed stuff in the commit range).
  - Lift caching out of the implementations into the base class.
  - Dirty the cache after we commit.

This doesn't do anything useful on its own and creates one caching problem (`commitRangeStatusCache` is not invalidated when the commit range changes because of `setBaseCommit()` or similar) but I wanted to break things apart here. I won't land it until there's a more complete picture.

This creates a minor performance regression in git and hg (we run less stuff in parallel than previously) but all the commands should be disk-bound anyway and the regression should be minor. It prevents a larger regression in `hg` in D4049, and lets us do less work to arrive at common error states (dirty working copy). We can examine perf at the end of this change sequence.

Test Plan: Ran unit tests, various `arc` commands.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4095
2012-12-17 12:53:28 -08:00
vrana
5f5392df8a Suggest upgrading Phabricator for unknown Conduit methods or parameters
Summary:
This allows using new methods without the need for bumping version number.

The usage is not neccessary because we already bumped the version number for this but I wanted to have a callsite.

Test Plan:
Made a typo in method name, then:

  $ arc lint --only-new 1

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4193
2012-12-14 18:16:01 -08:00
vrana
7133c76d37 Update PEP8
Test Plan:
Linted this Python file:

  def get_mapper_sets(
          compression=4.0,  # Currently works for most tables
          **kwargs):
      pass

Didn't see:

> E225 missing whitespace around operator

Reviewers: andrewjcg, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4172
2012-12-14 17:50:18 -08:00
durham
f476d1a0c5 add arc land hg support for landing with nested branches
Summary:
This changes arc land's hg support to allow you to land a branch or bookmark that has nested branches/bookmarks.  Example:

      // Initial state:
      // -a--------b  master
      //   \
      //    w--x  mybranch
      //        \--y  subbranch1
      //         \--z  subbranch2
      //
      // arc land --branch mybranch --onto master :
      // -a--b--wx  master
      //          \--y  subbranch1
      //           \--z  subbranch2

Test Plan:
Created several repos like in the summary and ran 'arc land' and 'arc land --keep-branch'. Did this with both bookmarks and named branches. Scenarios tested:

- mybranch having no child commits
- mybranch having a child branch with several commits
- mybranch having two child branches
- mybranch having a child branch which has two more child branches

No code was added outside of a "if ($this->isHg)" so I didn't run git arc land.

Reviewers: epriestley, dschleimer, bos, sid0

Reviewed By: dschleimer

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4089
2012-12-14 11:23:44 -08:00
epriestley
2d7224f0e3 Add an experimental "--mergeup" flag to use a less volatile merge strategy in "arc land"
Summary:
See chatlog from https://secure.phabricator.com/chatlog/channel/%23phabricator/?at=37257

Basically, the install's developers sometimes use "git merge master" instead of "git rebase master" to pull changes from master into their branch. When we run "git rebase master" at the end, this creates a lot of conflicts.

Instead, optionally run "git merge master". This should be equivalent in our case (where we always rebase) and much better in their case (where they sometimes merge).

We're both going to use it for a bit and see if it creates problems. If it improves the "sometimes-merge" workflow without affecting the "always rebase" workflow, we can make it a default. If it improves theirs but damages ours, we can keep it a flag/option. If it's just terrible, we can figure out something else.

Test Plan:
Ran `arc land --mergeup --trace <feature> --keep-branch --hold`, see P624 for output. Observed merge update strategy and general success.

Also verified the conflict:

  $ arc land --mergeup --merge
  Usage Exception: Arguments '--mergeup' and '--merge' are mutually exclusive: The --merge strategy does not update the feature branch.

Reviewers: btrahan, vrana, DurhamGoode

Reviewed By: btrahan

CC: aran, keir

Differential Revision: https://secure.phabricator.com/D4080
2012-12-13 14:11:52 -08:00
vrana
02694d73ab Simplify code by not passing local data to methods 2012-12-12 14:21:06 -08:00
vrana
48077c80f2 Use repository info from arcanist.projectinfo if available
Test Plan: Added a debug output there and ran.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4147
2012-12-10 15:18:52 -08:00
vrana
c68a048213 Support git svn dcommit in arc land
Test Plan:
  $ arc land # in Git SVN repository

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4123
2012-12-10 12:28:44 -08:00
Aviv Eyal
7b2ce3a987 Add arc browse workflow
Summary:
arc browse will open a browser to the Diffusion view of a file. Convenient if you like
Diffusion for reading source. Naturally, it fixes relative filenames.

Combined with git-grep it can be an easy replacement for server-side search functions.

Test Plan:
use feature with and without 'browser' configured.

I've only tested this on Linux, because that's all I have right now, but the principle is sound.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4127
2012-12-09 14:10:21 -08:00
vrana
65e3583235 Reuse code in close-revision workflow
Test Plan: Will test it by closing this revision.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4122
2012-12-07 18:22:23 -08:00
epriestley
c43d627cf2 Remove ArcanistSubversionAPI::hasMergeConflicts()
Summary: No callsites, redundant with getMergeConflicts().

Test Plan: Grepped for callsites.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4093
2012-12-06 12:20:02 -08:00
Edward Speyer
ecdb885236 Quote author parameter
Summary:
Fixes the exception:

  Exception
  Command 'git commit -a --author=Whatever Long Name <whatever@email.com> -F -' failed with error #1

Test Plan: Tested with full git name

Reviewers: epriestley, aurelijus

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3979
2012-12-05 15:45:54 -08:00
Xingyao Ye
6c3418a0e8 Introduce "arc diff --plan-changes"
Summary:
Allow authors to publish a new or updated revision to Phabricator
without requesting code reviews. The revision will have status
"Needs Revision" instead of "Needs Review".

In order to avoid a change of Conduit API, this is done by adding
a comment with the "plan changes" action immediately after the
revision is published.

Test Plan:
Using my local repository, run "./bin/arc diff --plan-changes"
Check the resulting diff in Phabricator.

Reviewers: vrana

Reviewed By: vrana

CC: aran, epriestley

Maniphest Tasks: T2024

Differential Revision: https://secure.phabricator.com/D4084
2012-12-05 14:04:11 -08:00
epriestley
ba1a17ac31 Fix a fatal for git uncommitted changes in new arc projects
Summary:
If you run `arc diff` in a repository which:

  - has uncommitted or untracked changes; and
  - has a .arcconfig with a never-before-seen project ID;
  - we fatal: http://pastebin.com/raw.php?i=ykpfr4MT

This patch is a bit iffy, open to alternatives. The "right" patch is probably an `arcanistproject.query` which behaves more sensibly.

I return array() directly since we'll later create the project.

Test Plan: Ran `arc diff` in a repository with untracked files or uncommitted changes and a new project ID.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4057
2012-12-05 09:20:15 -08:00
vrana
209ffba8c0 Bump Conduit client version number
Summary: Should have been part of D3934.

Test Plan:
  $ arc diff

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4076
2012-12-03 18:09:45 -08:00
durham
aada1440ef Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed.  For the most part all the arc land options work, but there are a few caveats:

- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default

Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches.  Also tested --hold, --revision, --onto, --remote.

See https://secure.phabricator.com/P619

Also tested git arc land with --merge and --keep-branch.

Reviewers: dschleimer, sid0, epriestley, bos

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4068
2012-12-03 17:59:12 -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
886c1721dd Restore order of operations after D4056
Summary:
See discussion in D4056. In `findRevision()` we call `loadWorkingCopyDifferentialRevisions()`. However, this method depends upon the state of the working copy, because the end of the commit range it examines is HEAD. Prior to D4056 we checked out the target branch before calling `findRevision()`; after D4056 we call it earlier.

This isn't problematic in the `arc land` case, but in the `arc land <branch>` case it means we may fail to identify a revision, or identify the wrong revision, because HEAD isn't where we expect it to be.

Instead, unconditionally check out the target branch before finding the revision.

See <http://dl.dropbox.com/u/116385/Slingshot/Pictures/Screen%20Shot%202012-12-03%20at%203.43.45%20PM.png> for a transcript of the issue.

Test Plan: Reproduced issue as per link above. Ran `arc land --keep-branch --hold somebranch` successfully after this patch.

Reviewers: DurhamGoode, zeeg

Reviewed By: DurhamGoode

CC: aran

Differential Revision: https://secure.phabricator.com/D4072
2012-12-03 16:31:45 -08:00
vrana
e8eacb6ae3 Allow setting lint cache granularity
Summary:
We can add `GRANULARITY_DIRECTORY` and `GRANULARITY_REPOSITORY` later.
Repository granularity may use current commit + changes.
Directory would need to use hashes of all files in dir which would be quite expensive.

Test Plan:
  $ echo '<?php class A extends B {}' > A.php
  $ arc lint --cache 1
  $ arc lint --cache 1
  $ echo '<?php class B {}' > B.php
  $ arc lint --cache 1
  $ arc lint --cache 1
  $ rm B.php
  $ arc lint --cache 1
  $ arc lint --cache 1

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4021
2012-12-03 15:30:06 -08:00
David Cramer
0d1d04e434 canRun should return false on scala linter instead of raising an exception
Summary:
This was causing the following error in environments that didnt have scala configured:

Some linters failed:
   - ArcanistScalaSBTLinter: ArcanistUsageException: This directory does not appear to be maintained by SBT, as we can't seem to find a working build file (project/Build.scala or build.sbt).

Test Plan: .

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4070
2012-12-03 15:25:28 -08:00
durham
3602d2aa15 Break arc land run() into smaller functions
Summary:
Refactor the arc land code into several
functions so it's easier to maintain. This is in
preparation for adding hg support to arc land
in my next commit.

Without this refactor, adding hg support makes the run()
function too big.

Test Plan:
Set up a git repo and clone with a branch scenario.
Example: https://secure.phabricator.com/P614
Ran and verified:
arc land
arc land --keep-branch
arc land --merge
arc land --merge --keep-branch
arc land --hold
arc land --revision <another phabricator rev>

Reviewers: epriestley

Reviewed By: epriestley

CC: dschleimer, sid0, aran, Korvin

Differential Revision: https://secure.phabricator.com/D4056
2012-12-03 13:03:13 -08:00
Ricky Elrod
b549f565c9 Add a very basic Scala (SBT) linter.
Summary:
SBT is the most common Scala buildsystem. This adds an extremely basic and
slightly horrible linter to check SBT's output for warnings and errors.

Test Plan:
Tested this with a Scala project I've been working on for some time.
It seemed relatively sane.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4064
2012-12-03 10:04:18 -08:00
vrana
6cb8d483b2 Improve getting Git author
Summary:
It has one more than source, see http://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html#_commit_information.
Also 'user.name' may not be set at all.
Also `git config` returns non-zero for non-existing value.

Test Plan:
  var_dump($api->getAuthor());

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4053
2012-11-30 11:09:31 -08:00
vrana
9917c1f06a Provide a method for getting Git SVN revision
Summary: I plan to use it in `save_lint.php`.

Test Plan:
  $api->getUnderlyingWorkingCopyRevision(); // In Git SVN repo

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4054
2012-11-30 11:06:23 -08:00
vrana
c12dee997d Prefer Mercurial and Git over Subversion in discovering repository
Summary: `svn info` is the slowest command for discovering repository (up to 300 ms) and Subversion is probably the least used repository type with Arcanist. Let's discover it last.

Test Plan:
  $ arc lint --trace

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4039
2012-11-27 13:48:31 -08:00
vrana
cd7f86d380 Set cache version per linter
Summary: Also delete cache with `--cache 0`.

Test Plan:
  $ arc lint --lintall --cache 1
  $ cat .git/arc/lint-cache.json
  $ arc lint --lintall --cache 1 # with debug output

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2036

Differential Revision: https://secure.phabricator.com/D4013
2012-11-21 17:22:06 -08:00
epriestley
d3afa9cc31 Fix some arcanist warnings
Summary:
  - Rename some very old variables.
  - Wrap some contributed lines.

Test Plan: `arc lint` / `arc unit`. Viewed a diff in an uncacheable mode to verify intraline behavior.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4018
2012-11-21 17:16:52 -08:00
vrana
fc2cd63739 Fix getting changed files in Git 2012-11-21 15:57:06 -08:00
vrana
10bcbf1f4b Emit advice for TODO in Phutil linter
Summary:
Let's try this.
It may be useful to see this together in Differential overview.

Test Plan: Linted a file with TODO.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T744

Differential Revision: https://secure.phabricator.com/D4014
2012-11-21 15:40:58 -08:00
vrana
3cfd58c29c Allow caching lint results
Summary:
There is one big decision: How to get linters version.
I've created `getCacheVersion()` which is supposed to be bumped every time engine or any linter is changed.
This is not very nice but the other alternative (detect this automatically) seems worse:

- The engine may be outside repo and may or may not be under version control so getting its version through something like `git log` may not be even possible.
- If it is in the same repo then every rebase will obsolete the whole cache.

Even though bumping the version manually is PITA I still think it's a better solution.

Test Plan:
  $ time arc lint --cache 1
  # verified file
  $ arc arc lint --cache 1
  # added some debug output to see the cached results
  # also observed better time (.57 s instead of 2.19 s)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2036

Differential Revision: https://secure.phabricator.com/D4006
2012-11-21 13:21:10 -08:00
vrana
0cf8ef02d8 Don't amend commits with different author
Summary: Also delete extra newlines.

Test Plan:
  $ arc diff # on top of my commit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2025

Differential Revision: https://secure.phabricator.com/D3996
2012-11-21 13:09:11 -08:00
vrana
ec8c214ddf Change lint_engine to lint.engine
Summary: Also unit_engine.

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D4001
2012-11-20 15:42:35 -08:00
vrana
dfdacc7f9a Don't use empty commit message in commit from arc diff
Summary:
There was a bug in Git: https://github.com/git/git/commit/d9a935

Also fix a bug with discovering existing commits.

Test Plan:
  $ arc diff # yes
  # abort
  $ arc diff # didn't see fatal

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2025

Differential Revision: https://secure.phabricator.com/D3983
2012-11-20 10:58:22 -08:00