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

420 commits

Author SHA1 Message Date
Jamie Wong
bcbe1737b8 Use .^ instead of HEAD^ for mercurial
Summary:
##arc amend## in a mercurial repo was failing with this message

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

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: vrana, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2690
2012-06-11 10:00:02 -04:00
vrana
6bc4da8c4c Remove support for skipping tests
Summary: Almost revert D2673 but leave the support for 'repeat'.

Test Plan: `arc help unit`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

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

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

    "immutable_history" : false

in arc configuration.

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

Test Plan:
without "immutable_history" turned on)>

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

Reviewers: epriestley

CC: csilvers, aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2654
2012-06-07 15:29:24 -04:00
epriestley
d016f81135 Add "--conduit-timeout" to arc and modernize argument parsing
Summary:
We added "repeat" to PhutilArgumentParser a while ago, so we can modernize the rest of the argument parsing (allow multiple --load-phutil-library flags).

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

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

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

        $ arc install-certificate

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

Reviewers: phleet, vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2603
2012-06-03 08:31:49 -07:00
vrana
2a99dc8b38 Remove unused variable 2012-06-01 23:33:58 -07:00
vrana
1d9ffce1ec Define interface for lint renderers
Summary:
It makes me nervous.

Also move them to the dir.

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

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

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

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin, meitros

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

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

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

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

Reviewers: csilvers, btrahan, vrana

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 11:41:39 -07:00
vrana
f288ee0e21 Depend on autoloading
Test Plan:
  arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

Test Plan: See D2588.

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

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

Test Plan: Upgraded libphutil, arcanist and phabricator to v2

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

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

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

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2580
2012-05-25 11:42:27 -07:00
vrana
3e4d1c6f19 Fix whitespace
I guess that the option does not have 'supports' to allow creating aliases working in all repos.

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

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

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

Reviewers: btrahan, csilvers

Reviewed By: csilvers

CC: aran

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

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

Reviewers: csilvers, btrahan

Reviewed By: csilvers

CC: aran

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

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

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

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

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

Reviewers: csilvers, btrahan

Reviewed By: csilvers

CC: aran

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

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

Reviewers: btrahan, csilvers, Makinde, jungejason, vrana

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2536
2012-05-22 11:08:57 -07:00
epriestley
ccdf9ae957 Bump Conduit client version
Summary:
Several related changes:

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

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

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

Reviewed By: vrana

CC: aran

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

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

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

Reviewers: Girish, btrahan, ashutoshc

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1206

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

Reviewers: btrahan, epriestley

Reviewed By: epriestley

CC: aran, epriestley

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

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

Reviewers: btrahan, jungejason

Reviewed By: jungejason

CC: epriestley, aran

Differential Revision: https://secure.phabricator.com/D2493
2012-05-18 00:04:29 -07:00
Nick Harper
032b9b30b0 Provide user-friendly error in arc diff --update
Summary:
If you forget to provide an argument for --update and have another argument
following it (e.g. HEAD^), we should provide a nice error message instead
of passing that argument through to a conduit call and then printing the
conduit error.

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

Reviewers: epriestley, jungejason, vrana

Reviewed By: epriestley

CC: aran, Koolvin

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

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

Reviewers: btrahan, Makinde

Reviewed By: Makinde

CC: aran

Maniphest Tasks: T1183

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

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

Reviewers: epriestley, jungejason, vrana, davidreuss

Reviewed By: jungejason

CC: aran, Koolvin

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

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

Reviewers: aurelijus, btrahan

Reviewed By: aurelijus

CC: aran

Maniphest Tasks: T1204

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

Test Plan: idk lmk?

Reviewers: Makinde

Reviewed By: Makinde

CC: aran

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

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

Reviewers: Makinde, nh, jungejason, btrahan

Reviewed By: nh

CC: aran

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

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

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, Koolvin

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

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

Reviewers: jungejason, epriestley, vrana

Reviewed By: epriestley

CC: aran, Koolvin

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

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

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

Reviewers: btrahan, csilvers

Reviewed By: csilvers

CC: aran

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

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

Reviewers: nh, jungejason, vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1183

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

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

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

Reviewers: jungejason, btrahan

Reviewed By: jungejason

CC: vrana, aran

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

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

Test Plan: Grepped for "committed".

Reviewers: btrahan, vrana, Makinde

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T909, T1182

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

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

Test Plan:
Get/set some values?

iiam

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2400
2012-05-07 06:07:23 -07:00
vrana
b77c379441 Document first line behavior in update message
Test Plan: (This diff)

Reviewers: epriestley, jungejason

Reviewed By: jungejason

CC: aran, Koolvin

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

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

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, Koolvin

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

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

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

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

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

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

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

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

Reviewers: aran, tuomaspelkonen, jungejason, btrahan, vrana

Reviewed By: vrana

CC: aran, epriestley, vrana

Maniphest Tasks: T230

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

Test Plan: Meta.

Reviewers: btrahan, vrana, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1159

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

Test Plan: Hit tab, landed this branch.

Reviewers: zeeg, btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran, kdeggelman

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

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

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1124

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

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

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran, Makinde

Maniphest Tasks: T909

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

Reviewers: blair

CC: aran, epriestley

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

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

Reviewers: btrahan, vrana, simpkins, beng

Reviewed By: btrahan

CC: aran, avive

Maniphest Tasks: T1117

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

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

Reviewers: svemir, btrahan, vrana, jungejason

Reviewed By: svemir

CC: aran

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

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

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

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

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

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

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

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

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran

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

Also improve a message.

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

Reviewers: svemir, btrahan, vrana, jungejason

Reviewed By: svemir

CC: aran

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

Test Plan:
  arc liberate

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Maniphest Tasks: T1085

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

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

Reviewers: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2162
2012-04-08 20:57:38 -07:00
Koolvin
b553af2763 Add arc tasks command
Summary:
Added `arc tasks`:

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

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

Reviewers: epriestley, indiefan

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T749

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

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

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

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

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

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

Reviewers: btrahan, jungejason, nh

Reviewed By: btrahan

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

Maniphest Tasks: T614

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

I broke this in rARC1f13e022cdc9bf4859274a83784bd615caf62ef9 when I improved Mercurial support.

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

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

Reviewers: vrana, jungejason, btrahan

Reviewed By: btrahan

CC: aran

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

Test Plan:
  arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

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

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

See D863 for the last attempt at this.

NOTE: This is contentious!

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

Reviewers: btrahan, vrana, nh, jungejason, tuomaspelkonen

Reviewed By: btrahan

CC: aran, epriestley, zeeg, davidreuss

Maniphest Tasks: T651

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

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

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

Also fix an issue identified by the linter.

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

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, epriestley, jungejason

Differential Revision: https://secure.phabricator.com/D2052
2012-03-29 13:21:18 -07:00
epriestley
ff94d699fe Minor Arcanist fixes
Summary:
Addresses concerns in rARCefb8219196abf047f14b505959e54d078e1df6d3:

  - As I recall, the intent of "generateFile" was that these warnings would replace all the other warnings for that file, under the theory that if one warning caused regeneration of
the file the other warnings were irrelevant.
  - However, this code never had any effect and I haven't seen any issues with the behavior.
  - So, just remove it.

Addresses concerns in rARC070e963d1c26879e47eab19a2377e388c2f166c5:

  - Ran "arc liberate --all".

Test Plan: Ran "arc lint" after removing an "__init__.php" with and without a "fixed" generateFile block, there was no behavioral change. So I just nuked it.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2049
2012-03-29 13:21:10 -07:00
vrana
30f036c6b9 Use assert_instances_of()
Summary: D2042

Test Plan:
- `arc lint` with dependent message
- `arc liberate`
- `arc diff`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2048
2012-03-29 08:35:49 -07:00
vrana
edb6a38389 Avoid double indenting in console wrapping
Summary:
D2016 changed the behavior of `phutil_console_wrap()`.
The new behavior is better so I am fixing callsites instead of the function.

Test Plan:
  arc help help

Verify that the options descriptions is not indented with 28 spaces.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2047
2012-03-28 22:28:15 -07:00
epriestley
070e963d1c Minor, squelch a warning about reference variables.
Auditors: vrana
2012-03-26 10:03:59 -07:00
epriestley
b67ce7e534 Raise a better error message when "arc patch" fails because of filename case changes
Summary: Git can't apply filename case change patches on case-insensitive filesystems. Some day we could manually do this ourselves, but it's fairly rare and complicated -- just raise a useful warning.

Test Plan: Tried to apply a case-changing patch, got a good error.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T618

Differential Revision: https://secure.phabricator.com/D2015
2012-03-26 09:43:37 -07:00
epriestley
4ca58d1129 Improve compatibility of "arc patch" on Windows
Summary: Can't use (cd ...) on windows.

Test Plan: Ran "arc patch" successfully.

Reviewers: Makinde, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T124, T1034

Differential Revision: https://secure.phabricator.com/D1987
2012-03-25 09:32:20 -07:00
epriestley
1acbe76cbf Minor, fix clowniness. 2012-03-23 08:56:38 -07:00
epriestley
3991e679e7 Minor, fix inverted condition. 2012-03-23 08:53:47 -07:00
epriestley
e31bc81b6c Update 'arc land': add --squash, add default config, fix windows compat
Summary:
  - We have "--merge", added similar "--squash" for completeness.
  - Switched away from (cd .. && ...) pattern which is not functional on Windows.
  - Allow a default --onto to be specified, if master isn't the best default for a project.

Test Plan:
  - Did --hold --keep dry runs, changes landed properly.
  - Set a default onto branch in .arcconfig.
  - Ran --merge and --squash together to verify conflict configuration.

Reviewers: btrahan

CC: aran, epriestley

Maniphest Tasks: T124, T1033

Differential Revision: https://secure.phabricator.com/D2001
2012-03-22 18:28:35 -07:00
epriestley
3bff9417e9 Set relative commit early in "arc diff"
Summary:
In Mercurial, we figure out if the working copy is dirty with "hg diff", and do a somewhat expensive merge-base / outgoing operation if the relative commit isn't set. We can set the relative commit earlier and avoid some extra work.

We also may incorrectly cache this state (diff from merge-base of outgoing to tip) and pass the wrong rev and file dirty list to the linters.

Test Plan: Made commits which changed (A, B) and then (A). Ran "arc diff tip^". Before this change, observed full outgoing + merge base resolve and both "A" and "B" passed to lint. Observed execution of fewer commands and lint executing against "A" only after this change.

Reviewers: Makinde, btrahan

Reviewed By: Makinde

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1998
2012-03-22 17:22:52 -07:00
epriestley
31a54d9b4a When a mercurial working copy has uncommitted changes, prompt to include them in "arc diff"
Summary:
See task. Allow mercurial users to diff with uncommitted changes.

  - By default, commit range is merge-base of `hg outgoing` to `.` (dirstate).
  - You can get JUST dirstate with `arc diff tip` or similar.
  - This ended up being a giant mess various other changes to deal with empty `hg outgoing` and empty dirstate.

Test Plan: Diffed with uncommitted changes, got sensible prompts and results.

Reviewers: Makinde, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T998

Differential Revision: https://secure.phabricator.com/D1954
2012-03-19 19:17:10 -07:00
epriestley
cdcb5cc25d Minor, address @btrahan feedback. 2012-03-19 19:16:50 -07:00
epriestley
d516f39bf3 Throw a helpful message when users run "arc diff --raw --update".
Summary: We crash and burn right now, trying to launch an interactive editor against a non-tty stdin. Raise a helpful error message instead.

Test Plan: Will run "arc diff --raw --update".

Reviewers: btrahan, yairlivne

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1949
2012-03-19 19:15:58 -07:00
epriestley
4e888458d7 In "arc patch", use "cat-file -t" instead of "rev-parse --verify" to check for commits.
Summary:
  - `git rev-parse --verify` "verifies" very valid-looking commit name, not just valid commit names.
  - Currently, if we can't find the base rev we'll incorrectly "verify" it and then fail on "git checkout -b <branch> <some bogus commit>".
  - Instead, use `git cat-file -t`.
  - See similar fix in D1590.

Example:

  $ git rev-parse --verify aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Test Plan: Ran "arc patch" in a mismatched local, hit "Y" to branch, got a branch off HEAD instead of an error.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1947
2012-03-19 19:11:52 -07:00
epriestley
89753d5d49 Don't fatal without Conduit for "--patch" and "--bundle"
Summary:
In some workflows, we don't have Conduit at all, so we'll fail with a raw exception. Test for conduit presence before trying to make the encoding call.

Also move some "instanceof" logic for updates into RepositoryAPI (factoring, windows compat).

Test Plan: Ran "arc patch --patch some.patch".

Reviewers: 20after4, davidreuss, nh, btrahan

Reviewed By: 20after4

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1935
2012-03-16 13:40:33 -07:00
David Reuss
545f51a4fb Respect custom set encoding in patch/export workflows
Summary:
In cases where a codebase is not UTF-8, we will attempt an conversion,
if an alternative encoding is given/configured.

This is now possible in two ways:

  - by configuring one under repository tracking in diffusion
  - by passing an --encoding option to the workflow

If the first is not available we will make a conduit call
to do an extra check and see if an encoding is configured directly with
phabricator.

Test Plan:
Tried various diffs with known encodings (mostly ISO-8859-1), and passed
it in, via stdin, or downloaded a known problematic revision from
phabricator, and they applied where they otherwise failed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T452

Differential Revision: https://secure.phabricator.com/D1880
2012-03-14 07:08:21 -07:00
Nick Harper
7494a95c40 [svn1.7] handle removed directories in svn in arc diff
Summary:
`svn rm $directory` removes the directory and its contents in svn 1.7, whereas
svn 1.6 only removes the directory's contents, so arc diff needs to not try
to read the directory.

Test Plan:
ran arc diff in a svn working copy that had a directory removed (with both
svn 1.6 and svn 1.7) and confirmed that the command did not throw an exception,
and that the removed directory was marked as directory (not a file).

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1889
2012-03-13 23:45:37 -07:00
epriestley
ec9a3ddb23 Add a check to 'arc liberate' for loose .php files in the library root
Summary: @koolvin ran into this and was justifiably confused.

Test Plan: Put some random .php file in src/, ran arc liberate src/, got warned.

Reviewers: btrahan, Koolvin

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1878
2012-03-13 11:17:28 -07:00
Nick Harper
024d108661 [svn1.7] treat nonpositive rev numbers as added files
Summary:
svn 1.7 reports a rev number of -1 for added files; previous versions
reported a rev number of 0. Interpret nonpositive rev numbers to mean
the file was added.

Test Plan: ran arc diff on an svn1.7 working copy with added files

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1867
2012-03-13 11:11:48 -07:00
epriestley
d8967290e9 Improve "arc cover" parameters
Summary: Give "arc cover" --rev and paths parameters like "arc lint" and "arc unit".

Test Plan: Ran 'arc cover' with various rev/path things. Ran in SVN to verify it works/fails correctly.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T707

Differential Revision: https://secure.phabricator.com/D1860
2012-03-12 17:04:20 -07:00
Edward Speyer
8f76800efc Make lint output look like a compiler
Summary:
Make lint output look like gcc errors / grep output; a format used by
editors to jump from a compiler error to a file+line of code which
triggered the error.

Test Plan:
In vim, I ran:

  :set makeprg=~/checkouts/devtools/arcanist/bin/arc\ lint\ --output\ compiler

Then:

  :make

And was able to jump directly to problematic lines of code.

Reviewers: jungejason

Reviewed By: jungejason

CC: aran, edwardspeyer, jungejason, codeblock, tuomaspelkonen, epriestley

Differential Revision: https://secure.phabricator.com/D550
2012-03-09 11:20:08 -08:00
epriestley
f57199268f Remove chooseRevision() and DifferentialRevisionRef
Summary: `arc which` and related workflows have supplanted these now-unused mechanisms.

Test Plan: Grepped for chooseRevision() and DifferentialRevisionRef.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1841
2012-03-09 08:57:24 -08:00
epriestley
a7866827a2 Fix another "arc patch" authentication issue
Summary: Similar to rARC298ed9cda55d90b755e4dc45d202213e91631888, work around "differential.anonymous-access" issues until we get proper permissions up.

Test Plan: Ran "arc patch" against a "differential.anonymous-acccess" install with a revision argument

Reviewers: btrahan, mbautin

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T848

Differential Revision: https://secure.phabricator.com/D1835
2012-03-09 08:57:18 -08:00
Bob Trahan
276b013d87 Arc patch - upgrade "same base rev" check to "does this commit exist in the working copy?" check
Summary: good title

Test Plan: ran "arc patch DX" a bunch

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T892

Differential Revision: https://secure.phabricator.com/D1789
2012-03-07 13:02:53 -08:00
epriestley
2c26304dd2 Catch "ConduitClientException", not "Exception", in "arc patch"
Summary: This may raise other types of exceptions, e.g. http/network exceptions, where getErrorCode() is not defined.

Test Plan: Reasoned about beahvior.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1804
2012-03-06 20:14:34 -08:00
vrana
ee21b3c661 Simplify arc help, add arc help --full
Summary:
`arc help` currently prints more than 500 lines and it is hardly usable without ##> arc.help##, ##| less##, ##| grep##, ##| wc -l## or such.
It is even worse with custom commands and options.

This diff changes `arc help` to only list commands with no description (under 100 lines).
It also adds `arc help --full` which maintains the original behavior.
It doesn't change `arc help <command>`.

NOTE: BC break on different levels.

Test Plan:
  arc help
  arc help --full
  arc help help
  arc help lint

Reviewers: epriestley

Reviewed By: epriestley

CC: nh, aran, epriestley

Differential Revision: https://secure.phabricator.com/D1769
2012-03-05 10:44:17 -08:00
epriestley
ba21708513 Make "arc diff --raw -C HEAD" work correctly
Summary:
There's no reason this can't work now, we're just not quite careful enough about definitions.

NOTE: If you use a message which has a revision ID in it already, this will fail in an obtuse way when launching the update editor fails because stdin isn't a tty. I'll clean this all up after T614 is fully sorted.

Test Plan: Ran "arc diff --raw -C HEAD".

Reviewers: btrahan, yairlivne

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1765
2012-03-05 10:08:50 -08:00
epriestley
2f9a422bc6 Improve arc compatibility on Windows
Summary:
  - When altering the include_path(), use PATH_SEPARATOR (";" on Windows, ":" elsewhere) instead of hard-coded ":".
  - Detect missing php_curl.dll extension.
  - Use APPDATA instead of HOME for storing .arcrc (the internet implies this is correct?)
  - Don't try to do chmod() stuff on Windows; it's not critical and I don't want to figure out how it works.

Test Plan: Was able to run part of some arc commands on Windows.

Reviewers: btrahan, Makinde, Koolvin

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T124

Differential Revision: https://secure.phabricator.com/D1756
2012-03-05 10:02:37 -08:00
vrana
eae497152c Warn about wrong ID in arc download D8O88
Summary: It also disables `arc download F7312-rainbow`.

Test Plan:
  arc download D8O88
  arc download F7312-rainbow
  arc download F7312

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1768
2012-03-04 03:16:32 -08:00
vrana
50cedc67ff Enable shell completion without set aliases
Summary:
Otherwise it says after hitting Tab everytime:

> Warning:  Invalid argument supplied for foreach() in arcanist/src/workflow/shell-complete/ArcanistShellCompleteWorkflow.php on line 99

Test Plan: arc h<Tab>

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1766
2012-03-04 03:14:54 -08:00
epriestley
77262c0cff Add "--revision <id>" flag to "arc land"
Summary: Allow the user to pick a revision explicitly if they think they know what they're doing. Similar to "arc amend --revision", etc.

Test Plan: Obviously compells a meta-test.

Reviewers: btrahan, fratrik

Reviewed By: fratrik

CC: aran, epriestley

Maniphest Tasks: T928

Differential Revision: https://secure.phabricator.com/D1753
2012-03-02 16:47:05 -08:00
Andrey Sukhachev
6d17dd6030 Allow disabling the part where you write an excuse
Summary:
Not everyone thinks it's a great feature

Task ID: #

Blame Rev:

Test Plan:
arc diff --skip-excuses

Revert Plan:

Tags:

Reviewers: akramer, epriestley, ide, mroch

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1735
2012-02-29 17:19:13 -08:00
epriestley
2fa18d80f8 Pre-fill template fields under "arc diff --create" in git
Summary:
When the user runs "arc diff --create" or triggers it via "arc diff
--auto", prefill the template as best we can.

Test Plan:
Ran "arc diff --auto" with a template commit message in the working
copy under various configurations, results seemed reasonable.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley, dmi

Maniphest Tasks: T614

Differential Revision: https://secure.phabricator.com/D1719
2012-02-28 17:00:35 -08:00
epriestley
1f13e022cd Prefill template update message in Mercurial during --update
Summary:
When a user invokes the update flow from Mercurial, prefill the update message
like we do for Git.

Also add a little caching to improve performance since "hg" execs cost ~100ms.

Test Plan: Updated a Mercurial diff repeatedly, got sensible default message
fills.

Reviewers: Makinde, btrahan

Reviewed By: Makinde

CC: aran, epriestley

Maniphest Tasks: T28

Differential Revision: https://secure.phabricator.com/D1718
2012-02-28 16:59:40 -08:00
vrana
ee8c8cf4e7 Missing space in lint message
Test Plan: arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1711
2012-02-27 18:12:34 -08:00
Natthu Bharambe
1722e2999b Merge branch 'master' of github.com:facebook/arcanist into arc_excuse 2012-02-23 13:59:50 -08:00
Natthu Bharambe
4722a187e6 Require explanation for failing lint/tests in arc.
Summary:
Modified the arc diff workflow, introduced new diff properties -
arc:lint-excuse and arc:unit-excuse for respective errors/warnings.
The diff author inputs the explanation in an editor (similar to commit
message).

Task ID: #

Blame Rev:

Test Plan:
Ran sandbox arc on itself with some lint errors and verified that the
Diff property (== user explanation) is being set.

Revert Plan:

Tags:

Reviewers: epriestley, nh

CC: akramer, blair, aran, andreygoder, Girish, epriestley

Differential Revision: https://secure.phabricator.com/D1676
2012-02-23 13:58:27 -08:00
epriestley
432e4fcf9c When updating revisions, pre-fill update message with more commits in Git
Summary:
When a Differential revision is updated in git, try to find all commit messages
in the range which we haven't already attached and combine them into a default
update message.

This won't work perfectly in a workflow where you rebase //and// stack local
commits, but worst case is that you just have to delete some lines, which is
still probably better overall than losing this information.

Test Plan: Meta-testing in progress.

Reviewers: btrahan, ptarjan

Reviewed By: btrahan

CC: aran, epriestley, davidreuss

Maniphest Tasks: T28

Differential Revision: https://secure.phabricator.com/D1671
2012-02-23 09:18:49 -08:00
epriestley
9fb634880e Make 'arc diff --auto' only identify open revisions
Summary: Otherwise, "arc diff --auto" on a branch with the same name as some
other branch you previously used tries to update that revision.

Test Plan: Ran "arc diff --auto" on a "listdocs" branch; arc didn't try to
update D1639.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T614

Differential Revision: https://secure.phabricator.com/D1662
2012-02-22 10:07:43 -08:00
epriestley
b058efbb51 Add an "arc alias" command
Summary:
Allow users to easily define aliased arc commands. This is easier than making
them muck around with shell stuff, and lets me do stuff like "arc alias adiff
diff -- --auto" so I can test --auto more easily.

There are some limitations here (for example, you can't put --trace in an alias
because it gets parsed too early) but I think it's a reasonable starting point.

Test Plan: Set, listed, removed and used aliases.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T896

Differential Revision: https://secure.phabricator.com/D1653
2012-02-21 13:16:52 -08:00
epriestley
964bdb63ba Improve handling of commit message on --auto/--update/--create workflows
Summary:
Our failure behavior currently sucks. In particular:

  - If lint or unit fail (expectedly or unexpectedly), we throw away your
message. omglol sux 2 b u
  - If there's a parsing error, we dump the message to 'arc-commit-message' in
CWD and tell you to go deal with it.

This is awful. Improve the behavior:

  - Once we read a message, save it in .arc/commit-message so we always have it
if anything goes wrong.
  - If that file exists, prompt to read it without any "-F" nonsense.
  - If there's a parsing error, tell the user and prompt them to just edit the
file again, showing what they need to fix.

Test Plan: Ran "arc diff --auto" and made a bunch of intentional errors; arc
never screwed me over and was generally fairly pleasant.

Reviewers: btrahan, Makinde

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T614, T895

Differential Revision: https://secure.phabricator.com/D1656
2012-02-21 12:35:39 -08:00
epriestley
4a0bd01550 Remove "arc merge" support for Mercurial
Summary:
Our one Mercurial client doesn't use it (T614) and I moved git off to "arc
land".

This workflow can never work properly for Mercurial without extensions anyway
since it doesn't have --no-ff.

Test Plan: Ran "arc merge" in SVN, git and Mercurial repositories.

Reviewers: btrahan, Makinde

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T614

Differential Revision: https://secure.phabricator.com/D1650
2012-02-21 09:27:52 -08:00
epriestley
085963501b Replace "arc merge" with "arc land --merge" for git
Summary:
I think "arc land" is better than "arc merge" in every case? Make "arc merge"
hg-only (possibly nuke it later, see T614) and point users at "arc land".

Add an explicit "--merge" flag to force --no-ff behavior in mutable reposiories.

Test Plan:
Ran "arc land --hold --merge <feature>" on this branch, got a clean
merge.

Reviewers: fratrik, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1647
2012-02-20 12:51:14 -08:00
epriestley
964260b1e0 Use "differential.query", not "differential.find", in "arc branch"
Summary: find is deprecated, query is new hotness.

Test Plan: Ran "arc branch", got identical output.

Reviewers: nh, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1646
2012-02-20 12:51:08 -08:00
epriestley
506e795fda Add an "--auto" flag to arc diff to activate heuristics
Summary:
For some workflows (all Mercurial, all SVN, some git) I eventually want arc to
pick between "arc --create" and "arc --update" automatically.

"arc which" laid the groundwork for this. For now, implement it as an optional
flag because I think there are still some rough edges on this pathway (for
example, handling of commit messages when errors happen).

When 'arc diff --auto' is invoked, guess whether the user meant --create or
--update.

Test Plan: Created this revision with 'arc diff --auto'.

Reviewers: Makinde, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T614

Differential Revision: https://secure.phabricator.com/D1648
2012-02-20 12:51:01 -08:00
Bob Trahan
298ed9cda5 hack up arc patch to not differential.query if its not authenticated
Summary: 'cuz the method would fail without authentication!  see D1604 for some
discussion on approaches here

Test Plan: ran arc patch and it worked

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, johnduhart

Maniphest Tasks: T856

Differential Revision: https://secure.phabricator.com/D1645
2012-02-19 15:31:16 -08:00
Bob Trahan
b24c228b5c Make arcanist-created branch names immune to potential git sha1 conflicts
Summary: T854 is hilarious.  seriously, what are the odds?

Test Plan: ran arc patch a few times in a row with the same DX and verified
branches were made with expected, differing names

Reviewers: epriestley, fratrik

CC: aran, epriestley

Maniphest Tasks: T854

Differential Revision: https://secure.phabricator.com/D1605
2012-02-14 15:55:27 -08:00
vrana
e8ca66ead4 Allow arc lint --output json --apply-patches
Summary:
I want to use JSON which allows me to automatically open the files in editor.
I also want to apply patches, especially those modifying __init__.php.
I see no reason why these options should be mutually exclusive.

Also output nothing for okay result which is more standard and better parsable.

Test Plan:
arc lint --output json
arc lint --output json --never-apply-patches # same as above
arc lint --output json --apply-patches

Reviewers: aran, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1599
2012-02-11 08:49:01 -08:00
epriestley
d3b0b009ce Remove sourcePath references from Arcanist
Summary: These are meaningless / unreachable after D1491 and nonsense after
D1582. Depends on D1579.

Test Plan: Grepped for 'sourcePath' references.

Reviewers: arice, btrahan

Reviewed By: arice

CC: aran, epriestley

Maniphest Tasks: T838

Differential Revision: https://secure.phabricator.com/D1584
2012-02-06 13:08:08 -08:00
epriestley
84f9148655 Make "arc list" use "differential.query", not "differential.find"
Summary: Move toward deprecating "differntial.find". Also update the output to
be more inline with "arc branch".

Test Plan: Ran "arc list", "arc branch".

Reviewers: btrahan, arice

Reviewed By: arice

CC: aran, epriestley

Maniphest Tasks: T838

Differential Revision: https://secure.phabricator.com/D1579
2012-02-06 13:08:01 -08:00
epriestley
aad56eca6a Switch back to former branch after landing some other branch
Summary:
If you're on A and run "arc land B", run "git checkout A" after
everything's said and done.

Test Plan: Ran "arc land B" from A, got switched back to it.

Reviewers: davidreuss, kdeggelman, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1568
2012-02-03 15:44:59 -08:00
epriestley
a83983fe81 Minor, fix bad conditional. 2012-02-03 15:26:13 -08:00
Kevin Deggelman
c44e8d57a2 Check for cleanWorkingCopy in sanityCheck, and execute sanityCheck first
Summary:
  - Renamed sanityCheckPatch to sanityCheck
  - Move check for clean working copy into sanityCheck
  - Execute sanityCheck before executing any other command

Test Plan:
  - Run ##arc patch <revision id>## from a dirty working copy
and verify that a usage exception is thrown before the new branch is
created.
  - Run ##arc patch <revision id> --force## and verify that it attempts
    to create a new branch, apply, and commit the patch.
  - Then clean your working copy and verify that ##arc patch <revision
    id> works as expected

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T830, T479

Differential Revision: https://secure.phabricator.com/D1546
2012-02-03 14:05:53 -08:00
epriestley
85083db929 Minor "arc unit" coverage display updates
Summary:
  - Show coverage for all files, not just files that have some coverage
information.
  - Read file data off disk, under git the "current" data is the data at HEAD,
not the (possibly unstaged/uncommitted) file in the working copy which we
actually ran.

Test Plan: Ran "arc unit --detailed-coverage" on various files.

Reviewers: tuomaspelkonen, btrahan

Reviewed By: tuomaspelkonen

CC: aran, epriestley

Maniphest Tasks: T818

Differential Revision: https://secure.phabricator.com/D1542
2012-02-01 17:36:25 -08:00
epriestley
bea4cd83d7 Add a "--no-amend" flag to "arc diff"
Summary: This flag blocks amends.

Test Plan: Ran "arc diff --no-amend" ooooooh meta

Reviewers: davidreuss, btrahan

Reviewed By: davidreuss

CC: aran, epriestley

Maniphest Tasks: T822

Differential Revision: https://secure.phabricator.com/D1539
2012-02-01 14:33:01 -08:00
epriestley
eaa565747e Run 'mark-committed' from 'arc land'
Summary:
  - Remove "new and experimental" because arc land is super awesome and great.
  - Run the 'mark-committed' finalize workflow after pushing for untracked repo
setups.

Test Plan: Ran "arc mark-committed --quiet --finalize 123". Will run "arc land"
on this. so lazy

Reviewers: cpiro, btrahan

Reviewed By: cpiro

CC: aran, epriestley

Maniphest Tasks: T819

Differential Revision: https://secure.phabricator.com/D1538
2012-02-01 14:32:43 -08:00
epriestley
4f07c3c8fd Add coverage support to Arcanist
Summary:
Add "--coverage" and "--no-coverage" flags, mechanisms for reporting
coverage information, xdebug coverage support, and CLI coverage reports.

Test Plan: Ran coverage locally.

Reviewers: tuomaspelkonen, btrahan, jungejason

Reviewed By: btrahan

CC: zeeg, aran, epriestley

Maniphest Tasks: T140

Differential Revision: https://secure.phabricator.com/D1526
2012-01-31 12:07:19 -08:00
epriestley
8fe38f8b6d Finalize Arcanist Classes
Summary:
Mark all applicable Arcanist classes as "final", except PhutilLintEngine, which
needs a little finesse.

@jungejason / @nh, does this break any Facebook stuff?

Test Plan: Linter no longer raises warnings. Ran "testEverythingImplemented" in
Phabricator.

Reviewers: btrahan, jungejason, nh

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T795

Differential Revision: https://secure.phabricator.com/D1519
2012-01-31 12:07:05 -08:00
Nick Harper
975b541d26 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
2012-01-27 10:31:52 -08:00
epriestley
02f111ba0b 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
2012-01-26 17:59:42 -08:00
epriestley
b1cd4f8efa 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
2012-01-26 17:41:11 -08:00
epriestley
9c11adc661 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
2012-01-26 17:40:55 -08:00
epriestley
a00ee82677 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
2012-01-26 17:40:49 -08:00
epriestley
c46dbbf61c 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
2012-01-25 15:10:59 -08:00
epriestley
5a894ba0d5 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
2012-01-25 11:40:22 -08:00
epriestley
3ee01bacac 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
2012-01-24 09:47:53 -08:00
Bob Trahan
03a9c516ea 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
2012-01-23 15:44:25 -08:00
Bob Trahan
a1a25f72f5 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
2012-01-23 13:18:34 -08:00
Bob Trahan
51cccfd21e 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
2012-01-18 15:25:54 -08:00
Bob Trahan
6c613292f7 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
2012-01-17 09:40:43 -08:00
Marke Hallowell
7e63e232ba 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
2012-01-15 10:11:52 -08:00
epriestley
f271e1d8e8 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
2012-01-12 20:09:53 -08:00
Bob Trahan
b61e4eacf1 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
2012-01-10 11:48:05 -08:00
epriestley
f3eccfbe81 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
2012-01-10 10:42:22 -08:00
epriestley
d359532842 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
2012-01-09 11:42:14 -08:00
epriestley
c49e9863d4 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
2012-01-05 14:13:30 -08:00
epriestley
560b339ad3 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
2012-01-05 12:59:05 -08:00
vrana
085aa6093b 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
2012-01-04 15:44:48 -08:00
Kunal Bhalla
62e527482b [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
2011-12-29 14:28:50 -08:00
jungejason
6910fd77a4 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
2011-12-24 15:05:13 -08:00
vrana
736b0deaac 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
2011-12-22 14:50:24 -08:00
epriestley
25ebebe0df 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
2011-12-22 06:47:15 -08:00
epriestley
ca879150c8 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
2011-12-21 09:02:04 -08:00
epriestley
89cb92a22c 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
2011-12-20 19:57:55 -08:00
adonohue
72ee0ced4f 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
2011-12-15 11:03:17 -08:00
Marek Sapota
f794b50b0e Merge branch 'amend_revision' 2011-12-13 11:41:31 -08:00
Marek Sapota
a89d2537a1 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
2011-12-13 11:41:16 -08:00
Marek Sapota
3abebbebfd 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
2011-12-13 11:41:11 -08:00
Marek Sapota
0788220af4 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
2011-12-09 16:06:47 -08:00
epriestley
331afdce87 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
2011-12-03 09:57:09 -08:00
epriestley
79da3a6ff9 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
2011-12-02 07:29:31 -08:00
Bob Trahan
d81d97f9c6 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
2011-12-01 09:44:55 -08:00
David Reuss
1f69ab5fdb 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
2011-12-01 08:56:03 -08:00
Jakub Vrana
647c047b3c 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
2011-11-30 15:23:09 -08:00
epriestley
c3c4f6ed4c 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
2011-11-30 11:17:37 -08:00
Marek Sapota
4ea0541aeb 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
2011-11-16 16:40:19 -08:00
Bob Trahan
16caf63d98 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
2011-11-12 09:57:22 -08:00
Nick Harper
28eae60821 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
2011-11-10 16:18:17 -08:00
epriestley
5150252f91 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
2011-11-04 14:07:12 -07:00
Marek Sapota
08ce2a2e2c 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
2011-11-04 12:13:03 -07:00
epriestley
d57ea379c6 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
2011-11-03 14:28:04 -07:00
Marek Sapota
9070a123d3 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
2011-11-01 15:31:04 -07:00
Andrew Gallagher
b2cd182527 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
2011-10-28 13:49:58 -07:00
Marek Sapota
bb05ddfb5a 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
2011-10-28 09:18:32 -07:00
Marek Sapota
6db055222a Allow anyone to mark Differential revisions as commited.
Test Plan:
Run `arc mark-committed` on a revision that you don't own, you should see a
prompt asking you if you really want to do that and if you answer `Y` it should
mark the revision as committed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, mareksapota

Differential Revision: 1052
2011-10-25 17:24:57 -07:00
epriestley
df8c0e5e25 Don't do working copy checks for "arc amend --show"
Summary: See T587. Reduce the strictness of working copy checks when using
"--show", since there's a reasonable workflow where you 'arc patch' and then
'arc amend --revision X --show | git commit -a -F -' that currently won't work.
There are other ways to accomplish the same thing but this increases flexibility
overall.

Test Plan: Ran 'arc amend --show' with a dirty working copy, didn't get yelled
at.

Reviewers: jungejason, nh, tuomaspelkonen, aran

Reviewed By: nh

CC: aran, nh

Differential Revision: 1033
2011-10-24 23:37:47 -07:00
Jason Ge
ab50afe583 Fix breaking because of D935
Summary:
D935 missed one place of parseGitRelativeCommit() in
ArcanistExportWorkflow.

Test Plan: ran arc export and verify that it worked.

Reviewers: epriestley, tuomaspelkonen, aran

Reviewed By: aran

CC: aran

Differential Revision: 1015
2011-10-17 19:32:38 -07:00
epriestley
2fd37a1728 Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.

Also reduce code duplication by sharing the "mark-committed" workflow.

This causes "arc merge" to effect commit marks.

Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.

This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.

Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran

Reviewed By: jungejason

CC: aran, jungejason

Differential Revision: 967
2011-09-27 11:06:02 -07:00
epriestley
c84d6255b4 Support "immutable_history" doctrine in arc
Summary: When a project uses a conservative history mutability doctrine, never
try to amend history.

Test Plan: Ran "arc amend" in an "immutable_history" working copy.

Reviewers: fratrik, Makinde, aran, jungejason, tuomaspelkonen

Reviewed By: Makinde

CC: aran, Makinde, epriestley

Differential Revision: 862
2011-09-15 07:44:29 -07:00
epriestley
44959afd4b Add an "arc merge" workflow
Summary:
This should support conservative rewrite policies in git fairly well, under an
assumed workflow of:

  - Develop in local branches, never rewrite history.
  - Commit with "-m" or by typing a brief, non-template commit message
describing the checkpoint.
  - Provide rich information in the web console (reviewers, etc.)
  - Finalize with "git checkout master && arc merge branch && git push" or some
flavor thereof.

This supports Mercurial somewhat. The major problem is that "hg merge" fails if
the local is a fastforward of the remote, at which point there's nowhere we can
throw the commit message. Oh well. Just push it and we'll do our best to link
them up based on local commit info.

I am increasingly forming an opinion that Mercurial is "saftey-scissors git".
But also maybe I have no clue what I'm doing. I just don't understand why anyone
would think it's a good idea to have a trunk consisting of ~50% known-broken
revisions, random checkpoint parts, whitespace changes, typo fixes, etc. If you
use git with branching you can avoid this by making a trunk out of merges or
with rebase/amend, but there seems to be no way to have "one commit = one idea"
in any real sense in Mercurial.

Test Plan: Execute "arc merge" in git and mercurial.

Reviewers: fratrik, Makinde, aran, jungejason, tuomaspelkonen

Reviewed By: Makinde

CC: aran, epriestley, Makinde

Differential Revision: 860
2011-09-15 07:42:45 -07:00
epriestley
31ec011922 Move some VCS-specific logic into VCS APIs
Summary:
We have some git-specific logic on main pathways which should be in the API
class, move it around so "arc lint" with an engine works under Mercurial. This
resovles the error @makinde reported:

> PHP Catchable fatal error:  Argument 1 passed to
ArcanistBaseWorkflow::parseGitRelativeCommit() must be an instance of
ArcanistGitAPI, instance of ArcanistMercurialAPI given, called in
/home/makinde/.arc_install/arcanist/src/workflow/lint/ArcanistLintWorkflow.php
on line 131 and defined in
/home/makinde/.arc_install/arcanist/src/workflow/base/ArcanistBaseWorkflow.php
on line 830

Test Plan: Ran "arc diff" in git and hg working copies, plus "arc lint" with a
configured "lint_engine".

Reviewers: Makinde, aran, jungejason, nh, tuomaspelkonen

Reviewed By: Makinde

CC: aran, Makinde

Differential Revision: 935
2011-09-15 07:39:34 -07:00
mgummelt
e9b7f8e3ca Merge branch 'master' of github.com:facebook/arcanist into get_engine 2011-09-08 18:26:07 -07:00
mgummelt
3250cbb4d3 two small changes for "arc unit" post hook
Summary:
1) unit engine getter method in the unit workflow

   we store some information (unit test results) in the engine that we
   need to access in the "arc unit" post hook

2) make requireCleanWorkingCopy() public

   "arc unit" doesn't need to be clean in general, but we'd like the
   option to upgrade the workflow to require it if necessary.  We use
   this for ensuring a repo is clean before updating unit test
   results.

Test Plan: Used both features in a custom post hook in arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: dpepper, aran, epriestley

Differential Revision: 917
2011-09-08 18:25:54 -07:00
epriestley
aa138a80d2 Attach local commit information to DVCS revisions
Summary: When a revision is created, attach relevant information about the local
commits which it came from if applicable. This supports T473, for DCVSes and
DCVS workflows with immutable history where we can't just amend commit messages.
It will also allow us to enrich the web interface.

Test Plan: Will verify this info shows up for this very diff.

Reviewers: fratrik, aran, jungejason, tuomaspelkonen

Reviewed By: fratrik

CC: aran, epriestley, fratrik

Differential Revision: 857
2011-08-25 18:13:53 -07:00
epriestley
58c09ab36d Improve Arcanist Mercurial support
Summary:
  - Build the manifest of file changes so unit and lint workflows work.
  - Default to creating a diff between the parent of the first outgoing change
and the tip.

Test Plan:
  - Ran "arc diff" in a dirty mercurial repo, got warned about
untracked/uncommitted changes.
  - Ran "arc diff" in a clean mercurial repo, got a diff of everything I'd done
locally.

Reviewed By: aran
Reviewers: Makinde, aran, jungejason, tuomaspelkonen
CC: aran, epriestley
Differential Revision: 796
2011-08-09 19:16:36 -07:00
epriestley
268de6428c Basic Mercurial support for Arcanist
Summary:
There's a lot of ground left to cover but this makes "arc diff" work (on one
trivial diff) in my sandbox, at least, and supports parsing of Mercurial native
diffs (which are unified + a custom header). Piles of missing features, still.
Some of this is blocked by me not understanding the mercurial model well yet.

This is also a really good opportunity for cleanup (especially, reducing the
level of "instanceof" in the diff workflow), I'll try to do a bunch of that in
followup diffs.

Test Plan: Ran "arc diff" in a mercurial repository, got a diff out of it.
Reviewed By: aran
Reviewers: Makinde, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock, fratrik
Differential Revision: 792
2011-08-09 18:22:58 -07:00
epriestley
40b445b387 Fix a variable usage
Summary: This stopped being available in scope when I refactored this
recentlyish.
Test Plan: Got error, saw useful message.
Reviewed By: jungejason
Reviewers: mgummelt, jungejason, tuomaspelkonen, aran
CC: aran, epriestley, jungejason
Differential Revision: 787
2011-08-07 16:04:20 -07:00
Edward Speyer
344fbb8d35 Fix documentation: stop __init__ rendering in bold
Summary:
Requires
https://secure.phabricator.com/rPHU0acf708b9b0fdbf59e4399f14dd8295b6a96972c
from libphutil, which allows a backslash prefix to control escape
sequences such as bold, underline, and invert.

Test Plan: "arc help liberate"
Reviewed By: epriestley
Reviewers: epriestley
CC: aran, epriestley
Differential Revision: 767
2011-08-04 14:09:13 +01:00
epriestley
57ff80e6c4 Provide "arc upload --json"
Summary:
  - Provide a "--json" flag for "arc upload"
  - Unify some of the stderr stuff across upload/download/paste.

Test Plan:
  - Ran "arc upload" and "arc upload --json", piped stderr away with 2>/dev/null
to verify only JSON got emitted to stdout
  - Ran "arc paste"

Reviewed By: codeblock
Reviewers: codeblock, jungejason, tuomaspelkonen, aran
CC: aran, codeblock
Differential Revision: 749
2011-08-01 17:44:43 -07:00
epriestley
0e4f7774fb Add an "arc paste" workflow
Summary: Read and write in the same workflow! Dogs and cats living together!
Test Plan:   - Performed a bunch of paste reads and writes and they looked ok?
Reviewed By: aran
Reviewers: codeblock, jungejason, tuomaspelkonen, aran
CC: aran
Differential Revision: 748
2011-07-29 20:11:41 -07:00
epriestley
bd9769ba92 Add 'arc upload' and 'arc download'
Summary: Mechanisms for interacting with Files via Arcanist.
Test Plan:
  - Ran 'arc upload x', 'arc upload x y z'
  - Ran 'arc download' with --as and --show.

Reviewed By: codeblock
Reviewers: codeblock, jungejason, tuomaspelkonen, aran
CC: aran, codeblock, epriestley
Differential Revision: 742
2011-07-29 13:38:24 -07:00
Jason Ge
1bb2409d47 Remove the size limit on arc side
Summary:
remove the size check. The conduit call will fail later if the
size is too large, and we will get better error message.

Test Plan:
run arc diff with files smaller and larger than the size
limit.

Reviewed By: epriestley
Reviewers: epriestley
CC: aran, epriestley
Differential Revision: 729
2011-07-25 16:27:34 -07:00
epriestley
8150fdf044 Deprecate ArcanistBaseWorkflow::getUserGUID in favor of "PHID"
Summary: One day all "GUID" references will be gone, maybe.
Test Plan: grep, ran workflow before changing and got a warning about
deprecation
Reviewed By: aran
Reviewers: mgummelt, tuomaspelkonen, aran, jungejason
CC: aran
Differential Revision: 671
2011-07-15 12:52:17 -07:00
epriestley
41b23519e6 Move Conduit management into Workflow
Summary:
The primary goal of this is to allow pre/post workflow hooks to upgrade a
workflow which doesn't require conduit into one which does, or one which doesn't
require authentication into one which does. They do this by calling
$workflow->establishConduit() or $workflow->authenticateConduit() respectively.

It also removes a bunch of dead code and a bunch of now-unnecessary public
interfaces.

Test Plan:
Broke my certificate and ran "arc list", "arc unit", "arc help", "arc
call-conduit".
Restored my certificate and re-ran the commands.

Reviewed By: mgummelt
Reviewers: mgummelt, jungejason, tuomaspelkonen, aran
CC: aran, epriestley, mgummelt
Differential Revision: 664
2011-07-15 12:38:45 -07:00
epriestley
2aa853f85c From Arcanist, send 'host' to server for validation on setup workflows
Summary: This allows us to detect and complain about mismatched client and
server host identities. It causes some subtle and not-so-subtle problems if the
client and server don't agree on the install's primary URI.
Test Plan: Ran "arc install-certificate" and "arc list" against my local host
with intentionally bogus configs and was warned. Ran with normal configs and
everything worked.
Reviewed By: tuomaspelkonen
Reviewers: jungejason, llorca, tuomaspelkonen, aran
CC: aran, tuomaspelkonen
Differential Revision: 591
2011-07-05 10:10:28 -07:00
James Ide
2892c6ef1a Have Arcanist record how much of my life was spent running each unit test
Summary:
Keeping unit tests speedy keeps them useful since people actually won't mind
running them. This diff records the time taken by each test and displays it nice
and colorized. Really, I just want to discourage non-unit tests from making
their way into ##__tests__##.

Some thoughts:

 - The "acceptableness" times are subjective but if dependencies are properly
mocked the times seem to be ok. Integration tests that make network requests to
third-party endpoints and pull in megabytes of data will not survive. This is a
good thing.
 - Fast tests get a gold star, encouraging small tests. I am sorry that the star
does not sparkle.
 - There is no way for a programmer to admit that their test is going to be slow
in some cases. They will be shamed with red text for the life of their test.
 - It might be confusing that fast but failing tests get green text and maybe a
gold star.

Test Plan: Ran some of the unit tests within Arcanist and libphutil. See
https://secure.phabricator.com/file/view/PHID-FILE-cdd3c94c219e0fd7470b/ for
sample output.
Reviewed By: epriestley
Reviewers: epriestley
CC: aran, epriestley
Differential Revision: 588
2011-07-03 23:32:27 -07:00
epriestley
304a2c73aa Prohibit creation of command-line revisions with yourself as the reviewer
Summary:
We do this check on the web interface but not from the CLI.

Also clean up some GUID/PHID stuff (eventually all GUID references should be
replaced with PHID, although they mean the same thing).

Test Plan: Tried to create a revision with myself on the reviewer line, got
called out.
Reviewed By: jungejason
Reviewers: moskov, jungejason, tuomaspelkonen, aran
CC: aran, jungejason
Differential Revision: 564
2011-07-03 11:50:54 -07:00
epriestley
4a8e247e66 Fix "arc branch" to work if you are on "(no branch)" add revision IDs
Summary:
If you checkout some commit you end up on "(no branch)" which currently breaks
the parser. Ignore that, and add revision IDs to the output. They aren't very
big and I hate flags so I didn't add a flag for this. You can add a flag to turn
them off if you really want.

Test Plan:
Ran "arc branch" and "arc branch --by-status" from a "(no branch)" working copy.

Reviewed By: slawekbiel
Reviewers: slawekbiel, ahupp, jungejason, tuomaspelkonen, aran, schrockn
CC: aran, slawekbiel
Differential Revision: 555
2011-06-29 13:30:44 -07:00
Adam Hupp
cc283a63a5 Add by-status option to 'arc branch'
Summary:
This diff adds a '--by-status' argument to arc branch that sorts the
output by status.  Example output:

    Accepted
      my-branch                         Amazing change
    Needs Revision
      nah-nah                           Not so good change
    Needs Review
      in-progress-change                I have no idea
    No Revision
      etc                               etc

Blame Rev:

Task ID:  #

Reviewers: epriestley, slawekbiel

Test Plan:
Ran it with and without --by-status, saw expected output in both cases.

DiffCamp Revision:

Revert Plan:

Database Impact:

Memcache Impact:

Other Notes:

EImportant:

- begin *PUBLIC* platform impact section -
Bugzilla: #
- end platform impact -

Differential Revision: 512
2011-06-28 20:35:23 -07:00
Andrew Gallagher
3715266209 arc lint: include lint errors in unresolved messages
Summary:
Currently, when arc-lint processes lint warnings and errors, it
accumulates the warnings into an "unresolvedMessages" array.  As
soon as it sees an errors, it breaks out of the loop that does the
collection and returns, causing individual lint errors messages to
not show up in differential.

This diff collects all lint warning and error messages into the
unresolved array.

Test Plan:
arc-diff on patch that had lint errors.  Verified that,
after this change, linte errors messages showed in differential.

Reviewed By: epriestley
Reviewers: jungejason, epriestley
Commenters: jungejason
CC: aran, epriestley, jungejason
Differential Revision: 543
2011-06-27 14:17:17 -07:00
epriestley
182e260472 Verify that ~/.arcrc is 600 before reading from it
Summary:
Since this has auth information in it now, we should prevent other users on the
system from reading it. Detect readable files and prompt the user to fix them.

Test Plan:
Did "o+r" on my ~/.arcrc, ran "arc list", got prompted, hit "Y", verified it set
perms to 600, ran "arc list" again and wasn't prompted.

Reviewed By: jungejason
Reviewers: fratrik, jungejason, aran, tuomaspelkonen
CC: aran, jungejason, epriestley
Differential Revision: 532
2011-06-26 11:55:31 -07:00
epriestley
051ef2c695 Provide a "--json" flag to 'arc diff'
Summary:
This should be implemented more elegantly, but this is a mostly-reasonable
attempt at it.

Test Plan:
Ran 'arc diff --only --json' with this diff.

Reviewed By: gc3
Reviewers: gc3
CC: aran, epriestley, gc3
Differential Revision: 509
2011-06-23 16:03:37 -07:00
epriestley
b6fb0f7a6b Improve documentation for 'arc call-conduit'
Summary:
This documentation isn't terribly clear and it isn't obvious how to use the
workflow. Make it more clear and provide examples.

Test Plan:
Ran "arc help call-conduit"

Reviewed By: gc3
Reviewers: gc3, aran, jungejason
CC: aran, gc3, epriestley
Differential Revision: 502
2011-06-23 13:15:28 -07:00