Changeset View
Changeset View
Standalone View
Standalone View
src/land/engine/ArcanistMercurialLandEngine.php
Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | foreach ($onto_refs as $onto_ref) { | ||||
$new_bookmark = id(new ArcanistMarkerRef()) | $new_bookmark = id(new ArcanistMarkerRef()) | ||||
->setMarkerType(ArcanistMarkerRef::TYPE_BOOKMARK) | ->setMarkerType(ArcanistMarkerRef::TYPE_BOOKMARK) | ||||
->setName($onto_ref) | ->setName($onto_ref) | ||||
->attachRemoteRef($remote_ref); | ->attachRemoteRef($remote_ref); | ||||
$onto_markers[] = $new_bookmark; | $onto_markers[] = $new_bookmark; | ||||
$new_markers[] = $new_bookmark; | $new_markers[] = $new_bookmark; | ||||
} else { | } else { | ||||
$onto_markers[] = $marker; | $onto_markers[] = head($matches); | ||||
} | } | ||||
} | } | ||||
$branches = array(); | $branches = array(); | ||||
foreach ($onto_markers as $onto_marker) { | foreach ($onto_markers as $onto_marker) { | ||||
if ($onto_marker->isBranch()) { | if ($onto_marker->isBranch()) { | ||||
$branches[] = $onto_marker; | $branches[] = $onto_marker; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | if ($bookmarks && $branches) { | ||||
'desired merge target.', | 'desired merge target.', | ||||
$target->getRemote(), | $target->getRemote(), | ||||
$target->getRef())); | $target->getRef())); | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht('Merge target is ambiguous.')); | pht('Merge target is ambiguous.')); | ||||
} | } | ||||
$is_bookmark = false; | |||||
$is_branch = false; | |||||
if ($bookmarks) { | if ($bookmarks) { | ||||
if (count($bookmarks) > 1) { | if (count($bookmarks) > 1) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Remote "%s" has multiple bookmarks with name "%s". This '. | 'Remote "%s" has multiple bookmarks with name "%s". This '. | ||||
'is unexpected.', | 'is unexpected.', | ||||
$target->getRemote(), | $target->getRemote(), | ||||
$target->getRef())); | $target->getRef())); | ||||
Show All 20 Lines | if ($branches) { | ||||
'Remote branch has multiple heads.')); | 'Remote branch has multiple heads.')); | ||||
} | } | ||||
$branch = head($branches); | $branch = head($branches); | ||||
$target_marker = $branch; | $target_marker = $branch; | ||||
} | } | ||||
if ($is_branch) { | if ($target_marker->isBranch()) { | ||||
$err = $this->newPassthru( | $err = $this->newPassthru( | ||||
'pull --branch %s -- %s', | 'pull --branch %s -- %s', | ||||
$target->getRef(), | $target->getRef(), | ||||
$target->getRemote()); | $target->getRemote()); | ||||
} else { | } else { | ||||
// NOTE: This may have side effects: | // NOTE: This may have side effects: | ||||
// | // | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | protected function executeMerge(ArcanistLandCommitSet $set, $into_commit) { | ||||
// If we're landing "--onto" a branch, set that as the branch marker | // If we're landing "--onto" a branch, set that as the branch marker | ||||
// before creating the new commit. | // before creating the new commit. | ||||
// TODO: We could skip this if we know that the "$into_commit" already | // TODO: We could skip this if we know that the "$into_commit" already | ||||
// has the right branch, which it will if we created it. | // has the right branch, which it will if we created it. | ||||
$branch_marker = $this->ontoBranchMarker; | $branch_marker = $this->ontoBranchMarker; | ||||
if ($branch_marker) { | if ($branch_marker) { | ||||
$api->execxLocal('branch -- %s', $branch_marker); | $api->execxLocal('branch -- %s', $branch_marker->getName()); | ||||
} | } | ||||
try { | try { | ||||
$argv = array(); | $argv = array(); | ||||
$argv[] = '--dest'; | $argv[] = '--dest'; | ||||
$argv[] = hgsprintf('%s', $into_commit); | $argv[] = hgsprintf('%s', $into_commit); | ||||
$argv[] = '--rev'; | $argv[] = '--rev'; | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | protected function pruneBranches(array $sets) { | ||||
$api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
$log = $this->getLogEngine(); | $log = $this->getLogEngine(); | ||||
// This has no effect when we're executing a merge strategy. | // This has no effect when we're executing a merge strategy. | ||||
if (!$this->isSquashStrategy()) { | if (!$this->isSquashStrategy()) { | ||||
return; | return; | ||||
} | } | ||||
$strip = array(); | $revs = array(); | ||||
// We've rebased all descendants already, so we can safely delete all | // We've rebased all descendants already, so we can safely delete all | ||||
// of these commits. | // of these commits. | ||||
$sets = array_reverse($sets); | $sets = array_reverse($sets); | ||||
foreach ($sets as $set) { | foreach ($sets as $set) { | ||||
$commits = $set->getCommits(); | $commits = $set->getCommits(); | ||||
$min_commit = head($commits)->getHash(); | $min_commit = head($commits)->getHash(); | ||||
$max_commit = last($commits)->getHash(); | $max_commit = last($commits)->getHash(); | ||||
$strip[] = hgsprintf('%s::%s', $min_commit, $max_commit); | $revs[] = hgsprintf('%s::%s', $min_commit, $max_commit); | ||||
} | } | ||||
$rev_set = '('.implode(') or (', $strip).')'; | $rev_set = '('.implode(') or (', $revs).')'; | ||||
// See PHI45. If we have "hg evolve", get rid of old commits using | // See PHI45. If we have "hg evolve", get rid of old commits using | ||||
// "hg prune" instead of "hg strip". | // "hg prune" instead of "hg strip". | ||||
// If we "hg strip" a commit which has an obsolete predecessor, it | // If we "hg strip" a commit which has an obsolete predecessor, it | ||||
// removes the obsolescence marker and revives the predecessor. This is | // removes the obsolescence marker and revives the predecessor. This is | ||||
// not desirable: we want to destroy all predecessors of these commits. | // not desirable: we want to destroy all predecessors of these commits. | ||||
try { | if ($api->getMercurialFeature('evolve')) { | ||||
$api->execxLocal( | $api->execxLocal( | ||||
'--config extensions.evolve= prune --rev %s', | 'prune --rev %s', | ||||
$rev_set); | $rev_set); | ||||
} catch (CommandException $ex) { | } else { | ||||
$api->execxLocal( | $api->execxLocal( | ||||
'--config extensions.strip= strip --rev %s', | '--config extensions.strip= strip --rev %s', | ||||
$rev_set); | $rev_set); | ||||
} | } | ||||
} | } | ||||
protected function reconcileLocalState( | protected function reconcileLocalState( | ||||
$into_commit, | $into_commit, | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |