]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
13 years agoRefactor getWorkingCopyStatus() into getUncommittedStatus() and getCommitRangeStatus()
epriestley [Mon, 17 Dec 2012 20:53:28 +0000 (12:53 -0800)]
Refactor getWorkingCopyStatus() into getUncommittedStatus() and getCommitRangeStatus()

Summary:
See discussion in D4049.

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

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

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

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

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

Reviewers: vrana

Reviewed By: vrana

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

13 years agoSuggest upgrading Phabricator for unknown Conduit methods or parameters
vrana [Sat, 15 Dec 2012 01:40:57 +0000 (17:40 -0800)]
Suggest upgrading Phabricator for unknown Conduit methods or parameters

Summary:
This allows using new methods without the need for bumping version number.

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

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

  $ arc lint --only-new 1

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoUpdate PEP8
vrana [Thu, 13 Dec 2012 02:05:48 +0000 (18:05 -0800)]
Update PEP8

Test Plan:
Linted this Python file:

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

Didn't see:

> E225 missing whitespace around operator

Reviewers: andrewjcg, epriestley

Reviewed By: epriestley

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

13 years agoadd arc land hg support for landing with nested branches
durham [Thu, 6 Dec 2012 03:31:25 +0000 (19:31 -0800)]
add arc land hg support for landing with nested branches

Summary:
This changes arc land's hg support to allow you to land a branch or bookmark that has nested branches/bookmarks.  Example:

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

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

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

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

Reviewers: epriestley, dschleimer, bos, sid0

Reviewed By: dschleimer

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

13 years agoAdd an experimental "--mergeup" flag to use a less volatile merge strategy in "arc...
epriestley [Thu, 13 Dec 2012 22:11:52 +0000 (14:11 -0800)]
Add an experimental "--mergeup" flag to use a less volatile merge strategy in "arc land"

Summary:
See chatlog from https://secure.phabricator.com/chatlog/channel/%23phabricator/?at=37257

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

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

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

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

Also verified the conflict:

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

Reviewers: btrahan, vrana, DurhamGoode

Reviewed By: btrahan

CC: aran, keir
Differential Revision: https://secure.phabricator.com/D4080

13 years agoSimplify code by not passing local data to methods
vrana [Wed, 12 Dec 2012 22:21:06 +0000 (14:21 -0800)]
Simplify code by not passing local data to methods

13 years agoUse repository info from arcanist.projectinfo if available
vrana [Mon, 10 Dec 2012 23:10:31 +0000 (15:10 -0800)]
Use repository info from arcanist.projectinfo if available

Test Plan: Added a debug output there and ran.

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoSupport `git svn dcommit` in `arc land`
vrana [Sat, 8 Dec 2012 02:13:32 +0000 (18:13 -0800)]
Support `git svn dcommit` in `arc land`

Test Plan:
  $ arc land # in Git SVN repository

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoAdd arc browse workflow
Aviv Eyal [Sun, 9 Dec 2012 22:09:35 +0000 (14:09 -0800)]
Add arc browse workflow

Summary:
arc browse will open a browser to the Diffusion view of a file. Convenient if you like
Diffusion for reading source. Naturally, it fixes relative filenames.

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

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

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

Reviewers: epriestley, vrana

Reviewed By: epriestley

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

13 years agoReuse code in close-revision workflow
vrana [Sat, 8 Dec 2012 02:02:09 +0000 (18:02 -0800)]
Reuse code in close-revision workflow

Test Plan: Will test it by closing this revision.

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoRemove ArcanistSubversionAPI::hasMergeConflicts()
epriestley [Thu, 6 Dec 2012 20:20:02 +0000 (12:20 -0800)]
Remove ArcanistSubversionAPI::hasMergeConflicts()

Summary: No callsites, redundant with getMergeConflicts().

Test Plan: Grepped for callsites.

Reviewers: vrana

Reviewed By: vrana

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

13 years agoQuote author parameter
Edward Speyer [Wed, 5 Dec 2012 23:37:14 +0000 (15:37 -0800)]
Quote author parameter

Summary:
Fixes the exception:

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

Test Plan: Tested with full git name

Reviewers: epriestley, aurelijus

Reviewed By: epriestley

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

13 years agoIntroduce "arc diff --plan-changes"
Xingyao Ye [Wed, 5 Dec 2012 22:04:10 +0000 (14:04 -0800)]
Introduce "arc diff --plan-changes"

Summary:
Allow authors to publish a new or updated revision to Phabricator
without requesting code reviews. The revision will have status
"Needs Revision" instead of "Needs Review".

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

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

Reviewers: vrana

Reviewed By: vrana

CC: aran, epriestley
Maniphest Tasks: T2024

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

13 years agoFix a fatal for git uncommitted changes in new arc projects
epriestley [Wed, 5 Dec 2012 17:20:15 +0000 (09:20 -0800)]
Fix a fatal for git uncommitted changes in new arc projects

Summary:
If you run `arc diff` in a repository which:

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

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

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

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

Reviewers: vrana

Reviewed By: vrana

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

13 years agoBump Conduit client version number conduit-6
vrana [Tue, 4 Dec 2012 01:55:15 +0000 (17:55 -0800)]
Bump Conduit client version number

Summary: Should have been part of D3934.

Test Plan:
  $ arc diff

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoAdd hg support for arc land
durham [Tue, 4 Dec 2012 01:59:12 +0000 (17:59 -0800)]
Add hg support for arc land

Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed.  For the most part all the arc land options work, but there are a few caveats:

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

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

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

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

Reviewers: dschleimer, sid0, epriestley, bos

Reviewed By: epriestley

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

13 years agoIntroduce `arc lint --only-new 1`
vrana [Tue, 4 Dec 2012 00:52:58 +0000 (16:52 -0800)]
Introduce `arc lint --only-new 1`

Test Plan:
  $ arc lint src/workflow/ArcanistLintWorkflow.php
  $ arc lint --only-new 1 src/workflow/ArcanistLintWorkflow.php

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2038

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

13 years agoRestore order of operations after D4056
epriestley [Tue, 4 Dec 2012 00:31:45 +0000 (16:31 -0800)]
Restore order of operations after D4056

Summary:
See discussion in D4056. In `findRevision()` we call `loadWorkingCopyDifferentialRevisions()`. However, this method depends upon the state of the working copy, because the end of the commit range it examines is HEAD. Prior to D4056 we checked out the target branch before calling `findRevision()`; after D4056 we call it earlier.

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

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

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

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

Reviewers: DurhamGoode, zeeg

Reviewed By: DurhamGoode

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

13 years agoAllow setting lint cache granularity
vrana [Thu, 22 Nov 2012 02:38:24 +0000 (18:38 -0800)]
Allow setting lint cache granularity

Summary:
We can add `GRANULARITY_DIRECTORY` and `GRANULARITY_REPOSITORY` later.
Repository granularity may use current commit + changes.
Directory would need to use hashes of all files in dir which would be quite expensive.

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

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agocanRun should return false on scala linter instead of raising an exception
David Cramer [Mon, 3 Dec 2012 23:25:16 +0000 (15:25 -0800)]
canRun should return false on scala linter instead of raising an exception

Summary:
This was causing the following error in environments that didnt have scala configured:

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

Test Plan: .

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoBreak arc land run() into smaller functions
durham [Mon, 3 Dec 2012 21:03:13 +0000 (13:03 -0800)]
Break arc land run() into smaller functions

Summary:
Refactor the arc land code into several
functions so it's easier to maintain. This is in
preparation for adding hg support to arc land
in my next commit.

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

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

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoAdd a very basic Scala (SBT) linter.
Ricky Elrod [Mon, 3 Dec 2012 16:13:45 +0000 (08:13 -0800)]
Add a very basic Scala (SBT) linter.

Summary:
SBT is the most common Scala buildsystem. This adds an extremely basic and
slightly horrible linter to check SBT's output for warnings and errors.

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

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoImprove getting Git author
vrana [Thu, 29 Nov 2012 23:35:57 +0000 (15:35 -0800)]
Improve getting Git author

Summary:
It has one more than source, see http://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html#_commit_information.
Also 'user.name' may not be set at all.
Also `git config` returns non-zero for non-existing value.

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

Reviewers: epriestley

Reviewed By: epriestley

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

13 years agoProvide a method for getting Git SVN revision
vrana [Fri, 30 Nov 2012 01:40:07 +0000 (17:40 -0800)]
Provide a method for getting Git SVN revision

Summary: I plan to use it in `save_lint.php`.

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoPrefer Mercurial and Git over Subversion in discovering repository
vrana [Mon, 26 Nov 2012 22:45:50 +0000 (14:45 -0800)]
Prefer Mercurial and Git over Subversion in discovering repository

Summary: `svn info` is the slowest command for discovering repository (up to 300 ms) and Subversion is probably the least used repository type with Arcanist. Let's discover it last.

Test Plan:
  $ arc lint --trace

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoParse "--help" correctly in `arc`
epriestley [Thu, 22 Nov 2012 16:36:28 +0000 (08:36 -0800)]
Parse "--help" correctly in `arc`

Summary:
We delegate parsing to `PhutilArgumentParser` but then skip the parts of the code which do something with this flag.

In particular, `arc --help list` just runs `arc list`.

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

Test Plan: Ran `arc --help`, `arc list --help`, `arc --help list`, `arc --help help --help`. Got expected help in all cases.

Reviewers: vrana, chad, btrahan

Reviewed By: chad

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

14 years agoSet cache version per linter
vrana [Wed, 21 Nov 2012 22:52:50 +0000 (14:52 -0800)]
Set cache version per linter

Summary: Also delete cache with `--cache 0`.

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2036

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

14 years agoFix some arcanist warnings
epriestley [Thu, 22 Nov 2012 01:16:52 +0000 (17:16 -0800)]
Fix some arcanist warnings

Summary:
  - Rename some very old variables.
  - Wrap some contributed lines.

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

Reviewers: vrana

Reviewed By: vrana

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

14 years agoFix getting changed files in Git
vrana [Wed, 21 Nov 2012 23:57:06 +0000 (15:57 -0800)]
Fix getting changed files in Git

14 years agoEmit advice for TODO in Phutil linter
vrana [Wed, 21 Nov 2012 23:30:42 +0000 (15:30 -0800)]
Emit advice for TODO in Phutil linter

Summary:
Let's try this.
It may be useful to see this together in Differential overview.

Test Plan: Linted a file with TODO.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T744

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

14 years agoAllow caching lint results
vrana [Wed, 21 Nov 2012 00:43:10 +0000 (16:43 -0800)]
Allow caching lint results

Summary:
There is one big decision: How to get linters version.
I've created `getCacheVersion()` which is supposed to be bumped every time engine or any linter is changed.
This is not very nice but the other alternative (detect this automatically) seems worse:

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

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2036

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

14 years agoDon't amend commits with different author
vrana [Tue, 20 Nov 2012 18:43:19 +0000 (10:43 -0800)]
Don't amend commits with different author

Summary: Also delete extra newlines.

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2025

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

14 years agoChange lint_engine to lint.engine
vrana [Tue, 20 Nov 2012 23:37:31 +0000 (15:37 -0800)]
Change lint_engine to lint.engine

Summary: Also unit_engine.

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoDon't use empty commit message in commit from `arc diff`
vrana [Mon, 19 Nov 2012 22:14:38 +0000 (14:14 -0800)]
Don't use empty commit message in commit from `arc diff`

Summary:
There was a bug in Git: https://github.com/git/git/commit/d9a935

Also fix a bug with discovering existing commits.

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2025

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

14 years agomake arcanist backwards compatible with various conduit versions
Bob Trahan [Tue, 20 Nov 2012 01:32:09 +0000 (17:32 -0800)]
make arcanist backwards compatible with various conduit versions

Summary: pragmatism wins the day, though I think eventually we might want something really fancy to deal with arcanist and conduit not being up to date with respect to one another

Test Plan: php -l

Reviewers: epriestley

Reviewed By: epriestley

CC: zeeg, aran, Korvin
Maniphest Tasks: T2088

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

14 years agoReintroduce `arc diff --advice`
vrana [Mon, 19 Nov 2012 21:20:44 +0000 (13:20 -0800)]
Reintroduce `arc diff --advice`

Summary:
Some users want be stopped even if there are lint advices.

NOTE: Deleted by D3364.

Test Plan:
On diff with lint advice:

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoAllow running `arc diff` without `git commit`
vrana [Thu, 15 Nov 2012 20:33:36 +0000 (12:33 -0800)]
Allow running `arc diff` without `git commit`

Summary:
There's quite some logic in here:

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

Resolves T2025.

Test Plan:
`arc diff` on:

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

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2025

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

14 years agoRevert "accommodate git's diff.suppress-blank-empty=true setting (D3963)"
epriestley [Thu, 15 Nov 2012 23:47:43 +0000 (15:47 -0800)]
Revert "accommodate git's diff.suppress-blank-empty=true setting (D3963)"

Summary: Reverts D3963, which is obsoleted by D3969.

Test Plan: Straight revert.

Reviewers: vrana, jiiix, btrahan

Reviewed By: vrana

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

14 years agoAllow ArcanistDiffParser to parse `diff.suppress-blank-empty` Git diffs
epriestley [Thu, 15 Nov 2012 23:47:35 +0000 (15:47 -0800)]
Allow ArcanistDiffParser to parse `diff.suppress-blank-empty` Git diffs

Summary: See D3963. Instead, parse these diffs so they'll work with `--raw`, etc.

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

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

  Included changes:
    M       things

Reviewers: vrana, jiiix, btrahan

Reviewed By: vrana

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

14 years agoaccommodate git's diff.suppress-blank-empty=true setting
Jim Meyering [Tue, 13 Nov 2012 01:34:00 +0000 (17:34 -0800)]
accommodate git's diff.suppress-blank-empty=true setting

Summary:
accommodate git's diff.suppress-blank-empty=true setting
Without this change, if you were to set diff.suppress-blank-empty=true
in your .gitconfig (as I do), then "arc diff" would always fail with the
cryptic diagnostic, "Diff Parse Exception: Found the wrong number of
hunk lines."

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

Reviewers: vrana, epriestley

Reviewed By: vrana

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

14 years agoIntroduce `arc lint --severity warning`
vrana [Fri, 9 Nov 2012 03:29:40 +0000 (19:29 -0800)]
Introduce `arc lint --severity warning`

Summary: I plan to exclude advices from our saved results.

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2038

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

14 years agoProvide repository API method for getting changed files
vrana [Fri, 9 Nov 2012 07:26:27 +0000 (23:26 -0800)]
Provide repository API method for getting changed files

Test Plan:
  print_r($api->getChangedFiles('HEAD~36')); // Under Git.

Verified that deleted files are false.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2038

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

14 years agoProvide repository API method for getting all files
vrana [Fri, 9 Nov 2012 07:22:29 +0000 (23:22 -0800)]
Provide repository API method for getting all files

Test Plan:
  print_r(iterator_to_array($api->getAllFiles())); // Under Git.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2038

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

14 years agomake arc patch workflow preserve author commit information
Bob Trahan [Fri, 9 Nov 2012 21:36:15 +0000 (13:36 -0800)]
make arc patch workflow preserve author commit information

Summary: assumes D3917 (or something like it that populates 'author' value from conduit call) exists in production

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T479

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

14 years agoArcanistBundle: fix attribution of $old_phid when building binary changes
Sergio Correia [Thu, 8 Nov 2012 19:33:28 +0000 (11:33 -0800)]
ArcanistBundle: fix attribution of $old_phid when building binary changes

Summary:
The variable $old_phid was not being set in a certain situation in
buildBinaryChange(), and that was causing the following error, during
`arc patch <revision>`:

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

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

Signed-off-by: Sergio Correia <sergio@correia.cc>
Test Plan:
I spotted the problem in a revision where I was renaming
some images, which are binary.

Reviewers: epriestley, vrana, btrahan

Reviewed By: btrahan

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

14 years agoPerformance improvements for linting in an HG repo.
keegancsmith [Wed, 7 Nov 2012 03:30:08 +0000 (19:30 -0800)]
Performance improvements for linting in an HG repo.

Summary:
Run `hg status` as a Future while getting the diff. Add a cache for
getRawDiffText().

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

Reviewers: epriestley

Reviewed By: epriestley

CC: yliang, dpepper, aran, Korvin
Maniphest Tasks: T2016

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

14 years agoRemove getLink() from ArcanistLinterTestCase
vrana [Sat, 3 Nov 2012 01:09:38 +0000 (18:09 -0700)]
Remove getLink() from ArcanistLinterTestCase

Summary:
Installations extend this.

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

Test Plan:
  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoDeclare abstract method in repository API
vrana [Wed, 7 Nov 2012 08:50:17 +0000 (00:50 -0800)]
Declare abstract method in repository API

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoUnignore changes in .arc/
vrana [Tue, 6 Nov 2012 07:47:14 +0000 (23:47 -0800)]
Unignore changes in .arc/

Summary:
It's inside `.git/` for some time.
It also ignored changes in `test.arc/`.

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoFix an issue where `arc diff` would loop indefinitely for a property change
epriestley [Wed, 7 Nov 2012 01:46:55 +0000 (17:46 -0800)]
Fix an issue where `arc diff` would loop indefinitely for a property change

Summary:
When we hit a diff which is missing file context, we try to pull it synthetically later. This works for moves and copies, but currently fails for property changes. Since it failed, we didn't have context, so we'd try to pull it again...

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

Adds commits to cover this behavior:

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

      Mark koan2 +x and edit it.

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

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

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

      Mark koan as +x.

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

Reviewers: vrana, btrahan

Reviewed By: btrahan

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

14 years agoIgnore duplicate PEP8 lint errors in comprehensive engine
vrana [Sat, 3 Nov 2012 21:47:38 +0000 (14:47 -0700)]
Ignore duplicate PEP8 lint errors in comprehensive engine

Test Plan:
  $ arc lint a.py # with too long line

Reviewers: zeeg, epriestley

Reviewed By: epriestley

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

14 years agoMove conversion to dictionary inside lint message
vrana [Tue, 6 Nov 2012 04:23:38 +0000 (20:23 -0800)]
Move conversion to dictionary inside lint message

Summary: Maybe I will need it on other places.

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoTrigger bad charset lint warning only once per line
vrana [Mon, 5 Nov 2012 23:52:19 +0000 (15:52 -0800)]
Trigger bad charset lint warning only once per line

Summary:
Makes lots of noise:
{F22758}

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoFix ArcanistLinterTestCase
vrana [Mon, 5 Nov 2012 23:58:24 +0000 (15:58 -0800)]
Fix ArcanistLinterTestCase

Summary: We could also inject the value from the test case config but this is simpler.

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2035

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

14 years agoChange severity of PEP8 errors to warnings
vrana [Sun, 4 Nov 2012 04:52:30 +0000 (21:52 -0700)]
Change severity of PEP8 errors to warnings

Summary: None of these are that serious that I would like to be informed about them on unmodified lines.

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

Reviewers: zeeg, epriestley

Reviewed By: zeeg

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

14 years agoDelete license headers from files
vrana [Sat, 3 Nov 2012 07:53:27 +0000 (00:53 -0700)]
Delete license headers from files

Summary:
This commit doesn't change license of any file. It just makes the license implicit (inherited from LICENSE file in the root directory).

We are removing the headers for these reasons:

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

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

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

Reviewers: epriestley, btrahan, edward

Reviewed By: epriestley

CC: aran, Korvin, davidrecordon
Maniphest Tasks: T2035

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

14 years agoAsk for explanation for skipping lint and unit
vrana [Fri, 2 Nov 2012 05:41:00 +0000 (22:41 -0700)]
Ask for explanation for skipping lint and unit

Summary: Fixes T2023.

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

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2023

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

14 years agoSpecify config for text editors
vrana [Thu, 1 Nov 2012 18:33:58 +0000 (11:33 -0700)]
Specify config for text editors

Summary: This is sort of documentation.

Test Plan:
Used the plugin for Notepad++ with default indent of 4 spaces.
Opened file from `src/`, verified that it indents 2 spaces.
Opened file from `externals/`, verified that it indents 4 spaces.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

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

14 years agoDeclare undeclared variable in lint engine
vrana [Fri, 2 Nov 2012 19:35:09 +0000 (12:35 -0700)]
Declare undeclared variable in lint engine

Test Plan:
  $ arc lint

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agomodify arc diff workflow to only do amend optimization if git repository
Bob Trahan [Thu, 1 Nov 2012 23:47:08 +0000 (16:47 -0700)]
modify arc diff workflow to only do amend optimization if git repository

Summary: fix for T2011, first option in list of possible fixes

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2011

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

14 years agoFix copy/paste error in comment
vrana [Thu, 1 Nov 2012 23:21:12 +0000 (16:21 -0700)]
Fix copy/paste error in comment

14 years agoAdvice user to set up stripping trailing white space in editor
vrana [Thu, 1 Nov 2012 18:09:11 +0000 (11:09 -0700)]
Advice user to set up stripping trailing white space in editor

Test Plan: Triggered it.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T2022

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

14 years agoFix `arc diff --raw`
epriestley [Wed, 31 Oct 2012 18:50:43 +0000 (11:50 -0700)]
Fix `arc diff --raw`

Summary: I broke this in D3750. Calling `getRepositoryAPI()` triggers a check for workflow requirement of the repository API. Instead, we should just check if we alreayd have one.

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

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T1998

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

14 years agoRequire defining getWorkflowName()
vrana [Fri, 19 Oct 2012 18:02:46 +0000 (11:02 -0700)]
Require defining getWorkflowName()

Test Plan:
  $ arc help

Reviewers: epriestley, edward

Reviewed By: epriestley

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

14 years agoescape files properly in arc commit
Bob Trahan [Wed, 31 Oct 2012 01:26:58 +0000 (18:26 -0700)]
escape files properly in arc commit

Summary: turns out retina has files like image.png and image@2x.png. The latter breaks since '@' is a special command telling svn to "look for image at revision 2x.png" -- nonsensical garbage. If we add it to the end every time this error goes way.

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

Reviewers: epriestley

Reviewed By: epriestley

CC: mbishopim3, aran, Korvin
Maniphest Tasks: T1999

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

14 years agoDon't try to run didAbortWorkflow() if the user never provided a command
epriestley [Tue, 30 Oct 2012 17:44:49 +0000 (10:44 -0700)]
Don't try to run didAbortWorkflow() if the user never provided a command

Summary:
If you type `arc`, you currently get a fatal since $config isn't defined. Don't try to run the hook if we never built a config.

(We could build the config earlier and then run the hook anyway, but $workflow and $command would not be defined. It seems unlikely that executing the hook here is useful, since it affects only the case that the user types `arc` on its own.)

Test Plan: Typed `arc`. Typed `arc diff`, etc.

Reviewers: vrana, btrahan

Reviewed By: vrana

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

14 years agoPartially revert D3748
epriestley [Tue, 30 Oct 2012 14:06:05 +0000 (07:06 -0700)]
Partially revert D3748

Summary:
D3748 attempted to improve the behavior of `arc diff` when dealing with files merged from another branch, but had the side effect of marking all normal edits and deletes as adds. Revert this side effect, at least. This likely degrades the merging case, but it's comparatively rare, and editing/deleting files is very common.

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

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

Reviewers: btrahan, vrana, svemir

Reviewed By: svemir

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

14 years agoIn `arc diff`, always check that you own a revision before trying to do anything...
epriestley [Thu, 25 Oct 2012 23:27:57 +0000 (16:27 -0700)]
In `arc diff`, always check that you own a revision before trying to do anything with it

Summary:
Some users assume they can update anything, not just revisions they own (see https://github.com/facebook/arcanist/issues/54).

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

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

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

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

Reviewers: btrahan, vrana

Reviewed By: btrahan

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

14 years agoSplit paths on "diff --git" lines correctly in more cases
epriestley [Thu, 25 Oct 2012 21:46:44 +0000 (14:46 -0700)]
Split paths on "diff --git" lines correctly in more cases

Summary:
See T1973. In T1675, we addressed parsing of diffs with `--no-prefix` or custom `--src-prefix` and `--dst-prefix` flags. However, this inadvetently broke diffing of files with spaces in their names, which Git does not quote. They look like this normally:

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

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

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

  diff --git a b c d e f g

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

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

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

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

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran, ReturnZero
Maniphest Tasks: T1973

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

14 years agoMinor, fix obvious method name typo.
epriestley [Thu, 25 Oct 2012 20:37:56 +0000 (13:37 -0700)]
Minor, fix obvious method name typo.

Test Plan: Ran `arc export --git`.

Auditors: btrahan

14 years agoFix didAbortWorkflow() without workflow
vrana [Wed, 24 Oct 2012 19:42:18 +0000 (12:42 -0700)]
Fix didAbortWorkflow() without workflow

Summary: This is a BC break but it was introduced recently.

Test Plan:
  $ arc unit x

No more:

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoDisallow using DD1 as revision ID
vrana [Wed, 24 Oct 2012 18:23:10 +0000 (11:23 -0700)]
Disallow using DD1 as revision ID

Test Plan:
  $ arc inlines --revision 1
  $ arc inlines --revision D1
  $ arc inlines --revision DD1

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoRun unit on background also in waiting for confirmation with `arc diff --excuse`
vrana [Tue, 23 Oct 2012 22:21:01 +0000 (15:21 -0700)]
Run unit on background also in waiting for confirmation with `arc diff --excuse`

Test Plan: Made lint error, slept in test, verified that tests are finished when I confirm `arc diff --excuse`.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoAsk for lint and unit excuses asynchronously
vrana [Mon, 22 Oct 2012 21:46:31 +0000 (14:46 -0700)]
Ask for lint and unit excuses asynchronously

Summary: This diff obsoletes D3385.

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoProvide a hook for aborted workflow
vrana [Tue, 16 Oct 2012 17:21:56 +0000 (10:21 -0700)]
Provide a hook for aborted workflow

Summary:
We start Sandcastle push when `arc diff` starts.
If `arc diff` throws then HHVM waits for finishing the futures.
We need to kill them sooner.

Test Plan: Will implement the hook.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoFix comprehensive lint engine
vrana [Mon, 22 Oct 2012 19:47:27 +0000 (12:47 -0700)]
Fix comprehensive lint engine

14 years agoUse PhutilAggregateException to aggregate unit test exceptions
epriestley [Mon, 22 Oct 2012 18:41:33 +0000 (11:41 -0700)]
Use PhutilAggregateException to aggregate unit test exceptions

Summary: Currently, a shutdown exception ("script exited with open transactions!") overwhelms the actual test failure exception, which is the one that needs to be fixed.

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

Reviewers: vrana, btrahan

Reviewed By: vrana

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

14 years agoFix some regexp issues for parsing SVN diffs with \r\n newlines
epriestley [Mon, 22 Oct 2012 18:15:36 +0000 (11:15 -0700)]
Fix some regexp issues for parsing SVN diffs with \r\n newlines

Summary: We need to tweak a few patterns to accommodate the possibility that lines end in "\r\n".

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

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, mbishopim3
Maniphest Tasks: T1944

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

14 years agoAdd a large number of move/copy diff/patch tests
epriestley [Sat, 20 Oct 2012 15:43:31 +0000 (08:43 -0700)]
Add a large number of move/copy diff/patch tests

Summary: The way we represent some move/copy stuff is a bit messed up, but it mostly works, so add coverage before I mess with it.

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T866

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

14 years agoImprove test coverage of diff/patch generation
epriestley [Sat, 20 Oct 2012 15:43:13 +0000 (08:43 -0700)]
Improve test coverage of diff/patch generation

Summary:
We have coverage for generating patches, applying them, and making sure they reproduce the original repository state. However:

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

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

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T866

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

14 years agoMake ArcanistDiffParser automatically load synthetic changes if the working copy...
epriestley [Sat, 20 Oct 2012 15:42:16 +0000 (08:42 -0700)]
Make ArcanistDiffParser automatically load synthetic changes if the working copy is available

Summary: Make this harder to get wrong. Instead of requiring a separate call for synthetic data, automatically load it if we can.

Test Plan: Unit tests; `arc diff`.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T866

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

14 years agoPass key to aggregate exception
vrana [Sat, 20 Oct 2012 14:11:02 +0000 (07:11 -0700)]
Pass key to aggregate exception

Summary: This information may be quite useful.

Test Plan: Threw exception from license linter.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoSet all lint paths at once
vrana [Sat, 20 Oct 2012 12:45:22 +0000 (05:45 -0700)]
Set all lint paths at once

Summary:
This code is much more readable to me.
It should also be faster as building the array at once should be faster than one by one.

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoFix lint tests after D3756
vrana [Sat, 20 Oct 2012 13:16:19 +0000 (06:16 -0700)]
Fix lint tests after D3756

Test Plan:
Threw normal exception, saw failed test.
Threw usage exception, saw skipped test.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoFix two arc issues
epriestley [Sat, 20 Oct 2012 13:13:12 +0000 (06:13 -0700)]
Fix two arc issues

Summary:
  - I caused $parser to be reused in D3732 which I belived was safe, but actually isn't. We end up writing to the same changes. We should make it safe but there's some mess in Phabricator that needs to be cleaned up first.
  - One minor error code thing, variable is undefined.

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

Reviewers: btrahan, vrana

Reviewed By: btrahan

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

14 years agoFix ArcanistSingleLintEngine for deleted paths
epriestley [Sat, 20 Oct 2012 13:12:24 +0000 (06:12 -0700)]
Fix ArcanistSingleLintEngine for deleted paths

Summary:
Currently, ArcanisSingleLintEngine lints deleted paths and directories. These are sometimes appropriate, but SingleLintEngine is a less-sophisticated linter and should have more safe defaults.

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

Test Plan:
Reproduced the problem:

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

      WIP

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

Applied the error message fix:

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

  stderr:

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

Applied the remove paths fix:

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

Reviewers: magazovski, btrahan, vrana

Reviewed By: btrahan

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

14 years agoPrint lint results before throwing
vrana [Sat, 20 Oct 2012 11:42:53 +0000 (04:42 -0700)]
Print lint results before throwing

Summary:
When some linter throws then we don't print any result.
This is bad in case when the linter threw e.g. because of syntax error in some file which some other linter will tell us about.

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoTreat a file merged from another svn branch as an addition
Svemir Brkic [Fri, 19 Oct 2012 22:55:02 +0000 (15:55 -0700)]
Treat a file merged from another svn branch as an addition

Summary:
After a reintegration merge, "Copied From URL" will be different and current approach will result in a wrong path. If the path does not match, just mark it as a new file.

moved the comment before if so lines stay at 80 chars

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoMake parser more flexible in the face of Git diff prefix flags
epriestley [Fri, 19 Oct 2012 21:07:34 +0000 (14:07 -0700)]
Make parser more flexible in the face of Git diff prefix flags

Summary: See T1675 for discussion. We currently strip `[abicwo12]/` from Git patches, but the user can provide arbitrary prefixes with `--src-prefix` and `--dst-prefix`, or strip prefixes entirely with `--no-prefix`. In these cases, trust they know what they're doing rather than rejecting the diff.

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

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T1675

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

14 years agoDon't unset linted paths from subdirectory and in commit hook mode
vrana [Fri, 19 Oct 2012 19:50:38 +0000 (12:50 -0700)]
Don't unset linted paths from subdirectory and in commit hook mode

Summary: D3737#6

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

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoSupport --nobranch when not currently on a branch
Edward Speyer [Fri, 19 Oct 2012 19:12:57 +0000 (12:12 -0700)]
Support --nobranch when not currently on a branch

Summary:
This is horrible and git specific, but fixes a case where people are using "arc
patch --nobranch ..." when they're not currently on a branch.

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

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

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

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

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

    ac1ad39 Updating a-file

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

   git branch new_branch_name ac1ad392350a51edd10343f12b9713f5e5b3707c

  HEAD is now at e7a3ec6... Fix arcconfig

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

  € git branch
  * (no branch)
    feature
    haddock
    master

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

Reviewers: vrana, epriestley

Reviewed By: epriestley

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

14 years agoDon't lint file content of directories
vrana [Thu, 18 Oct 2012 21:17:29 +0000 (14:17 -0700)]
Don't lint file content of directories

Summary: This also changes how we treat `@generated` and `@nolint` - after this diff, we will still lint their path.

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

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

Now it prints:

> No lint warnings.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoTemporarily unrequire defining getWorkflowName()
vrana [Fri, 19 Oct 2012 17:38:34 +0000 (10:38 -0700)]
Temporarily unrequire defining getWorkflowName()

Summary:
We need to run new Arcanist over old code in Perflab.
We also need to run new Arcanist over new code (with already deleted custom `buildAllWorkflows()`).

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

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

Reviewers: edward, epriestley

Reviewed By: epriestley

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

14 years agoRequire defining workflows' synopses and help
vrana [Fri, 19 Oct 2012 16:50:56 +0000 (09:50 -0700)]
Require defining workflows' synopses and help

Test Plan: Deleted `getCommandSynopses()` from workflow, ran `arc help`.

Reviewers: epriestley, edward

Reviewed By: epriestley

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

14 years agoImprove `arc` handling of various binary file operations in Git
epriestley [Fri, 19 Oct 2012 17:10:25 +0000 (10:10 -0700)]
Improve `arc` handling of various binary file operations in Git

Summary:
See T866, D3521. Additional things this fixes:

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

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

      Remove binary image.

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

      Copy binary image.

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

      Move binary image.

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

      Add a binary image.

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

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T866

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

14 years agoMake Arcanist workflow names explicit
epriestley [Wed, 17 Oct 2012 15:35:03 +0000 (08:35 -0700)]
Make Arcanist workflow names explicit

Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.

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

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

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

Reviewers: edward, vrana, btrahan

Reviewed By: edward

CC: aran, zeeg
Differential Revision: https://secure.phabricator.com/D3691

14 years agoUse git-cherry-pick for arc patch
Edward Speyer [Tue, 16 Oct 2012 23:46:21 +0000 (16:46 -0700)]
Use git-cherry-pick for arc patch

Summary:
This changes what --nobranch does, though not what it means.  In git, the patch
is applied to the git commit it is based off where it will commit cleanly, and
if you specify --nobranch then arc-patch will then switch back to your original
branch and try to cherry-pick the commit there.

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

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

Reviewers: epriestley, btrahan

Reviewed By: epriestley

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

14 years agoDon't pull message twice from Conduit in `arc diff`
vrana [Tue, 16 Oct 2012 18:51:15 +0000 (11:51 -0700)]
Don't pull message twice from Conduit in `arc diff`

Summary:
We currently pull message from Conduit twice in `arc diff` update.
Once in `buildCommitMessage()` and once in `buildRevisionFromCommitMessage()`.
Remeber that we already pulled it (and so it is authoritative) to save this call.

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

Test Plan:
  $ arc diff --trace

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoFix typo in comment
vrana [Tue, 16 Oct 2012 17:01:35 +0000 (10:01 -0700)]
Fix typo in comment

14 years agoFix parsing of PHPUnit JSON log format for PHPUnit 3.7.7
Stanislav Vorobyev [Mon, 15 Oct 2012 10:47:01 +0000 (14:47 +0400)]
Fix parsing of PHPUnit JSON log format for PHPUnit 3.7.7

Summary: See https://github.com/facebook/arcanist/pull/55

Reviewed by: epriestley