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

1007 commits

Author SHA1 Message Date
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
Bob Trahan
b71666a24a make arcanist backwards compatible with various conduit versions
Summary: pragmatism wins the day, though I think eventually we might want something really fancy to deal with arcanist and conduit not being up to date with respect to one another

Test Plan: php -l

Reviewers: epriestley

Reviewed By: epriestley

CC: zeeg, aran, Korvin

Maniphest Tasks: T2088

Differential Revision: https://secure.phabricator.com/D3988
2012-11-19 17:32:09 -08:00
vrana
5ca0f691a1 Reintroduce arc diff --advice
Summary:
Some users want be stopped even if there are lint advices.

NOTE: Deleted by D3364.

Test Plan:
On diff with lint advice:

  $ arc diff --preview # advice just printed
  $ arc diff --preview --advice # excuse required

Reviewers: epriestley

Reviewed By: epriestley

CC: akramer, aran, Korvin

Differential Revision: https://secure.phabricator.com/D3982
2012-11-19 17:14:38 -08:00
vrana
22d8e7467b Allow running arc diff without git commit
Summary:
There's quite some logic in here:

- It automatically decides whether to create a new commit or amend.
- It partially respects 'default-relative-commit'.
- However if it points to a closed revision then it creates a new commit.

Resolves T2025.

Test Plan:
`arc diff` on:

- Clean committed repository.
- Dirty repository without commit since 'default-relative-commit'.
- Dirty repository with non-revision commit since 'default-relative-commit'.
- Dirty repository with revision commit since 'default-relative-commit'.
- `arc diff HEAD^` on dirty repository on top of closed revision.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2025

Differential Revision: https://secure.phabricator.com/D3967
2012-11-19 12:06:03 -08:00
epriestley
f4222b3c8b Revert "accommodate git's diff.suppress-blank-empty=true setting (D3963)"
Summary: Reverts D3963, which is obsoleted by D3969.

Test Plan: Straight revert.

Reviewers: vrana, jiiix, btrahan

Reviewed By: vrana

CC: aran

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

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

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

  Included changes:
    M       things

Reviewers: vrana, jiiix, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3969
2012-11-15 15:47:35 -08:00
Jim Meyering
515399c0f6 accommodate git's diff.suppress-blank-empty=true setting
Summary:
accommodate git's diff.suppress-blank-empty=true setting
Without this change, if you were to set diff.suppress-blank-empty=true
in your .gitconfig (as I do), then "arc diff" would always fail with the
cryptic diagnostic, "Diff Parse Exception: Found the wrong number of
hunk lines."

Test Plan:
Put this in ~/.gitconfig or .git/config
[diff]
         suppress-blank-empty = true
and run "arc lint".  It should pass.  Without this chnage,
it would fail as described above.

Reviewers: vrana, epriestley

Reviewed By: vrana

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3963
2012-11-13 15:22:11 -08:00
vrana
15e4e6a003 Introduce arc lint --severity warning
Summary: I plan to exclude advices from our saved results.

Test Plan:
  $ arc lint src/lint/engine/PhutilLintEngine.php
  $ arc lint --severity advice src/lint/engine/PhutilLintEngine.php
  $ arc lint --severity error src/lint/engine/PhutilLintEngine.php

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2038

Differential Revision: https://secure.phabricator.com/D3936
2012-11-12 18:17:30 -08:00
vrana
58e3e928d1 Provide repository API method for getting changed files
Test Plan:
  print_r($api->getChangedFiles('HEAD~36')); // Under Git.

Verified that deleted files are false.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2038

Differential Revision: https://secure.phabricator.com/D3941
2012-11-12 18:17:10 -08:00
vrana
d3f351caae Provide repository API method for getting all files
Test Plan:
  print_r(iterator_to_array($api->getAllFiles())); // Under Git.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2038

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T479

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

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

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

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

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

Reviewers: epriestley, vrana, btrahan

Reviewed By: btrahan

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3925
2012-11-08 11:34:22 -08:00
keegancsmith
0a6444790d Performance improvements for linting in an HG repo.
Summary:
Run `hg status` as a Future while getting the diff. Add a cache for
getRawDiffText().

Test Plan:
Run `arc lint --trace` on a HG repo and confirm that `diff` is only called once
and `status` is run in the background.

Reviewers: epriestley

Reviewed By: epriestley

CC: yliang, dpepper, aran, Korvin

Maniphest Tasks: T2016

Differential Revision: https://secure.phabricator.com/D3913
2012-11-07 10:24:28 -08:00
vrana
ac92f9bdfc Remove getLink() from ArcanistLinterTestCase
Summary:
Installations extend this.

Another solution would be to extend `ArcanistLinterTestCase` from `ArcanistArcanistLinterTestCase` and return null in `getLink()` to avoid code duplication but I prefer clean class hierarchy.

Test Plan:
  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3878
2012-11-07 10:12:24 -08:00
vrana
53c9167953 Declare abstract method in repository API
Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3911
2012-11-07 10:10:26 -08:00
vrana
ae416d8788 Unignore changes in .arc/
Summary:
It's inside `.git/` for some time.
It also ignored changes in `test.arc/`.

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

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

Adds commits to cover this behavior:

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

      Mark koan2 +x and edit it.

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

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

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

      Mark koan as +x.

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

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3909
2012-11-06 17:46:55 -08:00
vrana
2e6dcf0fbb Ignore duplicate PEP8 lint errors in comprehensive engine
Test Plan:
  $ arc lint a.py # with too long line

Reviewers: zeeg, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3882
2012-11-06 11:48:00 -08:00
vrana
a83cb43d08 Move conversion to dictionary inside lint message
Summary: Maybe I will need it on other places.

Test Plan:
  $ arc lint --output json # on file with lint error

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3898
2012-11-05 22:39:35 -08:00
vrana
d53dcbe952 Trigger bad charset lint warning only once per line
Summary:
Makes lots of noise:
{F22758}

Test Plan:
Linted file with several bad characters per line.
Linted file with one bad character per line.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3896
2012-11-05 16:36:19 -08:00
vrana
0938091a99 Fix ArcanistLinterTestCase
Summary: We could also inject the value from the test case config but this is simpler.

Test Plan:
  $ arc unit src/lint/linter/ArcanistLicenseLinter.php

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2035

Differential Revision: https://secure.phabricator.com/D3895
2012-11-05 16:36:01 -08:00
vrana
21530fa459 Change severity of PEP8 errors to warnings
Summary: None of these are that serious that I would like to be informed about them on unmodified lines.

Test Plan: Linted Python file with lots of PEP8 errors, now warnings.

Reviewers: zeeg, epriestley

Reviewed By: zeeg

CC: aran, Korvin

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

We are removing the headers for these reasons:

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

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

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

Reviewers: epriestley, btrahan, edward

Reviewed By: epriestley

CC: aran, Korvin, davidrecordon

Maniphest Tasks: T2035

Differential Revision: https://secure.phabricator.com/D3881
2012-11-05 11:16:24 -08:00
vrana
d4a97d87c8 Ask for explanation for skipping lint and unit
Summary: Fixes T2023.

Test Plan:
  $ arc diff --nounit # Abort
  $ arc diff --nounit
  $ arc diff --nounit --excuse 'Move fast and break things.'

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2023

Differential Revision: https://secure.phabricator.com/D3872
2012-11-03 22:34:12 -07:00
vrana
851e579e94 Declare undeclared variable in lint engine
Test Plan:
  $ arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3876
2012-11-02 16:53:12 -07:00
Bob Trahan
027483f29a modify arc diff workflow to only do amend optimization if git repository
Summary: fix for T2011, first option in list of possible fixes

Test Plan: ...do I really have to setup mercurial with mq? :D

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2011

Differential Revision: https://secure.phabricator.com/D3869
2012-11-01 16:47:08 -07:00
vrana
5c4d2ae765 Fix copy/paste error in comment 2012-11-01 16:21:12 -07:00
vrana
90417fbda8 Advice user to set up stripping trailing white space in editor
Test Plan: Triggered it.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2022

Differential Revision: https://secure.phabricator.com/D3864
2012-11-01 11:23:31 -07:00
epriestley
24405e0e86 Fix arc diff --raw
Summary: I broke this in D3750. Calling `getRepositoryAPI()` triggers a check for workflow requirement of the repository API. Instead, we should just check if we alreayd have one.

Test Plan: Ran `cat x | arc diff --raw`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1998

Differential Revision: https://secure.phabricator.com/D3848
2012-10-31 11:50:43 -07:00
vrana
475a576fdc Require defining getWorkflowName()
Test Plan:
  $ arc help

Reviewers: epriestley, edward

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3742
2012-10-31 10:52:26 -07:00
Bob Trahan
522c35c1ed escape files properly in arc commit
Summary: turns out retina has files like image.png and image@2x.png. The latter breaks since '@' is a special command telling svn to "look for image at revision 2x.png" -- nonsensical garbage. If we add it to the end every time this error goes way.

Test Plan: touch 2@2.png; svn add '2@2@'; arc diff; <fill out form, accept commit>; arc commit -- observe commit working

Reviewers: epriestley

Reviewed By: epriestley

CC: mbishopim3, aran, Korvin

Maniphest Tasks: T1999

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

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

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

Reviewers: btrahan, vrana, svemir

Reviewed By: svemir

CC: aran

Differential Revision: https://secure.phabricator.com/D3836
2012-10-30 07:06:05 -07:00
epriestley
519e23f3a4 In arc diff, always check that you own a revision before trying to do anything with it
Summary:
Some users assume they can update anything, not just revisions they own (see https://github.com/facebook/arcanist/issues/54).

Currently, if you `arc patch` or `arc amend` and get a commit message, then `arc diff` for a revision you don't own, we:

  - Fail early with a very confusing message ("You can not review a revision you own!") if you are on the "Reviewers" line, until D3820.
  - Or fail very very late with a good error message, but after lint, unit and update messages.

Instead, check that you own the revision as early as we can.

Test Plan: Tried to update revisions I didn't own, got good error messages early on (with D3820).

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

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

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

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

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

  diff --git a b c d e f g

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

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

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

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

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran, ReturnZero

Maniphest Tasks: T1973

Differential Revision: https://secure.phabricator.com/D3818
2012-10-25 14:46:44 -07:00
epriestley
b8ead97637 Minor, fix obvious method name typo.
Test Plan: Ran `arc export --git`.

Auditors: btrahan
2012-10-25 13:38:23 -07:00
vrana
fa75a03b72 Fix didAbortWorkflow() without workflow
Summary: This is a BC break but it was introduced recently.

Test Plan:
  $ arc unit x

No more:

> Fatal error: Argument 2 passed to ArcanistConfiguration::didAbortWorkflow() must be an instance of ArcanistBaseWorkflow, null given

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3812
2012-10-24 14:09:02 -07:00
vrana
2d226f3110 Disallow using DD1 as revision ID
Test Plan:
  $ arc inlines --revision 1
  $ arc inlines --revision D1
  $ arc inlines --revision DD1

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3811
2012-10-24 11:33:12 -07:00
vrana
448e820eb6 Run unit on background also in waiting for confirmation with arc diff --excuse
Test Plan: Made lint error, slept in test, verified that tests are finished when I confirm `arc diff --excuse`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3803
2012-10-23 15:26:23 -07:00
vrana
0b02170723 Ask for lint and unit excuses asynchronously
Summary: This diff obsoletes D3385.

Test Plan: Made lint error, explained it, verified that unit already finished before I finished explaining (by adding `sleep(3)` to test).

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3786
2012-10-22 16:25:35 -07:00
vrana
1b51b74135 Provide a hook for aborted workflow
Summary:
We start Sandcastle push when `arc diff` starts.
If `arc diff` throws then HHVM waits for finishing the futures.
We need to kill them sooner.

Test Plan: Will implement the hook.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3713
2012-10-22 12:55:39 -07:00
vrana
47a036a535 Fix comprehensive lint engine 2012-10-22 12:47:27 -07:00
epriestley
538115bd0e Use PhutilAggregateException to aggregate unit test exceptions
Summary: Currently, a shutdown exception ("script exited with open transactions!") overwhelms the actual test failure exception, which is the one that needs to be fixed.

Test Plan: Ran a fixture test which opens a transaction and then throws. Got diagnostically useful output after this patch.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

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

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

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, mbishopim3

Maniphest Tasks: T1944

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

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

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

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

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

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

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

Test Plan: Unit tests; `arc diff`.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3750
2012-10-20 08:42:16 -07:00
vrana
835f2afb5d Pass key to aggregate exception
Summary: This information may be quite useful.

Test Plan: Threw exception from license linter.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3764
2012-10-20 07:33:56 -07:00
vrana
77af6fb35d Set all lint paths at once
Summary:
This code is much more readable to me.
It should also be faster as building the array at once should be faster than one by one.

Test Plan: Made license and XHPAST errors in PHP file, made spelling error in JS file.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3758
2012-10-20 06:49:54 -07:00
vrana
262423b5a8 Fix lint tests after D3756
Test Plan:
Threw normal exception, saw failed test.
Threw usage exception, saw skipped test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

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

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3749
2012-10-20 06:13:12 -07:00
epriestley
3853483c64 Fix ArcanistSingleLintEngine for deleted paths
Summary:
Currently, ArcanisSingleLintEngine lints deleted paths and directories. These are sometimes appropriate, but SingleLintEngine is a less-sophisticated linter and should have more safe defaults.

Also fix an error where JSHint reported useless messages on failure.

Test Plan:
Reproduced the problem:

  $ git show
  commit d71efe2b13770c8861bcd3415c15503fc377339f
  Author: epriestley <git@epriestley.com>
  Date:   Fri Oct 19 12:22:50 2012 -0700

      WIP

  diff --git a/test.js b/test.js
  deleted file mode 100644
  index 8bd6648..0000000
  --- a/test.js
  +++ /dev/null
  @@ -1 +0,0 @@
  -asdf
  $ arc set-config --local lint.engine.single.linter ArcanistJSHintLinter
  Set key 'lint.engine.single.linter' = "ArcanistJSHintLinter" in local config (was null).
  $ arc lint --engine ArcanistSingleLintEngine --rev HEAD^
  Usage Exception: JSHint returned output we can't parse. Check that your JSHint installation.
  Output:

Applied the error message fix:

  $ arc lint --engine ArcanistSingleLintEngine --rev HEAD^
  Usage Exception: JSHint returned unparseable output.
  stdout:

  stderr:

  node.js:181
          throw e; // process.nextTick error, or 'error' event on first tick
          ^
  Error: ENOENT, No such file or directory '/INSECURE/repos/git-working-copy/test.js'
      at Object.statSync (fs.js:400:18)
      at _collect (/usr/lib/node_modules/jshint/lib/hint.js:77:12)
      at /usr/lib/node_modules/jshint/lib/hint.js:93:13
      at Array.forEach (native)
      at Object.hint (/usr/lib/node_modules/jshint/lib/hint.js:92:17)
      at Object.interpret (/usr/lib/node_modules/jshint/lib/cli.js:137:21)
      at Object.<anonymous> (/usr/lib/node_modules/jshint/bin/hint:2:25)
      at Module._compile (module.js:420:26)
      at Object..js (module.js:426:10)
      at Module.load (module.js:336:31)

Applied the remove paths fix:

  $ arc lint --engine ArcanistSingleLintEngine --rev HEAD^
  Usage Exception: No paths are lintable.

Reviewers: magazovski, btrahan, vrana

Reviewed By: btrahan

CC: aran, Korvin, vissi

Differential Revision: https://secure.phabricator.com/D3735
2012-10-20 06:12:24 -07:00
vrana
d09eb881a3 Print lint results before throwing
Summary:
When some linter throws then we don't print any result.
This is bad in case when the linter threw e.g. because of syntax error in some file which some other linter will tell us about.

Test Plan: Threw from a linter, made lint error in a file, saw error then exception.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

moved the comment before if so lines stay at 80 chars

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

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

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1675

Differential Revision: https://secure.phabricator.com/D3744
2012-10-19 14:07:34 -07:00
vrana
4fb2b48d06 Don't unset linted paths from subdirectory and in commit hook mode
Summary: D3737#6

Test Plan:
  phabricator/src/ $ arc lint __phutil_library_init__.php

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3746
2012-10-19 12:57:46 -07:00
Edward Speyer
f0c0245957 Support --nobranch when not currently on a branch
Summary:
This is horrible and git specific, but fixes a case where people are using "arc
patch --nobranch ..." when they're not currently on a branch.

The old code assumed you were on a branch and used getBranchName() to record
this, in order to return to that branch later and cherry-pick the patch.

When not on a branch, and using arc patch --nobranch, this was trying to return
to the branch '(no branch)'.

Now, I detect that we're not on a branch and just record what HEAD is instead.

Test Plan:
Checkout the SHA of master (so I'm on master, but not on a branch) then try to
patch it with a feature diff:

  € git checkout e7a3ec68159d6847372cab5ad913f2f15aa7c249
  Warning: you are leaving 1 commit behind, not connected to
  any of your branches:

    ac1ad39 Updating a-file

  If you want to keep them by creating a new branch, this may be a good time
  to do so with:

   git branch new_branch_name ac1ad392350a51edd10343f12b9713f5e5b3707c

  HEAD is now at e7a3ec6... Fix arcconfig

  € arc patch --nobranch D7
  Created and checked out branch arcpatch-D7.
   OKAY  Successfully committed patch.

  € git branch
  * (no branch)
    feature
    haddock
    master

  € git log --oneline | head -2
  38c0235 Updating a-file
  e7a3ec6 Fix arcconfig

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3743
2012-10-19 12:12:57 -07:00
vrana
4585ab7363 Don't lint file content of directories
Summary: This also changes how we treat `@generated` and `@nolint` - after this diff, we will still lint their path.

Test Plan:
Created directory `a.php` and symlink `b.php` pointing to directory.
`arc lint` previously printed:

> Requested path `/data/users/jakubv/devtools/arcanist/_.php' is not a file.

Now it prints:

> No lint warnings.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3737
2012-10-19 11:38:44 -07:00
vrana
b52ee2fdee Temporarily unrequire defining getWorkflowName()
Summary:
We need to run new Arcanist over old code in Perflab.
We also need to run new Arcanist over new code (with already deleted custom `buildAllWorkflows()`).

This will work because old code overwrites `buildAllWorkflows()`.

Test Plan:
  $ arc help
  $ arc help # after deleting getWorkflowName() from one workflow

Reviewers: edward, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3741
2012-10-19 11:02:20 -07:00
vrana
94d283a453 Require defining workflows' synopses and help
Test Plan: Deleted `getCommandSynopses()` from workflow, ran `arc help`.

Reviewers: epriestley, edward

Reviewed By: epriestley

CC: aran, Korvin

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

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

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

      Remove binary image.

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

      Copy binary image.

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

      Move binary image.

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

      Add a binary image.

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

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3732
2012-10-19 10:10:25 -07:00
epriestley
4c476c0201 Make Arcanist workflow names explicit
Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.

Remove all the rules tying workflow names to class names through arcane incantations.

This has a very small performance cost in that we need to load every Workflow class every time now, but we don't hit __init__ and such anymore and it was pretty negligible on my machine (98ms vs 104ms or something).

Test Plan: Ran "arc help", "arc which", "arc diff", etc.

Reviewers: edward, vrana, btrahan

Reviewed By: edward

CC: aran, zeeg

Differential Revision: https://secure.phabricator.com/D3691
2012-10-17 08:35:03 -07:00
Edward Speyer
2d269aefed Use git-cherry-pick for arc patch
Summary:
This changes what --nobranch does, though not what it means.  In git, the patch
is applied to the git commit it is based off where it will commit cleanly, and
if you specify --nobranch then arc-patch will then switch back to your original
branch and try to cherry-pick the commit there.

If this fails, you end up with merge-conflict markers in the file which can be
handy.

Test Plan: https://secure.phabricator.com/P572

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3712
2012-10-16 16:46:21 -07:00
vrana
a850f1c6ef Don't pull message twice from Conduit in arc diff
Summary:
We currently pull message from Conduit twice in `arc diff` update.
Once in `buildCommitMessage()` and once in `buildRevisionFromCommitMessage()`.
Remeber that we already pulled it (and so it is authoritative) to save this call.

Even faster solution would be to not pull and update the message at all in common (non-`--edit`, non-`--verbatim` and such) update workflows but it's more involved.

Test Plan:
  $ arc diff --trace

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3716
2012-10-16 12:53:59 -07:00
Stanislav Vorobyev
9c2348f2f4 Fix parsing of PHPUnit JSON log format for PHPUnit 3.7.7
Summary: See https://github.com/facebook/arcanist/pull/55

Reviewed by: epriestley
2012-10-15 11:07:50 -07:00
vrana
eb5bdb03d0 Provide getter for test results properties in arc diff
Summary: We want to use them in event.

Test Plan: Will use it in event.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3690
2012-10-12 18:15:27 -07:00
vrana
3d00e0448d Resolve diff property updates in parallel
Summary:
I was thinking about creating a method `differential.setdiffproperties` updating all properties at once or adding 'properties' to `differential.creatediff` (better) but it will require bumping Conduit version.

This looks simpler and with similar effect.
We could postpone resolving properties more but I don't want to risk not resolving them after an error.

Test Plan:
This diff for that it works.
Benchmark: 0.55 s before, 0.25 s after (with three properties, the difference will be bigger with more).

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3689
2012-10-12 15:18:56 -07:00
Dereckson
646b37a343 (T1889) arc cover supports Mercurial too
Summary: improving documentation: add cover supports Mercurial

Test Plan: ./bin/arc help cover

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1889

Differential Revision: https://secure.phabricator.com/D3683
2012-10-12 07:41:24 -07:00
Dereckson
5725585f2d Allow to push revisions to review by himself to Differential (bug T1879, change 2/2, Arcanist part)
Summary:
The 'review its own revision' check is now handled by Differential (bug T1879)

Previous behavior:
    arc threw an "You can not be a reviewer for your own revision." exception
    if an users adds itself as reviewer, even when this configuration is
    allowed on the Differential remote install's configuration.

New behavior:
    Arc doesn't check that anymore. It still will be checked by the server.

Test Plan: Tested locally pushing revisions with "arc diff" to a Phabricator server with differential.allow-self-accept at true or false with myself or not as reviewer.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1879

Differential Revision: https://secure.phabricator.com/D3674
2012-10-12 07:40:59 -07:00
David Reuss
a63db7cd6e Added check for no tasks returned by 'arc tasks'
Test Plan: A lot of spew before. Not so much now.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, lesliepc16

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

Test Plan:
  $ arc diff --raw

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1261

Differential Revision: https://secure.phabricator.com/D3662
2012-10-08 16:34:18 -07:00
vrana
d0ed67ab1d Decrease severity of preg_quote() warning
Summary: I use it more often without second parameter than with it.

Test Plan:
Lint of:

  preg_quote('');
  preg_quote('', '/');

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3647
2012-10-05 18:05:11 -07:00
epriestley
d0425fc238 Retain newline style when generating diffs
Summary: Builds on D3441, D3440. Instead of exploding on "\r?\n" and then imploding on "\n", retain newline style throughout parsing.

Test Plan:
All unit tests pass (the parser has substantial existing coverage). These new tests pass in the git commit-by-commit test case:

  commit 176a4c2c3fd88b2d598ce41a55d9c3958be9fd2d
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:56:08 2012 -0700

      Convert \r\n newlines to \n newlines.

  commit a73b28e139296d23ade768f2346038318b331f94
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:55:31 2012 -0700

      Add text with \r\n newlines.

  commit 337ccec314075a2bdb4a912ef467d35d04a713e4
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:55:13 2012 -0700

      Convert \n newlines to \r\n newlines.

  commit 6d5e64a4a7a6a036c53b1d087184cb2c70099f2c
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:53:39 2012 -0700

      Remove tabs.

  commit 49395994a1a8a06287e40a3b318be4349e8e0288
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:53:33 2012 -0700

      Add tabs.

  commit a5a53c424f3c2a7e85f6aee35e834c8ec5b3dbe3
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:52:57 2012 -0700

      Add trailing newline.

  commit d53dc614090c6c7d6d023e170877d7f611f18f5a
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:52:41 2012 -0700

      Remove trailing newline.

Previously, the newline-related tests failed.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3442
2012-10-03 15:32:03 -07:00
Bob Trahan
383fb42ba8 make arc commit work on windows with multiline messages
Summary: cd && cmd won't work so use chdir; -m $multiline_message won't work so use -F $tmp_file

Test Plan: this is actually un-tested at the moment.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1617

Differential Revision: https://secure.phabricator.com/D3592
2012-10-03 14:54:43 -07:00
vrana
d83a884a91 Correctly mark patched text in lint console renderer
Summary:
Before:
`    >>> -      4 `**1**`* Copyright 2011 Facebook, Inc.`

After:
`    >>> -      4  * Copyright 201`**1**` Facebook, Inc.`

Test Plan: Rendered patchable message, multiline patchable message, unpatchable message.

Reviewers: andrewjcg, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3604
2012-10-03 13:58:36 -07:00
epriestley
b880dfd4c8 Improve handling of --background with --base
Summary:
Currently, we run `runDiffSetupBasics()` //after// splitting off background lint and unit tests. However, this means `--base` and any explicit revision name (like "HEAD^") will not be parsed, so the call to `getRelativeCommit()` in order to generate `arc lint --rev XXX` will fail or not work as expected, because it will ignore any arguments.

Instead, parse `--base`, explicit revisions, and other repository API arguments before doing lint and unit tests.

Test Plan:
  - Set global config for `base` to `arc:amended, git:branch-unique(origin/master)`.
  - Created a commit on master.
  - Ran `arc diff HEAD^`.
    - Before this change, the command fails with "Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly." when it attempts to run lint, because the `HEAD^` argument is never parsed. After
    - After this change, the command succeeds.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3574
2012-10-02 11:01:49 -07:00
vrana
f0a91a30c8 Amend commit after editing the message in diff
Summary:
We store the message to a scratch file.
But if I need to switch context, commit something else and then go back then I'll lose the message.
Amend the repository commit by it instead.
This also removes the annoying question "Do you want to use this message?".

Test Plan: Made an error in message, verified Git log.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3561
2012-10-01 09:37:22 -07:00
epriestley
dffaa17e41 Make arc tasks print output in a unicode-aware and console-width-aware way
Summary:
Currently, we print `arc tasks` in a console-agnostic and unicode-unaware way, so:

  - Tasks with multibyte characters get aligned incorrectly (see T1831); and
  - narrow terminals plus long task names results in a broken display.

Test Plan: Ran `arc tasks`. Will post screenshots.

Reviewers: btrahan, vrana, Korvin

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T749, T1831

Differential Revision: https://secure.phabricator.com/D3568
2012-09-30 19:40:54 -07:00
epriestley
777c119a0e Search for more test locations in PHPUnitTestEngine
Summary:
See https://github.com/facebook/arcanist/pull/53

  - Work correctly for directories with `%` in their name; this breaks under sprintf().
  - Search for `src/` -> `tests/` style directories.
  - Add coverage for search paths.

Test Plan:
Ran unit tests.

I don't have a working test case for PHPUnit tests, can one of you guys apply this and verify I didn't break your setups?

Reviewers: quard, aurelijus

Reviewed By: aurelijus

CC: aran

Differential Revision: https://secure.phabricator.com/D3558
2012-09-29 18:03:43 -07:00
vrana
36acc9a01d Search for SVN commit in Git SVN repository
Summary: `arc patch` currently warns about "This diff is against commit svn+ssh://... but the commit is nowhere in the working copy" in Git SVN repository.

Test Plan:
  $ arc patch # in Git SVN repository
  $ svn find-rev r121212112 # invalid revision

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3539
2012-09-28 11:34:53 -07:00
vrana
e58e408129 Delete flushing moved to libphutil
Test Plan:
  $ arc diff # under HPHP

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3563
2012-09-28 09:56:57 -07:00
vrana
a6221ea166 Patch 'unix:filemode' property as 'svn:executable' in SVN
Summary: Patch created on Git contains 'unix:filemode' property which is useless in SVN.

Test Plan: Exported a bundle changing a file to executable in Git, applied it in SVN, verified that the file is executable.

Reviewers: epriestley

Reviewed By: epriestley

CC: ptarjan, aran, Korvin, digoangeline

Differential Revision: https://secure.phabricator.com/D3554
2012-09-27 10:13:17 -07:00
vrana
b22e94d555 Don't run background process with raw diff source
Test Plan:
  $ arc diff

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3553
2012-09-26 09:44:42 -07:00
vrana
0a6be45f29 Unuse $argv in arc diff --background
Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: zeeg, aran, Korvin

Differential Revision: https://secure.phabricator.com/D3550
2012-09-24 12:02:54 -07:00
vrana
32e123c515 Step towards working arc diff --background 1 on Windows
Summary:
Running `a.php` from command line doesn't work on Windows, we need to run `php a.php`.
This shouldn't break other OSes.

Test Plan:
  $ arc diff --background 1

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3544
2012-09-24 11:04:19 -07:00
vrana
aa425c7ea9 Flush output before printing lint and unit results in diff
Summary:
Under HPHP, output buffer size is ignored.
Flush any buffered output before printing anything from `arc diff` to reduce user's confusion.

Test Plan:
  $ arc diff --preview --background 1
  $ arc diff --preview --background 0

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3543
2012-09-24 11:04:02 -07:00
vrana
e1b2d787c9 Make arc diff --background 1 default and disable it on Windows
Summary:
I am using it for about a month.
It works even in Facebook www.

Test Plan:
  $ arc diff --background 1 # hundreds of times

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3495
2012-09-21 15:29:22 -07:00
Bob Trahan
baa64a5c83 fix a bug in ArcanistXHPLinter
Summary: $param is null here. it should be $node.

Test Plan: arc lint no longer barfed on me!

Reviewers: vrana, epriestley

Reviewed By: vrana

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3540
2012-09-21 14:59:04 -07:00
epriestley
d7edc1021d Reformat lint severities for readability
Summary: See D3482.

Test Plan: `arc lint`

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3501
2012-09-21 12:27:32 -07:00
epriestley
95c663f461 Add git-repo-based bundle tests
Summary:
Adds a test which goes through a git repository commit by commit and applies them (in effect) via "arc patch", verifying that the results match the actual commit.

See D3439 for the fixture stuff.

The git repo archive has a couple of trivial commits in it:

  $ ../libphutil/scripts/utils/directory_fixture.php src/parser/__tests__/bundle.git.tgz
  Spawning an interactive shell. Exit when complete.

  sh-3.2$ git log
  commit f19fb9fa1385c01b53bdb6d8842dd154e47151ec
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:30:28 2012 -0700

      Edit a text file.

  commit 228d7be4840313ed805c25c15bba0f7b188af3e6
  Author: epriestley <git@epriestley.com>
  Date:   Wed Sep 5 14:30:11 2012 -0700

      Add a text file.

Test Plan: Ran tests.

Reviewers: edward

Reviewed By: edward

CC: aran

Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3440
2012-09-21 12:27:21 -07:00
vrana
22c51d0d71 Handle empty file add in Git export
Summary: Fixes T1555.

Test Plan: Added empty file, diffed it, exported and patched. Also manually created diff in Differential.

Reviewers: btrahan, epriestley

Reviewed By: btrahan

CC: aran, Korvin

Maniphest Tasks: T1555

Differential Revision: https://secure.phabricator.com/D3536
2012-09-21 11:22:21 -07:00
vrana
6bd2b372f5 Properly handle file moves in arc patch under SVN
Summary:
If the file has no changes (probably because it has been moved or copied) then we fail.

Fixes T1708, fixes T1559.

Test Plan:
  $ svn mv a b
  $ arc diff --only
  $ svn revert a b
  $ arc patch --diff # of created diff

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, Korvin

Maniphest Tasks: T1559, T1708

Differential Revision: https://secure.phabricator.com/D3526
2012-09-21 11:22:05 -07:00
vrana
6929f4e57e Build correct corpus in copied or moved files
Summary:
This problem shows very far away.
One of the symptomps is that the contents of a moved file is displayed as added in Differential but it is not a big deal.

The real trouble happens when you try to `arc patch` this diff.
It tries to both copy the file and to add a new contents (which fails).

Fixes T1709.

Test Plan:
  $ git mv a b
  $ git commit -m.
  $ arc diff --only
  $ git reset --hard HEAD^
  $ arc patch --diff # of the created diff

  $ arc unit src/parser/__tests__

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, Korvin, boris, mroch, slawekbiel

Maniphest Tasks: T1709

Differential Revision: https://secure.phabricator.com/D3524
2012-09-20 13:20:38 -07:00
vrana
7119f0c4cc Mark moved binary file as image
Test Plan: Moved image, verified that the source file is marked as image: https://secure.phabricator.com/differential/diff/6924/

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3520
2012-09-20 13:19:24 -07:00
vrana
1d744e932f Handle binary file moves in arc patch under Git
Summary: We don't store old file PHID for binary file moves here.

Test Plan: `arc patch` on revision with binary file moves which was failing earlier.

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3521
2012-09-20 13:16:11 -07:00
vrana
c8687a0c79 Lint functions not available on Windows on PHP 5.2
Summary: Also use absolute paths.

Test Plan: Linted Arcanist, libphutil, Phabricator, found no false positives and one real error in [[ https://secure.phabricator.com/diffusion/PHU/browse/master/src/channel/PhutilSocketChannel.php;42d8e8447c8b5d6a$92 | PhutilSocketChannel ]].

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3504
2012-09-17 13:51:06 -07:00
vrana
94f684e29e Declare ArcanistBaseWorkflow::run()
Summary: We call it from `arcanist.php`.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3496
2012-09-17 13:24:37 -07:00
vrana
589bccb716 Handle arc diff --background 1 --
Summary: We currently insert background parameters to end which causes ignoring them if there is '--'.

Test Plan:
  $ arc diff --background 1 -- HEAD^

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3497
2012-09-17 13:20:31 -07:00
vrana
3bbf9ccc3d Fix typo in comment 2012-09-14 17:52:24 -07:00
vrana
ac7b9e42d6 Publicize formatting unit test result
Summary: I want to use it from outside.

Test Plan:
  $ arc unit src/lint/linter/__tests__/

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3493
2012-09-13 22:36:46 -07:00
vrana
fefa9e2d72 Use array_mergev() in Phutil test engine
Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3491
2012-09-13 22:35:41 -07:00
dennis zhuang
d65b953252 Get branch name with --no-color option 2012-09-13 15:12:19 -07:00
vrana
7ee0f3e3b3 Lint short ternary as PHP 5.3 feature
Summary: I don't offer a replacement because `f() ?: 1` converted to `f() ? f() : 1` can cause side effects and whitespace issues.

Test Plan: New test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3489
2012-09-13 11:24:32 -07:00
vrana
a5e2f81928 Skip linter tests with usage problems
Summary: D3480#comment-1

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3481
2012-09-12 10:56:00 -07:00
vrana
261fd592b9 Add missing space in string 2012-09-12 10:42:39 -07:00
vrana
64f35f0b83 Tweak severity of pht() linter
Summary:
`pht()` can be some random function.
Better solution would be to separate this linter to its own class but it would be slower.

Also use `PhutilLintEngine` as `lint.engine`.

Test Plan:
  $ arc lint # on file with pht($a)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3480
2012-09-12 10:29:37 -07:00
vrana
7c0d99aac9 Fix typo in comment 2012-09-12 02:11:22 -07:00
Leah Xue
03e5d651b5 Make ruby -wc a linter in Arcanist
Summary: Add `ruby -wc` as a linter and raise Error whenever there's a syntax error

Test Plan: Just a few dumb unit tests.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3447
2012-09-11 10:42:50 -07:00
vrana
9dd1a87066 Make spell check linter patching
Test Plan:
Wrote "Posible" in the linter, let it change to "Possible".
New unit test.

Reviewers: jack, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3469
2012-09-10 16:21:58 -07:00
epriestley
918eff8ff9 Fix false negatives in "break;" lint check
Summary: See D3449, comments, unit tests.

Test Plan: Unit tests.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3463
2012-09-07 17:46:35 -07:00
vrana
339cabedcc Add a test case for false negative switch lint rule
Summary:
I tried to fixed it but I've given up.

See rP958e6cd109f3.

Test Plan:
  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3449
2012-09-07 15:55:34 -07:00
vrana
cdb161a19a Allow Phutil tests setting link
Summary: Also delete some copy pasta.

Test Plan: Next diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3455
2012-09-07 15:42:50 -07:00
vrana
af31ee4ed0 Link Arcanist test cases
Summary: See D3455.

Test Plan: This diff (after rebase).

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3460
2012-09-07 15:31:14 -07:00
vrana
c50b18142d Support linking unit tests
Summary: This is Arcanist part of D3434.

Test Plan: None.

Reviewers: epriestley, wez

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3450
2012-09-06 18:48:59 -07:00
Brandon Pedersen
4038e7be0a Fix commit message format returned by getCommitMessage
Git commit messages must have 2 newlines between the subject and body
If used to rewrite a commit message then the commit message will be
incorrectly reformatted.
2012-09-06 08:56:44 -06:00
epriestley
bc96d6036e Implement the arcanist top-level log handling in terms of $console->writeLog()
Summary:
  - See D3422.
  - Also improve some event configuration/debugging stuff.

Test Plan: Ran `arc list --trace`, set bogus/valid event handlers.

Reviewers: vrana, nh

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3423
2012-09-05 11:45:54 -07:00
vrana
a309e5e1eb Use punctuation in spelling linter
Summary: Also move dependency one directory down.

Test Plan:
  $ arc lint # on file with "teh"

Reviewers: jack, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3436
2012-09-05 10:14:29 -07:00
vrana
466910c700 Delete obsolete comment
Summary:
HPHP now autoloads in `is_subclass_of()`.
I've left the `class_exists()` check as the code is more explicit.

Test Plan:
  // under HPHP
  function __autoload($c) {
    echo "$c\n";
  }
  is_subclass_of('C', 'stdClass');

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3435
2012-09-04 23:13:43 -07:00
epriestley
a802a90123 Always include 'workflow' on Arcanist events
Summary:
This object is highly useful in many client event handlers (particularly for access to the CLI) and allows them to be implemented less intrusively.

This also slightly reduces code duplication.

Test Plan: Ran "arc diff".

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1753

Differential Revision: https://secure.phabricator.com/D3421
2012-09-04 12:08:04 -07:00
katherine
b0cfe9d94d [hg - arc patch] make mercurial bookmark with arc patch
Summary:
w00t!

Created new functions getBookmarkName, createBookmark that use mercurial
commands to create a new bookmark and apply the commit message when
running arc patch. Like with git, it checks if the bookmark already
exists. If it does, creates arcpatch-DXXX-1, -2 etc

Updated the mercurial section of run() to include applying the commit
message.

Pretty new to programming in general still, so I wasn't sure if I should
have just modified getBranchName and createBranch to work with Mercurial
(instead of creating new functions). This was easier for me to make sure
I didn't break the git functionality. Let me know I can merge the
functions.

Test Plan:
Tested in my www-hg repository. Probably need to test further (suggestions?)

Ran the following trials with arc patch D539987
1) the bookmark arcpatch-D539987 already existed
2) the bookmark did not exist
3) tried an invalid commit, arc patch R539987
4) --nobookmark flag (bookmark was not created, but the commit applied)
5) --nocommit flag (boomark was created, and the commit was not applied)
6) --nocommit and --nobokmark

Here's the summary of the results:
https://secure.phabricator.com/P493

Reviewers: dschleimer

Reviewed By: dschleimer

CC: aran, epriestley, phleet, bos, csilvers

Differential Revision: https://secure.phabricator.com/D3334
2012-08-31 17:05:46 -07:00
epriestley
d79664a30d Add a willCreateRevision event
Summary:
Adds an event prior to creation of a new revision so installs can muck around with titles, etc.

I'll also update the docs.

Test Plan: Ran "arc diff --trace" and observed event dispatch. Added `var_dump()` and verified $revision is a reasonable object.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, geoffberger

Differential Revision: https://secure.phabricator.com/D3408
2012-08-30 12:28:35 -07:00
Nick Harper
4a786f48de Use paste.query for arc paste
Summary: paste.info is deprecated; switch to using paste.query

Test Plan:
  arc paste P123
  arc paste P123 --json

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3402
2012-08-29 11:04:19 -07:00
vrana
600e052e72 Dispatch event after building diff message
Summary:
We log time of running `arc diff`. It's easy with `--verbatim` or with users just confirming the message built in commit template.

With `--background`, I want to log only waiting time, not message editing time. This event should allow it.

Test Plan:
  $ arc diff

Haven't created the listener yet.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3394
2012-08-27 18:34:31 -07:00
epriestley
d83768a949 Minor, fix obvious typo in SVN patch workflow (@mroch). 2012-08-23 17:52:47 -07:00
vrana
7ba210f89a Create v2 libraries
Summary:
This is how it looks like now:

>     What do you want to name this library? x
> Writing '__phutil_library_init__.php' to 'x/__phutil_library_init__.php'...
> Usage Exception: This library is using libphutil v1, which is no longer supported. Run 'arc liberate --upgrade' to upgrade to v2.

Test Plan:
  $ arc liberate # in new dir

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3368
2012-08-22 15:43:54 -07:00
vrana
129339019f Always use lint advices
Summary:
We want to have a class of lint problems which are displayed to author and attached to revision but don't require excuse in diff workflow.
Lint advices already serve this purpose but no linters emit them because they need `--advice` flag to be processed.

By always enabling advices, we can switch more linters from warnings to advices and don't stop the diff workflow for them.

This diff also bumps down default severity of TODO rule.

Test Plan: Made lint advice mistake, ran `arc lint`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, ide, Korvin

Differential Revision: https://secure.phabricator.com/D3364
2012-08-22 11:49:59 -07:00
epriestley
29ba92c0c2 Improve management of zlib dependency
Summary:
  - Add zlib functions to extension functions.
  - Provide a better error if the extension is actually missing.

Test Plan: Eyeballed it.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D3321
2012-08-20 17:26:42 -07:00
vrana
1779abef6f Link docs from message
Test Plan:
  phutil_console_confirm("See http://www.phabricator.com/docs/phabricator/article/Differential_User_Guide_Large_Changes.html for information");

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3317
2012-08-16 14:29:37 -07:00
vrana
13b64da47a Use console in unit inside diff 2012-08-15 15:54:34 -07:00
vrana
30bc4ca6e9 Don't ask for confirmation with unsound unit tests
Test Plan:
  $ arc diff # with unsound tests
  $ arc diff --ignore-unsound-tests # with unsound tests

Reviewers: epriestley, aran

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1515

Differential Revision: https://secure.phabricator.com/D2985
2012-08-15 15:49:50 -07:00
vrana
014521362f Fix lint warning 2012-08-15 14:27:04 -07:00
vrana
cae7631dff Warn about strstr() misuse
Summary: See D3296#1.

Test Plan:
New test.
Linted Arcanist, libphutil, Phabricator repositories, found no false positive and one real positive.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3297
2012-08-15 13:44:41 -07:00
vrana
34efe49e12 Warn before using strpos($a, $b) === 0
Summary:
I'm not sure if we are interested in this kind of linters ("Don't use slow function if there is a fast alternative").
I didn't find a case where `strpos() === 0` could be useful except [[ http://www.php.net/manual/en/mbstring.overload.php | mbstring.func_overload ]] craziness.

Test Plan:
New unit test.
Linted Arcanist, libphutil, Phabricator repositories, found no false positive and one real positive.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3296
2012-08-15 13:20:25 -07:00
Wez Furlong
390bb280e1 Add extraData field to test results
Summary:
See discussion on T1630.
extraData provides more scope for extensions to piggy-back
more data on the test results and have that pulled up to the UI.

We're using keys like "facebook:complexity" to store additional
data as part of the test results.

Test Plan:
Nothing in the codebase touches extraData at the moment, so
you'll just have to have faith/prove by inspection.

Reviewers: vrana, nh, tuomaspelkonen, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T1630

Differential Revision: https://secure.phabricator.com/D3276
2012-08-15 10:34:29 -07:00
epriestley
a0d4430271 Detect use of f()[0] in lint
Summary: XHPAST doesn't currently parse most PHP 5.4 stuff, but it does parse this. Warn about it.

Test Plan:
Unit tests, and:

   Error  (XHP35) Use Of PHP 5.4 Features
    The f()[...] syntax was not introduced until PHP 5.4, but this codebase
    targets an earlier version of PHP. You can rewrite this expression using
    idx().

             365   public function lintPHP54Features($root) {
             366
             367     if (false) {
    >>>      368       id()[0];
                            ^
             369     }
             370

Reviewers: alanh, vrana

Reviewed By: alanh

CC: aran

Differential Revision: https://secure.phabricator.com/D3291
2012-08-15 04:36:50 -07:00
vrana
ab602e3a52 Pass lint and unit results to diff created event
Summary:
I need to run some jobs only if the tests hasn't been skipped.
I know that this could end up by passing more and more data to the event but this is all I need so far.

Test Plan: Dumped `unitResult` from the listener.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3259
2012-08-13 14:57:18 -07:00
epriestley
061a9f8cbd Implement base85 in a 32-bit safe way, without bcmath
Summary: See T1635 and the giant inline comment.

Test Plan: Ran unit tests on 32-bit and 64-bit machines.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1635

Differential Revision: https://secure.phabricator.com/D3250
2012-08-12 19:21:33 -07:00
epriestley
08b29ad23f Add test coverage to the base85 implementation
Summary: See T1635. I'm going to make an effort to rewrite this in a way that's safe in 32-bit PHP, i.e. without bcmath. Add test coverage to limit the chance I screw it up.

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1635

Differential Revision: https://secure.phabricator.com/D3249
2012-08-12 19:20:46 -07:00
epriestley
be3ce781bb Switch arcanist to phutil_utf8_convert()
Summary: See D3252. Reduces code duplication a little bit. Also remove some dire warnings about impending doom -- this has been in use in the wild for a long time.

Test Plan: Added a file in ISO-8859-1, ran `arc diff --encoding ISO-8859-1` to generate this revision, got an encoding note in output.

Reviewers: davidreuss, vrana, btrahan

Reviewed By: davidreuss

CC: aran

Maniphest Tasks: T452

Differential Revision: https://secure.phabricator.com/D3253
2012-08-12 08:50:01 -07:00
vrana
6288bd6bcf Fix doc links
Summary: I will also commit fixes in other repos.

Test Plan: LinkChecker

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3242
2012-08-10 14:46:08 -07:00
epriestley
edcc5cf6e1 Remove beginRedirectOut() from Arcanist
Summary: We always do this on --recon now, see D3213.

Test Plan: Ran `arc diff --background 1` to generate this diff.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3241
2012-08-10 12:10:09 -07:00
epriestley
8f127af47c Make the "this is technical documentation" message of "Arcanist Overview" more clear
Summary:
The only purpose of "Arcanist Overview" is to tell people they shouldn't be here, but we bury the lede.

Make it clear that this is not user documentation.

After T988 we can improve the organization here, but some recent users found this pretty confusing.

Test Plan: Generated and read documentation.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3235
2012-08-10 11:37:30 -07:00
epriestley
d2e0dc3e68 Improve "arc patch" error messages for mismatched local and diff
Summary: We emit a confusing error if there's no ".arcconfig" in the local right now.

Test Plan:
  $ arc patch D3185

    This patch is for the 'phabricator' project,  but the working copy
    belongs to the 'phabricatox' project. Still try to apply the patch? [Y/n]

  $ arc patch D3185

    This patch is for the 'phabricator' project, but the working copy does
    not have an '.arcconfig' file to identify which project it belongs to.
    Still try to apply the patch? [Y/n]

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3231
2012-08-09 18:39:41 -07:00
vrana
239b90a076 Allow specifying root in arc inlines
Summary: Simplifies editor bindings.

Test Plan:
  $ arc inlines --root W:/devtools/phabricator/

Reviewers: epriestley

Reviewed By: epriestley

CC: vii, aran, Korvin

Differential Revision: https://secure.phabricator.com/D3229
2012-08-09 17:44:57 -07:00
vrana
45fc4c992c Redirect output to console in background mode of arc diff
Summary: See D3208.

Test Plan:
  $ arc diff --background 1

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3210
2012-08-08 19:04:59 -07:00
epriestley
678efa44c6 Fix an issue where 'arc alias' reverses parameters
Summary:
We shove alias parameters onto the front of the arg list so if you make an alias like "qdiff" = "diff x y z" and then run "qdiff a b c", we end up with "diff x y z a b c". However, currently we reverse alias parameters, so you actually get "diff z y x a b c".

This is a problem for `arc alias bdiff -- diff --background 1`, which evaluates to `arc diff 1 --background` and fails.

Test Plan: Created a `bdiff` alias and ran it successfully.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3196
2012-08-08 12:58:27 -07:00
vrana
1ea9b8b02c Run lint and unit before updating revision
Summary: Depends on D2614.

Test Plan:
Updated a diff with no lint errors.
Updated a diff with lint errors, verified that the previous message is not lost.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3174
2012-08-08 12:19:14 -07:00
vrana
7e49cb4bfc Run lint and unit tests in arc diff on background
Summary:
I usually write commit messages 1-2 minutes.
`arc lint` in our repository usually runs for around 30 seconds, `arc unit` another minute or two.
Even Phabricator unit tests sometimes runs long (because `CREATE DATABASE` and `DROP DATABASE` is slow in our setup for some reason).

Waiting for the results is boring and unnecessary.

This diff presents two different concepts how to run them on background:

# Lint is run with `--output json`, results are parsed and presented back to user. It isn't perfect - there's no context in printed lint errors which is a serious problem.
# Unit tests are run normally and the results are written to a scratch file. It also isn't perfect - colors are lost during the process.

I'll probably choose one approach and use it on both places. Let me know your thoughts about them.

This can be further improved to resolve the futures also after inputting the update message but it can be done in a separate diff.

Test Plan:
- Remove lint engine.
- Remove unit engine.
- Make lint errors.
- Make unit errors.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, beng, tuomaspelkonen, alanh

Differential Revision: https://secure.phabricator.com/D2614
2012-08-08 12:07:12 -07:00
vrana
df81d25f1e Depend on events when attaching Diff ID to postponed unit tests
Summary:
According to @epriestley, it's nasty and kind of crazy: D2933#1.
It also stands in my way for D2614.

Test Plan: Rewrote our callsite to event listener and verified that it still works.

Reviewers: tuomaspelkonen, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D3171
2012-08-08 12:04:15 -07:00
epriestley
cb5cfb28cd Fix an issue where branches at the same commit race to destruction in "arc branch"
Summary:
If two branches have the same HEAD, they currently race to overwrite each other in $commit_map.

We don't need to return a map indexed by commit since nothing ever reads the keys out of it. Just update $branches in place.

Test Plan: With two branches at the same HEAD, ran "arc branch". Saw both branches in output.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3188
2012-08-07 18:21:32 -07:00
epriestley
fae2adba9e Throw properly if there are uncommitted changes under Git
Summary: This was accidentally disabled with some Mercurial changes that allowed dirty working copies.

Test Plan: Ran `arc diff` with staged changes.

Reviewers: nh

Reviewed By: nh

CC: aran

Differential Revision: https://secure.phabricator.com/D3165
2012-08-06 11:56:01 -07:00
vrana
5d6e2a4e08 Use PhutilConsole in lint and unit
Test Plan:
`arc lint` with OK result and with patchable error.
`arc unit` with passes and errors.
`arc diff` with patchable lint error.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3151
2012-08-05 18:39:32 -07:00
Alan Huang
877e6f743b Add an arc flag workflow
Summary:
Allow querying and modifying flags from arcanist. Currently
supports only printing and deleting flags for Differential revisions,
but it should be straightforward to add more capabilities (given Conduit
support).

Test Plan:
Run arc flag, passing it various revisions. Flags are
modified appropriately.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1556

Differential Revision: https://secure.phabricator.com/D3133
2012-08-03 12:00:54 -07:00
Aurelijus
7f4ad7117a JSHint linter issue on windows
Summary: On windows there is no 'which', only 'where'

Test Plan: Run JSHint linter on windows and unix-like system.

Reviewers: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3096
2012-07-30 09:26:37 +02:00
Bob Trahan
333bb09e04 Make arc patch show the superior error message if you are not authenticated
Summary: ...by making requireAuthentication return true if conduit is required.

Test Plan: mv ~/.arcrc ~/.arcrcbak; arc patch D12121; <verify error message>

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1522

Differential Revision: https://secure.phabricator.com/D3014
2012-07-29 11:57:36 -07:00
Grigory
414e1e3e40 Added support for 'hg export' diff format
Summary: This diff format is used by de-facto mercurial GUI called "TortoiseHG".
It is available as the only way to copy diff into clipboard (right click commit,
select "export", select "copy patch". I added this format support into arcanist
so revisions in Differential can be created from TortoiseHG via simple copy-
paste. Unit test added, manually tested.

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

Reviewed by: epriestley
2012-07-26 10:08:49 -07:00
epriestley
8d9e1d8479 Minor, improve behavior of arc get-config. 2012-07-25 20:14:38 -07:00
Nick Harper
8e00d3cfaf Allow hyphens in arc library names
Summary:
We've had these in our library names and they're quite useful as word
separators. Allowing them shouldn't cause any trouble.

Test Plan:
ran arc liberate in an empty directory, and it didn't complain when I gave
it a name with a hyphen.

Reviewers: epriestley, vrana, jungejason

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3070
2012-07-25 18:37:25 -07:00
epriestley
768a125b58 Enrich arc configuration and add stronger typing
Summary:
See <https://github.com/facebook/arcanist/issues/45>

Currently, when the user types `arc set-config x false`, we set it as the string "false", which is usually not desirable. We have some steps toward typed config already, but expand on what we have and move as much stuff as possible into it, including all the config settings that aren't currently documented (there are still some lint-specific and project-specific settings not present here, but this is most of it).

Also make the `phutil_libraries` key a legacy name for `load`, and `immutable_history` a legacy name for `history.immutable`. Generally the goal here is to make config simpler and bring it more in-line with Git/Mercurial, which use dotted hierarchies.

I'll add some documentation here but I think most of the changes should be fairly straightforward.

Test Plan:
  - `arc set-config history.immutable on` (And similar -- sets to boolean true.)
  - `arc set-config history.immutable off` (And similar -- sets to boolean false.)
  - `arc set-config history.immutable derp` (And similar -- raises exception.)
  - `arc set-config history.immutable ''` (And similar -- removes setting value.)
  - `arc set-config --show`
  - `arc get-config`
  - `arc get-config base`

Reviewers: dschleimer, bos, btrahan, vrana

Reviewed By: dschleimer

CC: aran

Maniphest Tasks: T1546

Differential Revision: https://secure.phabricator.com/D3045
2012-07-25 18:37:09 -07:00
epriestley
11d0331d21 Fix parsing of "hg diff -r x:y" diffs
Summary: When you run `hg diff -r x:y`, we get two "-r" arguments in the diff header. Currently, we parse this incorrectly.

Test Plan: Added unit test which previously failed; test now passes.

Reviewers: dschleimer, btrahan

Reviewed By: dschleimer

CC: aran, cakoose

Maniphest Tasks: T1550

Differential Revision: https://secure.phabricator.com/D3061
2012-07-25 15:55:32 -07:00