Example #1
0
    important('Note: Not checking uncommitted changes. Make sure you commit the right files!');
} else {
    if (has_uncommited_changes('.')) {
        error("Working copy has uncommited changes. Revert or commit them before merging a branch.");
    }
}
// Proceed to update
if ($ignore_externals) {
    important('Note: Updating but ignoring external libraries - only use this if you are sure this working copy is up to date.');
} else {
    info("Updating...");
}
update_working_copy('.', $ignore_externals);
$revision = (int) get_info($source)->entry->commit['revision'];
// Do merge
info("Merging...");
$last = find_last_merge('.', $source);
if (!$last) {
    error("Could not find previous merge. Impossible to merge automatically.");
}
merge('.', $source, $last, $revision);
important("After verifications, commit using `svn ci -F svn-commit.tmp`");
$conflicts = get_conflicts('.');
if ($conflicts->length > 0) {
    $message = "Conflicts occurred during the merge. Fix the conflicts and start again.";
    foreach ($conflicts as $path) {
        $path = $path->parentNode->getAttribute('path');
        $message .= "\n\t{$path}";
    }
    error($message);
}
Example #2
0
}
$source = full($_SERVER['argv'][1]);
if (!is_experimental($source)) {
    error("The provided source cannot be used to update this working copy. Only experimental branches can be used.");
}
if (has_uncommited_changes('.')) {
    error("Working copy has uncommited changes. Revert or commit them before merging a branch.");
}
$revision = (int) get_info($destination)->entry->commit['revision'];
$last = find_last_merge($source, $destination);
$sDest = short($destination);
$sSource = short($source);
if ($last !== $revision) {
    error("You must branchupdate {$sSource} from {$sDest} before merging.");
}
// Proceed to update
info("Updating...");
update_working_copy('.');
// Do merge
info("Merging...");
incorporate($destination, $source);
important("After verifications, commit using a meaningful message for this feature.");
$conflicts = get_conflicts('.');
if ($conflicts->length > 0) {
    $message = "Conflicts occurred during the merge. Fix the conflicts and start again.";
    foreach ($conflicts as $path) {
        $path = $path->parentNode->getAttribute('path');
        $message .= "\n\t{$path}";
    }
    error($message);
}
Example #3
0
/**
 * @param $msg
 * @param bool $increment_step
 * @param bool $commit_msg
 * @return bool
 */
function important_step($msg, $increment_step = true, $commit_msg = false)
{
    global $options;
    static $step = 0;
    // Auto-Skip the step if this is a commit step and if there is nothing to commit
    if ($commit_msg && !has_uncommited_changes('.')) {
        return false;
    }
    // Increment step number if needed
    if ($increment_step) {
        $step++;
    }
    if ($commit_msg && $options['no-commit']) {
        print "Skipping actual commit ('{$commit_msg}') because no-commit = true\n";
        return;
    }
    $do_step = false;
    if ($options['force-yes']) {
        important("\n{$step}) {$msg}...");
        $do_step = true;
    } else {
        important("\n{$step}) {$msg}?");
        $prompt = '[Y/n/q/?] ';
        if (function_exists('readline')) {
            // readline function requires php readline extension...
            $c = readline($prompt);
        } else {
            echo $prompt;
            $c = rtrim(fgets(STDIN), "\n");
        }
        switch (strtolower($c)) {
            case 'y':
            case '':
                $do_step = true;
                break;
            case 'n':
                info(">> Skipping step {$step}.");
                $do_step = false;
                break;
            case 'q':
                die;
                break;
            default:
                if ($c != '?') {
                    info(color(">> Unknown answer '{$c}'.", 'red'));
                }
                info(">> You have to type 'y' (Yes), 'n' (No) or 'q' (Quit) and press Enter.");
                return important_step($msg, false);
        }
    }
    if ($commit_msg && $do_step && ($revision = commit($commit_msg))) {
        info(">> Commited revision {$revision}.");
    }
    return $do_step;
}