1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-20 17:09:01 +02:00
Commit graph

829 commits

Author SHA1 Message Date
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
Alan Huang
316122c4e0 Create a mysterious new workflow
Summary:
Phabricator, as we all know, is marketed as a fun adventure game. However, while it is occasionally fun and often an adventure, it's so far been sorely deficient in the game aspect. This patch aims to rectify that oversight. (Presence of the first two qualities is not guaranteed.)

Note: In case there's any doubt, this is not a serious suggestion. I was bored.

Test Plan: Seriously?

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3026
2012-07-22 14:39:53 -07:00
vrana
1914bce11e Enable raising lint warnings for mulitple lines at once
Summary:
We have a lint rule checking if some string is too long.
This string can span multiple lines.
If we report a warning at the first line then it is muted if the first line wasn't modified.
We need to say that this whole block is wrong and report it when at least one line from the block was modified.

Test Plan: Changed a lint rule to call `raiseLintAtLines()` and verified that the warning is reported even if the changed line isn't first.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3029
2012-07-22 13:26:44 -07:00
epriestley
d2f0ffac7d Fix ambiguous argument where a branch has the same name as a file
Summary: Currently, if you have a branch named "docs" and a local file named "docs", `git show -s docs` complains because it's ambiguous. Use `--` to unambiguously mark branches as revisions, not files.

Test Plan: Ran `arc branch` in a working copy with a "docs" branch and a "docs" file, got expected results.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3030
2012-07-22 13:19:09 -07:00
epriestley
1e8add9583 Show "Fnnn" number in "arc upload"
Summary: We don't show the "Fnnn" number, but should.

Test Plan:
```$ arc upload README --conduit-uri=http://local.aphront.com:8080/
Uploading 'README'...
  F121 README: http://local.aphront.com:8080/file/data/fnu76irnwftin4akjpxv/PHID-FILE-yrjeblelwq6rv5a5gjko/README

Done.```

Reviewers: phleet, btrahan, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3023
2012-07-21 06:44:21 -07:00
Izzy Fraimow
1a111dc86c Adding confirmation message to 'arc todo' with information about the task created
Summary: 'arc todo' now logs a message with the task title and URI when run.

Test Plan: Run 'arc todo test' and see that it logs a message with the form 'Created task <task number>: '<task title' at <task URI>

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3016
2012-07-19 15:12:12 -07:00
vissi
b28efb8f88 Allow running phpunit tests from any directory
Test Plan: Run `arc unit` anywhere.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D3017
2012-07-19 15:00:56 -07:00
Rafik Salama
6e2016b47b Specify error message for some pyflakes messages 2012-07-19 10:40:31 -07:00
vrana
cd2f8edb83 Speedup arc branch
Summary:
This reduces time of `arc branch` from 13s to 7s in my repo which is faster than `git branch --verbose` (10s).

The price for this speedup is that we loose the information [ahead 1, behind 21242] but we showed it only in branches with no revision so it's not a big deal.

Test Plan:
  $ arc branch

Reviewers: epriestley

Reviewed By: epriestley

CC: ahupp, aran, Korvin

Differential Revision: https://secure.phabricator.com/D3005
2012-07-18 18:01:44 -07:00
epriestley
9997dd7830 Fix arc handling of "\n" files on Windows in SVN
Summary:
On Windows, a diff may have "\n" newlines (from the file itself) but "\r\n" blocks (from svn).

NOTE: indents are funky since I edited this with Notepad++, I'll fix before landing.

Test Plan: Diffed an edit to a "\n" newline file on Windows in SVN.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2998
2012-07-18 06:53:07 -07:00
epriestley
f649837785 Dump problematic parser patches to temp files in "arc diff"
Summary: I'm trying to get a repro for a Windows + SVN patch issue. Dump patches which fail to a temp file so there's less bewilderment in getting the right patch handed over for analysis.

Test Plan: Forced a parse failure, ran "arc diff", inspected temp file.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2997
2012-07-17 16:16:18 -07:00
epriestley
802c0ed89f Fix some arc/mercurial issues
Summary:
  - In "arc which", we recommend "--rev x --rev ." to show changes. This is not accurate if there are uncommitted changes in the working copy. Just "--rev x" shows the correct changes (implicitly, the other end of the range is the working copy state).
  - When you diff only working copy changes, we currently incorrectly identify all your open revisions as belonging to the working copy. Instead, correctly identify none of them as belonging to the working copy (in theory, we could go farther than this and do path-based identification like SVN, but with --amend in hg 2.2+ this workflow should be going away in the long run).
  - If you have uncommitted working copy changes, never try to amend.

Test Plan: Ran "arc which .", "arc diff ." in a working copy with dirty changes, got better results than before.

Reviewers: dschleimer, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1507

Differential Revision: https://secure.phabricator.com/D2980
2012-07-17 16:16:11 -07:00
epriestley
cb56743521 Improve Arcanist + Windows + SVN compatibility
Summary: From "cmd.exe" with, e.g. SilkSVN, there are some issues getting arc to do anything useful. Resolve enough of them so that it's at least usable.

Test Plan: Created a revision from Windows / cmd.exe / arc / SVN.

Reviewers: btrahan, jungejason, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2984
2012-07-16 17:28:13 -07:00
Andrew Gallagher
19e718a267 arcanist: add postponed linter support
Summary:
This uses a similiar approach as with postponed unittests, allowing
the lint workflow/engine to report postponed linter names.  After
the lint engine is run, a separate method is used to collect any
postponed linters and these are reposted to the diff via the
"arc:lint-postponed" property.

Also, a ##diff.wasCreated## was added allowing hooks to be called
immediately after the call ##differential.creatediff## with the
returned diff ID.

Test Plan:
Created diffs with a dummy lint engine which always reports a
postponed linter.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1332

Differential Revision: https://secure.phabricator.com/D2933
2012-07-11 18:09:05 -07:00
epriestley
daa210022d Fix "arc branch" performance regression
Summary: See discussion in T1467. This `log` logs everything in the repo. The old command was `show -s`, I just unthinkingly converted it and it doesn't matter for non-Facebook-sized repositories.

Test Plan: Ran "arc branch".

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1467

Differential Revision: https://secure.phabricator.com/D2963
2012-07-11 16:55:29 -07:00
epriestley
1b4205c1a1 Support an 'editor' config in arc
Summary: See D2955. Allow "arc set-config editor ..." to override all other editor settings.

Test Plan: Ran "arc set-config editor 'mate -w'", am typing this in textmate.

Reviewers: btrahan, ezfoxie

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1309

Differential Revision: https://secure.phabricator.com/D2956
2012-07-11 16:55:11 -07:00
Alan Huang
1f65a115cc Create an arc todo workflow for quickly creating a task.
Summary:
Run `arc todo o rly?` to create a Maniphest task
titled 'o rly?'. Pass --cc to add CCs besides yourself.

Test Plan: Ran `arc todo o rly?`. Behaved as expected.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T749, T1325

Differential Revision: https://secure.phabricator.com/D2952
2012-07-10 17:32:36 -07:00
Jason Ge
178b7346a1 Support invalid commit message in "arc branch"
Summary:
when a commit message contains error which fails the parsing, we 'arc branch' fails. One sample commit message we saw contains

  Differential Revision: 363812, 367983, 370452

The author manually committed the code without a real revision.

Test Plan: ran on the repo with problem commit and it succeeded.

Reviewers: epriestley

Reviewed By: epriestley

CC: malmond, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2944
2012-07-09 12:32:02 -07:00
Jason Ge
f9415e37d0 Use binary safe diff in arc diff
Summary: Otherwise svn diff fails when the file is binary but the "svn:mime-type = application/x-shellscript" is missing in it.

Test Plan: arc diff succeeded against deleting a binary file which doesn't have svn:mime-type = application/x-shellscript.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2915
2012-07-03 13:33:28 -07:00
epriestley
6366464202 Minor, stop arc upgrade from prompting for commit ranges. 2012-07-02 19:50:35 -07:00
epriestley
d3313e3fd7 Minor, don't explode when mbstring is missing and don't do utf8-to-utf8 conversions. 2012-07-02 19:34:59 -07:00
epriestley
563230b0fb Implement "arc:amended" and fix various problems with ArcanistMercurialAPI
Summary:
  - Implement "arc:amended", a base commit DSL rule which always selects HEAD (git) or `.` (hg) if it has "differential revision:" in the commit message. This is unambiguously correct in amend workflows, and can cover holes in other rules like "git:branch-unique(*)".
  - Fix a bunch of Mercurial stuff:
    - Our use of '.' is wrong, and based on a misunderstanding on my part of the behavior of `hg diff --rev . --rev .`, which means "ignore the second --rev flag", not ". means working directory state". As far as I know there's no explicit way to say "the working copy plus all its changes".
    - The `--prune` argument to "hg log" does not support symbolic names like ".^". Use revsets instead.
    - Reduce the number of times we need to run `hg branch`.
    - We can safely use "." to mean "the working copy revision", and do not need to do "hg --debug id" or similar.
    - Generally simplify some of the nonsense in the implementation left over from me having no idea how Mercurial works.

Test Plan:
Ran "arc which" in various scenarios in a mercurial working copy. I //think// I exercised all the changes.

Ran "arc which --base arc:amended" in hg and git working copies without "Differential Revision:" in head/. (no match) and with it (matched head/.).

Reviewers: dschleimer

Reviewed By: dschleimer

CC: Makinde, tido, phleet, aran

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2876
2012-07-01 11:06:05 -07:00
dschleimer
470e2eca67 [Arcanist] collect svn and bookmark info for Mercurial
Summary:
This increases the amount of information arc diff collects in
Mercurial repositories.  IN particular, it collects the active
bookmark, if there is one, and svn information in hgsubversion
repositories.

The Phabricator half of this is https://secure.phabricator.com/D2897

Test Plan:
[14:06:59 Sat Jun 30 2012] dschleimer@dev4022.snc6 ~/www-hg
www-hg  2941 $ ~/devtools/arcanist/bin/arc diff --only --conduit-uri http://phabricator.dschleimer.dev4022.facebook.com
HipHop Notice:  Undefined index: 1 in /data/users/dschleimer/devtools/arcanist/src/repository/api/ArcanistMercurialAPI.php on line 708
Created a new Differential diff:
        Diff URI: http://phabricator.dschleimer.dev4022.facebook.com/differential/diff/126/

Included changes:
  A       foo
HipHop Notice:  Undefined index: 1 in /data/users/dschleimer/www-hg/lib/arcanist/arcanist/FacebookArcanistConfiguration.php on line 81
mcproxy on this server is out of date
version: , expected version:
please restart (http://fburl.com/1787362)

[14:07:46 Sat Jun 30 2012] dschleimer@dev4022.snc6 ~/www-hg
www-hg  2941 $ echo '{"diff_id": 126}' | ~/devtools/arcanist/bin/arc call-conduit differential.getdiff --conduit-uri http://phabricator.dschleimer.dev4022.facebook.com | json_pretty | egrep -i 'bookmark|sourcecontrol'
        "bookmark": "bar",
        "sourceControlBaseRevision": "svn+ssh://tubbs/svnroot/tfb/trunk/www@583442",
        "sourceControlPath": "svn+ssh://tubbs/svnroot/tfb/trunk/www",
        "sourceControlSystem": "hg",

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1331

Differential Revision: https://secure.phabricator.com/D2896
2012-06-30 16:00:48 -07:00
epriestley
9c33c7330c Support "D123", not just "123", for "arc export --revision"
Summary: We currently error if a user types "--revision D123".

Test Plan: `arc export --git --revision D123`, got a diff.

Reviewers: vrana, jungejason

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2880
2012-06-27 18:33:28 -07:00
epriestley
98b3dfda3b Implement "git:branch-unique(*)" in the base commit DSL
Summary:
Add a DSL command to select the first commit between HEAD and (the merge-base of some target with HEAD) that's on more than one branch.

This is similar to @csilvers' suggestion in <https://secure.phabricator.com/T1233#comment-8>. A specific problem this address is that, currently, if you use this workflow:

  $ git checkout -b feature
  $ git commit
  $ git checkout -b subfeature
  $ git commit

..i.e., develop dependent features in sub-branches, "arc diff" will try to send up (feature + subfeature). If you use the rule 'git:branch-unique(origin/master)' instead, diffing from 'subfeature' will correctly select only the commit(s) on 'subfeature'.

Test Plan: Constructed feature/subfeature branches, verified that we select the correct base commit.

Reviewers: dschleimer, csilvers, btrahan, jungejason

Reviewed By: dschleimer

CC: aran

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2866
2012-06-27 12:12:39 -07:00
vrana
33e53a2852 Add newline 2012-06-27 11:21:24 -07:00
epriestley
a235a041e5 Remove PhutilModuleRequirements
Summary: Yeah, we can nuke this.

Test Plan: Grepped for callsites.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2871
2012-06-26 18:22:36 -07:00
dschleimer
9edff28999 [Arcanist] add an arc:bookmark base for Mercurial
Summary:
This adds a new base option that Does the Right Thing (or as close to
it as I can get) for someone using Mercurial bookmarks as lightweight
branches, and where each branch should be one differential revision.
Specifically, it walks backwards through the ancestors of the working
copy until it finds a revision that is either not outgoing (ie already
in the remote) or that is bookmarked.  This means that bookmarks
effectively act as delimiters, and point at the last revision that
will be included in an arc diff.

Test Plan:
[14:40:54 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ hg log -r '(first(outgoing())^)::' --template='node: {node}\nbookmark: {bookmarks}\n\n' -G
@  node: c8379ef32b0d0e6cf94fe636751ea4fe1353e157
|  bookmark:
|
| o  node: 14f03139049cbda339190b814e52f4ec8b05c431
| |  bookmark: more
| |
| o  node: 6970e9263ab8c6da428420606d1f15c9980da183
| |  bookmark: something
| |
| o  node: 433a93023f03d5f3eddaa243fa973d32a1566aee
|/   bookmark:
|
o  node: f47ccfe34267592dd2e336174a3a311b8783c024
|  bookmark:
|

[14:41:00 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:bookmark'
f47ccfe34267592dd2e336174a3a311b8783c024

[14:41:05 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ hg up 14f03139049cbda339190b814e52f4ec8b05c431
3 files updated, 0 files merged, 1 files removed, 0 files unresolved

[14:41:10 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:bookmark'
6970e9263ab8c6da428420606d1f15c9980da183

[14:41:14 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ hg up 6970e9263ab8c6da428420606d1f15c9980da183
0 files updated, 0 files merged, 1 files removed, 0 files unresolved

[14:41:44 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1227 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:bookmark'
f47ccfe34267592dd2e336174a3a311b8783c024

Reviewers: epriestley, bos

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1331

Differential Revision: https://secure.phabricator.com/D2863
2012-06-26 15:04:35 -07:00
vrana
31e36fe3fa Require space after //
Summary:
I use `//~` for marking places which shouldn't be committed.
It also looks ugly.
Maybe it can be just a warning but we provide a patch so error is OK?

Test Plan: New test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2824
2012-06-26 14:12:17 -07:00
epriestley
d724ed0860 Minor, always show the current branch in "arc branch" 2012-06-26 12:45:47 -07:00
epriestley
67956306cb Remove all libphutil v1 support
Summary:
Delete all code related to v1 libraries in arcanist.

When users liberate a v1 library, prompt them to upgrade.

Test Plan: Reverted phabricator/ to a couple of months ago and liberated it. Got prompted to upgrade. Upgraded.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2861
2012-06-26 12:40:42 -07:00
epriestley
5b1a00eab1 Add various flags to the HgProxy daemons
Summary:
  - Add flags to exit after an idle time or client count.
  - Add flags to control daemonization.
  - Add flags to control output.
  - Add flags to skip the "hello" frame of the protocol.
  - Make the client launch a server if one does not exist.

The one-time overhead to launch a server and run a command through it looks to be ~130% of the overhead to run the command directly with "hg", so even if we never run a second command we're not paying too much.

The incremental overhead to run subsequent command appears to be less than 3% of the overhead to run the command directly with "hg" (and maybe less than 1%, I'm not sure how long the computation part of a command like 'hg log' "actually" takes).

The overhead to launch a PHP client, connect to an existing server, run a command, and then print it and exit is roughly 50% of the overhead to run the command directly with "hg". So theoretically a user can achieve an amortized 2x performance increase for all 'hg' commands by aliasing 'hg' to the PHP client in their shell.

Test Plan:
  - Ran servers with idle and client count limits, let them idle and/or hit their connection limits, saw them exit.
  - Ran foreground and background servers.
  - Ran a daemon server with redirected stdout/stderr. Verified logs appeared.
  - Ran with --quiet.
  - Ran clients and servers with and without --skip-hello, things work if they agree and break if they disagree. The throughput gain on this is fairly small (maybe 5%?) but it seems simple enough to keep for the moment.
  - Ran serverless clients and verified that servers launched the first time, were available subsequently, and relaunched after 15 seconds idle.

Reviewers: csilvers, vrana, btrahan

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2680
2012-06-26 11:00:26 -07:00
epriestley
69246b282d Simplify "arc branch" and make it work in immutable history repositories
Summary:
  - Move "arc branch"-specific code to the branch workflow.
  - Instead of doing "git rev-parse", just do "git branch --verbose --abbrev=40".
  - Use revision owners to identify ownership, not working copy identity. Particularly with the advent of "Commandeer", you might not own commits you made.
  - Do a batch lookup for commits by hash (depends on D2859, but doesn't break without it).
  - Use PhutilConsole for console stuff.
  - Removed color from "arc list" for the moment.
  - The "--by-status" flag has a slightly different output format now.

Test Plan: Ran "arc branch" in various circumstances, verified it identifies branches in immutable history repositories.

Reviewers: btrahan, vrana, jungejason, nh, slawekbiel

Reviewed By: slawekbiel

CC: aran

Maniphest Tasks: T693

Differential Revision: https://secure.phabricator.com/D2860
2012-06-26 10:50:43 -07:00
dschleimer
acf5350221 [Arcanist] fix scratch dir for svn >= 1.7
Summary:
svn 1.7 got rid of the per-direcotry .svn dirs in favor of a single
.svn directory under the root of the working copy.  Unfortunately, we
relied on ther being a .svn directory at the same level as .arcconfig,
which may or may not be at the root of the working copy.  We now walk
up the directory tree until we find a .svn directory that we can use
for scratch files.

Test Plan:
[16:27:52 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ ls -la .arcconfig .svn ../../../.svn/arc/config
ls: .svn: No such file or directory
ls: ../../../.svn/arc/config: No such file or directory
-rw-r--r-- 1 dschleimer users 239 Jun 25 16:15 .arcconfig

[16:27:54 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ ~/devtools/arcanist/bin/arc set-config --local foo bar
Set key 'foo' = 'bar' in local config.

[16:29:40 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ ls -la .arcconfig .svn ../../../.svn/arc/config
ls: .svn: No such file or directory
-rw-r--r-- 1 dschleimer users 239 Jun 25 16:15 .arcconfig
-rw-r--r-- 1 dschleimer users  20 Jun 25 16:29 ../../../.svn/arc/config

[16:29:43 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ cat ../../../.svn/arc/config
{
  "foo" : "bar"
}

[16:29:48 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21299 $ ~/devtools/arcanist/bin/arc get-config foo
(global) foo =
(local) foo = bar

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1411

Differential Revision: https://secure.phabricator.com/D2856
2012-06-25 17:13:29 -07:00
dschleimer
82d05fee9f [arcanist] add system arc config file
Summary:
Adds a system arc config file with precedence below the user config
file, both to ArcanistWorkingCopyIdentity::readConfigFromAnySource()
and to base commit resolution.

Test Plan:
[14:48:45 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist system_config 21245 $ cat /etc/arcconfig
{
    "base": "literal:foobar"
}
[14:52:31 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist system_config 21246 $ ./bin/arc get-config base
(system) base = literal:foobar
(global) base =

[14:52:39 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist system_config 21247 $ ./bin/arc which --show-base --base 'arc:system'
foobar

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2854
2012-06-25 15:14:11 -07:00
Jamie Wong
356cd860e1 Fix help message for arc tasks --status 2012-06-25 17:46:51 -03:00
vrana
1817f929c2 Introduce arc inlines
Summary: This displays all inline comments attached to a revision in a format consumable by editors.

Test Plan: Ran it, opened the file on the line.

Reviewers: epriestley

Reviewed By: epriestley

CC: vii, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2845
2012-06-23 16:01:38 -07:00
vrana
67c772d919 Warn about PHP 5.3 only functions and parameters
Test Plan:
Linted:

  json_decode('{}', true, 1, 1);
  gethostname();

Also linted all Phabricator repositories and found no occurrence.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1158

Differential Revision: https://secure.phabricator.com/D2806
2012-06-22 15:52:10 -07:00
vrana
1708a03f96 Simplify handling errors in PHPCS linter
Test Plan:
  libxml_use_internal_errors(true);
  $report_dom = new DOMDocument();
  $report_dom->loadXML('<a</a>');
  $report_dom = new DOMDocument();
  $report_dom->loadXML('<a></a>');
  $report_dom = new DOMDocument();
  $report_dom->loadXML('');
  print_r(libxml_get_errors());

Reviewers: aurelijus

Reviewed By: aurelijus

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2816
2012-06-22 14:32:48 -07:00
Jamie Wong
e18e4886ba Fix mixing parens on getWorkingCopyIdentity in ArcanistMercurialAPI 2012-06-22 16:25:49 -03:00
epriestley
887c3484a7 Support 'arc:exec(command)' in base-commit DSL
Summary: Allow users to run a command to determine the base revision of the commit range.

Test Plan: Ran stuff like `arc which --show-base --base 'arc:exec(ls)'` and got the expected results.

Reviewers: dschleimer, csilvers, btrahan, vrana

Reviewed By: csilvers

CC: aran

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2830
2012-06-22 08:13:06 -07:00
dschleimer
7f640b9db9 [Arcanist] mercurial base commit DSL support
Summary:
This adds Mercurial support to the base commit DSL that's equivalent
to git's, though not identical.  Specifically, Mercurial has
arc:outgoing instead of arc:upstream, and hg:gca(commit) instead of
git:merge-base(commit), though they have similar behaviors.

Test Plan:
  [13:37:13 Thu Jun 21 2012] dschleimer@dev4022.snc6 ~/hg-dummy
  hg-dummy  20536 $ hg log -G -r master::
  @  changeset:   11:6970e9263ab8
  |  bookmark:    something
  |  tag:         tip
  |  user:        David Schleimer <dschleimer@fb.com>
  |  date:        Thu Jun 21 13:03:46 2012 -0700
  |  summary:     thing
  |
  o  changeset:   10:433a93023f03
  |  parent:      8:f47ccfe34267
  |  user:        David Schleimer <dschleimer@fb.com>
  |  date:        Thu Jun 21 13:03:34 2012 -0700
  |  summary:     some
  |
  | o  changeset:   9:c8379ef32b0d
  |/   bookmark:    other
  |    user:        David Schleimer <dschleimer@fb.com>
  |    date:        Thu Jun 21 13:01:04 2012 -0700
  |    summary:     other
  |
  o  changeset:   8:f47ccfe34267
  |  bookmark:    master
  |  user:        David Schleimer <dschleimer@fb.com>
  |  date:        Mon Jun 04 14:30:47 2012 -0700
  |  summary:     typo-fix
  |

  [13:38:00 Thu Jun 21 2012] dschleimer@dev4022.snc6 ~/hg-dummy
  hg-dummy  20536 $ ~/devtools/arcanist/bin/arc which --show-base --base hg:.^
  .^

  [13:38:11 Thu Jun 21 2012] dschleimer@dev4022.snc6 ~/hg-dummy
  hg-dummy  20536 $ ~/devtools/arcanist/bin/arc which --show-base --base 'hg:gca(other)'
  f47ccfe34267592dd2e336174a3a311b8783c024

  [13:38:21 Thu Jun 21 2012] dschleimer@dev4022.snc6 ~/hg-dummy
  hg-dummy  20536 $ hg id -r f47ccfe34267592dd2e336174a3a311b8783c024
  f47ccfe34267 master

  [13:38:31 Thu Jun 21 2012] dschleimer@dev4022.snc6 ~/hg-dummy
  hg-dummy  20537 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:empty'
  null

  [13:38:44 Thu Jun 21 2012] dschleimer@dev4022.snc6 ~/hg-dummy
  hg-dummy  20538 $ hg id -r null
  000000000000

  [13:38:48 Thu Jun 21 2012] dschleimer@dev4022.snc6 ~/hg-dummy
  hg-dummy  20538 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:outgoing'
  f47ccfe34267592dd2e336174a3a311b8783c024

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2822
2012-06-21 18:12:09 -07:00
vrana
a9dbb937e8 Warn about pht() with non constant string
Summary: We will extract them at some point, lint before it's too late.

Test Plan:
New test.
Linted all callsites.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2825
2012-06-21 18:07:13 -07:00
vrana
22d2d6743d Remove bogus warning in liberate 2012-06-21 11:52:16 -07:00
vrana
7f10b43eca Add example to --ansi 2012-06-21 10:32:28 -07:00
vrana
37b494d974 Move line to a better place 2012-06-20 13:03:06 -07:00
epriestley
1d5a2aff20 Allow the "arc land --onto" default to be read from user config
Summary: Allow the default to be set in global config, not just project config.

Test Plan: `arc set-config arc.land.onto.default derp; arc land`

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2686
2012-06-20 12:29:07 -07:00
vrana
a121313ca4 Document --ansi 2012-06-20 12:23:48 -07:00
vrana
fa54b2ea27 Wrap and simplify diff error excuse
Test Plan: Performed a lint error.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2802
2012-06-19 18:18:01 -07:00
vrana
b2bb06ad0c Use pht() for plural 2012-06-19 15:16:52 -07:00
vrana
450433dbae Use new SVN format for all property changes
Test Plan: `svn diff`

Reviewers: nh

Reviewed By: nh

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2799
2012-06-19 14:21:20 -07:00
vrana
23b3dd7e95 Display number of assertions in unit test details
Test Plan: Show Full Unit Results on this diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2777
2012-06-17 13:39:46 -07:00
epriestley
7c3c1e88bd Add test for "static::" to the PHP 5.3 linter
Summary: See https://github.com/facebook/phabricator/issues/133.

Test Plan: Unit tests.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1158

Differential Revision: https://secure.phabricator.com/D2778
2012-06-17 09:01:47 -07:00
epriestley
f2220e74fc Add a DSL for selecting base commits
Summary:
New optional mode. If you set 'base' in local, project or global config or pass '--base' to 'arc diff' or 'arc which', it switches to DSL mode.

In DSL mode, lists of rules from args, local, project and global config are resolved, in that order. Rules can manipulate the rule machine or resolve into actual commits. Provides support for some 'arc' rules (mostly machine manipulation) and 'git' rules (symbolic ref and merge-base).

Test Plan:
Ran unit tests. Also:

```$ arc which --show-base --base 'arc:prompt'

    Against which commit? HEAD
HEAD
$ arc which --show-base --base 'git:HEAD'
HEAD
$ arc which --show-base --base 'git:fake'
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.
$ arc which --show-base --base 'git:origin/master'
origin/master
$ arc which --show-base --base 'git:upstream'
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.
$ arc which --show-base --base 'literal:derp'
derp
$ arc which --show-base --base 'arc:halt'
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.
$ arc set-config --local base git:origin/master
Set key 'base' = 'git:origin/master' in local config.
$ arc which --show-base
origin/master
$ arc which --show-base --base 'git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:yield, git:HEAD^'
origin/master
$ arc which --show-base --base 'arc:global, git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:global, git:merge-base(origin/master)'
3f4f8992fba8d1f142974da36a82bae900e247c0```

Reviewers: dschleimer, vrana

Reviewed By: dschleimer

CC: aran

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2748
2012-06-15 14:01:28 -07:00
vrana
57499106ec Use pht()
Test Plan: `arc cover`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1139

Differential Revision: https://secure.phabricator.com/D2716
2012-06-14 16:26:11 -07:00
epriestley
4448bd09c7 Call clearstatcache() after changing ~/.arcrc permissions
Summary: Otherwise we'll get a cached result from fileperms() if we end up here again.

Test Plan: `chmod 644 ~/.arcrc ; arc help` no longer double prompts when run from outside of a .arcconfig working copy.

Reviewers: csilvers

Reviewed By: csilvers

CC: aran

Maniphest Tasks: T1359

Differential Revision: https://secure.phabricator.com/D2752
2012-06-14 12:30:21 -07:00
epriestley
c5b7afb344 Move "relativeExplanation" to ArcanistRepositoryAPI with getters/setters
Summary:
We currently use the language "relative commit" or "relative local commit" to refer to the head of a commit range. I want to move toward callign this a "base commit", since I think that makes more sense. This moves us a small step in that direction.

The DSL stuff in T1233 also needs access to this stuff, so move it up to the base. This is mostly a bite-sized piece of the change in that diff.

Test Plan: Ran "arc which" in a couple of circumstances, read explanations.

Reviewers: dschleimer, vrana

Reviewed By: dschleimer

CC: aran

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2747
2012-06-14 12:02:41 -07:00
dschleimer
5089cd7de1 [Arcanist] add a local (per working copy) config file
Summary:
This adds the concept of a local (i.e. working copy local) config file
to arc.  This config file has the highest precedence for config
settings that may come from any config file.  The config is stored in
.(git|hg|sv)/arc/config, and is read ahead of the project config by
getConfigFromAnySource().

Test Plan:
#Testing arc set-config and arc get-config

[16:57:04 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19410 $ ./bin/arc get-config
(global) default = https://phabricator.fb.com/conduit

[16:57:12 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19410 $ ./bin/arc set-config foo bar
Set key 'foo' = 'bar' in global config.

[16:57:23 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19411 $ ./bin/arc get-config
(global) default = https://phabricator.fb.com/conduit
(global) foo = bar

[16:57:26 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19411 $ ./bin/arc set-config --local foo baz
Set key 'foo' = 'baz' in local config.

[16:57:35 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19412 $ ./bin/arc get-config
(global) default = https://phabricator.fb.com/conduit
(global) foo = bar
(local) foo = baz

[16:57:39 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19412 $ ./bin/arc set-config foo ''
Deleted key 'foo' from global config (was 'bar').

[16:57:49 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19413 $ ./bin/arc get-config
(global) default = https://phabricator.fb.com/conduit
(global) foo =
(local) foo = baz

[16:57:51 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19413 $ ./bin/arc set-config --local foo ''
Deleted key 'foo' from local config (was 'baz').

[16:58:05 Tue Jun 12 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19414 $ ./bin/arc get-config
(global) default = https://phabricator.fb.com/conduit

#testing getConfigFromAnySource by means of lint

[11:26:57 Wed Jun 13 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19612 $ ./bin/arc set-config lint.engine BogusLintEngine
Set key 'lint.engine' = 'BogusLintEngine' in global config.

[11:30:04 Wed Jun 13 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19613 $ ./bin/arc set-config --local lint.engine DummyLintEngine
Set key 'lint.engine' = 'DummyLintEngine' in local config.

[11:30:19 Wed Jun 13 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19587 $ ./bin/arc lint
Exception
Failed to load symbol 'DummyLintEngine'. If this symbol was recently added or moved, your library map may be out of date. You can rebuild the map by running 'arc liberate'. For more information, see: http://www.phabricator.com/docs/phabricator/article/libphutil_Libraries_User_Guide.html
(Run with --trace for a full exception trace.)

[11:30:25 Wed Jun 13 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19586 $ ./bin/arc set-config --local lint.engine ''
Deleted key 'lint.engine' from local config (was 'DummyLintEngine').

[11:30:34 Wed Jun 13 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist
arcanist local_config 19587 $ ./bin/arc lint
 OKAY  No lint warnings.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2739
2012-06-13 16:02:29 -07:00
vrana
d93bb5abd4 Use verbatim commit message if it couldn't be parsed
Summary:
We currently remove an invalid user from Reviewers and similar fields and print a note in the template. There are several problems:

# If I only made a typo in the name then it takes some effort to fix this typo and put the name on the original place (this information is lost).
# The notice is almost invisible and most users will just confirm the message without noticing it.
# If I fill the data in the commit message (and not in the template) then I probably want to treat that as authoritative so I want it to be correct.

Test Plan:
`arc diff` with invalid reviewer in commit message.
`arc diff` on empty commit message.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, nh

Differential Revision: https://secure.phabricator.com/D2730
2012-06-12 17:30:13 -07:00
dschleimer
1100e8768a [Arcanist] move scratch directory into the vcs metadata directory
Summary:
Using .arc as the scratch and per-repository configuration directory
has some unfortunate consequenses in the real world.  Among other
things, people forget to .gitignore it so it gets checked in.

Test Plan:
the only thing that seems to use this is the relative commit setting
for git.  This diff consists of 2 commits, one for the .gitignore and
one for everything else.

Comment out the portion of my .git/config that defines the upstream
for the branch.  Run arc diff --only with HEAD^ in
.arc/default-relative-commit.  See that .gitignore is not included in
the resultant diff, that .arc no longer exists, and that .git/arc
exists and has HEAD^ in .git/arc/default-relative-commit.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2725
2012-06-12 12:39:15 -07:00
vrana
6d98ac0e3d Wrap errors in arc diff
Test Plan: Add invalid reviewer in `arc diff`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2727
2012-06-12 12:20:54 -07:00
vrana
7650efc72d Fix lint errors found by Nemo
Test Plan: Ran a script analyzing sources by HPHP.

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2710
2012-06-11 16:27:53 -07:00
Evan Priestley
c4cb7abd9a Merge pull request #37 from phleet/immutable-history-config-from-any-source
Use getConfigFromAnySource when checking for immutable_history
2012-06-11 07:20:18 -07:00
Jamie Wong
0aaa13016c Use getConfigFromAnySource when checking for immutable_history 2012-06-11 10:15:28 -04:00
Jamie Wong
bcbe1737b8 Use .^ instead of HEAD^ for mercurial
Summary:
##arc amend## in a mercurial repo was failing with this message

    Usage Exception: Commit 'HEAD^' is not a valid Mercurial commit identifier.

mercurial's .^ is about the same thing as git's HEAD^

Test Plan:
##arc amend## in a mercurial repo with ##"immutable_history" : "false"## in the
##.arcconfig##.

Reviewers: epriestley

Reviewed By: epriestley

CC: vrana, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2690
2012-06-11 10:00:02 -04:00
vrana
08b53c3803 Pass for phutil test that was expected to fail and skip
Summary:
I just hope that we will not create `ArcanistPhutilTestCaseTestCaseTestCase`.

Also fix a copy/paste error (@edward's this time).

Test Plan: `arc unit`

Reviewers: epriestley

Reviewed By: epriestley

CC: edward, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2692
2012-06-08 14:29:51 -07:00
vrana
6bc4da8c4c Remove support for skipping tests
Summary: Almost revert D2673 but leave the support for 'repeat'.

Test Plan: `arc help unit`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2689
2012-06-08 13:42:12 -07:00
epriestley
1df922b74f Minor, make amendCommit() prototypes match up to avoid E_STRICT. 2012-06-07 19:36:30 -07:00
epriestley
f9d55d809f Rough cut of hgdaemon
Summary:
This need a bunch of work, but is a sort of minimum viable product for the hgdaemon.

The two ProtocolChannels implement the client and server halves of the protocol.

The Server implements the server logic, the Client implements the client logic.

Test Plan: Launched a server and client on the same repo, got hg output in ~2-3ms instead of 100ms+.

Reviewers: csilvers, btrahan, vrana

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2665
2012-06-07 18:23:57 -07:00
vrana
6433f7ff3d Allow skipping unit tests and support 'repeat' workflow arguments
Summary:
We run all tests before deploy but some of them are expected to fail.
We need to skip them.
It can be useful also for someone else.

I don't propagate this to `arc diff` as that would be much more complicated - we would need a new state 'partially skipped'.

The 'path' argument needs to be a file, skipping whole dirs is not supported.
The 'path' argument is in fact engine specific and engines can support format like 'Class::testMethod' but I didn't bother to document it to not confuse people.

Test Plan:
`arc unit --skip test.php`
`arc unit --skip ../src/test.php`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2673
2012-06-07 17:42:49 -07:00
Jamie Wong
1ea5e7e9cf Support mutable history in mercurial for arc diff and arc amend
Summary:
This adds basic support for mutable history for arc diff and arc amend for
mercurial. This is purely opt-in (so it shouldn't affect anyone who doesn't want
this feature) by explicitly setting

    "immutable_history" : false

in arc configuration.

This also fixes another instance of weird behaviour for multiple heads - the
first instance was fixed here:
https://github.com/facebook/arcanist/pull/28

Test Plan:
without "immutable_history" turned on)>

When ##arc diff## produces an update diff, it should list only commits that are
ancestors of the current revision - not ones from other heads.

Reviewers: epriestley

CC: csilvers, aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2654
2012-06-07 15:29:24 -04:00
vrana
52f8f49aef Use project root instead of library root in unit engine 2012-06-05 21:08:59 -07:00
epriestley
d016f81135 Add "--conduit-timeout" to arc and modernize argument parsing
Summary:
We added "repeat" to PhutilArgumentParser a while ago, so we can modernize the rest of the argument parsing (allow multiple --load-phutil-library flags).

Add a "--conduit-timeout" flag to allow users to set the timeout. See D2602.

Test Plan:
  $ arc diff --conduit-timeout=0.01
  Exception
  [cURL/28] <CURLE_OPERATION_TIMEOUTED> The request took too long to complete.
  (Run with --trace for a full exception trace.)
  $ arc diff --conduit-version 33
  Exception
  ERR-BAD-VERSION: Your 'arc' client version is '33', which is newer than the server version, '5'. Upgrade your Phabricator install.
  (Run with --trace for a full exception trace.)
  $ arc diff --conduit-uri http://derp.derp/
  Usage Exception: YOU NEED TO INSTALL A CERTIFICATE TO LOGIN TO PHABRICATOR

  You are trying to connect to 'http://derp.derp/api/' but do not have a certificate installed for this host. Run:

        $ arc install-certificate

  ...to install one.
  $ arc diff --load-phutil-library src --load-phutil-library ../phabricator/src --trace
  Loading phutil library '0' from '/INSECURE/devtools/arcanist/src'...
  Loading phutil library '1' from '/INSECURE/devtools/phabricator/src'...

Reviewers: phleet, vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2603
2012-06-03 08:31:49 -07:00
vrana
35b60d7562 Fix comment 2012-06-02 10:09:23 -07:00
vrana
5d78869de0 Fix context for lint errors at top of file in JSON renderer 2012-06-01 23:43:21 -07:00
vrana
2a99dc8b38 Remove unused variable 2012-06-01 23:33:58 -07:00
vrana
1d9ffce1ec Define interface for lint renderers
Summary:
It makes me nervous.

Also move them to the dir.

Test Plan:
`arc lint`
`arc lint --output json`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2644
2012-06-01 17:35:38 -07:00
vrana
21acd2180e Examine only HEAD in amend workflow
Summary: We don't support `git rebase -i` or other magic in `arc amend` so we can examine just HEAD which we always amend.

Test Plan: `arc amend` on a branch with two commits.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2643
2012-06-01 17:06:23 -07:00
epriestley
c2788c8797 Render chevrons and carets in lint output for messages without "original" text
Summary:
If a message has only "line", or "line" and "char", we don't point out the location in the context block.

When a message includes "line", show chevrons on the line.
When a message includes "line" and "char", show chevrons on the line and a caret on the next line.

Test Plan: Ran regex linters to capture line, line+char, and normal linters to capture everything. Output appeared sane.

Reviewers: csilvers, vrana, btrahan

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2642
2012-06-01 15:53:16 -07:00
vrana
0b45ec30be Move files in Arcanist one level up
Summary:
- `kill_init.php`
- Manually change library map.
- Manually rename `/data/` test dirs.
- [src/lint/linter] `git mv base/ArcanistLinterTestCase.php __tests__/`
- `arc liberate`

Test Plan: Browse around to make sure I like it better, especially `repository/api`, and `workflow`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2637
2012-06-01 11:56:00 -07:00
vrana
29c8ff9ddf Fix arc unit when running from non-root directory
Summary:
`$this->getPaths()` gives us paths relative to repository root.
We resolve them relative to cwd.

Test Plan: [src] `arc unit difference`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2634
2012-06-01 11:19:52 -07:00
vrana
2ba9f34f5c Simplify diff excuses
Summary:
The theory is that lint and unit errors are rare with no false positives.
Our reality is currently different.

This diff removes the question for providing explanation before actually providing it.
I hope that the wording is not confusing.

It also simplifies the code with less copy/paste errors (not me!) potential.

Test Plan:
`arc diff` on code with lint and unit errors.
Repeat with `--excuse .`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin, meitros

Differential Revision: https://secure.phabricator.com/D2631
2012-06-01 09:07:38 -07:00
vrana
693943c1a4 Prime SVN in parallel
Summary: Same as D2629.

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2632
2012-06-01 08:24:45 -07:00
vrana
7148519bbc Run xhpast in parallel
Summary: I wonder if this is not by purpose?

Test Plan: Modified two files, ran `arc lint`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2629
2012-05-31 15:19:35 -07:00
epriestley
9cd098ca01 Add "ArcanistSingleLintEngine" and "ArcanistScriptAndRegexLinter"
Summary:
Request from @csilvers. Allow installs to get most linter features with regexes, configuration and external scripts if they are hesitant to write phutil libraries.

  - Add "ArcanistSingleLintEngine", which implements the smallest possible engine behavior (run one linter on every path).
  - Add "ArcanistScriptAndRegexLinter", which uses a script and a regex to parse lint output from other scripts.

Depends on D2618.

Test Plan:
Basics:

  $ arc set-config lint.engine ArcanistSingleLintEngine
  Set key 'lint.engine' = 'ArcanistSingleLintEngine'.
  $ arc set-config lint.engine.single.linter ArcanistScriptAndRegexLinter
  Set key 'lint.engine.single.linter' = 'ArcanistScriptAndRegexLinter'.
  $ arc set-config linter.scriptandregex.script 'echo derp #'
  Set key 'linter.scriptandregex.script' = 'echo derp #'.
  $ arc set-config linter.scriptandregex.regex '/^(?P<message>.*)$/m'
  Set key 'linter.scriptandregex.regex' = '/^(?P<message>.*)$/m'.
  $ arc lint
  >>> Lint for .arcconfig:

     Error  (S&RX) Lint
      derp

                 1 {
                 2   "project_id" : "arcanist",
                 3   "conduit_uri" : "https://secure.phabricator.com/",

Throw:

  $ arc set-config linter.scriptandregex.regex '/^(?P<throw>.*)$/m'
  Set key 'linter.scriptandregex.regex' = '/^(?P<throw>.*)$/m' (was '/^(?P<message>.*)$/m').
  $ arc lint
  Usage Exception: ArcanistScriptAndRegexLinter: configuration captured a 'throw' named capturing group, 'derp'. Script output:
  derp

Ignore:

  $ arc set-config linter.scriptandregex.regex '/^(?P<ignore>.*)$/m'
  Set key 'linter.scriptandregex.regex' = '/^(?P<ignore>.*)$/m' (was '/^(?P<throw>.*)$/m').
  $ arc lint
   OKAY  No lint warnings.

Severity:

  $ arc set-config linter.scriptandregex.regex '/^(?P<warning>.)(?P<message>.*)$/m'
  Set key 'linter.scriptandregex.regex' = '/^(?P<warning>.)(?P<message>.*)$/m' (was '/^(?P<ignore>.*)$/m').
  $ arc lint
  >>> Lint for src/lint/engine/single/ArcanistSingleLintEngine.php:

     Warning  (S&RX) Lint
      erp

                 1 <?php
                 2
                 3 /*

Reviewers: csilvers, btrahan, vrana

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2619
2012-05-31 12:09:01 -07:00
epriestley
8b7a5157f8 Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.

  - Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
  - Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
  - Add some type checking to "arc set-config".
  - Add "arc set-config --show".

Test Plan:
  - **load**
    - Ran `arc set-config load xxx`, got error about format.
    - Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
    - Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
    - Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
    - Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
    - Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
    - Set `.arcconfig` to point at a bad library, verified hard error.
  - **lint.engine** / **unit.engine**
    - Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
    - Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
  - **--show**
    - Ran `arc set-config --show`.
  - **misc**
    - Ran `arc get-config`.

Reviewers: csilvers, btrahan, vrana

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 11:41:39 -07:00
epriestley
e214ea7b18 Run phutil unit tests in v2 libraries
Summary:
Move away from setModule(), to setPathPrefix(). Also simplify test location/selection.

Depends on D2621.

Test Plan: Ran "arc unit".

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2622
2012-05-31 10:40:35 -07:00
epriestley
d80c4f683e Use ArcanistPhutilLibraryLinter, not ArcanistPhutilModuleLinter
Summary:
  - The library linter works fine on v1 or v2 libraries, so switch to it for all libraries.
  - "arc liberate" on v1 libraries will still invoke the Module linter, and thus generate __init__.php files.

Test Plan: Ran "arc lint". Grepped for module linter.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2620
2012-05-31 10:36:00 -07:00
vrana
5aef938391 Remove unnecessary usages of newv()
Test Plan:
  arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2611
2012-05-30 16:11:27 -07:00
vrana
f288ee0e21 Depend on autoloading
Test Plan:
  arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2609
2012-05-30 16:02:36 -07:00
vrana
94074cbc8c Revert D2306
Summary: We don't use this concept.

Test Plan:
  arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2607
2012-05-30 15:20:25 -07:00
epriestley
71afde1988 Upgrade arcanist to libphutil v2
Summary: Mechanical changes from D2588. No "Class.php" moves yet because they aren't necessary for libraries to function.

Test Plan: See D2588.

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2589
2012-05-30 14:22:59 -07:00
epriestley
a8ddec4f64 Allow "arc liberate" to liberate v2 libraries and upgrade v1 -> v2
Summary:
  - "arc liberate" now works for v1 or v2 libraries.
  - "arc liberate --upgrade" converts a v1 to a v2.
  - We delete __init__.php files but do not move Class.php files, since this is vastly simpler. Authors can do this on their own if they want. We'll do it separately.
  - v2 has less lint support than v1, but I think we can move first and migrate lint support later. Much of the v1 lint is bad anyway.

Test Plan: Upgraded libphutil, arcanist and phabricator to v2

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2588
2012-05-30 14:18:11 -07:00
epriestley
7a4c97f9c3 Recover from all file upload exceptions; add "--skip-binaries" flag
Summary: We recover from Conduit exceptions, but not from transport exceptions or other general classes of error here. Recover from everything, and add an explicit flag to skip uploads.

Test Plan: Added a "throw", created a diff, skiped upload. Removed throw, created a diff with --skip-binaries. Created a diff normally.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2598
2012-05-30 14:11:07 -07:00
epriestley
009e6c4dbf Add "ArcanistPhutilLibraryLinter" to replace "ArcanistPhutilModuleLinter"
Summary:
Adds a linter for v2 libraries which raises the relevant errors.

NOTE: Not hooked up anywhere yet, so this diff has no effect.

Test Plan:
Switched the ModuleLinter to LibraryLinter and ran it with a junk block to trigger errors:

  >>> Lint for src/lint/linter/phutillibrary/ArcanistPhutilLibraryLinter.php:

     Error  (PHL3) One Class Per File
      File 'lint/linter/phutillibrary/ArcanistPhutilLibraryLinter.php' mixes
      function (id) and class/interface (ArcanistPhutilLibraryLinter)
      definitions in the same file. A file which declares a class or an
      interface MUST declare nothing else.

               190 }
               191
               192 if (false) {
               193   function id() { }
               194   new XYZ();
               195 }

     Error  (PHL2) Duplicate Symbol
      Definition of function 'id' in
      'lint/linter/phutillibrary/ArcanistPhutilLibraryLinter.php' in library
      'arcanist' duplicates prior definition in 'utils/utils.php' in library
      'phutil'.

               190 }
               191
               192 if (false) {
               193   function id() { }
               194   new XYZ();
               195 }

     Error  (PHL1) Unknown Symbol
      Use of unknown class 'XYZ'. This symbol is not defined in any loaded
      libphutil library.

               191
               192 if (false) {
               193   function id() { }
               194   new XYZ();
               195 }

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2597
2012-05-30 07:25:09 -07:00
vrana
61b0cfac63 Shorten excuse prompt in arc diff
Test Plan: `arc diff` on a commit with lint error.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2595
2012-05-29 12:59:42 -07:00
Nick Harper
c51590dc1e Provide api to get committed data in a hook
Summary:
We have a linter that needs to read data from the repo that isn't in the commit,
so that data isn't part of the svn transaction, thus not available in svnlook
cat --transaction. This change provides a method to get data from a committed
file.

Test Plan:
Successfully ran arc svn-hook-pre-commit with a linter that needs something
not in the transaction.

Reviewers: epriestley, jungejason, vrana

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2582
2012-05-25 15:28:45 -07:00
vrana
051cbcb8e9 Use phutil_console_prompt() instead of PhutilInteractiveEditor for excuses
Summary:
One line is usually more than enough for these excuses.
The excuse is quite often the same as in past so history is very useful.
Prompting user right below the errors is better than writing them below prompt.

Test Plan:
Produce a lint error.
Provide an empty explanation.
Provide a non-empty explanation.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2580
2012-05-25 11:42:27 -07:00
Evan Priestley
b95aac1421 Merge pull request #34 from aurelijus/phpcs-linter
PHPCS Linter
2012-05-25 06:36:23 -07:00
vrana
3e4d1c6f19 Fix whitespace
I guess that the option does not have 'supports' to allow creating aliases working in all repos.

Auditors: beng
2012-05-25 01:59:43 -07:00
vrana
a089484042 Inform user about current branch in diff
Summary: I am trying to stop using `--verbatim` and miss this information.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2575
2012-05-24 18:13:18 -07:00
vrana
812f7f782d Don't trim spaces in diff template
Summary:
`arc diff` adds a space after each field in template.
It is later removed for the last field.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2564
2012-05-24 11:58:00 -07:00
Evan Priestley
ee41e9c720 Merge pull request #32 from aurelijus/phpunit-simplify-names
Simplify phpunit test names
2012-05-24 07:09:09 -07:00
Aurelijus
1c6f66dab3 PHPCS Linter
Summary:
Simple wrapper for PHP_CodeSniffer.
You need to have PHP_CodeSniffer and it's dependencies installed.

Test Plan: - Try running it with your custom lint engine

Reviewers: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2560
2012-05-24 10:55:46 +02:00
Aurelijus
c5b7c13c7c Filename linter fix for Windows
Summary: On windows paths are separated with \.

Test Plan: - Run filename linter on windows (or some path with \)

Reviewers: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2559
2012-05-24 10:28:11 +02:00
epriestley
fb4f3c9446 Allow users to define shell aliases in arc with "!"
Summary: Git supports this feature (https://git.wiki.kernel.org/index.php/Aliases), it's fairly simple to implement, and gives us a little more ammunition to dissuade users with unusual workflow requirements from actually requesting features.

Test Plan: Defined the alias described in the documentation. Ran "arc ls", "arc ls -alh", etc.

Reviewers: btrahan, csilvers

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2552
2012-05-23 17:52:37 -07:00
Jason Ge
ed7034ab38 Fix arc ArcanistSvnHookPreCommitWorkflow
Summary:
there are two problems making the ArcanistSvnHookPreCommitWorkflow not working.

  - pathExists($path) will always return false because it hasn't loaded the path yet. Because of this, PhutilLintEngine will unset the path at https://secure.phabricator.com/diffusion/ARC/browse/master/src/lint/engine/phutil/PhutilLintEngine.php;032b9b30b0721c3f$46, so ArcanistSvnHookPreCommitWorkflow will have no path to lint against and never detects a problem.
  - In ArcanistSubversionHookAPI::getCurrentFileData(), the $path is already the full path in svnroot (path got from https://secure.phabricator.com/diffusion/ARC/browse/master/src/workflow/svn-hook-pre-commit/ArcanistSvnHookPreCommitWorkflow.php;032b9b30b0721c3f$72). Prepending the project root to it will make the file path to be wrong so that the file content is empty. Again, ArcanistSvnHookPreCommitWorkflow never detects a problem.

Test Plan:
changed --transaction to --revision in related code and manually ran the following command. It detected the syntaxt error correctly. 558937 is a revision with syntax error.

/usr/local/bin/php -f /home/jungejason/nfs_devtools/arcanist/bin/arc svn-hook-pre-commit     --load-phutil-library=/tmp/testwww/www/lib/arcanist --load-phutil-library=/home/jungejason/nfs_devtools/facebook/src /svnroot 558937 2>&1

Reviewers: epriestley, nh

Reviewed By: nh

CC: aran, Girish, Koolvin

Differential Revision: https://secure.phabricator.com/D2485
2012-05-23 16:29:27 -07:00
Nick Harper
2c72779c7d Improve example linter to not lint deleted paths
Summary:
It's easy to forget to do this when writing a new lint engine (like I recently
just did), so I added it to the example to improve documentation on how to write
a lint engine. This code is copied from PhutilLintEngine (as well as many
others).

Test Plan: php -l

Reviewers: jungejason, vrana, epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2553
2012-05-23 14:59:31 -07:00
epriestley
833ae9c152 Remind user about 'arc amend' when they try to land a branch onto itself
Summary: If you develop in "master" and try to "arc land", you get an error. You can reasonably "arc amend" in this situation, most of the time. Give the user an explicit pointer.

Test Plan:
  $ arc land master
  Usage Exception: You can not land a branch onto itself -- you are trying to
  land 'master' onto 'master'. For more information on how to push changes, see
  'Pushing and Closing Revisions' in 'Arcanist User Guide: arc diff' in the
  documentation. You may be able to 'arc amend' instead.

Reviewers: csilvers, btrahan

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2547
2012-05-23 11:55:30 -07:00
Aurelijus
2f3f45614b Simplify phpunit test names
Summary:
More & more use cases come up with empty suite names, guessing
and making test names nice is mess. Will leave it as it is, except
data set part, as it could be super long.

Test Plan: - Try running some phpunit tests with & without data sets

Reviewers: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2544
2012-05-23 11:55:01 +02:00
epriestley
833e8355d8 Add "--reviewers" and "--ccs" flags to arc diff
Summary: Request from @csilvers, whose team is alergic to $EDITOR.

Test Plan:
Adding reviewers and CCs to this diff via CLI. The initial commit message for this diff is:

  Add "--reviewers" and "--ccs" flags to arc diff

  Request from @csilvers, whose team is alergic to $EDITOR.

  Tested: Adding reviewers and CCs to this diff via CLI. The initial commit message for this diff is:
  (...infinite recursion omitted...)

Reviewers: csilvers, btrahan

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2538
2012-05-22 14:38:53 -07:00
epriestley
04606d2833 Improve default fill of Differential messages from commits
Summary:
  - When you run "arc diff" in Mercurial, we currently give you an empty template. Instead, prefill a likely template by parsing messages, as we do for Git.
  - Unify Git and Mercurial logic for acquiring messages, since `getLocalCommitInformation()` now provides this information. This should improve Git performance, and allows us to delete some code.
  - Merge messages more intelligently. Currently, we just overwrite fields. Instead, merge arrays (like ccs, reviewers, tasks) and concatenate strings (like summary and test plan). We need to special case "title", see inline.
  - @csilvers: this is a precursor to implementing "--reviewers", etc.

Test Plan: See next post, test plan includes giant output.

Reviewers: btrahan, csilvers, Makinde, jungejason, vrana

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2536
2012-05-22 11:08:57 -07:00
Aurelijus
6e87de7304 PHPUnit test name handling improvements
Summary:
Better test name handling for tests with data sets.
Instead of showing test name with full data set, show it's id/name,
e.g. `testConstructor with data set #1`

Test Plan: - Try running tests with data sets

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2535
2012-05-22 09:13:43 -07:00
Aurelijus
4f739014ae PHPUnit test engine
Summary:
PHPUnit wrapper for arc.
The idea here is simple - find the test case which is related to the updated
class file. Generate tmp files for json & clover reports, run phpunit
with provided arguments.
It supports phpunit configuration file setting in `.arcconfig`: `phpunit_config`.
Path should be relative to project root.

Test Plan:
- Set `unit_engine` to `PhpunitTestEngine`
- Try running tests with & without `phpunit_config` option.

Reviewers: epriestley, davidreuss

Reviewed By: epriestley

CC: aran, Koolvin, jungejason

Differential Revision: https://secure.phabricator.com/D2472
2012-05-22 07:12:03 -07:00
epriestley
ccdf9ae957 Bump Conduit client version
Summary:
Several related changes:

  - Add a "--conduit-version" flag, so you can actually diff conduit version bumps. Otherwise, the server rejects you.
  - Make "arc upgrade" upgrade both libphutil and arcanist, not just arcanist.
  - Bump the version number to 5. See D2527.

Test Plan:
  - Ran "arc upgrade".
  - Ran "arc diff". Got told there was a version issue.
  - Ran "arc diff --conduit-version=4" to create this diff.

Reviewers: indiefan, nh, vrana, btrahan, jungejason, Makinde

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2528
2012-05-21 16:45:03 -07:00
epriestley
3e655e7d4c Dispatch a "diff.willBuildMessage" event from Arcanist
Summary:
Hive has custom integration which relies on prefilling a bunch of information from JIRA. This is currently broken and accomplished in a roundabout way. Instead, add an event that the integration can listen for. See next diff.

@Girish, I guess you're official Phabricator/Hive support now?

Test Plan: Ran the Hive/JIRA workflows in Git and SVN, see next diff.

Reviewers: Girish, btrahan, ashutoshc

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1206

Differential Revision: https://secure.phabricator.com/D2449
2012-05-20 16:39:38 -07:00
vrana
d23d2df7e1 Say until when the reviewers are away
Test Plan: `arc diff` with reviewers away.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2496
2012-05-19 13:11:54 -07:00
vrana
a5c6f32a06 Warn user about specifying reviewers that are away
Summary:
There are different options how to implement this:
We can also generate the warning in `validateField()` and handle it in all callsites.
This is sufficient for me and simple enough.

Test Plan: `arc diff` revision with reviewer away/not away.

Reviewers: btrahan, jungejason

Reviewed By: jungejason

CC: epriestley, aran

Differential Revision: https://secure.phabricator.com/D2493
2012-05-18 00:04:29 -07:00
Jamie Wong
92819458b8 Make arc diff work with multiple heads in hg 2012-05-17 13:07:53 -04:00
Jamie Wong
b8fb074dcf Make arc diff not crash on hg bookmarks 2012-05-16 13:24:30 -04:00
Nick Harper
032b9b30b0 Provide user-friendly error in arc diff --update
Summary:
If you forget to provide an argument for --update and have another argument
following it (e.g. HEAD^), we should provide a nice error message instead
of passing that argument through to a conduit call and then printing the
conduit error.

Test Plan: ran 'arc diff --update HEAD^' and got a nice error message

Reviewers: epriestley, jungejason, vrana

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2468
2012-05-11 19:10:20 -07:00
epriestley
a31fc544c8 Fix "local commits" for Git and Mercurial to align with user expectations, and fix a parsing bug
Summary:
  - "git log" still includes "\n", so we're currently generating nonsense hashes like "\nabd9879bab86ad78ab...".
  - Correct the log range we use in Git. See comment. When users perform merges, their expectations about what the "included commits" and what the included changes are are different. Represent them with two different ranges.
  - Same deal for Mercurial

Test Plan: Ran "arc which" in various contexts.

Reviewers: btrahan, aurelijus, Makinde

Reviewed By: Makinde

CC: aran, nh, jungejason

Maniphest Tasks: T873

Differential Revision: https://secure.phabricator.com/D2460
2012-05-11 13:52:14 -07:00
epriestley
e50ea62271 Make "arc which" really really really verbose
Summary: Provide far more information about what "arc diff" intends to do.

Test Plan: Ran "arc which" in a variety of circumstances.

Reviewers: btrahan, Makinde

Reviewed By: Makinde

CC: aran

Maniphest Tasks: T1183

Differential Revision: https://secure.phabricator.com/D2454
2012-05-11 06:07:33 -07:00
Nick Harper
97262085b7 Remove arc export's dependency on a working copy when using --diff
Summary:
When getting an encoding, we should query the server for the encoding of the
project that we're exporting from, not the project that we're running arc in
(arc might not be in a working copy).

Test Plan: ran arc export with --diff and didn't get a workflow exception

Reviewers: epriestley, jungejason, vrana, davidreuss

Reviewed By: jungejason

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2455
2012-05-10 17:44:42 -07:00
epriestley
86ead1b8f1 arc land: add --delete-remote, raise an error for landing a branch onto itself
Summary:
  - Allow users to delete the remote copy of a feature branch as well as the local one, for workflows that push feature branches. We test if the remote exists before trying to delete it.
  - Raise a better warning when you misuse "arc land".
  - I also wrote some documentation about this, see next diff.

Test Plan:
  - Tried to land a branch onto itself.
  - Ran "arc land --delete-remote" on feature branches with and without remote feature branches.

Reviewers: aurelijus, btrahan

Reviewed By: aurelijus

CC: aran

Maniphest Tasks: T1204

Differential Revision: https://secure.phabricator.com/D2445
2012-05-10 12:14:53 -07:00
epriestley
9d5c5f6310 Fix 'rev' index error for Mercurial
Summary: I renamed this in D2437 for greater consistency with everything else, but missed this use of the old key.

Test Plan: idk lmk?

Reviewers: Makinde

Reviewed By: Makinde

CC: aran

Differential Revision: https://secure.phabricator.com/D2452
2012-05-10 11:43:21 -07:00
epriestley
53161a1b84 Ship complete commit messages to Phabricator from Arcanist
Summary: Currently, we ship only the summary, but we need to ship the whole thing for T1189.

Test Plan: Added var_dump() + die, ran in git and hg working copies, verified 'message' included the whole message.

Reviewers: csilvers, btrahan, Makinde

Reviewed By: csilvers

CC: aran

Maniphest Tasks: T1189

Differential Revision: https://secure.phabricator.com/D2437
2012-05-09 15:56:16 -07:00
epriestley
19aa759f39 "arc upgrade", to automatically upgrade arc (client changes)
Summary:
  - Try to limit the pain of //future// version bumps by making arc self-updating.
  - When the server needs a newer version, prompt the user to update.
  - (We need them to reissue their command because we may already have loaded classes which have changed in the update.)
  - Make the message sound exciting!

Test Plan: Artifically bumped server forward, ran "arc list", got to upgrade!

Reviewers: Makinde, nh, jungejason, btrahan

Reviewed By: nh

CC: aran

Differential Revision: https://secure.phabricator.com/D2435
2012-05-09 10:01:31 -07:00
Nick Harper
b34915020e Catch ArcanistUsageException when getting git parent log info
Summary:
ArcanistDiffWorkflow::getGitParentLogInfo() calls
ArcanistDifferentialCommitMessage::newFromRawCorpus() which may throw a
ArcanistUsageException if the parent commit message is malformed (specifically,
a bad "Differential Revision:" line); this should not stop arc diff.

Test Plan: successfully ran arc diff where the parent commit message was malformed.

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2434
2012-05-08 17:32:54 -07:00
Nick Harper
b8b4082efd Allow --verbatim and -m in arc diff
Summary:
There's no reason these should be exclusive: -m is used only on update for the
update message, and --verbatim doesn't affect the udpate message. It's also
useful to allow both of these, if say I want to update my test plan by editing
my git commit message and also provide a message for the update from the
command line.

Test Plan:
ran arc diff with --verbatim and -m and saw my message from -m was used, as
well as my updates in the commit message went through.

Reviewers: jungejason, epriestley, vrana

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2426
2012-05-07 17:32:21 -07:00
epriestley
5c684594d4 Allow 'arc' to run without '.arcconfig'
Summary:
This is mostly an onboarding thing, but also allows "arc upload", "arc download", and "arc paste" to work anywhere on the system.

  - Try to read the Phabricator install URI from arc global config if we can't find ".arcconfig".
  - Build a WorkingCopy anyway if we can't find ".arcconfig", as long as we can find ".svn", ".git", or ".hg".
  - Make all the workflows handle "no project ID" at least somewhat gracefully.

Test Plan:
  - Ran "arc diff" in .arcconfig-less Mercurial, Git, and Subversion working copies.
  - Ran "arc upload" and "arc download" from my desktop.
  - Ran "arc paste" from somewhere random.
  - Cleared my config and hit the error, got useful instructions.

Reviewers: btrahan, csilvers

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2424
2012-05-07 15:24:58 -07:00
epriestley
9063cfbdba Provide more context in "arc diff" messages in Git
Summary: These are the unambiguously-good changes from D2388. Show commits included in a revision in the editor in "arc diff".

Test Plan: Ran "arc diff", saw which commits were being included.

Reviewers: nh, jungejason, vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1183

Differential Revision: https://secure.phabricator.com/D2406
2012-05-07 13:18:16 -07:00
Nick Harper
6fcd2db646 Always use git.default-relative-commit, if present
Summary:
Always use the value in git.default-relative-commit when getting the relative
commit in git.

Test Plan:
Ran arc diff in a repo with git.default-relative-commit set to HEAD^ on a
branch tracking a remote (that is different from HEAD^), and checked that
the diff against HEAD^, not the remote, was published.

Reviewers: jungejason, epriestley, vrana

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2409
2012-05-07 09:54:47 -07:00
epriestley
0253bb9475 With --verbatim, update some fields automatically when updating revisions
Summary:
Essentially D2391, but with, uh, more comments?

  - I forgot that we already implemented shouldOverwriteWhenCommitMessageIsEdited(). This patch already behaves nearly correctly.
  - Requires changes in D2412.
  - Use `'edit' => 'edit'`, which does the same thing as `'edit' => true`, but is more correct after the "edit" / "create" split.
  - Under "--verbatim", always get the message "from the user", which means "from the working copy" because verbtatim disables the editor part.

Test Plan:
      - Created and updated revisions with `arc diff`.
      - Created and updated revisions with `arc diff --verbatim`.
      - Updated revisions with `arc diff --edit`.

Reviewers: jungejason, btrahan

Reviewed By: jungejason

CC: vrana, aran

Differential Revision: https://secure.phabricator.com/D2411
2012-05-07 08:16:29 -07:00
epriestley
d40a30f10f Finish "Committed" -> "Closed" changes
Summary:
Clean up the remaining odds-and-ends here -- move to "differential.close", get rid of the old constant, etc.

I'll wait a week or two to land this since "differential.close" just landed and all the other stuff is trivial.

Test Plan: Grepped for "committed".

Reviewers: btrahan, vrana, Makinde

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T909, T1182

Differential Revision: https://secure.phabricator.com/D2309
2012-05-07 08:16:14 -07:00
epriestley
9f3a0963cb Add "arc get-config" and "arc set-config" for managing ~/.arcrc values
Summary:
The major thing I want to do here is allow you to set a default Phabricator URI, so we can make "arc paste", and "arc upload", "arc download" work anywhere.

We can also relax the .arcconfig requirements (request from @csilvers).

Test Plan:
Get/set some values?

iiam

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2400
2012-05-07 06:07:23 -07:00
epriestley
b2dc11940f Clean up some "arc" edge cases in Mercurial
Summary:
  - We no longer need color options since we fake our way through parsing ANSI colorized diffs and use HGPLAIN (on Windows, too!). Drop 'em.
  - In the case where you have nothing outgoing, we don't cache the relative commit and thus run "hg outgoing" too many times, which is fairly slow (even if you have nothing outgoing). Cache it.

Test Plan: Ran "arc diff --trace" in a mercurial working copy with nothing outgoing; verified we run "hg outgoing" only once.

Reviewers: Makinde, csilvers, btrahan

Reviewed By: Makinde

CC: aran

Differential Revision: https://secure.phabricator.com/D2399
2012-05-04 15:46:10 -07:00
vrana
b77c379441 Document first line behavior in update message
Test Plan: (This diff)

Reviewers: epriestley, jungejason

Reviewed By: jungejason

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2389
2012-05-04 13:00:21 -07:00
vrana
299c673b7c Don't ask user to use saved message in arc diff --verbatim
Test Plan:
Cancel `arc diff`.
Verify that the message is created.
Run `arc diff --verbatim` and see no reuse message question.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2390
2012-05-04 12:56:31 -07:00
vrana
4d1e5b1b74 Warn before parse errors in arc diff --verbatim
Summary: With `--verbatim` flag, notes created from parse errors are never displayed to user resulting in blank fields.

Test Plan:
- `arc diff --verbatim` with invalid Cc
- `arc diff --verbatim` with all fields correct

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2395
2012-05-04 12:42:51 -07:00
Marke Hallowell
4645204c11 Updated arc land workflow to use temp file approach for messages to avoid newline escaping issue in windows.
Test Plan: Ran arc land locally with both the mutable default option and with the --merge flag to ensure that messages are set properly.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2372
2012-05-02 16:48:49 -07:00
epriestley
52e08cc6c5 Fix "HGPLAIN" environmental variable in Windows
Summary: In Windows, you can't use `X=y cmd` syntax to set variables. Use "set X=y & cmd" instead.

Test Plan:
  - Ran "arc diff" in a Mercurial repo in Windows, created D2367.
  - Verified this does //not// cause 'HGPLAIN' to be set in the outer shell (where you type "arc diff").

Reviewers: Makinde, tido, indiefan, btrahan

Reviewed By: tido

CC: aran

Maniphest Tasks: T1179

Differential Revision: https://secure.phabricator.com/D2368
2012-05-02 12:40:02 -07:00
Marke Hallowell
9a718f210a Using a temp file for git commit --amend instead of passing multi-line message to the shell. Avoids escaping issue on windows.
Test Plan: Run arc diff locally, verify via git log that the commit is amended afterwards (using the mutable history paradigm)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2369
2012-05-02 12:39:46 -07:00
epriestley
47ed2aca95 Don't check working copy status for "arc commit --show"
Summary:
We do unnecessary working copy checks under "--show", even though the working copy isn't relevant.

Also, 'sourcePath' may not be set (e.g., "arc commit --show --revision X" where X is some "--only" revision).

Test Plan: Ran "arc commit --show --revision 1" against some test data, got clean output.

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2353
2012-05-01 10:35:14 -07:00
epriestley
c0c3c8a113 Remove "--no-decorate"
Summary: Apparently my advice here was terrible, and `--no-decorate` and `--decorate=no` are both very recent additions to Git which a bunch of users don't have. Get rid of them since D2344 allows us to parse all decorate levels anyway.

Test Plan: Tried to google "git changelog", got a bunch of pages about managing changelogs with git.

Reviewers: zeeg, ehren

Reviewed By: ehren

CC: ehren, aran, NorthIsUp

Differential Revision: https://secure.phabricator.com/D2354
2012-04-30 17:36:50 -07:00
epriestley
7070d0a065 Show text of moved files in Differential
Summary:
"git diff -M -C" generates useful metadata (moves/copies) but (for a pure move) no diff text. Synthetically build the diff text after the fact so this information is available in Differential.

This patch is kind of nasty but I couldn't see a cleaner way to do it. :/

This also needs some UI changes in Differential: we get a full-green new file right now, but it would be better to default-hide it with "This file was moved. Show More" or similar.

Test Plan: Moved a file, ran "arc diff", got textual diff.

Reviewers: aran, tuomaspelkonen, jungejason, btrahan, vrana

Reviewed By: vrana

CC: aran, epriestley, vrana

Maniphest Tasks: T230

Differential Revision: https://secure.phabricator.com/D479
2012-04-30 16:47:12 -07:00
Ehren Kret
b32b868a61 add support for using Arcanist with git's log.decorate setting enabled
Summary:
Arcanist fails to find git's 'commit <hash>' header when log.decorate is
set in one of git's config files. git adds the named refs that point to
the commit in parentheses following the hash. This changes the regex
used by arcanist to match git commit headers to optionally match the
branch names in parentheses following the hash.

Test Plan:
Run `git config --global log.decorate short` and check that `arc diff`
runs successfully.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2344
2012-04-30 14:14:23 -07:00
epriestley
e9ab03a48e Use Filesystem::getMimeType() in Arcanist
Summary: Missed this when getting rid of all the 'file' calls.

Test Plan: Meta.

Reviewers: btrahan, vrana, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1159

Differential Revision: https://secure.phabricator.com/D2327
2012-04-27 12:48:47 -07:00
Julius Seporaitis
cb051d8568 Wrapper for 'nose' unittest and code coverage tools.
Summary:
Wrapper for Python 'nose' (http://readthedocs.org/docs/nose/en/latest/)
testing tool.

Test Plan:
Install latest 'nose' v1.1.3. Currently it is available through
Github only (``pep install git+https://github.com/nose-devs/nose.git``).

Create a Python project with following structure:

  /package_name/module_name.py
  /tests/package_name/test_module_name.py

Write some tests

Run ``arc unit``

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin, zeeg

Differential Revision: https://secure.phabricator.com/D2322
2012-04-27 12:12:20 -07:00
epriestley
dd11fee5ef Fix PhutilUnitTest issue with symlinks that point into a libphutil library
Summary: Currently, if you change a symlink outside a libphutil library and the link target is something inside a libphutil library, we may enter an inifite loop in the "do { ... } while(...)" later. Just bail if the loop won't resolve.

Test Plan: Ran arc unit, Airtime reported the issue resolved by a similar fix.

Reviewers: cpiro, btrahan

Reviewed By: cpiro

CC: aran

Differential Revision: https://secure.phabricator.com/D2318
2012-04-25 16:13:04 -07:00
Edward Speyer
946a9e44a3 Allow tests to be skipped
Summary:
Allow tests to be skipped by calling assertSkipped().  It's not really
an assertion of anything tangible; more like "assert that we can't
really assert anything right now".

Test Plan: Added a new test to the PhutilUnitTestEngineTestCase.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2312
2012-04-24 21:45:22 -07:00
vrana
cc1e4d4676 Lint libraries without __init__
Summary: After D2207.

Test Plan:
`arc lint` on D2208.
`arc lint` on mistyped class name.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2306
2012-04-24 15:07:55 -07:00
epriestley
9c4c1de512 Autocomplete branches to "arc land"
Summary:
  - Add branch name tab completion to "arc land".
  - Default to landing the current branch.
  - This is a little bit hacky but not too terrible. I'm planning to move the whole thing to PhutilArgumentParser at some point so that'll be an opportunity for a big refactor.

Test Plan: Hit tab, landed this branch.

Reviewers: zeeg, btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran, kdeggelman

Differential Revision: https://secure.phabricator.com/D2293
2012-04-23 14:09:29 -07:00
Edward Speyer
dd6ffa4a13 [Tests] Only use concrete TestCases
Summary:
Don't use abstract subclasses of ArcanistPhutilTestCase, only use
concrete ones.

This lets you put common functionality in an abstract BaseTestCase
(which itself is a subclass of ArcanistPhutilTestCase), then implement
concrete subclasses of the BaseTestCase.

Test Plan: Tested with a simple Base -> {Case1, Case2} setup.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2300
2012-04-23 10:40:56 -07:00
epriestley
2831d075c0 Remove only trailing "#" and empty lines as comments from CLI editors
Summary: Don't strip numbered lists in comment bodies, etc.

Test Plan: Unit tests, meta-testing this diff.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1124

Differential Revision: https://secure.phabricator.com/D2262
2012-04-18 06:08:41 -07:00
epriestley
da4b6b5799 Rename "arc mark-committed" to "arc close-revision"
Summary:
  - Replace SVN-specific language with VCS-agnostic language.
  - Add new "arc close-revision", works exactly like "arc mark-committed" but with agnostic language.
  - Use status constants, not status strings.
  - Mark "arc mark-committed" deprecated.
  - Remove deprecated "arc merge".

Test Plan: Ran "arc mark-committed", "arc close-revision".

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran, Makinde

Maniphest Tasks: T909

Differential Revision: https://secure.phabricator.com/D2244
2012-04-17 13:51:10 -07:00
vrana
c320e0987d Don't advice using --less-context if already used
Test Plan:
  arc diff
  arc diff --less-context

Reviewers: blair

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2233
2012-04-14 21:50:52 -07:00
epriestley
ea0f737e85 Drop <project + branch> herusitic from Git
Summary: See rage in T1117. Don't use the <project + branch> heuristic anymore..

Test Plan: Ran "arc diff --strict HEAD^" on a commit stacked on top of this one, got no matches.

Reviewers: btrahan, vrana, simpkins, beng

Reviewed By: btrahan

CC: aran, avive

Maniphest Tasks: T1117

Differential Revision: https://secure.phabricator.com/D2221
2012-04-13 10:55:28 -07:00
epriestley
56cdc31426 Fix some --only / --preview / SVN issues with Arcanist
Summary:
  - Historically, "--preview" was forbidden under SVN. No reason for that now.
  - The "--auto" patch moved the "--preview" / "--only" checks later than they should be.
  - Fix an issue with Conduit query construction in SVN.

Test Plan: Ran "arc diff --preview" in an SVN working copy. Ran "arc diff" in an SVN working copy.

Reviewers: svemir, btrahan, vrana, jungejason

Reviewed By: svemir

CC: aran

Differential Revision: https://secure.phabricator.com/D2218
2012-04-12 10:32:54 -07:00
Git user
83ad377bdb Read default relative commit from scratch file with newline
Summary:
When people create the .arc/default-relative-commit scratchfile with $EDITOR of
choice, their editor usually puts a newline at the end, which breaks arc diff.
We should trim the newline before using the contents of the scratchfile.

Test Plan:
ran arc diff in a working copy that contained a .arc/default-relative-commit
with a newline

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2209
2012-04-11 17:44:57 -07:00
epriestley
d2915d8c5f Don't let "arc which" identify the working copy as belonging to a different project
Summary: If you have two projects (say, libphutil and arcanist) and you prepare a patch for one of them on branch "master", run "arc diff", and then prepare a patch for the other one on the same branch, "arc diff" will try to update the first revision when you run it. Instead, make it smart enough to stay within arc projects.

Test Plan: Ran "arc which" in circumstances where it previously generated a false positive, no false positive.

Reviewers: btrahan, vrana, jungejason

Reviewed By: jungejason

CC: aran

Maniphest Tasks: T1100

Differential Revision: https://secure.phabricator.com/D2199
2012-04-10 16:06:57 -07:00
epriestley
7ea51b6bb7 If a Git upstream is configured for the current branch, always use that as the default relative commit
Summary: See discussion in D1861.

Test Plan: Ran "arc diff" on master, got an upstream-based relative commit. Ran "arc diff" on a feature branch, got a config-based relative commit. Ran "arc diff x", got an argument-based relative commit.

Reviewers: btrahan, vrana, davidreuss, elgenie

Reviewed By: davidreuss

CC: aran

Differential Revision: https://secure.phabricator.com/D2192
2012-04-10 15:33:31 -07:00
Ben Gertzfield
2c02e79df4 Allow defining aliases in .arcconfig.
Summary:
For Objective-C repositories, we want to provide aliases to
arc diff --amend-autofixes by default.

This adds the ability to define aliases in .arcconfig (overridden
by any specified in the user config, of course).

Test Plan:
Tested defining alias with nothing in .arcconfig, with
an alias in .arcconfig.  Tested arc alias outside of working
repository.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2191
2012-04-10 12:42:13 -07:00
Ben Gertzfield
14d49d2565 Add ArcanistLintSeverity::SEVERITY_AUTOFIX.
Summary:
Xcode (a popular code editor on Mac OS X) has no facility
to trim trailing whitespace automatically.

This adds a new lint severity "AUTOFIX" that's between
WARNING and ERROR. When running the linter, any lint message
whose severity is AUTOFIX will automatically be patched.

Furthermore, if all lint messages returned from the engine are
AUTOFIX, we'll automatically amend HEAD with the patch.

Test Plan:
arc lint on files with and without trailing whitespace,
with and without UTF-8 contents to confirm those still error

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2125
2012-04-10 12:42:09 -07:00
epriestley
55dce2beeb Make --auto creates actually work in SVN and HG
Summary:
--auto doesn't work right now on the implicit --create pathway in SVN and HG because we hit these conditions.

Also improve a message.

Test Plan: Ran "arc diff" in unaffiliated working copies in HG and SVN.

Reviewers: svemir, btrahan, vrana, jungejason

Reviewed By: svemir

CC: aran

Differential Revision: https://secure.phabricator.com/D2187
2012-04-10 12:06:41 -07:00
epriestley
5068e8ad56 Provide a "loadFileDataCallback" for ArcanistBundle
Summary: See next diff for an explanation of this issue.

Test Plan: See next diff.

Reviewers: Makinde, btrahan, vrana, jungejason

Reviewed By: Makinde

CC: aran

Differential Revision: https://secure.phabricator.com/D2174
2012-04-09 17:34:45 -07:00
Evan Priestley
94c695cf0f Merge pull request #25 from Koolvin/arc_close
Add arc close command
2012-04-09 08:46:14 -07:00
vrana
a2c125d4ef Call phutil_passthru() instead of passthru() in liberate
Summary: Solves T1085 and is probably slightly better anyway.

Test Plan:
  arc liberate

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Maniphest Tasks: T1085

Differential Revision: https://secure.phabricator.com/D2151
2012-04-08 21:34:36 -07:00
Koolvin
e7d9ff18d3 Add arc close command
Summary:
```arc close T1088 --status wontfix --message "I'm not going to fix this."```
T1088 is the test task to screw with, so feel free.

Test Plan: ```arc close T1088 --status [ resolved | wontfix | invalid | duplicate | spite | open ] -m "Message"```

Reviewers: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2162
2012-04-08 20:57:38 -07:00
epriestley
2c599f8928 Raise lint warning on missing space after comma
Summary: Saw this in a diff somewhere; complain about it.

Test Plan: Unit coverage.

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1060

Differential Revision: https://secure.phabricator.com/D2153
2012-04-08 16:09:11 -07:00
Koolvin
b553af2763 Add arc tasks command
Summary:
Added `arc tasks`:

%%%arc tasks
arc tasks --view-all    // View Open and Closed Tasks
arc tasks --by-status   // Group By Status
arc tasks --by-priority // Group By Priority%%%

Test Plan: Connect to conduit and run arc tasks >> make sure you have tasks =p

Reviewers: epriestley, indiefan

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T749

Differential Revision: https://secure.phabricator.com/D1943
2012-04-07 17:40:25 -07:00
epriestley
038d8e86d6 Make "--auto" the default for "arc diff"
Summary:
NOTE: This is a disruptive change to how 'arc diff' behaves by default.

Many years ago, Differential (then DiffCamp) supported SVN. Someone added a "-i" mode to the "diffcamp" script so you could "git show | diffcamp -i", and thus we were
forever bound to storing metadata in commit messages.

But this isn't a common use case outside of Facebook + git-svn, and isn't very flexible. We now have a great deal of flexibility to identify revisions based on
hashes, branch names, etc, and to sync metdata from web to CLI and back. I want to jettison the commit-message-bound artifacts of the tool's history, and move to a
more flexible, modern workflow.

I added "--auto" a while ago, which figures out if you want to create or update a diff automatically, and then prompts you for whatever data it needs, reading
information if it can from commit messages in the range. This is a vastly better workflow in general, especially for SVN and Mercurial users (who currently need to
jump to the web UI to create revisions). It's better for git users too, since they don't need to use template commits and don't have to muck with or configure
templates. However, it's a nontrivial change to git users' core workflow that is clearly different in more ways than it is clearly better.

  - This might be contentious, but probably not toooo much, I hope?
  - I also deleted the (fairly ridiculous) workflow where we sync commit message changes from the working copy. I think two or three people will be REALLY upset about
this but I have no sympathy. "--edit" covers this and has been around for like two years now, and making the commit message and web dual-authoritative was always a bad
idea that we only ever half-accommodated anyway (see giant swaths of removed TOOD nonsense).

Test Plan:
  - I've been using "--auto" exclusively for like a month, it seems to work well.
  - Created/updated SVN, Git and HG diffs with "arc diff" under this workflow.

Reviewers: btrahan, jungejason, nh

Reviewed By: btrahan

CC: Makinde, vrana, zeeg, mbautin, aran, yairlivne, 20after4

Maniphest Tasks: T614

Differential Revision: https://secure.phabricator.com/D2080
2012-04-07 10:39:27 -07:00
epriestley
39c3a0c43a Fix an issue with "arc diff --update" in Git on immutable workflows
Summary:
This should be a raw text block, not a parsed message object.

I broke this in rARC1f13e022cdc9bf4859274a83784bd615caf62ef9 when I improved Mercurial support.

See: https://github.com/facebook/arcanist/issues/23

Test Plan: (Will update this diff...)

Reviewers: vrana, jungejason, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2136
2012-04-07 10:36:16 -07:00
vrana
a5f0323d5c Return $this from didApplyPatch() shortcut
Test Plan: https://secure.phabricator.com/diffusion/ARC/browse/master/src/lint/patcher/ArcanistLintPatcher.php;bd7dc8abaa7bb4c0$75?view=blame

Reviewers: epriestley, jungejason

Reviewed By: jungejason

CC: aran

Differential Revision: https://secure.phabricator.com/D2101
2012-04-04 15:11:52 -07:00
epriestley
bd7dc8abaa Allow configuration of a weak per-project default relative commit
Summary: Allows you to set a default in .arcconfig. This default is overriden by any .arc/ setting.

Test Plan: Ran "arc diff" with a .arcconfig setting but no .arc/ setting, got a diff against the specified relative commit.

Reviewers: nh, btrahan

Reviewed By: nh

CC: aran

Differential Revision: https://secure.phabricator.com/D2093
2012-04-03 16:06:43 -07:00
vrana
8971a91444 Return $this from setters
Summary:
Most setters returns `$this` but some don't.
I guess it's not by purpose.

Test Plan:
  arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2084
2012-04-02 18:47:59 -07:00
epriestley
39b3778287 Revenge of the git relative commit default
Summary:
The default of "arc diff" to "arc diff HEAD^" in git is universally confusing to everyone not at Facebook.

Drive the default with configuration instead. Even at Facebook, "origin/trunk" (or whatever) is probably a better default than "HEAD^".

See D863 for the last attempt at this.

NOTE: This is contentious!

Test Plan: Ran "arc diff", got prompted to set a default. Ran "arc diff" from a zero-commit repo, got sensible behavior

Reviewers: btrahan, vrana, nh, jungejason, tuomaspelkonen

Reviewed By: btrahan

CC: aran, epriestley, zeeg, davidreuss

Maniphest Tasks: T651

Differential Revision: https://secure.phabricator.com/D1861
2012-04-02 16:52:20 -07:00
vrana
a0c5835a43 Whitespace 2012-03-30 14:55:55 -07:00
epriestley
3ae1bf1a8c Add a lint check for clobbering locals with iterators
Summary:
See D2049, D2050. Identify reuses of locals as iterator variables. Before raising an error, we require:

  - Variable is declared before the loop.
  - Variable is used after the loop, ignoring uses as an iterator variable.

I think this identifies all problems with a very low false positive rate (the false positives are suspicious/unconventional code, but not necessarily errors).

Also fix an issue identified by the linter.

Test Plan:
  - Verified this identified the bugs in D2049 and D2050.
  - Ran linter against libphutil/, arcanist/ and phabricator/ (see D2051, this, and next diff).
  - Ran unit tests.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, epriestley, jungejason

Differential Revision: https://secure.phabricator.com/D2052
2012-03-29 13:21:18 -07:00