]> khamidou — GitHub mirrors - arcanist.git/commit
Refactor getWorkingCopyStatus() into getUncommittedStatus() and getCommitRangeStatus()
authorepriestley <git@epriestley.com>
Mon, 17 Dec 2012 20:53:28 +0000 (12:53 -0800)
committerepriestley <git@epriestley.com>
Mon, 17 Dec 2012 20:53:28 +0000 (12:53 -0800)
commit0e27dbfd17a4587daf8645170eab6b7a83a28336
treeb935f7c728424d4e77e2c17e40f9f1a16af52080
parent5f5392df8a40dc0e2294db94ad5fd9853d278123
Refactor getWorkingCopyStatus() into getUncommittedStatus() and getCommitRangeStatus()

Summary:
See discussion in D4049.

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

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

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

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

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

Reviewers: vrana

Reviewed By: vrana

CC: aran
Differential Revision: https://secure.phabricator.com/D4095
src/__phutil_library_map__.php
src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php
src/repository/api/ArcanistRepositoryAPI.php
src/repository/api/ArcanistSubversionAPI.php
src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php [new file with mode: 0644]
src/repository/api/__tests__/state/git_basic.git.tgz [new file with mode: 0644]
src/repository/api/__tests__/state/hg_basic.hg.tgz [new file with mode: 0644]
src/repository/api/__tests__/state/svn_basic.svn.tgz [new file with mode: 0644]