]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
14 years agoImprove Arcanist symbol name linter
epriestley [Sat, 28 Jan 2012 19:17:45 +0000 (11:17 -0800)]
Improve Arcanist symbol name linter

Summary:
  - Move name helper functions to ArcanistXHPASTLintNamingHook to make it easier
to write custom linters.
  - Add test coverage for name functions.
  - Add 'variable' and 'global' naming convention tests.
  - Expand test cases.
  - Improve lint message error when an unexpected message is raised during a
test.
  - Remove a defunct XHP lint message.

Test Plan:
  - Ran unit tests.
  - Ran "arc lint --lintall" on arcanist/.

Reviewers: btrahan, nh, jungejason

Reviewed By: btrahan

CC: johnduhart, aran, epriestley, arudolph
Differential Revision: https://secure.phabricator.com/D1506

14 years agoFix arc patch in git-svn repos
Nick Harper [Fri, 27 Jan 2012 02:36:43 +0000 (18:36 -0800)]
Fix arc patch in git-svn repos

Summary:
Check that the base revision is a valid git ref before trying to create a branch
starting at that rev. When arc patch is used in a git repo using the git-svn
bridge, the base reversion is a uri for the svn rev, not a git ref.

Test Plan:
run arc patch on a git-svn repo, run it on a pure git repo, and verify it works
for both

Reviewers: epriestley, btrahan

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

14 years agoPrint out recovery command before running "git branch -D" in "arc land"
epriestley [Fri, 27 Jan 2012 01:59:42 +0000 (17:59 -0800)]
Print out recovery command before running "git branch -D" in "arc land"

Summary: You can get this out of reflog, but we can easily just give you the
command in case you want to undo the -D.

Test Plan: Ran "arc land --hold" on this branch, used recovery command to
recover it.

Reviewers: cpiro, btrahan, jungejason

Reviewed By: cpiro

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

14 years agoImprove 'arc land' in immutable workflows
epriestley [Fri, 27 Jan 2012 01:41:11 +0000 (17:41 -0800)]
Improve 'arc land' in immutable workflows

Summary: Better instructions in the 'git merge' failure case for 'arc land'.

Test Plan: no you test

Reviewers: fratrik, btrahan, jungejason

Reviewed By: fratrik

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

14 years agoUse "arc which" in "arc commit", modernize checks
epriestley [Fri, 27 Jan 2012 01:40:55 +0000 (17:40 -0800)]
Use "arc which" in "arc commit", modernize checks

Summary:
  - Use differential.query, not differential.find.
  - Use loadWorkingCopyDifferentialRevisions ("arc which").
  - Some general cleanup.

Test Plan:
oh man

  $ arc commit --revision 999 # Does not exist
  Usage Exception: Revision 'D999' does not exist.

  $ arc commit --revision 1 # Exists, not accepted.

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

  Committing 'D1: bleorp'...
  A locally modified path is not included in this revision:

      DERP

      It will NOT be committed. Commit this revision anyway? [y/N] y

  Done.

  $ arc commit --revision 3 # Not mine, from a git repo

      You are not the author of 'D3: bloop'. Commit this revision anyway? [y/N]
y

      Revision 'D3: bloop' was generated from
      '/INSECURE/repos/git-working-copy/', but current working copy root is
      '/INSECURE/repos/svn-working-copy/'. Commit this revision anyway? [y/N] y

  Committing 'D3: bloop'...
  A locally modified path is not included in this revision:

      DERP

      It will NOT be committed. Commit this revision anyway? [y/N] y

  svn: Commit failed (details follow):
  svn: '/INSECURE/repos/svn-working-copy/derp' is not under version control

  Exception:
  Executing 'svn commit' failed!
  (Run with --trace for a full exception trace.)

  $ arc commit # Nothing accepted
  Usage Exception: Unable to identify the revision in the working copy. Use
'--revision <revision_id>' to select a revision.

  $ arc commit # Now accepted
  Committing 'D1: bleorp'...
  Marking revision D1 'bleorp' committed...
  Done.

  $ svn st # Complicated test for a bizarre SVN edge case
  A       svnderp
  A       svnderp/A
  A       svnderp/B
  $ arc diff --create
  Linting...
   LINT OKAY  No lint problems.
  Running unit tests...
  No unit test engine is configured for this project.
  Created a new Differential revision:
          Revision URI: http://local.aphront.com/D28

  Included changes:
    A (dir) svnderp
    A       svnderp/A
    A       svnderp/B
  $ touch svnderp/C
  $ svn add svnderp/C
  A         svnderp/C
  $ arc commit
  Usage Exception: Unable to identify the revision in the working copy. Use
'--revision <revision_id>' to select a revision.
  $ arc commit --revision 28

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

  Committing 'D28: derp'...
  Usage Exception: This commit includes the directory 'svnderp', but it contains
a modified path ('svnderp/C') which is NOT included in the commit. Subversion
can not handle this operation and will commit the path anyway. You need to sort
out the working copy changes to 'svnderp/C' before you may proceed with the
commit.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

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

14 years agoMinor 'arc' text fixes
epriestley [Fri, 27 Jan 2012 01:40:49 +0000 (17:40 -0800)]
Minor 'arc' text fixes

Summary: I removed the "--interactive" flag since it makes no sense with 'arc
merge --squash', and transposed a space.

Test Plan: Read text.

Reviewers: cpiro, btrahan, davidreuss

Reviewed By: cpiro

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

14 years agoSplit ArcanistXHPASTLinter::LINT_FORMATTING_CONVENTIONS into seperate lint names
John Du Hart [Thu, 26 Jan 2012 03:05:47 +0000 (19:05 -0800)]
Split ArcanistXHPASTLinter::LINT_FORMATTING_CONVENTIONS into seperate lint names

Summary:
Split ArcanistXHPASTLinter::LINT_FORMATTING_CONVENTIONS into seperate
lint names so that each linting rule can be controled sperately

Test Plan:
This shouldn't break anything, if it does we'll know soon enough.
<epriestley> Better things break loudly/obviously I think.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoAdd "arc land" as a first-class workflow
epriestley [Wed, 25 Jan 2012 23:10:59 +0000 (15:10 -0800)]
Add "arc land" as a first-class workflow

Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.

Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.

Reviewers: cpiro, btrahan, jungejason, davidreuss

Reviewed By: davidreuss

CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723

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

14 years agoUse 'arc which' in 'arc amend'
epriestley [Wed, 25 Jan 2012 19:40:22 +0000 (11:40 -0800)]
Use 'arc which' in 'arc amend'

Summary:
  - Allow 'arc amend' to identify revisions by hash and branch, so it works with
"arc diff --create".
  - Warn when the requested revision is not (apparently) in the working copy.

Test Plan:
Ran "arc amend" in working copies with different states (right
revision, wrong revision, hash/branch identification).

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, epriestley
Maniphest Tasks: T723

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

14 years agoAdd 'arc which', and
epriestley [Tue, 24 Jan 2012 16:07:38 +0000 (08:07 -0800)]
Add 'arc which', and
ArcanistRepositoryAPI->loadWorkingCopyDifferentialRevisions()

Summary:
  - See T787.
  - @cpiro has an immediate use case for this, which is ##arc amend --revision
`arc which --id` --show master## for "git merge --autosquash" or similar.
  - For T614, we need this to choose "--create" vs "--update".
  - Other workflows should also use this to improve how often we automatically
get things right, particularly in Mercurial and SVN.

Test Plan:
Ran "arc which" in SVN, Git and HG working copies with various flags;
results seemed reasonable.

Reviewers: btrahan, cpiro, jungejason

Reviewed By: btrahan

CC: aran, epriestley
Maniphest Tasks: T787

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

14 years agoMake arc install-certificate respect --conduit-uri
Bob Trahan [Mon, 23 Jan 2012 23:31:56 +0000 (15:31 -0800)]
Make arc install-certificate respect --conduit-uri

Summary: ...basically by adding "getConduitURI" and then falling through to
that, rather than repeating work from the main arc wrapper that setConduitURI in
the first place.   The explicit drawback here is the error message gets a little
more vague.

Test Plan:
- arc install-certifate --conduit-uri=https://secure.phabricator.com
// verified that the install flow was going for
https://secure.phabricator.com...!
- arc install-certificate https://secure.phabricator.com
// verified that the install flow was going for
https://secure.phabricator.com...!
- arc install-certificate
// verified that it reverted back to the .arcconfig conduit uri

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Maniphest Tasks: T794

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

14 years agoAugment arc patch behavior
Bob Trahan [Thu, 19 Jan 2012 20:16:01 +0000 (12:16 -0800)]
Augment arc patch behavior

Summary:
under git, we now create a branch that is at the patch's base revision if we
know it or whatever the working copy happened to be at if we don't.   This diff
also adds the --nobranch flag to disable this new behavior.
Also added an --update flag.  When specified, we run the appropriate "update"
command in the VCS.  By default this is off.
Finally, tried to give the user more information about what the heck arc just
did to their working copy.

Test Plan:
// verify --update flag works
// -- git
Assume we are at HEAD and we got to HEAD from HEAD^1 via DX
git reset --hard <THE BEGINNING>
arc patch --update DX
// ...versus svn
Assume we are at HEAD and we got to HEAD from HEAD^1 via DX
svn checkout -r 1
arc patch --update DX
// ...versus hg
Assume we are at HEAD and we got to HEAD from HEAD^1 via DX
hg update -r 1
arc patch --update DX

// verify under git a nice branch is made
// -- test where we should get a good name
// -- test where we have a base revision to check out the branch at
Assume we are at HEAD and we got to HEAD from HEAD^1 via DX
git reset --hard HEAD^1
arc patch DX

// verify under git an "okay" branch is made if we can't get "nice"
// -- test where we should get a "bad" name
// -- test where we DON'T have a base revision to check out the branch at
git diff HEAD^1 > ~/example.patch
git reset --hard HEAD^1
arc patch --patch ~/example.patch

// verify --nobranch flag skips the test for git
Assume we are at HEAD and we got to HEAD from HEAD^1 via DX
git reset --head HEAD^1
arc patch --nobranch DX

Reviewers: epriestley

Reviewed By: epriestley

CC: aran
Maniphest Tasks: T479

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

14 years agoAdd ArcanistConduitLinter, a linter that delegates through Conduit
adonohue [Fri, 20 Jan 2012 01:09:27 +0000 (17:09 -0800)]
Add ArcanistConduitLinter, a linter that delegates through Conduit

Summary:
Julien built a really cool static analysis database of our codebase. One
capability is that it can suggest typehints that are not in the code. The
analysis to do this is very expensive, so it can't reasonably be run locally.
But it can remain indexed on a server.

The idea here is to provide a familiar interface to it through arc lint, via a
generic Conduit service call.

In our lint engine, this will probably be gated on --advice for performance.
This will introduce a slight awkwardness in that running with --advice can add
new non-advice lint if the server chooses, but this isn't likely to cause a
practical problem.

Test Plan:
Construct a fake Conduit lint endpoint, attach this linter to it, and see bogus
lint
appear with --advice.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoMerge pull request #16 from disqus/improve-pep8-linter
Evan Priestley [Fri, 20 Jan 2012 05:07:19 +0000 (21:07 -0800)]
Merge pull request #16 from disqus/improve-pep8-linter

Improve PEP8 Linter

14 years agoAdd "nocommit" git-only flag to arc patch workflow
Bob Trahan [Tue, 17 Jan 2012 23:47:00 +0000 (15:47 -0800)]
Add "nocommit" git-only flag to arc patch workflow

Summary:
without "nocommit" we commit the patch to the working copy. add the nocommit
flag and this commit does not happen.

making this happen required adding revisionID to arc bundle to fetch the proper
commit message.  if we can't get a commit message -- suppose the fetch fails or
the source is self::SOURCE_PATCH, we ask the user for the commit message on the
command line

Test Plan:
git reset --hard <SOME_REV>
arc patch DX, where this got us to <SOME_REV + 1>
observe correct patch committed with correct commit message in working copy

git reset --hard <SOME_REV>
arc patch --nocommit DX, where this got us to <SOME_REV + 1>
observe correct patch landed BUT NOT committed.  note "commit message" does not
exist since there isn't a commit...!

git diff HEAD^1 > ~/file.patch
git reset --hard HEAD^1
arc patch --patch ~/file.patch
observe prompted for commit message and patch committed with commit message i
typed in

Reviewers: epriestley

Reviewed By: epriestley

CC: aran
Maniphest Tasks: T479

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

14 years agoMerge pull request #17 from disqus/improve-linters
Evan Priestley [Wed, 18 Jan 2012 01:16:08 +0000 (17:16 -0800)]
Merge pull request #17 from disqus/improve-linters

Add canRun to linters.

14 years agoAdd canRun to linters.
David Cramer [Wed, 18 Jan 2012 00:30:59 +0000 (16:30 -0800)]
Add canRun to linters.

Summary:
This allows engines to check the canRun method on linters,
which should determine if a linter is configured and can
be run in the current environment.

Test Plan:
Implement a linter with canRun as false, and ensure
it doesnt run.

Ensure all existing linters still run by default.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoRebuild phutil library map for arc
Bob Trahan [Tue, 17 Jan 2012 22:54:27 +0000 (14:54 -0800)]
Rebuild phutil library map for arc

Summary: D1439 added a new class which had the wrong name in the map from D1439.
 Whoopsiepoos!

Test Plan: unit tests now pass

Reviewers: epriestley, zeeg

Reviewed By: epriestley

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

14 years agoImprove PEP8 Linter
David Cramer [Tue, 17 Jan 2012 20:38:54 +0000 (12:38 -0800)]
Improve PEP8 Linter

Summary:
This cleans up the PEP8 linter to bring it inline
with the new JSHint Linter's level of quality.

It adds a getPEP8Path method which gives the ability
for users to override the pep8 binary with two new
options in .arcconfig:

* lint.pep8.prefix
* lint.pep8.bin
* lint.pep8.options

Test Plan:
Adjust your engine to use the 'ArcanistPEP8Linter' and run
arc lint against Python files.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoMerge pull request #15 from disqus/comprehensive-linter
Evan Priestley [Tue, 17 Jan 2012 20:48:09 +0000 (12:48 -0800)]
Merge pull request #15 from disqus/comprehensive-linter

Implement Comprehensive Lint Engine

14 years agoImplement Comprehensive Lint Engine
David Cramer [Tue, 17 Jan 2012 20:17:51 +0000 (12:17 -0800)]
Implement Comprehensive Lint Engine

Summary:
This adds a new lint engine, ComprehensiveLintEngine, which
includes sane defaults for some generic languages.

Ideally this would include *all* available language linters,
but that can be enhanced at a later point. Right now it's mostly
the base linter with additional JavaScript and Python linters.

Test Plan:
Adjust the lint_engine to be "ComprehensiveLinterEngine". You'll
also need jshint, pyflakes, and pep8 to all be available on PATH.

Run arc lint against files which contain .php, .py, and .js.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoMake arc patch be less ROFL for mercurial
Bob Trahan [Tue, 17 Jan 2012 01:12:34 +0000 (17:12 -0800)]
Make arc patch be less ROFL for mercurial

Summary:
pretty easy stuff as mercurial accepts git style patches...!

also fixed two issues where we were 1) storing the short hash and 2) storing it
with a trailing "\n".  This diff makes us store the full hash AND no trailing
return character

Test Plan:
in my mercurial repo
<note repo at revision $foo>
<did something dumb>
hg commit -m "something dumb"
arc diff
<go to web and fill out stuff for DX>
hg checkout $foo
arc patch DX
<verify patch DX successfully applied!>

use conduit console to verify a few diffs were returning the correct full
revision hash with a trailing \n

Reviewers: epriestley

Reviewed By: epriestley

CC: aran
Maniphest Tasks: T630

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

14 years agoAdd spell check linter
Jack Lindamood [Mon, 16 Jan 2012 05:28:58 +0000 (21:28 -0800)]
Add spell check linter

Summary:
Inspired by http://news.ycombinator.com/item?id=3464671 and a lot of
diffs I've seen @ FB, I've added a spell checking linter.  To reduce
false positives, it's only a blacklist.  Still, it catches a large
number of 'issues'.

Test Plan:
Unit tests.  Ran on FB's codebase.  No false positives
noticed but a lot of cases caught.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoFix for `arc install-certificate` timeout.
Marke Hallowell [Sun, 15 Jan 2012 03:55:20 +0000 (19:55 -0800)]
Fix for `arc install-certificate` timeout.

Summary:
Extended the install-certificate workflow's timeout from 5
seconds to rely on the ConduitClient default (30 seconds), which matches the HTTP interface.

Test Plan: Run arc install-certificate

Reviewers: epriestley

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

14 years agoAdds ArcanistJSHintLinter to check JS files for errors and potential problems.
Anton Kovalyov [Fri, 13 Jan 2012 23:21:57 +0000 (15:21 -0800)]
Adds ArcanistJSHintLinter to check JS files for errors and potential problems.

This patch adds ArcanistJSHintLinter class and three new .arcconfig options:

 * lint.jshint.prefix - directory where JSHint binary resides
 * lint.jshint.bin - JSHint binary name (if different from 'jshint')
 * lint.jshint.config - a JSON file with JSHint project-wide options

By default, this linter assumes that JSHint is installed on user's system
as an NPM package.

Test Plan:

(1)

Run `npm install jshint -g` to install JSHint and add
ArcanistJSHintLinter to your Lint Engine (I didn't see PEP8 or
PyFlakes in the PhutilLintEngine so I decided to not to put
JSHint in there). After that you can do `arc lint my.js`.

(2)

Create a new file, config.json, and add `{ "white": true }` in it.
Add `"lint.jshint.config": "/path/to/config.json"` to your .arcconfig and
run `arc lint my.js`. After that, unless your name is Douglas Crockford,
you'll see tons of JSHint warnings about minor PEP8-like things (spacing, etc.)

14 years agoImprove 'arc' behavior under git mutable history with ambiguous commit messages
epriestley [Fri, 13 Jan 2012 03:03:11 +0000 (19:03 -0800)]
Improve 'arc' behavior under git mutable history with ambiguous commit messages

Summary:
Currently, we throw a fairly perplexing error when there are multiple valid
commit messages. Installs can also remove the "test plan" field entirely, which
is the only really strong discriminator here.

When the message to use is ambiguous, show the user all the valid messages and
prompt them to choose one.

Also add a -C flag like "git commit -C", so they can choose a message
explicitly.

Test Plan: Ran "arc diff HEAD^^^^^", "arc diff -C <rev>".

Reviewers: cpiro, btrahan, jungejason

Reviewed By: cpiro

CC: aran, cpiro
Differential Revision: https://secure.phabricator.com/D1385

14 years agoAllow "arc liberate" / PhutilModuleLinter to ignore declared external symbols
epriestley [Thu, 12 Jan 2012 21:51:35 +0000 (13:51 -0800)]
Allow "arc liberate" / PhutilModuleLinter to ignore declared external symbols

Summary:
See T762. Currently, some externals functions (recaptcha, xhprof) raise errors
and prevent clean runs of "arc liberate" without --force-update or a forced
cache.

Allow such symbols to be declared:

  /**
   * @phutil-external-symbol function some_function
   */

This prevents them from being treated as dependencies.

Test Plan: Ran "arc liberate src/ --all" on Phabricator, fixed all the warnings
by adding @phutil-external-symbol declarations.

Reviewers: btrahan, jungejason

Reviewed By: jungejason

CC: aran, jungejason
Maniphest Tasks: T762

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

14 years agoStop XHPASTLinter from eating a newline after else
Kiyoto Tamura [Thu, 12 Jan 2012 02:03:56 +0000 (18:03 -0800)]
Stop XHPASTLinter from eating a newline after else

Summary:
If the else clause does not have braces (one-liner), XHPASTLinter eats the
newline and brings the body statement of the else clause to the same line.

Test Plan: added a new test to space-after-control-keywords.lint-test

Reviewers: epriestley

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

14 years agoArc - add a sanity check to arc patch workflows to make sure the vcs base
Bob Trahan [Sat, 3 Dec 2011 00:21:14 +0000 (16:21 -0800)]
Arc - add a sanity check to arc patch workflows to make sure the vcs base
revision is the correct base revision relative to the patch.

Summary: What the title says.   If not correct, warn the user.   This check
honors the --force flag to skip all these checks.   This change also includes
moving some Differential constants into Arc so they can be used for both
projects.   There is a corresponding phabricator diff (incoming) to address this
part of the change.

Test Plan:
For a project with actual diffs, a git repository tracked by phabricator, *AND*
development in master branch only, do some...
- git reset --hard HEAD^1
- arc patch DX, where X is what got us to HEAD in the first place
- verify successful patch
...then...
- git reset --hard HEAD^^
- arc patch DX, where X is what got us to HEAD in the first place
- verify warning
- verify Y versus N continues versus stops appropriately
Note if development were done outside the master branch this warning message
will fire early / often as git commit hashes are based on the commit *and* the
rest of the source code the commit is made against.  This is (unfortunately) the
"typical" case so this warning is pretty active at the moment.   T201 will
eventually land and when parsing a given commit update the corresponding diff.

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoUnify arguments for 'arc lint', 'arc unit'
epriestley [Mon, 9 Jan 2012 20:40:50 +0000 (12:40 -0800)]
Unify arguments for 'arc lint', 'arc unit'

Summary: See T645. These commands take inconsistent and overly-magical arguments
right now. Instead, make them behave consistently and allow them both to operate
on "arc <workflow> path path2 path3 ...", which is a generally useful workflow.

Test Plan: Ran "arc lint <path>", "arc unit <path>", "arc lint --rev
HEAD^^^^^^", "arc unit --rev HEAD^^^^^^^^^^^^", etc. Ran "arc diff --trace" and
verified --rev argument to child workflows.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, epriestley, btrahan
Maniphest Tasks: T645

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

14 years agoMerge pull request #11 from mlew/master
Evan Priestley [Mon, 9 Jan 2012 21:17:33 +0000 (13:17 -0800)]
Merge pull request #11 from mlew/master

Added support to bash-completion for zsh

14 years agoAdd support for zsh completion to bash-completion
Mark Lewandowski [Mon, 9 Jan 2012 19:52:51 +0000 (11:52 -0800)]
Add support for zsh completion to bash-completion

14 years agoAdd an "--update <revision>" flag to Arcanist
epriestley [Mon, 9 Jan 2012 17:33:55 +0000 (09:33 -0800)]
Add an "--update <revision>" flag to Arcanist

Summary:
See T614. This flag explicitly tells Arcanist to use the message for an existing
revision, and attach the change to it directly.

Next step is to have "arc diff" automatically choose "--create" or "--update" in
the absence of "--create", "--update", "--only", "--preview" or a template
commit message.

Test Plan:
Ran "arc diff --update <n>" for various revisions. Got updates or
errors as expected.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, btrahan, jungejason
Maniphest Tasks: T614

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

14 years agoApproximate "git merge-base" in Mercurial
epriestley [Fri, 6 Jan 2012 21:14:41 +0000 (13:14 -0800)]
Approximate "git merge-base" in Mercurial

Summary: Find the relative commit by finding the first non-outgoing commit, so
we don't show changes caused by merges we've performed since the last time we
pushed.

Test Plan: Checked out two hg working copies, A and B. Made a change in A. Made
a change in B. Pushed B. Merged in A. Made another change in A. Ran "arc diff"
in A. Got only changes I made in A in the diff, not the change from B.

Reviewers: Makinde, btrahan, jungejason

Reviewed By: btrahan

CC: aran, btrahan
Differential Revision: https://secure.phabricator.com/D1339

14 years agoAdd a "--raw" flag to "arc diff"
epriestley [Thu, 5 Jan 2012 21:36:24 +0000 (13:36 -0800)]
Add a "--raw" flag to "arc diff"

Summary:
Some Mercurial users at Dropbox have very specific diff preparation
needs. Allow "arc" to read an arbitrary diff off stdin. This disables most
features.

Test Plan:
Ran "git diff HEAD | arc diff --raw", "git show | arc diff --raw",
"hg diff --rev 8 | arc diff --raw".

Reviewers: btrahan, jungejason, Makinde

Reviewed By: btrahan

CC: aran, btrahan
Maniphest Tasks: T617

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

14 years agoRefactor ArcanistDiffWorkflow to be a little more manageable
epriestley [Thu, 5 Jan 2012 19:26:17 +0000 (11:26 -0800)]
Refactor ArcanistDiffWorkflow to be a little more manageable

Summary:
I want to make some changes to this workflow but it a huge mess right now. Try
to refactor a bit to make it a little more manageable.

Broadly:

  - Moved lint/unit constant mapping into separate methods.
  - Moved lint/unit/local properties into separate methods.
  - Moved diff spec construction into a separate method.
  - Moved some message stuff into separate methods and reorganized related
methods near to one another.
  - Removed an unused findRevisionInformation() method.

I fixed a couple of small bugs, too:

  - --create now conflicts with --only and --preview.
  - --create now probably works in Mercurial.
  - --create messages now have basic reviewer validation.

This should have not have any significant behavioral changes.

Test Plan:
  - Created this revision.
  - Ran "arc diff --create".

Reviewers: btrahan, jungejason

Reviewed By: btrahan

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

14 years agoRemove all XHP lint tests from Arcanist
epriestley [Thu, 5 Jan 2012 18:25:43 +0000 (10:25 -0800)]
Remove all XHP lint tests from Arcanist

Summary:
  - Remove XHP tests so I can remove XHP support from XHPAST.
  - Update license tests so they don't break every year.

Test Plan:   - Ran all unit tests.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, pad, jungejason, btrahan
Maniphest Tasks: T635

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

14 years agoIgnore non-plaintext changes in cover
vrana [Wed, 4 Jan 2012 23:22:17 +0000 (15:22 -0800)]
Ignore non-plaintext changes in cover

Test Plan:
Run ##arc lint## after changing a binary file
"Warning:  Invalid argument supplied for foreach() in
src/workflow/cover/ArcanistCoverWorkflow.php on line 88" should not be displayed

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoMake XHPASTLinter correct too little space before opening braces
epriestley [Wed, 4 Jan 2012 19:15:33 +0000 (11:15 -0800)]
Make XHPASTLinter correct too little space before opening braces

Summary: Previously, we would not correct missing space before "{".

Test Plan: Ran unit tests.

Reviewers: btrahan, jungejason, kiyoto

Reviewed By: jungejason

CC: aran, jungejason
Differential Revision: https://secure.phabricator.com/D1313

14 years agoMake XHPAST linter correct too much space after control keywords like "if"
epriestley [Wed, 4 Jan 2012 18:59:00 +0000 (10:59 -0800)]
Make XHPAST linter correct too much space after control keywords like "if"

Summary: Previously, we would not correct excessive space after "if", etc.

Test Plan: Ran test case.

Reviewers: btrahan, jungejason, kiyoto

Reviewed By: jungejason

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

14 years agoSlightly improve Arcanist unit test output messages
epriestley [Wed, 4 Jan 2012 15:02:41 +0000 (07:02 -0800)]
Slightly improve Arcanist unit test output messages

Summary:
  - Show file/line so you can tell which assertion failed if there's a block
with a zillion of them and they don't have messages.
  - Try to format stuff a little better.

Test Plan:   - Ran some failing unit tests.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, btrahan
Differential Revision: https://secure.phabricator.com/D1304

14 years ago[arc svn-hook-pre-commit] Access working copy
Kunal Bhalla [Wed, 21 Dec 2011 04:26:05 +0000 (20:26 -0800)]
[arc svn-hook-pre-commit] Access working copy

Summary:
Creates a new hook API that can be used to interface with
SVN/Git/Mercurial in the context of a commit hook. Currently only adds a
function to read the modified file data in a Subversion commit hook.

An object of this API is created in the SvnHookPreCommitWorkflow and
passed on the Lint Engine which then uses it to access current file
data, of the way the APIs seem to be structured); linters use the
getData function which is essentially a wrapper around the engine's
call, with another layer of caching.

Task ID: #770556

Blame Rev:

Test Plan:
- Create a local svn repository and add a minimal hook to run the local
  version of arc to test commits

(http://phabricator.com/docs/arcanist/article/Installing_Arcanist_SVN_Hooks.html)
- Create a temporary repository that can trigger any of the linters
  available, and test against a temporary linter by committing against
  the test repository: the linter should be able to access all required
  files by using loadData/getData in the LintEngine and Linter.

Revert Plan:

Tags: lint, svn-hook-pre-commit

Reviewers: jungejason, asukhachev, epriestley, aran

Reviewed By: epriestley

CC: aran, jungejason, epriestley, kunalb, asukhachev
Differential Revision: https://secure.phabricator.com/D1256

14 years agoReplace preg_quote() lint error by warning
Jakub Vrana [Sat, 3 Dec 2011 00:55:02 +0000 (16:55 -0800)]
Replace preg_quote() lint error by warning

Summary: See http://php.net/regexp.reference.delimiters

Test Plan: arc lint on a file with preg_quote() with one parameter

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoUse getcwd() which is more reliable than $_SERVER['PWD']
jungejason [Sat, 24 Dec 2011 07:48:46 +0000 (23:48 -0800)]
Use getcwd() which is more reliable than $_SERVER['PWD']

Summary:
in arcanist we are using $_SERVER['PWD'], but in some cases it
is not returning the correct result. For example, when I'm using
PhpStorm (an php IDE) to launch the script, $_SERVER['PWD'] returns the
path of the binary of the IDE:
/home/jungejason/tools/PhpStorm-107.658/bin, not the path where arcanist
is at. getcwd() returns the correct value.

One difference between getcwd() and $_SERVER['PWD'] is that getcwd()
resolves symlink where $_SERVER['PWD'] does not. From what I can see,
using realpath should work.

Test Plan:
* ran arcanist as normal and it worked;
* run arcanist in PhpStorm and it worked.
* created a symlink pointing to the repository inside which
I ran the arc command, and it worked.
* created a symlink pointing to arcanist project, run `.
* resources/shell/bash-completion`  and it worked

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoDecompose TYPE_MULTICOPY changes into a MOVE_HERE plus one or more COPY_HERE
epriestley [Thu, 22 Dec 2011 21:48:17 +0000 (13:48 -0800)]
Decompose TYPE_MULTICOPY changes into a MOVE_HERE plus one or more COPY_HERE

Summary:
See T419 for some philosophical musing on this. The "ideal" way to represent
these changes is two or more COPY_HERE plus a DELETE, but we can't build the
DELETE patch yet.

Just turn one of the COPY_HERE changes into a MOVE_HERE. While less idealistic,
I think this should always work.

Test Plan: This seemed to cleanly apply TenXer D265. TenXer guys, can you
confirm that this makes it actually patch correctly?

Reviewers: jonathanhester, bizrad6, kdeggelman, jungejason, btrahan

Reviewed By: jungejason

CC: aran, jonathanhester, jungejason, epriestley
Maniphest Tasks: T419

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

14 years agoAdd some version/env sanity checks to 'arc'
epriestley [Thu, 22 Dec 2011 18:23:29 +0000 (10:23 -0800)]
Add some version/env sanity checks to 'arc'

Summary:
A user filed an issue on GitHub about not having 'json_decode()':

  https://github.com/facebook/arcanist/issues/10

Detect this issue and raise a detailed error message.

Test Plan:
  - Set minimum version to 6.0.0, arc told me to upgrade.
  - Changed function/flag configuration and hit the flag and no-flag error
pathways.

Reviewers: btrahan, jungejason, rm

Reviewed By: rm

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

14 years agoarc cover doesn't support against_commit
vrana [Thu, 22 Dec 2011 22:43:35 +0000 (14:43 -0800)]
arc cover doesn't support against_commit

Summary: Blame Rev:

Test Plan: arc help cover

Reviewers: epriestley

Reviewed By: epriestley

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

14 years agoBump Arcanist client version to 3
epriestley [Wed, 21 Dec 2011 15:35:56 +0000 (07:35 -0800)]
Bump Arcanist client version to 3

Summary:
Thinking about this, I think it's worthwhile to bump versions for T1249/T1250.
The problem is that if you have an old Arcanist, trying to update diffs against
a new Phabricator will create new diffs instead, and it probably won't be
obvious what's wrong.

Bump the versions so users will get a message like "oh, hey, you should
upgrade".

Test Plan:
  - Tried to diff against a mismatched version.
  - Diffed against a matching version.

Reviewers: btrahan, jungejason, aran

Reviewed By: aran

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

14 years agoImprove detection of invalid unit and lint engines
epriestley [Wed, 21 Dec 2011 16:51:34 +0000 (08:51 -0800)]
Improve detection of invalid unit and lint engines

Summary: We fatal confusingly if you specify a valid class that isn't of the
right subclass (like a linter rather than a lint engine). Improve the error
message.

Test Plan:
  - Ran "arc lint --engine PhutilSymbolLoader", "arc unit --engine
PhutilSymbolLoader", got expected failures.
  - Ran "arc diff" normally without errors.

Reviewers: btrahan, jungejason, aran

Reviewed By: aran

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

14 years agoParse full URIs for "Differential Revision" in Arcanist
epriestley [Tue, 20 Dec 2011 23:05:46 +0000 (15:05 -0800)]
Parse full URIs for "Differential Revision" in Arcanist

Summary:
  - Allow Arcanist to parse either "123", "D123" (existing behaviors) or
"http://phabricator.example.com/D123" (new behavior) values.
  - Drop support for labeling this field "DiffCamp". This should only impact
people trying to update revisions that are more than ~a year old, which should
be very very few.

Test Plan:   - Ran "arc diff" with values "74", "D74", "x74",
"http://local.aphront.com/D74", "http://local.aphront.com/x74". Got the expected
behaviors.

Reviewers: jungejason, btrahan

Reviewed By: jungejason

CC: aran, jungejason
Maniphest Tasks: T54, T692

Differential Revision: 1249

14 years agoUse --allow-empty when git amending to HEAD
Chris Piro [Tue, 20 Dec 2011 00:12:13 +0000 (16:12 -0800)]
Use --allow-empty when git amending to HEAD

Summary: ... in case the head commit is empty. Empty commits are useful for
injecting an Arcanist commit message in a branch then sending the whole thing
off for review. As far as I know there is no situation in which an empty commit
would exist unintentionally and using ##--allow-empty## would suppress an error.

Test Plan: works fine for a branch I just sent for review

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1241

14 years agoDon't output "OKAY" for arc lint --output json.
adonohue [Thu, 15 Dec 2011 18:02:29 +0000 (10:02 -0800)]
Don't output "OKAY" for arc lint --output json.

Summary: --output json will be used for scripts, so support script writers a
little better.

Test Plan:
arc lint [--output {json, summary}]
arc lint --output json {--apply-patches, --never-apply-patches}

Reviewers: epriestley

Reviewed By: epriestley

CC: jack, aran, epriestley
Maniphest Tasks: T675

Differential Revision: 1220

14 years agoMerge pull request #9 from cep21/master
Evan Priestley [Wed, 14 Dec 2011 23:32:43 +0000 (15:32 -0800)]
Merge pull request #9 from cep21/master

https://secure.phabricator.com/D1210

14 years agoAdd description to json output
Jack Lindamood [Wed, 14 Dec 2011 20:31:45 +0000 (12:31 -0800)]
Add description to json output

Summary:
Adds a 'desc' field to json output so I can use that inside my vim
plugin.

Test Plan:
Lint a few things.  Description text shows up in vim

Reviewers: epriestley

Reviewed By: epriestley

Differential Revision: 1210

14 years agoUse -M instead of -C in `git blame`
Jakub Vrana [Tue, 13 Dec 2011 19:38:42 +0000 (11:38 -0800)]
Use -M instead of -C in `git blame`

Test Plan: arc cover

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Maniphest Tasks: T668

Differential Revision: 1199

14 years agoMerge branch 'amend_revision'
Marek Sapota [Tue, 13 Dec 2011 19:41:31 +0000 (11:41 -0800)]
Merge branch 'amend_revision'

14 years agoAllow revision numbers prefixed with 'D' in `arc commit --revision`
Marek Sapota [Tue, 13 Dec 2011 19:18:07 +0000 (11:18 -0800)]
Allow revision numbers prefixed with 'D' in `arc commit --revision`

Test Plan: Tried `arc commit --revision D123` and it worked.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1194

14 years agoMake --revision switch of amend workflow easier to use
Marek Sapota [Tue, 13 Dec 2011 19:38:45 +0000 (11:38 -0800)]
Make --revision switch of amend workflow easier to use

Summary:
--revision doesn't allow the revision to be prefixed with 'D'.  Also the error
message showed when specified revision doesn't exist is hard to understand.

Test Plan:
Used `arc amend --revision D123`, tried it without 'D' and with a non existing
revision.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1193

14 years agoExtra variable in ArcanistMercurialAPI::getBlame()
Jakub Vrana [Tue, 13 Dec 2011 17:44:31 +0000 (09:44 -0800)]
Extra variable in ArcanistMercurialAPI::getBlame()

Summary:
derp derp derp

Blame Rev: rARCdb402a6836eaf521

Test Plan: none

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1197

14 years agoBlame command in Mercurial is named `annotate`
Jakub Vrana [Mon, 12 Dec 2011 22:28:34 +0000 (14:28 -0800)]
Blame command in Mercurial is named `annotate`

Summary: Also invalid regular expression

Test Plan: arc cover

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1192

14 years agoFix arc commit workflow when new directories were added.
Marek Sapota [Fri, 9 Dec 2011 23:58:13 +0000 (15:58 -0800)]
Fix arc commit workflow when new directories were added.

Summary: This adds parent directories of modified files to commit paths if
needed.

Test Plan:
Used https://reviews.facebook.net/D603 patch on Apache Hive repository, called
`arc commit` and SVN didn't complain about missing paths.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Maniphest Tasks: T667

Differential Revision: 1189

14 years agoAdd an experimental "--create" flag to "arc diff"
epriestley [Fri, 2 Dec 2011 23:50:36 +0000 (15:50 -0800)]
Add an experimental "--create" flag to "arc diff"

Summary:
See T614. This adds a "--create" flag which I think works properly, but doesn't
make it the default.

Once I add "--update" and am confident the flags actually work, I'll work on
some heuristics to make "arc diff" automatically choose "--udpate" or "--create"
as per T614.

Test Plan:
This revision was created with "--create" and a bogus commit message ("derp").
I intentionally goofed the message at first to test the fail + file workflow.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley, btrahan
Differential Revision: 1162

14 years agoRemove client-side commit message validation from Arcanist
epriestley [Thu, 1 Dec 2011 23:50:44 +0000 (15:50 -0800)]
Remove client-side commit message validation from Arcanist

Summary:
Commit templates are fully configurable on the server now, so we should be doing
validation there, since an install can add or remove fields and change
validation rules. Remove these outdated client validations, as per comment.

Also update the API call to use the 'errors' field, which allows us to show the
user all the parse errors at once. See:

https://secure.phabricator.com/diffusion/P/browse/origin:master/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php;cfaab709df37739b$75

Test Plan:
Ran "arc diff" on a change with multiple errors:

```$ arc diff --conduit-uri=http://local.aphront.com/
Usage Exception: Commit message is not properly formatted:

Error parsing field 'Reviewers': Commit message references nonexistent users:
jjjderp.
Error parsing field 'CC': Commit message references nonexistent users and
mailing lists: jjjderp.

You should use the standard git commit template to provide a commit message. If
you only want to create a diff (not a revision), use --preview to ignore commit
messages.```

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, btrahan
Differential Revision: 1154

14 years agomake arc patch issue a warning if applying a patch against a different project
Bob Trahan [Wed, 30 Nov 2011 06:27:40 +0000 (22:27 -0800)]
make arc patch issue a warning if applying a patch against a different project

Summary: adds a little bit of sanity checking to the arc patch workflow.  in
short, if the working copy project is not the same as the patch project, don't
apply the patch

Test Plan:
ran

arc patch DX
arc patch DX --force

in the top line directory for project A and proejct B.   DX is for project A.

verified for project A that the patch was applied and for project B i was issued
warnings as expected.  also verified in project B case that saying Y or N to the
warning had the desired effect.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, btrahan, epriestley
Differential Revision: 1140

14 years agoAdded local encoding parameter for arc diff workflow
David Reuss [Thu, 1 Dec 2011 16:56:03 +0000 (08:56 -0800)]
Added local encoding parameter for arc diff workflow

Summary:
If any hunks is detected as non-utf8, and you've never submitted diffs
for a certain project before, you would get a ERR-BAD-ARCANIST-PROJECT
exception. This makes it possible to submit the patch properly, so you
can set the encoding in the interface afterwards. Further this fixes
cases where you don't supply a diff but will result in hunks getting
treated as binary, but that still beats the exception behaviour.

Test Plan:
Ran `arc diff` with and without the new --encoding param and
got the expected results. Also ensured the diff (with non utf-8 hunks)
would be properly created even when no encoding is specified.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1135

14 years agoAvoid infinite loop in 'arc unit'
epriestley [Thu, 1 Dec 2011 00:10:27 +0000 (16:10 -0800)]
Avoid infinite loop in 'arc unit'

Summary: If you modify a file at the root level (like the celerity map) we run
the dir/path checks in the wrong order and fail to detect that we can't possibly
find any modules. This leads to an infinite loop inside the while loop below.

Test Plan: Ran "arc unit" on a change which affects the celerity map.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, btrahan
Differential Revision: 1146

14 years agoMerge pull request #8 from vrana/master
Evan Priestley [Wed, 30 Nov 2011 23:55:22 +0000 (15:55 -0800)]
Merge pull request #8 from vrana/master

Document paths parameter in arc unit

14 years agoDocument paths parameter in arc unit
Jakub Vrana [Wed, 30 Nov 2011 20:56:18 +0000 (12:56 -0800)]
Document paths parameter in arc unit

Summary:
arc unit supports paths parameter
It is not documented in arc help

Test Plan:
arc help
Search for unit

Reviewers: slawekbiel, aran

Reviewed By: aran

CC: aran, vrana
Differential Revision: 1143

14 years agoImprove git behavior in the zero- and one- commit case
epriestley [Wed, 30 Nov 2011 17:15:37 +0000 (09:15 -0800)]
Improve git behavior in the zero- and one- commit case

Summary:
Git works completely differently for commits zero and one than for 2..N so add
more special casing to handle them. See:

  - {T206}
  - {T596}

The getCommitRange() block is also fatal land, although I wasn't able to reach
it. I'll follow up with @s on T596.

Test Plan:
  - Created a new, empty repository ("mkdir x; cd x; git init").
  - Ran "arc lint", "arc unit", "arc diff" against it with no commits (the first
two work, the third fails helpfully).
  - Made an initial commit.
  - Ran "arc lint", "arc unit", "arc diff" against it (all work correctly).

Reviewers: btrahan, jungejason, aran

Reviewed By: aran

CC: s, aran
Differential Revision: 1142

15 years agoEnable override ArcanistXHPASTLinter
Jason Ge [Tue, 29 Nov 2011 06:15:06 +0000 (22:15 -0800)]
Enable override ArcanistXHPASTLinter

Summary:
add method setXHPASTTreeForPath() so that a child class of
ArcanistXHPASTLinter can set the tree easily.

Test Plan: wrote a subclass of ArcanistXHPASTLinter and it worked.

Reviewers: pad, epriestley

Reviewed By: pad

CC: aran, pad, jungejason
Differential Revision: 1134

15 years agoWhen running phutil tests from "arc unit", trigger __tests__ in all parent
epriestley [Fri, 18 Nov 2011 19:27:55 +0000 (11:27 -0800)]
When running phutil tests from "arc unit", trigger __tests__ in all parent
modules

Summary:
Right now, if you add a file to "__tests__/data/blah.testcase" it doesn't
trigger those __tests__, but it should. Trigger __tests__ in all parent modules
when a file changes.

(We could be a little more complex about choosing what to run but all the tests
are super fast so it hardly matters if we run "too many" tests.)

Test Plan: Ran "arc unit" on this, got a test trigger. Added a file to a
__tests__/data/ directory and got a test trigger. Added some var_dump() and
spot-checked things for sanity.

Reviewers: btrahan, jungejason, nh, tuomaspelkonen, aran

Reviewed By: jungejason

CC: aran, jungejason
Differential Revision: 1127

15 years agoCorrectly parse Mercurial output for "hg diff --git" when binary files are
epriestley [Fri, 18 Nov 2011 19:03:17 +0000 (11:03 -0800)]
Correctly parse Mercurial output for "hg diff --git" when binary files are
removed

Summary: Mercurial output diverges from git output when binary files are
removed. Parse the Mercurial flavor.

Test Plan:
  - Unit test fails before this change and passes afterward.
  - Removed a binary file in my hg local and successfully "arc diff --only"'d
the change.

NOTE: Git can't apply these patches, and reports:

  $ git apply < ~/Desktop/patch.txt
  error: removal patch leaves file contents
  error: level.png: patch does not apply

Reviewers: Makinde, btrahan, jungejason, nh, tuomaspelkonen, aran

Reviewed By: jungejason

CC: aran, jungejason, Makinde
Differential Revision: 1126

15 years agodon't stopAllLinters() for disabled error
Chris Piro [Thu, 17 Nov 2011 05:53:47 +0000 (21:53 -0800)]
don't stopAllLinters() for disabled error

Summary: if we don't care and don't expect it to break all other linters then
continue

Test Plan: ##arc lint --trace## on a commit with non-ascii characters, saw other
linters continue

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, cpiro
Differential Revision: 1122

15 years agoProvide more information when unit tests fail with exceptions
epriestley [Thu, 17 Nov 2011 19:12:17 +0000 (11:12 -0800)]
Provide more information when unit tests fail with exceptions

Summary:
When a unit test throws an exception, provide more data (type, trace) in the
test failure message.

Previously, we would show only the message itself, which may not be very useful
in debugging test failures.

Test Plan: Ran "arc unit" on a test which throws, got a stack trace.

Reviewers: edward, btrahan, jungejason, nh, tuomaspelkonen, aran

Reviewed By: nh

CC: aran, nh
Differential Revision: 1123

15 years agoAllow modification of the svn commit message via an event listener
Marek Sapota [Thu, 17 Nov 2011 00:40:09 +0000 (16:40 -0800)]
Allow modification of the svn commit message via an event listener

Test Plan:
Wrote an event listener modifying the commit message and the message was
successfully changed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, jungejason, epriestley
Differential Revision: 1103

15 years agoAdd events framework to Arcanist
Marek Sapota [Thu, 10 Nov 2011 21:47:45 +0000 (13:47 -0800)]
Add events framework to Arcanist

Test Plan:
Added a test event listener, added an event dispatch in diff workflow, run the
workflow, the listener was called.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, jungejason, epriestley
Differential Revision: 1102

15 years agoUse linear distance instead of square distance in levenshtein
Emil Hesslow [Tue, 15 Nov 2011 18:43:36 +0000 (10:43 -0800)]
Use linear distance instead of square distance in levenshtein

Summary:
We used square distance that optimized for the wrong thing. Making the same
markers spread out instead of being together

Also added a very little cost for switching type. That will make diff types
stick together a bit more

Task ID: #623

Blame Rev:

Test Plan:
Ran my new unit test. And tested a few diff in phabricator

Revert Plan:

Tags:

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1112

15 years agomake arc issue a warning if file upload fails during diff creation
Bob Trahan [Thu, 10 Nov 2011 03:44:53 +0000 (19:44 -0800)]
make arc issue a warning if file upload fails during diff creation

Summary:
just a little try / catch action in ArcanistDiffWorkflow.

"Ideally, it would be good to flag these changes somehow so that "arc patch" can
issue the inverse warning (e.g., "This patch could not be completely applied
because some binary data was not uploaded.") but that hasn't come up in a real
use case yet."

I think a change w/ filetype of FILE_IMAGE || FILE_BINARY *and* no phid means
that the upload failed so there's no additional flag needed.  (True?)  however,
it would be easy enough to store metadata that explicilty stated whether or not
the file upload succeeded.

(also / related - i looked through the arc patch workflow a bit and i don't
understand how the svn codepath loads up the actual binary files...  for git,
toGitPatch => buildBinaryChange => getBlob is the right path )

Test Plan:
 - set 'storage.mysql-engine.max-size' to 0 in my conf, uploaded diffs with
files
 - noted in differential that it correctly detected images versus binary despite
file upload failing
 - noted in differential that images had some empty UI
 - reverted conf change, uploaded diffs with files
 - noted in differential file showed up
 - ran arc patch with DX, where DX had broken files
 - noted "Downloading binary data...

Exception:
ERR-BAD-PHID: No such file exists."

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1100

15 years agoCheck that rev is accepted in arc mark-committed --finalize
Nick Harper [Fri, 11 Nov 2011 00:02:40 +0000 (16:02 -0800)]
Check that rev is accepted in arc mark-committed --finalize

Summary:
If arc amend is run on a rev that isn't accepted, it runs arc mark-committed
--finalize. The rev shouldn't be marked as committed if it hasn't been accepted,
so this diff adds in that check.

Test Plan:
Ran arc amend on a rev that hasn't been accepted, checked that it didn't get
marked as completed.

Reviewers: jungejason, epriestley

Reviewed By: epriestley

CC: aran, epriestley, nh
Differential Revision: 1104

15 years agoFix ArcanistBundle to generate disjoint, minimal hunks
epriestley [Thu, 10 Nov 2011 01:55:04 +0000 (17:55 -0800)]
Fix ArcanistBundle to generate disjoint, minimal hunks

Summary: 'patch' chokes on hunks with too much trailing stuff. 'git apply'
chokes on overlapping hunks. Make them both happy. Write some test cases so I
stop breaking this stuff.

Test Plan:
  - Applied a previously-failing patch via SVN.
  - Applied a previously-failing-then-succeeding patch via Git.
  - Ran unit tests.

Reviewers: jungejason, btrahan, nh, tuomaspelkonen, aran

Reviewed By: jungejason

CC: aran, jungejason
Differential Revision: 1099

15 years agobash completion: work around PHP CLI readline in command substitution
Chris Piro [Thu, 10 Nov 2011 00:37:32 +0000 (16:37 -0800)]
bash completion: work around PHP CLI readline in command substitution

Summary: (At least my build of) PHP tries to do readline magic on the terminal
when invoked from the shell, even inside bash's command substitution operator.
Work around it by piping the output of ##echo## to ##php##, so the input isn't a
terminal.

Test Plan: ##bash$ arc li<TAB>## now gives me possible completions rather than
breaking and inserting a literal tab

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1096

15 years agoDisable "color" extension in Mercurial in an extension-agnostic way
epriestley [Wed, 9 Nov 2011 02:21:19 +0000 (18:21 -0800)]
Disable "color" extension in Mercurial in an extension-agnostic way

Summary:
In D1079, I added "--color never", but this flag is provided by the "color"
extension, which is why I missed it originally, because it doesn't show up until
you enable that extension. Providing it causes installs which don't have it
enabled (disabled is the default) to fail.

Use "--config" to disable color instead. This sets a configuration setting and
works regardless of whether the color extension is present.

Test Plan: Ran "arc diff" in a mercurial working copy with the color extension
enabled and disabled.

Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran

Reviewed By: nh

CC: aran, nh
Differential Revision: 1092

15 years agoThere's an off-by-one derp issue with this.
epriestley [Tue, 8 Nov 2011 01:19:23 +0000 (17:19 -0800)]
There's an off-by-one derp issue with this.

15 years agoUpdate Arcanist README text
epriestley [Mon, 7 Nov 2011 02:07:04 +0000 (18:07 -0800)]
Update Arcanist README text

Summary: Make this text a little more informative, this stuff is fairly stable
now and has actual documentation available.

Test Plan: Read the document.

Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran

Reviewed By: Makinde

CC: aran, Makinde
Differential Revision: 1086

15 years agoRemove "mercurial support is imaginary" warning from Arcanist
epriestley [Mon, 7 Nov 2011 01:56:13 +0000 (17:56 -0800)]
Remove "mercurial support is imaginary" warning from Arcanist

Summary: We ostensibly now support Mercurial at least mostly, so don't
underpromise quite so much.

Test Plan: Ran "arc diff" in a Mercurial working copy without being warned.

Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran

Reviewed By: Makinde

CC: aran, Makinde
Differential Revision: 1085

15 years agoPrevent ArcanistBundle from generating patches with overlapping hunks
epriestley [Mon, 7 Nov 2011 01:48:43 +0000 (17:48 -0800)]
Prevent ArcanistBundle from generating patches with overlapping hunks

Summary: We currently may generate patches which have hunks that include overlapping context. Git was okay with this until at least 1.7.3.4, but started rejecting these patches some time later.

We already attempt to detect and prevent this condition, we just don't do a very good job of it. Fix the check so that we avoid generating overlapping hunks.

Test Plan:

  - Cleanly applied troublesome patches under Git 1.7.7.2.
  - Used "arc export --git" to verify patches generate without overlapping sections.
  - Locally changed $context to 2 and 1, verified patch behavior was reasonable.

Reviewers: kdeggelman, bizrad6, jonathanhester, jungejason, nh, tuomaspelkonen, aran

CC:

Differential Revision: 1084

15 years agoDisable color extensions in Mercurial
epriestley [Fri, 4 Nov 2011 20:33:08 +0000 (13:33 -0700)]
Disable color extensions in Mercurial

Summary: Mercurial has a --color flag which disables the use of ANSI colors. Use
it to prevent "hg diff" from giving us colorized diff output.

Test Plan: Ran "hg diff --color never", verified it disabled ANSI color in diff
output.

Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran

Reviewed By: aran

CC: aran
Differential Revision: 1079

15 years agoAdd very hacky encoding transformation support for arc
epriestley [Mon, 15 Aug 2011 16:10:22 +0000 (09:10 -0700)]
Add very hacky encoding transformation support for arc

Summary:
Adds a secret, undoucmented "encoding" key to ".arcconfig" which makes a very
half-hearted effort to convert encodings. This is probably good enough that
Differential can be used for code review, but there will be issues with 'arc
patch', 'arc export', paste, maybe conduit stuff, Diffusion, and whatever else I
haven't thought of.

This also doesn't store the original encoding so anything converted like this
won't reasonably be able to be made to work with all that stuff in the future.

See T452 for a broader discussion of the issues involved.

Test Plan:
Short circuited the UTF-8 detection to always fail, had my files "converted"
from ISO-8859-1 to UTF-8.

@davidreuss: you can test this by applying this patch to arcanist/, adding
'"encoding" : "ISO-8859-1"' to your .arcconfig, touching some non-ASCII file,
and then running "arc diff".

Reviewers: davidreuss, jungejason, tuomaspelkonen, aran

Reviewed By: davidreuss

CC: aran, davidreuss, epriestley, nshamg123
Differential Revision: 812

15 years agoSave committed revision id in workflow.
Marek Sapota [Fri, 4 Nov 2011 19:12:14 +0000 (12:12 -0700)]
Save committed revision id in workflow.

Summary:
Save commited revision id in workflow, so it can be used in Arcanist
didRunWorkflow hook.

Test Plan:
Running getRevisionID on the workflow should return id of the committed
revision.

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, epriestley, mareksapota
Differential Revision: 1078

15 years agoFix "arc lint" exploding on new directories
epriestley [Thu, 3 Nov 2011 20:42:19 +0000 (13:42 -0700)]
Fix "arc lint" exploding on new directories

Summary:
D1061 introduced a 'text file' check, but it fails under SVN for new
directories.

  - Revert D1061 (This reverts commit b2cd18252701be2093b52652fb3d1d94c5df571e.)
  - Make getChangedLines() return null to indicate that the operation doesn't
make sense. I think this was the intent of the code in the lint engine.
  - Fix a bug where running "arc lint" on a change in an SVN working copy from a
subdirectory would fail.
  - Fix a bug where warnings with no line information were incorrectly
discarded.

Test Plan:
  - Ran "arc lint" in an SVN working copy with a new directory (no failure).
  - Forced FilenameLinter to always raise a warning. Added a binary file and ran
"arc lint". The warning was reported for the new binary file, a new text file,
and a new directory.

Reviewers: jungejason, andrewjcg, nh, tuomaspelkonen, aran

Reviewed By: andrewjcg

CC: aran, andrewjcg, epriestley
Differential Revision: 1076

15 years agoCorrectly implement getFileDataAtRevision()
epriestley [Wed, 2 Nov 2011 00:21:39 +0000 (17:21 -0700)]
Correctly implement getFileDataAtRevision()

Summary: Apparently I just never tested this or something. Make it work
correctly.

Test Plan: Ran "arc diff" in a Mercurial working copy with a binary file in
outgoing.

Reviewers: Makinde

Reviewed By: Makinde

CC: aran, Makinde
Differential Revision: 1074

15 years agoDon't flag "Untracked" files in Mercurial as "Uncommitted"
epriestley [Wed, 2 Nov 2011 00:10:48 +0000 (17:10 -0700)]
Don't flag "Untracked" files in Mercurial as "Uncommitted"

Summary: We incorrectly add the "Uncommitted" flag to untracked files, which
causes them to raise various prompts and not respect "--allow-untracked".

Test Plan: Ran "arc diff --allow-untracked" in a clean working copy with
untracked files, was not fatally error'd.

Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran

Reviewed By: Makinde

CC: aran, Makinde, epriestley
Differential Revision: 1073

15 years agoAllow running `arc patch` without authentication.
Marek Sapota [Tue, 1 Nov 2011 19:34:27 +0000 (12:34 -0700)]
Allow running `arc patch` without authentication.

Summary:
Allow `arc patch` without authentication if Phabricator instance has
'differential.anonymous-access' set to true.

Test Plan:
Set 'differential.anonymous-access' in Phabricator to true and run `arc patch`
without installing a certificate.  `arc patch` should work as expected.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1069

15 years agoFix "arc diff" under Mercurial with a dirty working copy
epriestley [Tue, 1 Nov 2011 22:07:39 +0000 (15:07 -0700)]
Fix "arc diff" under Mercurial with a dirty working copy

Summary:
In D962, I switched us from using "hg summary" to "hg id" to find the working
copy revision. However, "hg id" reports the revision with a trailing "+" if the
working copy is dirty, so we fail before hitting the explicit check for this
later.

Trim off the trailing '+' if it is present.

Test Plan:
Ran "arc diff" in a dirty Mercurial working copy and got a good error message
about uncommitted changes.

  ~/repos/hg-working-copy $ arc diff
  WARNING: Mercurial support is largely imaginary right now.
  Usage Exception: You have uncommitted changes in this branch. Commit (or
revert) them before proceeding.

    Working copy: /INSECURE/repos/hg-working-copy/

    Uncommitted changes in working copy
      hello.c

Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran

Reviewed By: Makinde

CC: aran, Makinde
Differential Revision: 1070

15 years agosupport newer PyLint column numbers
Chris Piro [Thu, 27 Oct 2011 22:37:45 +0000 (15:37 -0700)]
support newer PyLint column numbers

Summary: newer PyLint includes commas and a column number for every message
after the line number. ignore that if it's present.

Test Plan: ##arc lint --trace --lintall## a file with messages with the old and
new pylint (2.5), works fine with both

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1062

15 years agoShow lint warnings for non-"line-able" files
Andrew Gallagher [Thu, 27 Oct 2011 22:26:23 +0000 (15:26 -0700)]
Show lint warnings for non-"line-able" files

Summary:
Currently, lint messages are only included if they are errors or
if they affect lines which the diff changed.  The implementation
of this caused issues for non-text files (e.g. binaries), as line
change information is not available, and the corresponding lint
messages were dropped (for non-errors).

In this diff, only lint messages concerning text files are dropped
based on this line filtering.

Test Plan: arc lint with binary file

Reviewers: jungejason, epriestley

Reviewed By: epriestley

CC: aran, aravindn, andrewjcg, liat, epriestley
Differential Revision: 1061

15 years agoMerge pull request #7 from mareksapota-fb/master
Evan Priestley [Fri, 28 Oct 2011 16:26:14 +0000 (09:26 -0700)]
Merge pull request #7 from mareksapota-fb/master

Pull request for differential revision D1055

15 years agoAllow anyone to run `arc commit` on an accepted revision
Marek Sapota [Wed, 26 Oct 2011 03:03:41 +0000 (20:03 -0700)]
Allow anyone to run `arc commit` on an accepted revision

Test Plan:
Using SVN make some changes to the repo, run `arc diff`.  As other user accept
the revision, add the changes to your repo using `arc patch` and then run `arc
commit --revision revisionID` to commit them.  Arcanist should ask if you are
sure that you want to commit this revision and if you answer `Y` it should
commit to SNV repo.

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, mareksapota, epriestley
Differential Revision: 1055

15 years agoSupport other encodings in ArcanistDiffParser
David Reuss [Fri, 28 Oct 2011 15:01:21 +0000 (08:01 -0700)]
Support other encodings in ArcanistDiffParser

Test Plan:
Tried viewing a diff detected as binary in diffusion with and without
setting my desired encoding. Worked as expected.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1008

15 years agoadd lint.pylint.pythonpath option for ArcanistPyLintLinter
Chris Piro [Tue, 25 Oct 2011 22:23:08 +0000 (15:23 -0700)]
add lint.pylint.pythonpath option for ArcanistPyLintLinter

Summary: allow adding PYTHONPATHs directly in addition to the hardcoded few
already allowed.

Test Plan: ##arc lint## successfully picks up the paths listed in my .arcconfig,
and no longer errors on modules not found from those directories

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1050