1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-15 03:12:40 +01:00
Commit graph

2134 commits

Author SHA1 Message Date
epriestley
a30378a34a Update "arc help land"
Summary: Ref T13546. Provide more up-to-date help about the "land" workflow, including modern flags and behavior.

Test Plan: Read "arc help land".

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21326
2020-06-08 16:22:43 -07:00
epriestley
709c9cb6fb Improve the logic for identifying ambiguous commits and applying "--revision" to them
Summary: Ref T13546. This is mostly minor cleanup that improves behavior under "--revision".

Test Plan: Ran `arc land --into-empty` and `arc land --into-empty --revision 123` with ambiguous revisions in history to hit both the force and non-force outcomes.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21325
2020-06-08 16:22:43 -07:00
epriestley
8a53b5a451 When landing changes in an empty repository, merge cleanly in Git
Summary:
Fixes T12876. Ref T13546. When you make the first change in a new Git repository, "arc land" currently can not merge it because there's nothing to merge into.

Support merging into the empty state formally, reachable by using "--into-empty" (which should be uncommon) or "arc land" in an empty repository.

Test Plan:
  - Used "arc land --into-empty --hold ..." to generate merges against the empty state under "squash" and "merge" strategies in Git.
    - Got sensible result commits with appropriate parents and content.

Maniphest Tasks: T13546, T12876

Differential Revision: https://secure.phabricator.com/D21324
2020-06-08 16:19:55 -07:00
epriestley
57d0d690cc Modernize output when pruning branches in Git during "arc land"
Summary: Ref T13546. Make this output look more similar to other modern output.

Test Plan: Ran "arc land", saw consistent-looking output.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21319
2020-06-08 16:19:55 -07:00
epriestley
94f78cf87c Provide more information about merge progress in "arc land" under Git
Summary: Ref T13546. Communicate more progress information and provide additional details when merge conflicts occur.

Test Plan: Hit a merge conflict, saw more helpful output.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21318
2020-06-08 16:19:55 -07:00
epriestley
1552397c86 Sometimes discard already-closed revisions in "arc land"
Summary:
Ref T13546. When we find commits in history which are associated with already-closed revisions, and they weren't named explicitly on the command line, and we're using a squash strategy, discard them.

This generally happens when "feature2" is on top of "feature1", but "feature1" gets amended or branched elsewhere and lands independently.

Test Plan: Ran "arc land feature3" where prior revisions had already landed, got discards on the duplicated changes.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21322
2020-06-08 16:17:20 -07:00
epriestley
6fb84e5164 Add a synopsis and example for "arc help land"
Summary: Ref T13546. Small documentation fix. Mostly so I can have more things to land.

Test Plan: Ran "arc help land", saw help.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21321
2020-06-08 16:17:20 -07:00
epriestley
25afb93f7a In "arc land", rebase branches in natural order
Summary: Ref T13546. When "arc land" performs cascading rebases, do them in "feature1", "feature2", etc., order so they're easier to follow. The outcome is not dependent on execution order.

Test Plan: Landed a change which cascaded many other branches, saw more comprehensible update order.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21320
2020-06-08 16:17:19 -07:00
epriestley
68f28a1718 Substantially modernize the "arc land" workflow
Summary: Ref T13546. This has a lot of dangerously rough edges, but has managed to land at least one commit in each Git and Mercurial.

Test Plan:
  - Landed one commit under ideal conditions in Git and Mercurial.
  - See followups.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21315
2020-06-08 16:17:19 -07:00
epriestley
7d615a97e2 In "arc branch" output, sort branches updated in the same second by name
Summary:
Ref T13546. The new "arc land" workflow can rebase several branches per second. With branches like "feature1", "feature2", etc., this leads to out-of-order listing in "arc branch".

When two branches would otherwise sort to the same position, sort them by name.

Test Plan: Ran "arc branch" after a cascading rebase by "arc land", saw "land5", "land7", "land8", etc., instead of an arbitrary order.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21316
2020-06-08 16:04:12 -07:00
epriestley
86471fc0fe Remove "--ignore-unsound-tests" from "arc diff"
Summary: Ref T13544. This flag only disables a warning and should be a prompt default, not a flag.

Test Plan: Grepped for "ignore-unsound-tests", created this revision.

Maniphest Tasks: T13544

Differential Revision: https://secure.phabricator.com/D21303
2020-06-08 15:58:27 -07:00
epriestley
3ed81d35a2 When "arc" receives SIGWINCH or other signals during display of a prompt, recover
Summary:
Ref T13546. Resizing the terminal window to send SIGWINCH, or other signals, may interrupt "stream_select()" with an error which upgrades to a RuntimeException.

When "stream_select()" fails, continue and test the stream itself.

Test Plan: Waited for a prompt, resized the window. Before patch: SIGWINCH interruption. After patch: undisturbed prompt.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21317
2020-06-08 15:56:59 -07:00
epriestley
0da395ffe4 Introduce "RepositoryLocalState", a modern version of "requireCleanWorkingCopy()"
Summary:
Ref T13546. Introduces a more structured construct for saving and restoring local repository state.

This is similar to old behavior, except that:

  - "arc.autostash" is no longer respected;
  - untracked changes are stashed; and
  - we do not offer to amend.

Test Plan: In future changes, saved and restored various permutations of local state.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21314
2020-06-08 15:40:01 -07:00
epriestley
7ac3b791b0 Provide modern config options for "arc land" configuration
Summary: Ref T13546. Adds modern support for "arc.land.onto", "arc.land.onto-remote", and "history.immutable".

Test Plan: Read configuration in a future change.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21313
2020-06-08 15:40:01 -07:00
epriestley
de607e9fbc Add modern refs and hardpoints for buildables, builds, and build plans
Summary: Ref T13546. Prepares "arc land" to use hardpoint queries to load build information.

Test Plan: Ran `arc inspect --explore revision(1234)`, got a full related object tree including build information.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21312
2020-06-08 15:39:27 -07:00
epriestley
c1a4bee4a1 Add "Author" and "Parent Revision" hardpoints to RevisionRefs
Summary: Ref T13546. These are used by a future "arc land" workflow to support the "Land changes you don't own?" and "Land changes with open dependencies?" prompts.

Test Plan: Ran a future "arc land" flow, hit both prompts.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21311
2020-06-08 15:10:20 -07:00
epriestley
0a4a841f8f Remove the "--less-context" flag from "arc diff"
Summary: Ref T13544. This is an obscure flag and almost never useful. You can accomplish the same goal, roughly, with "git diff | arc diff --raw -". See also PHI675. See also T13338.

Test Plan: Grepped for "less-context", created this revision.

Maniphest Tasks: T13544

Differential Revision: https://secure.phabricator.com/D21301
2020-06-05 13:32:14 -07:00
epriestley
466de2d2e1 Remove "--encoding" flag from "arc diff"
Summary: Ref T13544. This flag is generally questionable, likely has no actual uses, and is slated for obsoletion and replacement elsewhere (see T13338).

Test Plan: Grepped for "encoding", found no relevant hits.

Maniphest Tasks: T13544

Differential Revision: https://secure.phabricator.com/D21300
2020-06-05 13:27:42 -07:00
epriestley
bb81172eb7 Remove "haveUncommittedChanges" property from "arc diff"
Summary: Ref T13544. This property is private and has no writers.

Test Plan: Grepped for symbol.

Maniphest Tasks: T13544

Differential Revision: https://secure.phabricator.com/D21299
2020-06-05 13:26:30 -07:00
epriestley
d0eb822e37 Remove "--lintall" and "--only-new" flags to "arc diff"
Summary:
Ref T13544. These flags change the behavior of the "arc lint" subprocess.

I believe there is no reason to ever use "arc diff --lintall". If you want to find extra warnings to fix, you can use "arc lint --lintall" to express this intent.

Use of "arc diff --only-new" almost certainly means your linters are raising messages at "error" severity which should instead be raised at "warning" severity. If you only care about fixing a particular type of error in changed code, it should be raised as a "warning". The correct remedy is to adjust the severity, not use "--only-new", which is a very broad, slow, complicated hammer.

Test Plan: Searched for "lintall" and "only-new" in this workflow. These flags still exist in "arc lint", but may be changed in the future. Generated this change.

Maniphest Tasks: T13544

Differential Revision: https://secure.phabricator.com/D21298
2020-06-05 13:24:48 -07:00
epriestley
76dc154955 Remove lint and unit excuses and "--advice" and "--excuse" flags from "arc diff"
Summary:
Ref T13544. Long ago, "arc diff" started prompting the user to provide "excuses" when they submitted changes with failing lint or unit tests.

At the time, "arc" was generally more heavy-handed and the review workflow had fewer points where it provided feedback about lint and test issues.

As the workflow has evolved, there is now significantly more feedback (promotion behavior from Draft in Differential, warnings on "arc land", etc). These days, these prompts feel archaic and like they're just getting in the way.

When lint/unit have Harbormaster-triggered components, this prompt is also too early (since Harbormaster tests may fail or raise lint messages later). A modern version of this would look more like putting revisions in some kind of locked state until authors explain issues. It's possible that's worth building, but I'd like to see more interest in it. I suspect this feature is largely just a "nag" feature these days with few benefits.

Test Plan: Grepped for "advice", "excuse", "handleServerMessage", "sendMessage", "getSkipExcuse", "getErrorExcuse", got no hits. Generated this revision.

Maniphest Tasks: T13544

Differential Revision: https://secure.phabricator.com/D21297
2020-06-05 13:22:00 -07:00
epriestley
ff3cea78ee Remove "--use-commit-message/-C" from "arc diff"
Summary:
Ref T13544. This flag was introduced in D1385 (2012) as part of a workflow which no longer exists. I can't recall anyone ever reporting an issue which involves its use and believe it is likely unused. It's not obvious to me why someone would use it in modern "arc".

(The same goal can be accomplished with "--message-file ...", although this requires more steps.)

Test Plan: Grepped for "use-commit-message" and "getCommitMessageFromCommit", ran "arc diff".

Maniphest Tasks: T13544

Differential Revision: https://secure.phabricator.com/D21296
2020-06-05 13:22:00 -07:00
epriestley
6af46f289a Support short aliases and repeatable arguments in Arcanist Workflow arguments
Summary: Ref T13546. Add support for short "-x" flags and repeatable "--say moo --say quack" flags.

Test Plan: In future changes, used "arc diff -m" and "arc land --onto ... --onto ...".

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21310
2020-06-05 12:47:43 -07:00
epriestley
7c80a9006d Add a "%?" ("hint") conversion to "tsprintf()"
Summary: Ref T13546. Future "arc land" workflows use this element to provide "hint" or "next step" suggestions to make error resolution easier.

Test Plan: Ran future "arc land" workflows, saw tips like "use --revision to do such-and-such" or "add these files to .gitignore".

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21309
2020-06-05 12:22:09 -07:00
epriestley
0e82474007 Support appending arbitrary lines to DisplayRef output
Summary:
Ref T13546. Several substeps in the new "arc land" flow benefit from this. For example:

  - When prompting "land revisions you don't own?", it's used to show authors.
  - When prompting "land revisions in the wrong state?", it's used to show the current states.

Test Plan: Ran future "arc land" workflows, got relevant contextual information via this mechanism.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21308
2020-06-05 12:22:09 -07:00
epriestley
fc3974ed70 Impose a HardpointEngine future parallelism limit
Summary:
Ref T13546. If we try to resolve several hundred hardpoint queries which execute subprocesses, we can currently hit system limits.

For now, limit resolution to 32 simultaneous futures. In the future, this should switch to `FuturePool` and possibly become more nuanced.

Test Plan: In a future change, ran `arc land --into-empty ...` to land thousands of commits. Before change, got a "proc_open()" error when launching too many simultaneous subprocesses. After change, this "worked".

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21307
2020-06-05 12:15:47 -07:00
epriestley
7378e2baad Remove special casing of "arc --version"
Summary: See PHI1765. You can find version information with "arc version". Remove this undocumented special-case.

Test Plan:
  - Ran `arc --version`, no longer got a workflow API exception.
  - Searched the documentation for references to `arc --version` (instead of `arc version`), found none.

Differential Revision: https://secure.phabricator.com/D21306
2020-06-02 08:58:06 -07:00
epriestley
0da1a2e17d Allow PhutilArrayCheck to accept a list of objects as a context
Summary: This simplifies merging a list-of-lists, which is a common pattern when asking a list of extensions to each provide some kind of list of items.

Test Plan: Used elsewhere in Piledriver.

Differential Revision: https://secure.phabricator.com/D21294
2020-05-30 03:37:42 -07:00
epriestley
a0c346bf63 Add a support class to simplify typechecking list-of-objects return values
Summary:
With some frequency, code wants to assert that some "$o->m()" returns a list of objects of type X, possibly with unique values for some "getKey()"-style method result.

Existing checks via `PhutilTypeMap` and `assert_instances_of()` aren't quite powerful enough to do this while producing an easily understandable error state. We want to know that the error arose from a call to "$o->m()" in particular.

Test Plan: Currently used elsewhere, in Piledriver code.

Differential Revision: https://secure.phabricator.com/D21293
2020-05-28 07:33:23 -07:00
epriestley
c76cfc8c82 Mark the wildcard argument to "arc liberate" as a path argument for shell completion
Summary: This is a path argument, and shell completion should suggest tabs.

Test Plan: Typed "arc liberate s<tab>", got path suggestions.

Differential Revision: https://secure.phabricator.com/D21292
2020-05-28 07:33:12 -07:00
epriestley
fce72b9c89 Make lint tests handle paths better and distinguish between "0" and "null" more carefully
Summary:
Ref T13543. Currently, the `cpplint` tests do not function because `cpplint` is passed a path which does not end in a suffix it recognizes.

Change the tempfile / path code to pass `linter path/to/example.c`-style linters a path they expect.

Then, correct some older code which was playing it fast-and-loose with "null" vs "0".

Test Plan: Ran `arc unit --everything`, got a clean bill of health on all the linters I have installed. (This is probably not all tests, since I have only a subset of linters installed locally that we have code for.)

Maniphest Tasks: T13543

Differential Revision: https://secure.phabricator.com/D21291
2020-05-27 12:38:11 -07:00
epriestley
e69aa32603 Fix an issue when rendering a lint message which removes whitespace at the end of a file
Summary:
Ref T13543. If a file ends in spaces and no newline, we'll emit a message suggesting removal of the spaces. This will effectively remove the line, but the code will then attempt to highlight text within the line.

Prior to D21044 this continued without raising an error and produced a reasonable result, but it now fatals. Insetad, don't try to highlight lines which no longer exist.

Test Plan: See T13543 for details.

Maniphest Tasks: T13543

Differential Revision: https://secure.phabricator.com/D21290
2020-05-27 11:28:16 -07:00
epriestley
25ee39b657 In the "cpplint" binding, raise messages on "line 0" without a line
Summary:
Ref T13543. The "cpplint.py" script may emit messages on line 0, but Arcanist doesn't accept these messages.

This is a small piece of a whole set of broader issues, but stop the bleeding for now.

Test Plan:
  - Ran `arc lint example.h` on a file with no `#ifndef` guard, and `cpplint` configured.
  - Cpplint raised a message at line "0".
  - Before change: arc choked when trying to render this.
  - After change: arc survives rendering.

Maniphest Tasks: T13543

Differential Revision: https://secure.phabricator.com/D21289
2020-05-27 10:59:10 -07:00
epriestley
e3030ebcad Allow construction of a ConduitEngine with a bare ConduitClient
Summary:
See PHI1735. "ConduitEngine" was once a future pool, but this has moved to "HardpointEngine". This class may no longer make much sense.

In Phacility code, "bin/host upload" depends on using the Uploader, which needs a "ConduitEngine", not a "ConduitClient". This workflow may use asymmetric key signing, which "ConduitEngine" does not support.

To unblock PHI1735, provide glue code between "Client" and "Engine". But a "more correct" change is probably removal of "Engine".

Test Plan:
  - Ran `bin/host upload`, uploaded files (with additional changes to wrap the Client).
  - Created this revision.

Differential Revision: https://secure.phabricator.com/D21260
2020-05-15 08:24:10 -07:00
Aviv Eyal
2d8156a727 update SSL error messge re:libphutil
Test Plan: ╰(*°▽°*)╯

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D21258
2020-05-15 12:15:50 +00:00
epriestley
b76b9c4065 Add "HTTPSFuture->addCurlOption()" for raw access to "curl_setopt()"
Summary: Fixes T13533. This is a narrow, fragile API for a particular Kerberos use case on one install.

Test Plan:
- Set a non-scalar key, got an exception.
- Set <"duck", "quack">, got an exception from cURL that the value was invalid.
- Set a bunch of made-up options to arbitrary values, no errors. cURL accepts anything so there's nothing we can do about this.
- Set `CURLOPT_NOBODY` and saw the request behavior change, demonstrating that the call can produce effects.

Maniphest Tasks: T13533

Differential Revision: https://secure.phabricator.com/D21251
2020-05-14 09:16:36 -07:00
epriestley
6937d38947 Fix an initialization issue in VectorTree
Summary: Ref T13520. In unusual cases where there are no changes in a changeset list (e.g., empty commits) we can fatal when trying to iterate over an empty list of vectors.

Test Plan:
  - Created an empty commit.
  - Used "git show | pbcopy" to create a diff from it.
  - Viewed it in the web UI.
  - Before: fatal when iterating on `null`.
  - After: clean page.

Maniphest Tasks: T13520

Differential Revision: https://secure.phabricator.com/D21221
2020-05-04 15:50:26 -07:00
epriestley
af9faba02f Add "--browse" and "--input" to "arc paste", and remove "--json" (which had no effect)
Summary:
Ref T13528. For consistency with other commands ("arc upload", "arc diff"), support a "--browse" flag to "arc paste".

Support "--input" as a more robust alternative to `x | y` (see T6996).

Test Plan: Ran `arc paste --browse --input X`, got a new paste in a browser window. Ran other variations of flags and parameters.

Maniphest Tasks: T13528

Differential Revision: https://secure.phabricator.com/D21203
2020-05-01 09:13:20 -07:00
epriestley
c0d151e0e9 Add "--browse" to "arc upload" and update behavior, particularly "--json"
Summary:
Ref T13528. Provide a "--browse" flag to open files after they are uploaded.

Update the code to use modern query strategies.

This impacts the output of "--json", which was just raw "file.info" output before and could not represent the same path being passed several times (`arc upload X X`).

Test Plan: Ran `arc upload` with `--browse` and `--json`.

Maniphest Tasks: T13528

Differential Revision: https://secure.phabricator.com/D21202
2020-05-01 09:13:01 -07:00
epriestley
5448fe2165 When recent PHP raises a "broken pipe" error in ExecFuture, treat it as a blocked stdin
Summary:
Ref T13528. If we start a subprocess that immediately exits and then write to it, we can get a broken pipe error.

Recent versions of PHP appear to raise this as an actual warning, and recent changes upgrade the warning to a runtime exception.

I can't find any way to tell if the RuntimeException is a broken pipe or something else, except by examining the text of the error string.

At least for now, treat this like a "blocked pipe" condition. Since the subprocess has exited and the bytes didn't write, this should generally be reasonable.

Test Plan:
  - Viewed a file in Paste with an extension that Pygments does not have a lexer for.
  - This causes Pygments to exit immediately with an "unrecognized lexer" error. This closes the pipe, and the next write will fail with a broken pipe error.
  - Before patch: fatal on broken pipe.
  - After patch: clean resolution of the future and error condition.

Maniphest Tasks: T13528

Differential Revision: https://secure.phabricator.com/D21199
2020-05-01 09:12:43 -07:00
epriestley
a77cfb023d When a proxy future wraps a future which throws an exception, resolve with an exception
Summary:
Ref T13528. When you call `$future->resolve()`, we currently guarantee it is resolved by calling `FutureIterator->resolveAll()`.

`resolveAll()` does not actually "resolve()" futures: it guarantees that they are ready to "resolve()", but does not actually call "resolve()".

In particular, this means it does not throw exceptions.

This can lead to a case where a Future has "resolve()" called directly (e.g., via a FutureProxy), uses "FutureIterator" to resolve itself, throws an exception inside "FutureIterator", the exception is captured and attached to the Futuer, then the outer future tries to access results. This fails since it's out-of-order.

This can happen in practice with syntax highlighting futures, which may proxy pygments futures.

Instead, "resolveAll()" before testing for exaceptions.

Test Plan:
  - Locally, tried to highlight a Paste with an unrecognized lexer extension using Pygments.
  - Before patch: fatal when trying to access results of a Future with no results (because it has an exception instead).
  - After patch: resolution throws the held exception properly.
  - (See also next change.)

Maniphest Tasks: T13528

Differential Revision: https://secure.phabricator.com/D21198
2020-05-01 09:12:22 -07:00
epriestley
696ec3f975 Work around "mb_check_encoding(<stringlike-object>)" warning in particular versions of PHP
Summary: Fixes T13527. Some versions of PHP strictly require that we pass a string value, and reject "stringlike" objects (objects which implement "__toString()").

Test Plan: Ran unit test, although this is somewhat aspirational because my local PHP version isn't affected.

Maniphest Tasks: T13527

Differential Revision: https://secure.phabricator.com/D21193
2020-04-30 07:19:45 -07:00
epriestley
284139a24e Restore the ":(attr:filter=lfs)" test for LFS
Summary:
See D21190. The ".gitattributes" approach fails when ".gitattributes" is in a subdirectory (or global). These are probably unusual cases, but at least one is known in the wild.

Instead:

  - Restore the ":(attr:filter=lfs)" test, which seems to be the fastest accurate test available in modern Git.
  - If the test fails, assume the repository is not LFS. This only impacts users running very old versions of Git.

Test Plan:
  - In LFS and non-LFS repositories, created diffs. Saw correct detection again.
  - Broke the command on purpose, saw LFS detection conclude "no LFS", but not fail disastrously.

Subscribers: ptarjan

Differential Revision: https://secure.phabricator.com/D21192
2020-04-29 21:04:44 -07:00
epriestley
ade9b51a1f Detect LFS by looking for tracks in ".gitattributes" instead of using "ls-tree"
Summary:
See PHI1718. See also <https://discourse.phabricator-community.org/t/arc-diff-fails-due-to-git-cmd-fails/3680/>.

Currently, `arc diff` detects Git LFS with `git ls-files -z -- ':(attr:filter=lfs)'` magic. This is an accurate test, but does not work on older Git.

Try a simpler, dumber test and see if that will work. If this also has issues, we can try this stuff:

  - do version detection;
  - pipe the whole tree to `git check-attr`;
  - try a command like `git lfs ls-files` instead, which is probably a wrapper on one of these other commands.

Test Plan:
  - In a non-LFS repository, ran "arc diff" and saw the repository detect as non-LFS.
  - In an LFS repository, ran "arc diff" and saw the repository detect as LFS.

Differential Revision: https://secure.phabricator.com/D21190
2020-04-29 16:23:44 -07:00
epriestley
6ec09b2f48 Replace "PhutilFileTree" with a more abstract "VectorTree"
Summary:
Ref T13520. Replace "FileTree" with a "VectorTree" that does roughly the same thing. The major goals are:

  - Compress trees which contain sequences of child directories with no sibilings.
  - Build hierarchies of paths where path components may include renames.

This is approximately similar to "FileTree" and similar to client logic in the new paths panel.

Test Plan: See next change.

Maniphest Tasks: T13520

Differential Revision: https://secure.phabricator.com/D21182
2020-04-28 12:09:56 -07:00
epriestley
b81818b287 Accommodate PHP 7.4 changes to certain "preg_match_all()" calls
Summary:
Ref T13518. The result format of this call changed in PHP 7.4, which causes us to emit "-1" matches because "-1" survives `array_filter()`.

Filter results in a way that should survive both result formats.

Test Plan: Ran `arc unit --everything` under PHP 7.4.

Maniphest Tasks: T13518

Differential Revision: https://secure.phabricator.com/D21173
2020-04-26 08:40:08 -07:00
epriestley
bf76fa547d Make "arc <workflow> --help" work again for workflows which haven't updated yet
Summary:
See <https://discourse.phabricator-community.org/t/help-is-no-longer-present-for-arc-subcommands-in-todays-stable/3786>.

The "--help" flag ends up falling through to the old "arcanist.php", where it becomes lost. Catch it earlier so "arc diff --help" prints diff help, for instance.

Test Plan: Ran `arc help diff`, `arc diff --help`, `arc --help diff`, and similar commands for updated workflows; got help.

Differential Revision: https://secure.phabricator.com/D21168
2020-04-25 08:57:28 -07:00
epriestley
68f050bd14 Allow HTTPFuture callers to disable processing of "Content-Encoding" response headers
Summary: Ref T13507. In Phabricator, we perform a specific "Accept-Encoding: gzip" setup test and want to manually decode the result. Allow callers to disable handling of "Content-Encoding".

Test Plan: Ran all Phabricator setup checks.

Maniphest Tasks: T13507

Differential Revision: https://secure.phabricator.com/D21121
2020-04-15 06:28:25 -07:00
epriestley
377ed2ed8d If the Conduit server asserts it has the "gzip" capability, compress requests
Summary:
Ref T13507. For various messy reasons we can't blindly assume the server supports "gzip" -- but if the server tells us it does, we're on firmer ground.

If the server returns an "X-Conduit-Capabilities: gzip" header and we have compression support locally, compress subsequent requests.

This restores D21073, which was reverted by D21076.

Test Plan: With a gzip-asserting server, added debugging code and ran various "arc" commands. Saw the 2nd..Nth calls hit compression code.

Maniphest Tasks: T13507

Differential Revision: https://secure.phabricator.com/D21119
2020-04-14 16:50:54 -07:00
epriestley
a77da426af If the Conduit client supports gzip, make calls with "Accept-Encoding: gzip"
Summary:
Ref T13507. Add "Accept-Encoding: gzip" to requests if we can decompress responses.

When we receive a compressed response, decompress it.

Test Plan: Added debugging code, ran some commands, saw smaller payloads over the wire and inline decompression.

Maniphest Tasks: T13507

Differential Revision: https://secure.phabricator.com/D21118
2020-04-14 16:23:53 -07:00
epriestley
890b57de1e In "phutil_loggable_string()", encode every byte above 0x7F
Summary:
Ref T13507. Currently, this function is a bit conservative about what it encodes, and passing it a string of binary garbage may result in an output which is not valid UTF8.

This could be refined somewhat, since it's less than ideal if the input has valid UTF8. The ideal behavior for byte sequences where all bytes are larger than 0x7F is probably a variation of "phutil_utf8ize()" that replaces bytes with "<0xXX>" instead of the Unicode error glyph.

For now, just err on the side of mangling.

Test Plan: Dumped various binary payloads in the new gzip setup check, saw sensible output in the web UI.

Maniphest Tasks: T13507

Differential Revision: https://secure.phabricator.com/D21117
2020-04-14 16:03:12 -07:00
epriestley
9d0100bda7 Only inject legacy Arcanist workflows into "help" if run from the context of an Arcanist runtime
Summary: Ref T13490. This code is reachable from Phabricator binaries; only inject the legacy stuff if we're in an Arcanist stack.

Test Plan: Ran `bin/conduit help` from `phabricator/`.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21113
2020-04-14 13:24:00 -07:00
epriestley
d408a80ae1 Update "arc paste" for Toolsets
Summary: Ref T13490. More-or-less straightforward upgrade to modern calls.

Test Plan: Created and viewed pastes.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21104
2020-04-13 15:01:51 -07:00
epriestley
c8dd2a3753 Crudely bridge legacy workflows into "arc help"
Summary:
Ref T13490. One of the biggest issues users are hitting in modern "arc" is that workflows don't appear in "arc help" until they're updated.

Since there's still some work to do and gluing them in isn't terribly difficult, at least get things connected for now.

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

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21101
2020-04-13 11:41:05 -07:00
epriestley
196f8f54ce Remove "backout", "close", "flag", "start", "stop", "time", and "revert" workflows
Summary: Ref T13490. These workflows don't seem worth the maintenance cost, see T13488 for discussion.

Test Plan: Grepped for methods which looked like they might only be called by these flows, only dug up the backout stuff.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21100
2020-04-13 07:09:49 -07:00
epriestley
4719341c27 Upgrade (most) Differential API callsites to "differential.revision.search"
Summary: Ref T13490. The "RevisionRef" is currently based on "differential.query" data, but all calls other than the hash-based lookup can move to "differential.revision.search".

Test Plan: Ran revision workflows like `arc inspect` and `arc browse`.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21099
2020-04-13 06:42:25 -07:00
epriestley
ab589ab31d Restore "%d" support to "tsprintf()"
Summary: Ref T13490. I recently made "tsprintf()" more strict, but we do sometimes use "%d" and this is reasonable to support.

Test Plan: Ran "arc branch".

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21098
2020-04-13 04:35:59 -07:00
epriestley
21e80a635d Upgrade "arc download" to Toolsets
Summary:
Ref T13490. This is mostly straightforward.

  - Drop "--show" in favor of "--as -".
  - Drop support for 4+ year old "file.info" API.
  - Use modern stream-to-disk support so we get a real progress bar and don't need to buffer files into memory.

Test Plan: Downloaded various files, including large files.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21097
2020-04-12 16:18:03 -07:00
epriestley
076f7be484 Update "arc call-conduit" for Toolsets
Summary: Ref T13490. Fairly straightforward update.

Test Plan: Made various Conduit calls.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21096
2020-04-12 16:17:47 -07:00
epriestley
0f2e277cd9 Update "arc amend" for Toolsets
Summary: Ref T13490. Moves "arc amend" to Toolsets with modern ref/hardpoint code.

Test Plan: Ran "arc amend --show", "--revision", etc. Hit all the prompts and errors, probably?

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21095
2020-04-12 13:48:26 -07:00
epriestley
ff4c1e7c81 Add a "SymbolEngine" to support top-level ref resolution by symbol
Summary:
Ref T13490. I'm continuing to move toward modernizing "amend", which needs to load some objects by symbol at top level.

Add an API to support this.

Test Plan: Added an API caller to "arc inspect", ran it and hit the new code. Things seemed to work.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21094
2020-04-12 13:48:09 -07:00
epriestley
5fc50c226a Add some support code for printing refs to stdout
Summary: Ref T13490. Make terminal strings work more like HTML does in Phabricator, and make it easier to display refs.

Test Plan: Added some display code, ran `arc inspect` to hit it, saw a nice ref printed.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21093
2020-04-12 13:44:46 -07:00
epriestley
088b157444 Add ref lookup for username symbols
Summary:
Ref T13490. I'm attempting to update "arc amend", but it needs to fetch revision authors to raise an "amending a revision you don't own" error.

Support user-symbol resolution.

Along the way, this introduces some infrastructure for abstracting away iteration over a multi-page Conduit result set.

Test Plan:
  - Ran "arc inspect ..." for various "user(...)" queries.
  - Set page size to 3 and issued a general query, saw the future page it away properly.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21092
2020-04-12 13:42:51 -07:00
epriestley
1f18f25fa5 Add a "RevisionSymbolRef", revision commit messages, and make "--explore" recursive
Summary:
Ref T13490.

  - Support resolution of revision symbols into revision objects.
  - Align commit inspection better against commit symbols.
  - Make "arc inspect --explore" recursively load all object hardpoints.
  - Add a "commit message" hardpoint to "RevisionRef".

Test Plan: Used "arc inspect" to resolve commits and revisions. Used "--explore" to see the whole tree.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21091
2020-04-12 13:24:32 -07:00
epriestley
4cc05c377d Add a "CommitSymbolRef" for resolving symbolic commits into stable commit hashes
Summary:
Ref T13490. Frequently, we know the symbolic name of a commit (like "master") but need the immutable identifier for it (the commit hash).

Provide a Ref and Query for doing this lookup.

Test Plan: Ran `arc inspect symbol(...)` with various symbols, saw appropriate resolutions, nulls, or errors.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21090
2020-04-12 13:19:53 -07:00
epriestley
92be6df0eb Add a mode to "ExecFuture" that makes "resolvex()" semantics the default
Summary:
Ref T13490. "ExecFuture" can raise a "CommandException" when the subprocess fails. In most cases, this is desirable, since we usually do not expect subprocesses to fail.

Currently, "execx()" (which raises these exceptions) is the synchronous default (with the more verbose "exec_manual()" as an alternative if you expect the command may return an error code), but the Future variation has no way to hint that external resolution should raise an exception if the process exits with an error.

Since the "HardpointEngine" yield construct can resolve external futures, add a mode for this to simplify implementing "HardpointQuery" classes a bit. Without this, they either need to retain "$futures" and manually call "resolvex()", or check the "$err" result and throw some other exception, both of which are low-value boilerplate (queries that want to do this still can, of course).

This is basically like providing a hint that the futures should be resolved with "resolvex()" instead of "resolve()".

Also, make this the default behavior of a new "$api->newFuture()" wrapper.

Test Plan: Intentionally broke a command in a HardpointQuery, got a sensible exception automatically during external future resolution.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21089
2020-04-12 13:18:11 -07:00
epriestley
73f48aca74 Allow "loadHardpoints()" to accept a single ref and/or a single hardpoint
Summary: Ref T13490. There's more `array(...)` happening in this API than necessary. Sugar it slightly.

Test Plan: Grepped for "loadHardpoints()", ran a couple workflows.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21088
2020-04-12 13:17:41 -07:00
epriestley
6e24e10bdb Remove obsolete definitions of "defineHardpoints()" in older Ref objects
Summary: Ref T13490. A few older "defineHardpoint()" calls are sticking around. They no longer have callers; get rid of them.

Test Plan: Grepped for this symbol, no hits.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21087
2020-04-12 13:16:22 -07:00
epriestley
9a198ffcc5 Update "feature", "branch", and "bookmark" flows to report properly in "arc help"
Summary:
Ref T13490. These workflows are aliases of one another, which is a little silly, but currently all identify as "arc feature" in "arc help".

Straighten that out, at least.

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

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21086
2020-04-12 13:16:07 -07:00
epriestley
ccd1ebb256 Port "arc prompts" from wilds and fix a path issue in shell completion
Summary:
Ref T13490. Bring "arc prompts" from "wilds" and hook it into the prompt in "arc shell-complete".

See D21069. Fix an issue where the shell hook tested for a path other than the path it writes to.

Test Plan: Ran "arc shell-complete" with no hook and got a prompt. Shell completed things. Ran "arc prompts shell-complete".

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21085
2020-04-11 10:43:05 -07:00
epriestley
387027eb3a Restore "arc alias" shell aliases
Summary:
See <https://discourse.phabricator-community.org/t/exception-when-trying-to-run-an-arc-alias-undefined-method-arcanistalias-getshellcommand/3731/>.

Shell aliases got lost in the shuffle of porting "arc alias"; restore them.

Test Plan: Bound `arc ls` to `ls -alh`, ran `arc ls`.

Differential Revision: https://secure.phabricator.com/D21084
2020-04-11 09:59:48 -07:00
epriestley
fff2fc8bc9 Remove "RefQuery" and all "HardpointLoader" code
Summary: Ref T11968. "RefQuery" is now "HardpointEngine". "HardpointLoader" is now "HardpointQuery".

Test Plan: Grepped for affected symbols.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21083
2020-04-11 06:46:53 -07:00
epriestley
dc42f51cf7 Reroute all RefQuery callers to HardpointEngine
Summary:
Ref T11968. "arc browse", "arc branch", and "arc diff" currently may execute into the RefQuery engine. Reroute them to the HardpointEngine.

This removes older-generation "Ref" objects and renames the replacement "RefPro" objects to "Ref".

Test Plan: Ran "arc branch", "arc browse <various things>", "arc diff", searched for affected symbols.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21082
2020-04-11 06:46:23 -07:00
epriestley
9e72e4ed1d Bring "pro" browse queries from modern hardpoint code
Summary: Ref T11968. Merge the modern hardpoint queries and refs for the "browse" workflow as "pro" variations.

Test Plan: Ran `arc inspect browse(...)` for objects, paths, commits, and revisions.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21080
2020-04-10 08:05:24 -07:00
epriestley
8bb81217d5 Bring a "pro" WorkingCopyState ref to "master"
Summary:
Ref T11968. Continue bringing modern yield-based hardpoint code into "master" in the parallel "Pro" classtree.

Adds "working-copy(commit-hash)" as an inspectable ref.

Test Plan: Inspected working copy refs, saw them resolve revisions by commit hash and commit message.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21079
2020-04-10 06:16:37 -07:00
epriestley
adea2550f5 Introduce "arc inspect" and some of the new ref/hardpoint classes
Summary:
Ref T11968. Inches toward the new ref/hardpoint code by introducing the modern refs as "RefPro" objects and supporting an "arc inspect <object>" to load objects and hardpoints.

This doesn't impact any existing runtime behavior.

Test Plan: Ran "arc inspect [--all] commit(...)", got hardpoint queries and yield-based data fetching.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21078
2020-04-10 05:01:25 -07:00
epriestley
92b29f53f3 Rename "getWorkingCopy()" to "getWorkingCopyIdentity()" in Arcanist
Summary:
Depends on D21074. Ref T13490. Ref T11968. Before toolsets, Arcanist has a "WorkingCopyIdentity" object. After toolsets, it has a "WorkingCopy" object.

Most workflows don't access either one, so make a slightly-breaking API change to simplify the transition.

  - "getWorkingCopy()" now returns a modern object (a "WorkingCopy").
  - "getWorkingCopyIdentity()" now returns an older object (a "WorkingCopyIdentity").

This isn't backward-compatible, but out-of-date code should get an explicit failure with clear resolution steps.

Test Plan: Ran "arc lint", "arc branch", and a few other commands. Grepped for "getWorkingCopy()".

Maniphest Tasks: T13490, T11968

Differential Revision: https://secure.phabricator.com/D21075
2020-04-10 04:24:29 -07:00
epriestley
391c164313 Trivially update "arc branch/feature" and "arc browse" for Toolsets
Summary:
Ref T11968. Ref T13490. These are the workflows which currently use the intermediate-level hardpoint code (which made hardpoints formal, but didn't do the yield stuff).

Move toward updating them by doing some basic bookkeeping, with a few compatibility adjustments to the parent Workflow class.

Test Plan: Ran "arc branch" and "arc browse" with various arguments.

Maniphest Tasks: T13490, T11968

Differential Revision: https://secure.phabricator.com/D21074
2020-04-10 04:23:03 -07:00
epriestley
f56c6bde2b Revert "Compress requests from the Conduit client to Phabricator"
Summary:
This reverts commit 7e25288f49. See T13507 for discussion, shortly.

This needs to be switched to capability detection because some server configurations can not actually accept these requests.

Test Plan: Straight revert.

Differential Revision: https://secure.phabricator.com/D21076
2020-04-09 12:25:18 -07:00
epriestley
7e25288f49 Compress requests from the Conduit client to Phabricator
Summary: Ref T13507. Enable compression in the body of Conduit requests if we have client support for it; we expect the server should always support it.

Test Plan: Created this revision, ran random "arc" commands that use Conduit. Added debugging code, saw payload size drop.

Maniphest Tasks: T13507

Differential Revision: https://secure.phabricator.com/D21073
2020-04-08 09:24:54 -07:00
epriestley
deb72c37db Remove onboard future bulk-resolution from ConduitEngine
Summary:
Depends on D21071. Ref T11968. Currently, "ConduitEngine" tries to lightly parallelize futures. This was a compromise when the initial "hardpoint" change didn't plan to pursue real request paralleization.

Now that the newer hardpoint change does, we don't need onboard resolution in ConduitEngine. Throw it away.

When the engine is supposed to resolve a future, it now just resolves that future on its own. This should be functionally identical to the previous behavior, except that it may be slower.

(In practice, because HTTP futures are backed by an internal cURL request pool, this proably has little effect anywhere. Moving to modern hardpoints will make performance no worse than it was prior to this change, in any case.)

Test Plan: Ran various modern "arc" commands.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21072
2020-04-08 09:24:37 -07:00
epriestley
85141c4d90 Add new "Hardpoint" classes to support request parallelization
Summary:
Depends on D21070. Ref T11968. Adds "yield"-aware query classes for parallelizing service calls.

These will replace the similar (but not yield-aware) "Hardpoint" classes introduced previously. This is an API change but most of the old classes still exist and still do the same thing, just with more "yield" statements.

This just adds a bunch of new code with no callers and no API updates.

Test Plan: See future changes.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21071
2020-04-08 09:23:50 -07:00
epriestley
0b3cd39230 Update the "WorkingCopy" API and create a fallback "Filesystem" working copy
Summary:
Ref T11968.

  - Allow "WorkingCopy" objects to maintain an API object and update callers ("get...()" instead of "new...()").
  - Always generate a WorkingCopy object and a RepositoryAPI object.

Currently, code has to look like this:

```
$working_copy = ...
if ($working_copy) {
  $repository_api = ...
  if ($repository_api [instanceof ... ]) {
```

This is clunky. There's also no reason some "arc" commands can't run outside a VCS working directory without special-casing how they interact with the filesystem.

Conceptually, model the filesystem as a trivial VCS (which stores exactly one commit, always amends onto it, and discards history). Provide a trivial WorkingCopy and API for it.

(This change isn't terribly interesting on its own, but chips away at landing the new Hardpoint infrastructure.)

Test Plan: Ran `arc version`, `arc upgrade`.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21070
2020-04-08 09:22:43 -07:00
epriestley
a1ee2ab931 Fix improper XHPAST parsing of namespace grammar like "use x as private;"
Summary:
Depends on D21067. Ref T13492. Converting unit tests to be readable exposed this error in the grammar.

Normally, "grammar_rule" rules emit a standalone Node. In this case, the bottom-level grammar rule is a collection of trivial rules and the callers configure the Node. Wrap the bottom-level rule in a configuration rule so the node is configured correctly and consistently, in exactly one place.

Test Plan: Ran unit tests.

Maniphest Tasks: T13492

Differential Revision: https://secure.phabricator.com/D21068
2020-04-07 14:35:42 -07:00
epriestley
e03431def8 Fix XHPAST parsing of variadic calls
Summary:
Depends on D21066. Ref T13492. The switch of unit test data to stable/readable output exposed this bug in parsing of variadic calls: some nodes are not given types properly.

Fix the parser and update the test.

Test Plan: Ran the test, which now works.

Maniphest Tasks: T13492

Differential Revision: https://secure.phabricator.com/D21067
2020-04-07 14:33:37 -07:00
epriestley
a689dee228 Update XHPAST "expect" test blocks to the new stable, human-readable format
Summary:
Depends on D21065. Ref T13492. Swap existing "expect" blocks from unstable, unreadable JSON to readable, stable trees.

(There are two "INVALID TYPE" outputs which this update effectively detects and which future changes correct.)

Test Plan: Ran "arc unit --everything", got a clean build.

Maniphest Tasks: T13492

Differential Revision: https://secure.phabricator.com/D21066
2020-04-07 14:32:48 -07:00
epriestley
8a7ce97b51 Make XHPAST unit test "expect" blocks stable and human-readable
Summary:
Depends on D21064. Ref T13492. Earlier, see D17819. This is essentially the same change, although I inlined the token stream into the node list.

This intentionally breaks most tests since it just has the new "expect" generator; the next change will fix them by swapping the test bodies.

Test Plan: Ran "arc unit --everything" after the next change (which fixes all the tests), got a clean build. This change on its own fails all existing XHPAST tests since the block formats don't match.

Maniphest Tasks: T13492

Differential Revision: https://secure.phabricator.com/D21065
2020-04-07 14:31:56 -07:00
epriestley
33dc2fe819 Allow "phage" to print execution status on SIGINT
Summary: Ref T13490. The new Arcanist runtime supports workflow signal handling, but Phage isn't quite able to make use of it. Clean up the last few pieces so it can work.

Test Plan: Ran "phage", hit ^C, got status information.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21060
2020-04-06 11:09:43 -07:00
epriestley
32005f26a4 Move Phage to FuturePool
Summary: Ref T11968. Phage has another "sustained pool of Futures" use case, and needs some slight adjustments after Future API changes.

Test Plan: Ran `bin/phage status ...`, got a clean result instead of a JSON decoding failure.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21058
2020-04-05 05:56:21 -07:00
epriestley
099c2ae648 Introduce "FuturePool" to make it easier to manage an ongoing pool of futures
Summary:
Ref T11968. "FutureIterator" recently became non-rewindable, and starting a Future twice is now an error.

This complicates a handful of use cases where a mostly-constant pool of futures is maintained over a long period of time, notably in daemon overseers and repository pull daemons.

They previously relied on being able to do "new FutureIterator($futures)" to continue resolution of a list of futures from any state. This no longer works quite like it used to, since Futures generally may not belong to more than one iterator now (and this property is desirable).

Introduce "FuturePool", which maintains exactly one iterator but manages the small amount of glue around adding and removing Futures from it, destroying it if the pool empties, and rebuilding it if the pool fills.

Test Plan: See next change, which makes use of this.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21053
2020-04-03 12:05:09 -07:00
epriestley
368aec16a1 Update some ancient "set X=Y" environment code for new Windows execution without a shell
Summary:
Depends on D21051. Ref T13504. Ref T13209. This very old Mercurial code uses "X=Y hg ..." on Linux and "set X=Y & hg ..." on Windows.

The latter construct no longer works because we bypass the shell. The former construct is obsolete.

Additionaly, delete some ancient "branch merge" code which has no callers.

Test Plan: Created a diff in a Mercurial repository on Linux. I minimally vetted this on Windows since I don't have a "hg + Windows" environment at the moment.

Maniphest Tasks: T13504, T13209

Differential Revision: https://secure.phabricator.com/D21052
2020-04-02 13:50:57 -07:00
epriestley
d4d095dbf6 Make Windows escaping preserve "%" symbols in arguments
Summary:
Ref T13504. Ref T13209. We currently use "escapeshellarg()" under Windows, which destructively replaces "%" symbols with spaces. This is wrong, breaks general behavior with "git log --format=...", and has led to a lot of weird workarounds in `arc` code where we don't escape arguments we should be escaping to tiptoe around issues with "%".

Now that execution occurs via "bypass_shell", we can safely (probably?) escape things, although programs are still apparently free to parse the command string however they want.

Test Plan: Added unit tests, ran them under Mac and Windows, got clean results. Ran "arc version" on Mac and Windows.

Maniphest Tasks: T13504, T13209

Differential Revision: https://secure.phabricator.com/D21051
2020-04-02 13:44:13 -07:00
epriestley
5ce1d79717 Fix error behavior of "arc version" when it encounters a library which is not a working copy
Summary:
Ref T13504. The API has changed here slightly, and if you run "arc version" without "arcanist/" being a Git working copy, it currently fatals in a misleading way.

Instead, reach the error properly.

Test Plan: Ran "arc version" after moving aside ".git/", got a helpful error message instead of a confusing "call on null" exception.

Maniphest Tasks: T13504

Differential Revision: https://secure.phabricator.com/D21050
2020-04-02 08:24:22 -07:00
epriestley
63276697eb Fix three Windows subprocess issues
Summary:
Fixes T13504. This fixes three issues:

  # In ExecFuture, "proc_open()" on an invalid binary could fail with an unconditional exception.
  # In ExecPassthru, "proc_open()" on an invalid binary could fail with an unconditional exception.
  # In "arc browse", "start <url>" does not work when the shell is bypassed.

In (1) and (2), the desired behavior is to fail with an exit code which is sometimes upgraded to an exception depending on calling convention.

Issue (1) most commonly manifested as "find" failing when run via "cmd.exe".

Issue (2) most commonly manifested as "arc browse" failing.

Issue (3) was entangled with issue (2).

In cases (1) and (2), assume "proc_open()" failures under Windows are because of bad binaries and treat them like bogus commands on Linux/Mac.

In case (3), use "cmd /c start" instead of "start" as a default browser on Windows.

Test Plan:
  - On Windows, did mime type detection in cmd.exe. Before patch: proc_open() exception in "find". After patch: clean (albeit not terribly useful) detection.
  - On Windows, did "arc browse ...". Before patch: proc_open() exception in "start". After patch: clean browser execution.

Maniphest Tasks: T13504

Differential Revision: https://secure.phabricator.com/D21047
2020-04-01 16:11:05 -07:00
epriestley
492113370a Fix two issues with Future key selection inside FutureIterator
Summary:
Ref T11968.

  - Rekeying natural lists of futures creates more problems than it solves. For now, don't try to deal with this.
  - The scope of the future autokey was incorrect (per subclass, not per process).

Test Plan: Ran various future-oriented flows on new HardpointEngine code.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21046
2020-04-01 10:36:44 -07:00
epriestley
b1a712add8 Integrate "ServiceProfiler" into the base "Future"
Summary:
Depends on D21036. Ref T11968. Ref T13177. Currently, each Future integrates separately with ServiceProfiler, but much of the code is similar.

Move integration to the base class and lift up most of the implementation details.

Test Plan: Ran `arc diff --trace`, saw sensible output.

Maniphest Tasks: T13177, T11968

Differential Revision: https://secure.phabricator.com/D21038
2020-03-30 07:42:40 -07:00
epriestley
cb80f69715 Make "FutureIterator" queue management more formal
Summary: Depends on D21035. Ref T11968. This allows a "FutureIterator" to hold futures which are blocked because of unresolved dependencies, and makes the resolution process more structured.

Test Plan: Ran unit tests, created this revision.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21036
2020-03-30 07:42:09 -07:00
epriestley
6b75562c3e Make "exception" on Future a private property
Summary: Depends on D21034. Ref T11968. Continue modernizing Future.

Test Plan: Ran tests, created a revision.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21035
2020-03-30 07:34:51 -07:00
epriestley
4d55067fd8 Make the "result" property on Future private
Summary: Depends on D21033. Ref T11968. This is just an incremental step in modernizing Future and making it more robust. Currently, subclasses are expected to write directly to `$this->result`, but this isn't consistent with how modern classes generally work.

Test Plan: Ran unit tests, created this revision.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21034
2020-03-29 10:18:26 -07:00
epriestley
e20dce875c Resolve all futures inside FutureIterator
Summary:
Depends on D21032. Ref T11968. Currently, "Future" and "FutureIterator" can both resolve futures.

Treat "Future->resolve()" as sugar on resolving an iterator of size 1.

Test Plan: Ran tests, created this revision.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21033
2020-03-29 10:18:06 -07:00
epriestley
3df48c9257 Remove the "timeout" parameter from "Future->resolve()"
Summary:
Ref T11968. This future-level parameter has no nontrivial callers and makes the "fate of FutureGraph" changes more difficult.

Callers that are genuinely interested in this behavior can wrap the Future in a FutureIterator and use "setUpdateInterval()" to get the same behavior.

Test Plan: Grepped for "resolve()" and "resolvex()", updated callers.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21031
2020-03-29 10:13:59 -07:00
Paul Tarjan
33b9728b5f Run ls-files from the root of the directory
Summary:
One of our users ran into an issue where they were running `arc diff` in
a subdirectory and it so happened that in that directoy there wasn't any `lfs`
files so the repo was marked as `$is_lfs == false`. Lets allow `arc` to be run
from anywhere.

Test Plan: Internally this patch worked

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D21045
2020-03-25 14:23:53 -07:00
epriestley
4c12c3119b Treat all PHP language-level errors as exceptions by default
Summary:
Ref T13499. Currently, we throw most language errors as exceptions, but this list isn't exhaustive and errors we don't specifically make more severe are allowed to slip through.

This is generally undesirable, particularly in the case of "Undefined index:" errors. See T13499 for a specific case where this caused behavior to be more difficult to understand and diagnose than it should have been.

Make this the default behavior instead, except for "E_USER" errors, which we never expect to arise from first-party code.

This may be slightly too aggressive, but future changes can selectively reduce the severity of some types of errors if problems arise.

Test Plan:
  - Executed code which intentionally accessed an undefined index, got an exception.
  - Poked around Phabricator and Arcanist without any further issues cropping up, but I don't have a good way to develop confidence that the "reduced severity" list should genuinely be empty.

Maniphest Tasks: T13499

Differential Revision: https://secure.phabricator.com/D21044
2020-03-22 12:41:05 -07:00
epriestley
18799c1829 Switch file uploader in "arc diff" to use ConduitEngine
Summary: Fixes T13498. Currently, `arc diff` may invoke the file upload flow using an older variation of the API. Both the modern and fallback clients build an Engine, so switching to the modern API is trivial.

Test Plan:
  - Created a local commit with a 1MB binary file.
  - Ran `arc diff --only`.
  - Before patch: fatal on old API call.
  - After patch: clean upload.

Maniphest Tasks: T13498

Differential Revision: https://secure.phabricator.com/D21043
2020-03-20 12:19:17 -07:00
Paul Tarjan
97e050fce7 Use a named remote and branches for staging to help git-lfs
Summary:
I'm working on a fairly large monorepo using phabricator and we are
running into a `git-lfs` issue. Every single `arc diff` we have to wait
many seconds while all our lfs files are walked before the push goes through.

I chatted with the `git-lfs` folks in
https://github.com/git-lfs/git-lfs/issues/4076 and they suggested this workflow
change. I tested it on our repo and it does indeed seem to fix the issue. Three
things were change:

1. The remote url is named
2. Use branches instead of tags
3. Do a `git fetch`

(Also, hello after all this time! Hope you're all doing well over at phacility.)

Test Plan:
Before
```
$ arc diff
Linting...
 LINT OKAY  No lint problems.
Running unit tests...
 UNIT OKAY  No unit test failures.
 PUSH STAGING  Pushing changes to staging area...
Uploading LFS objects: 100% (8211/8211), 1.0 GB | 0 B/s, done.
Enumerating objects: 31, done.
Counting objects: 100% (31/31), done.
Delta compression using up to 12 threads
Compressing objects: 100% (21/21), done.
Writing objects: 100% (24/24), 1.77 KiB | 8.00 KiB/s, done.
Total 24 (delta 19), reused 0 (delta 0)
remote: Resolving deltas: 100% (19/19), completed with 6 local objects.
To github.com:robinhoodmarkets/web-staging.git
 * [new tag]             2581578b59b6341c1023377fd8741814e89fcd0c -> phabricator/base/427095
 * [new tag]             7d9be50fbca590f15742d8cc20edd4f082dfbb3b -> phabricator/diff/427095
Updated an existing Differential revision:
        Revision URI: https://phabricator.robinhood.com/D135442

Included changes:
  M       __shared/tools/arcanist-js/src/workflow/RHArcanistDiffWorkflow.php
```

After
```
$ arc diff
Linting...
 LINT OKAY  No lint problems.
Running unit tests...
 UNIT OKAY  No unit test failures.
 PUSH STAGING  Pushing changes to staging area...
Enumerating objects: 15, done.
Counting objects: 100% (15/15), done.
Delta compression using up to 12 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 638 bytes | 2.00 KiB/s, done.
Total 8 (delta 6), reused 0 (delta 0)
remote: Resolving deltas: 100% (6/6), completed with 6 local objects.
To github.com:robinhoodmarkets/web-staging.git
 * [new branch]          2581578b59b6341c1023377fd8741814e89fcd0c -> phabricator/base/427105
 * [new branch]          274cc3a25eb7856291c1d4c078b28b76af8a43b2 -> phabricator/diff/427105
Updated an existing Differential revision:
        Revision URI: https://phabricator.robinhood.com/D135442

Included changes:
  M       __shared/tools/arcanist-js/src/workflow/RHArcanistDiffWorkflow.php
```

(notice the lack of `Uploading LFS objects`)

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D21041
2020-03-20 11:57:26 -07:00
epriestley
66a6128239 Remove the "preg_quote()" lint rule and update the "__CLASS__" lint rule
Summary:
Depends on D21031. Ref T11968. This clears some lint with the word "Future", but is just a minor cleanup patch not really related to the main goal in that task.

We currently warn on `preg_quote()` with no second parameter, but this is valid and correct:

```
preg_match('('.preg_quote($x).')', ...)
```

This is the modern recommended style for this sort of expression, so the warning is often a false positive; drop it.

The "__CLASS__" warning looks for hard-coded class names in strings, but currently looks for them as a word anywhere in the string.

This is often a false positive and sometimes makes error messages or exceptions untranslatable. For example, translators can't do anything with this:

> Filesystem path "%s" does not exist.

...if it's written as:

> %s path "%s" does not exist.

...just because it happens to appear in the class "Filesystem". Some other classes, including "Future", suffer from this.

Even when the detection is correct, it's clunky and a mistake here (failing to update the class name in an error message) is unlikely to ever do any real damage.

Test Plan: Ran unit tests and `arc lint`.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21032
2020-03-06 09:14:10 -08:00
epriestley
31653f6b77 Fix an issue where "arc" may fail on startup when trying to read older "default" config
Summary:
See PHI1663. If "phabricator.uri" is not configured, we try to fall back to "default", but doesn't have a modern config specification and fails.

Instead, read "default" as a raw config value to preserve compatible behavior. My intent is to eventually remove it.

Test Plan:
In a directory with no "phabricator.uri" config available, ran `echo {} | arc call-conduit conduit.ping`. After the patch, got a reasonable error instead of a fatal.

In a directory with "default" configured but not "phabricator.uri", ran the same command. After the patch, got a ping.

Maniphest Tasks: T13497

Differential Revision: https://secure.phabricator.com/D21039
2020-03-06 08:31:25 -08:00
epriestley
1b97f8b408 Update "arc upload" for Toolsets
Summary: Ref T13490. This largely makes "arc upload" work, although the Future stuff is still a bit wonky. See T11968.

Test Plan: Ran "arc upload README.md", got an upload.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21030
2020-02-26 08:22:18 -08:00
epriestley
9bd5c23b2a Improve error handling in ArcanistRuntime when failing to load libraries
Summary: Ref T13490. This fixes one bug in D21025 (loading relative to "arcanist/" rather than the parent directory) and improves behavior when a library fails to load (we prompt the user to continue).

Test Plan:
  - Ran `arc list` with bad library specifications, got a sensible error and an option to continue.
  - Ran `arc list` with a library specification that existed next to "arcanist/", got a library load instead of an error.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21029
2020-02-25 14:07:22 -08:00
epriestley
9cd72baae9 Update Phage for toolsets and restore library loading behaviors
Summary: Ref T13490. This makes the "phage" toolset work properly and updates external library behavior to match the "classic" behavior, except that "--library" is now supported.

Test Plan: Ran "phage remote" workflows.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21025
2020-02-23 09:30:53 -08:00
epriestley
de461bb179 Fix two "implode()" order issues arising from wilds/experimental collapse
Summary:
Ref T13490. There's one simple "implode()" order issue here, and one slightly more complex one that uses "DIRECTORY_SEPARATOR" as glue.

Add test coverage for this, update the lint check to detect constants used as glue, and fix the callsites.

Test Plan:
  - Added a failing test and made it pass.
  - Ran `arc lint --everything` and looked for remaining implode warnings, found none.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21024
2020-02-23 08:34:30 -08:00
epriestley
ee66b15bd4 Port "arc upgrade" to Toolsets
Summary: Ref T13490. Allows "arc upgrade" to run through the new Toolsets infrastructure.

Test Plan: Ran "arc upgrade", although you can't upgrade feature branches so this can't be entirely tested until it hits "master".

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21006
2020-02-17 11:33:17 -08:00
epriestley
d4e4271b57 Remove obscure features no longer supported by Toolsets from "classic" Arcanist
Summary: Depends on D21004. Ref T13490. The "wilds" branch removed a bunch of dead features but some of them were resurrected by the merge. I don't think any of these are desirable to retain, so purge them all again, even in classic mode.

Test Plan: Grepped for affected symbols.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21005
2020-02-17 09:28:39 -08:00
epriestley
d3b77af8a5 Require "--" as an argument terminator when running noninteractively
Summary:
Depends on D21001. Ref T13490.

  - Require "--" to terminate arguments when running noninteractively.
  - Don't correct spelling when running noninteractively (we still suggest corrections).
  - Remove old "phage" wrapper script.
  - Fix an issue where "argv" could implicitly generate a parseable "--argv" flag.
  - Accept "--" as an argument terminator even when there is no argument list.
  - Update some strings to use more modern quoting style.
  - Make workflows decline to handle signals by default.
  - Allow "arc weld" to weld non-UTF8 files together.

Test Plan: Ran various commands. Welded non-UTF8 files.

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21002
2020-02-16 09:16:51 -08:00
epriestley
db8419f19b Port "arc weld" and "arc anoid" to Toolsets workflows, plus minor fixes
Summary: Ref T13490. Update the "weld" workflow and the "anoid" workflow. Incorporates D20938.

Test Plan: Ran "arc weld". Ran "arc anoid".

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21001
2020-02-16 09:16:24 -08:00
epriestley
8cd79d38af Port "arc shell-complete" to Toolsets
Summary: Depends on D20996. Ref T13395. Ports the updated version of this workflow from "experimental".

Test Plan: Ran `arc shell-complete` to install the hook, then shell-completed commands.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20997
2020-02-14 09:16:46 -08:00
epriestley
70c6045c7f Update "arc alias" to modern workflows
Summary: Depends on D20993. Ref T13395. Merges the more-modern "alias" out of "experimental".

Test Plan: Defined and invoked aliases. This has some rough edges: notably, no easy list/delete flow.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20996
2020-02-14 09:16:18 -08:00
epriestley
0c6ae6bbcf Port "arc version" to Toolsets
Summary: Ref T13395. Depends on D20992. Run "arc version" as a modern workflow, not a classic workflow.

Test Plan: Ran "arc version".

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20993
2020-02-14 09:15:58 -08:00
epriestley
cf9469e0d1 Port "arc liberate" to Toolsets
Summary: Ref T13395. Depends on D20991. Make "arc liberate" run as a toolset command, not a classic command.

Test Plan: Ran "arc liberate"; created this diff.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20992
2020-02-14 09:14:56 -08:00
epriestley
0e95fcbb7f Port "arc help" to Toolsets
Summary: Ref T13395. Make "arc help" run as a toolset command, not a classic command.

Test Plan: Ran "arc help".

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20991
2020-02-14 09:14:30 -08:00
epriestley
c471983697 Collapse Arcanist toolsets from "wilds" into "master", as an overlay layer
Summary:
Depends on D20988. Ref T13395. Ref T13098. Ref T13203.

This brings all the "toolsets" code into "master". We try to run commands as toolsets commands first, then fall back to older code.

Since the "toolsets" class tree is mostly parallel to the older class tree, this isn't completely broken. Currently, all commands fall back.

Test Plan: Created this diff, ran various other commands. But this is probably a long shot from finished.

Maniphest Tasks: T13395, T13203, T13098

Differential Revision: https://secure.phabricator.com/D20990
2020-02-13 14:10:46 -08:00
epriestley
acf0607683 Merge utility/support changes from "wilds" to "master"
Summary:
Ref T13395. Merge a lot of stuff which doesn't break existing workflows:

    - Merge a UTF8 fix for "cmd.exe" on Windows.
    - Merge minor changes to JSON linters.
    - Merge some shell completion stuff.
    - Merge some "arc anoid" fixes.
    - Merge various Windows improvements to unit tests which interact with processes / the filesystem.
    - Merge some other Windows path fixes.
    - Merge a UTF8 character class fix.
    - Merge script initialization.
    - Merge unit test support scripts.
    - Merge some initialization code.
    - Merge Windows stdout/stderr-as-files code.
    - Merge a bunch of code for making exec tests work on Windows.
    - Merge more Windows unit test fixes.
    - Merge "continue on failure" mode when loading symbols.
    - Merge "GPC" order CLI fixes.

Test Plan: Ran `arc unit --everything`; created this change. There's likely some less-than-perfect code here.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20988
2020-02-13 14:10:09 -08:00
epriestley
0d62a10eda Don't depend on "XMLWriter" to load the lint renderer class tree
Summary: Fixes T13489. See that task for discussion.

Test Plan: Ran `arc lint` and `arc lint --output xml`. Faked a missing extension, ran `arc lint` (no problems) and `arc lint --output xml` (sensible error message).

Maniphest Tasks: T13489

Differential Revision: https://secure.phabricator.com/D20989
2020-02-13 13:38:52 -08:00
epriestley
8c4f6ce161 Merge the remainder of the "experimental" branch
Summary:
Depends on D20986. Ref T13395. This //mostly// collapses the entire "experimental" branch into "master".

I plan to change the "Ref/Hardpoint" pattern to become future oriented, but this is more steps forward than sideways.

Test Plan: Ran various `arc` workflows.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20987
2020-02-13 06:05:08 -08:00
epriestley
4c36860c43 Merge Arcanist lint changes from "experimental" branch
Summary: Ref T13395. Collapse changes to the linter workflow from "experimental" into "master".

Test Plan: Ran `arc lint`. Noted flag changes in changelog.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20986
2020-02-13 06:04:47 -08:00
epriestley
26f853b634 Merge "--draft" flag and related changes from "experimental" to "master"
Summary: Ref T13010. This brings the "--draft" flag (and a handful of related flags) to "master" from "experimental".

Test Plan: Ran "arc diff". This code has been in use on "experimental" for a long time.

Maniphest Tasks: T13010

Differential Revision: https://secure.phabricator.com/D20985
2020-02-12 16:54:18 -08:00
epriestley
a8a50b2fc0 Make "arcanist/" unit tests pass
Summary: Ref T13395. Fixes a file-locking test and removes a logging test that's more trouble than it's worth.

Test Plan: Ran "arc unit --everything" locally, got a clean bill of health.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20984
2020-02-12 16:20:30 -08:00
epriestley
61e059984a Merge "phage" from "experimental"
Summary: Ref T13395. Currently, "phage" is required for various cluster operations. Bring the working code out of "experimental". This isn't the final form; "wilds" has a fancier version.

Test Plan: Ran phage workflows against the cluster.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20982
2020-02-12 15:53:23 -08:00
epriestley
9b74cb4ee6 Fully merge "libphutil/" into "arcanist/"
Summary: Ref T13395. Moves all remaining code in "libphutil/" into "arcanist/".

Test Plan: Ran various arc workflows, although this probably has some remaining rough edges.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20980
2020-02-12 15:17:38 -08:00
epriestley
a36e60f0a3 Move HTML-only intraline diff code to Phabricator
Summary:
Ref T13395. This code relies on PhutilHTML, but that's moving to Phabricator.

It has no callers in libphutil or Arcanist.

Test Plan: Looked for callers.

Maniphest Tasks: T13395

Differential Revision: https://secure.phabricator.com/D20978
2020-02-12 13:13:23 -08:00
epriestley
21a1828ea0 Omit "--" in older fallback commands for Git remote URIs
Summary: Ref T13481. Some older versions of Git appear to not support "--" in these commands. Just drop it. This can lead to ambiguous results with certain obviously-silly remote names, but doesn't appear to lead to anything dangerous.

Test Plan: Will followup with user on ancient Git.

Maniphest Tasks: T13481

Differential Revision: https://secure.phabricator.com/D20952
2020-01-23 16:50:54 -08:00
epriestley
70c0fd3f22 In Git, fall back across versions more cleanly when trying to get the URI for a remote
Summary: Fixes T13481. When identifying the URI for a remote, fall back from "git remote get-url" to "git ls-remote --get-url" to "git config remote.<name>.url" based on command output and version tests.

Test Plan: Ran `arc land --hold`, rigged the subcommands to fail to try all three fallbacks, ran `arc land --hold --remote asdfasdf` to get an explicit failure.

Maniphest Tasks: T13481

Differential Revision: https://secure.phabricator.com/D20950
2020-01-23 15:19:28 -08:00
epriestley
cc850163f3 When "arc close-revision --finalize ..." skips closing a revision, print a message
Summary: Fixes T13458. Emit an explicit message when "arc close-revision --finalize" bails out because the revision is not "Accepted".

Test Plan: Ran `arc close-revision [--finalize] ...` on various revisions, saw more clear messaging.

Maniphest Tasks: T13458

Differential Revision: https://secure.phabricator.com/D20915
2019-11-18 20:31:51 -08:00
epriestley
cc1ff38843 When generating diffs in "arc diff", disable Git config option "diff.suppressBlankEmpty"
Summary:
Ref T13432. Git has a "diff.suppressBlankEmpty" config option which makes it emit nonstandard diffs with trimmed trailing whitespace on unchanged blank lines.

Currently, we don't parse these diffs correctly. Even if we do in the future, emitting a more standard diff is desirable.

Explicitly disable this option when executing "git diff" so we build more standard diffs.

Test Plan:
  - Configured this option.
  - Modified a file with a blank line in it without changing the blank line, got this goofy display diff:

{F6985234}

  - Applied patch, rediffed the same change, saw "-c diff.suppressBlankEmpty" in "--trace" output and got this sensible diff:

{F6985235}

Maniphest Tasks: T13432

Differential Revision: https://secure.phabricator.com/D20877
2019-10-29 10:14:40 -07:00
epriestley
73943d1bc9 Make "arc land --merge" an explicit error when targeting a Perforce remote
Summary: Ref T13434. Since "git p4 submit" gets more complicated when submitting merges, and empty merges (as with "--no-ff") seem to vanish, and it's not clear this is desirable or useful anyway, just make the "merge" strategy an explicit error with Perforce remotes.

Test Plan: Ran "arc land --merge ..." in a Git/Perforce repository, got an explicit error. Ran "arc land --squash ...", got existing working behavior.

Maniphest Tasks: T13434

Differential Revision: https://secure.phabricator.com/D20871
2019-10-28 11:59:42 -07:00
epriestley
7383c2f4e6 In "arc land", when "remote/onto" does not exist locally, try to fetch it before giving up
Summary:
Fixes T10650. It's valid to `arc land --remote origin --onto master` without first fetching that ref. If we can't find a local ref for a specified remote branch, try to fetch it before giving up.

(In the long run, this should be valid even if the remote branch does not exist at all and the user intends to create it -- see T12876 -- but this is a step toward that.)

Test Plan:
  - Ran `rm .git/refs/remotes/origin/master`, then landed into "master".
  - Before: "arc land" bailed out immediately.
  - After: "arc land" fetches the missing ref.

```
$ arc land
 TARGET  Landing onto "master", the default target under git.
 REMOTE  Using remote "origin", the default remote under Git.
 TARGET  No local ref exists for branch "master" in remote "origin", attempting fetch...
 FETCHED  Fetched branch "master" from remote "origin".
...
```

Maniphest Tasks: T10650

Differential Revision: https://secure.phabricator.com/D20870
2019-10-28 11:31:18 -07:00
epriestley
a76054f8d6 Update "arc help land" to reference Perforce support
Summary: Fixes T12668. Ref T13434. This is far from exhasutive, but suggest that Perforce probably works.

Test Plan: Read documentation.

Maniphest Tasks: T13434, T12668

Differential Revision: https://secure.phabricator.com/D20869
2019-10-28 11:25:32 -07:00
epriestley
ca66743905 Support Perforce/Git repositories in "arc land"
Summary: Ref T13434. Detect perforce remotes and use "git p4" commands in place of "git" commands when operating in Perforce mode.

Test Plan:
  - Landed "master" onto itself, saw master update.
  - Landed "feature1" onto clean "master", saw master update.
  - Landed "feature2" onto dirty "master", saw master stay dirty.
  - Landed with "--hold", got sensible submit instructions.

Maniphest Tasks: T13434

Differential Revision: https://secure.phabricator.com/D20868
2019-10-28 11:25:00 -07:00
epriestley
9c7bbb760a Move Git-specific "arc land" parsing of "--onto" and "--remote" into GitLandEngine
Summary: Ref T13434. Move some git-engine-specific handling of "arc land" arguments into the Git engine. This prepares to handle Perforce workflows.

Test Plan: Will "arc land" this change.

Maniphest Tasks: T13434

Differential Revision: https://secure.phabricator.com/D20867
2019-10-28 11:24:34 -07:00
epriestley
da6d4f85ee Add a lint check for deprecated argument order to "implode()"
Summary:
Ref T13428. Historically, "implode()" accepts arguments in either order. PHP 7.4+ warns about glue not being first.

Add a lint check when the second parameter is a static scalar, implying it is the glue parameter.

Test Plan: Ran unit tests. See next change.

Maniphest Tasks: T13428

Differential Revision: https://secure.phabricator.com/D20857
2019-10-17 09:09:08 -07:00
epriestley
3cdfe1fff8 When running "arc land" from a detached HEAD, don't try to delete the source ref
Summary:
Fixes T10321. Some reasonable but less-common workflows involve running `arc land` from a detached HEAD state.

When users do this, we currently try to delete the raw hash as though it were a branch during cleanup. Instead, detect if the thing we're thinking about deleting is a branch or not, and just leave it alone if it isn't.

Test Plan:
  - Ran `git checkout <some hash>`, then `arc land --revision <some revision>`.
  - Before, everything worked but cleanup tried to `git branch -D <some hash>`.
  - After, everything worked and cleanup skipped branch deletion.

Maniphest Tasks: T10321

Differential Revision: https://secure.phabricator.com/D20786
2019-09-05 05:31:00 -07:00
epriestley
d92fa96366 Fix two "msort()" vs "msortv()" issues in "arc land"
Summary: See <https://github.com/phacility/arcanist/pull/242>. Ref T13303. A little more fallout turned up in `arc`.

Test Plan: `grep msort(`

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13303

Differential Revision: https://secure.phabricator.com/D20605
2019-06-20 16:07:13 -07:00
epriestley
1ef9409817 Update "arcanist/" for "topological" API changes
Summary: Ref T13325.

Test Plan: Grepped for `topograph`.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13325

Differential Revision: https://secure.phabricator.com/D20598
2019-06-20 16:05:21 -07:00
Asher Baker
7329bc7c32 Fix arc land on odd/modern git-svn checkouts
Summary:
The current code assumes git-svn is always working from a remote called
`trunk`, but if the repository is initialized without the `-T` option it
will instead be called `git-svn`, and if `--prefix` is used (which is
set by default to `origin/` in Git 2+) the remote name will have the
specified prefix as well.

Instead, look at the `fetch` target refspec set in the git-svn config.

Fixes T13293.

Test Plan:
`arc land` without errors (or manually creating a `trunk` branch) from a
checkout made with Git 2.18.0 (verified this manually on a non-`-T`
checkout as well).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T13293

Differential Revision: https://secure.phabricator.com/D19681
2019-05-23 10:58:42 +01:00
Joshua Spence
dd514e268b Modify the lint-test file format to allow for more powerful assertions
Summary:
Fixes T6854. The current format for `lint-test` files is somewhat inflexible and does not allow us to make assertions regarding the code or name of the linter messages (of class `ArcanistLintMessage`) that are raised. Specifically, the `${severity}:${line}:${char}` format is hardcoded in `ArcanistLinterTestCase`. In this diff, I extend the this format to achieve the following goals:

- Allow for the lint message code and name to be specified. Specifically, the full format is `${severity}:${line}:${char}:${code}:${name}`.
- Make all fields optional. `error:3:` will match any and all errors occuring on line 3.
- Provide more useful output when assertions fail. Specifically, output //all// lint messages that are missing and/or surplus. Previously, only the first lint message was output.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley, chad

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6854

Differential Revision: https://secure.phabricator.com/D11176
2019-05-21 13:48:30 +10:00
Wenzheng Jiang
82445bb605 Let lint rules support anonymous classes
Summary: Ref T4334. Depends on D19740. Improve some lint rules so they can handle anonymous classes.

Test Plan: Ran updated tests

Reviewers: joshuaspence, #blessed_reviewers, epriestley

Reviewed By: joshuaspence, #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T4334

Differential Revision: https://secure.phabricator.com/D19741
2019-05-15 11:11:10 +10:00
Joshua Spence
6a8e76db32 Allow buildFutures and resolveFutures to be overridden
Summary:
I am writing a proxy linter that can be used to wrap any `ArcanistExternalLinter` and execute all commands within a Docker container (see [[https://github.com/freelancer/flarc/blob/master/src/lint/linter/ArcanistDockerContainerLinterProxy.php |`ArcanistDockerContainerLinterProxy`]] from [[https://github.com/freelancer/flarc | `flarc`]]). In order for `ArcanistDockerContainerLinterProxy` to behave like the `ArcanistExternalLinter` that is being proxied, `final` needs to be removed from some methods.

I figured this was reasonable to submit upstream as a similar change ({D19630}) was previously accepted.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D19730
2019-05-15 09:10:07 +10:00
Joshua Spence
fceac878f1 Allow setCustomSeverityRules to be overridden in subclasses
Summary:
I am writing a proxy linter that can be used to wrap any `ArcanistExternalLinter` and execute all commands within a Docker container (see [[https://github.com/freelancer/flarc/blob/master/src/lint/linter/ArcanistDockerContainerLinterProxy.php |`ArcanistDockerContainerLinterProxy`]] from [[https://github.com/freelancer/flarc | `flarc`]]). In order for `ArcanistDockerContainerLinterProxy` to behave like the `ArcanistExternalLinter` that is being proxied, `final` needs to be removed from some methods.

I figured this was reasonable to submit upstream as a similar change ({D19630}) was previously accepted.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D20514
2019-05-15 09:06:13 +10:00
Joshua Spence
4f583dded3 Call $linter->setEngine in linter tests
Summary: We aren't calling `$linter->setEngine($engine)`, even though we do have an `$engine`. This causes unit tests for any linters which require an engine to fail.

Test Plan: Ran the unit tests for a [[https://github.com/freelancer/flarc/blob/master/src/lint/linter/ArcanistDockerContainerLinterProxy.php | third-party linter]].

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D20515
2019-05-15 09:01:54 +10:00
epriestley
9ccbbee336 Fix a potential double-prompt in "arc land" when landing with ongoing builds
Summary: The recently-added, build-plan-behavior-aware check here does all of its own prompting, so we should skip the other prompting if it doesn't throw.

Test Plan: Will `arc land` something sketchy sooner or later.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20494
2019-05-14 09:27:53 -07:00