Exemplo n.º 1
0
def verify_user(ui, repo, revs):
    """
    Checks that the revisions we are attempting to squash belong to the user performing the
    operation

    Args:
        ui - the ui object
        repo - the current repository
        revs - the set of revisions to squash
    """
    for r in revs:
        if repo[r].user() != ui.username():
            raise util.Abort(_("Revision %s does not belong to %s\n") % (r, ui.username()))
Exemplo n.º 2
0
def squash(ui, repo, **opts):
    """Simple extension that squashes multiple revisions into a single one"""

    revrange = scmutil.revrange(repo, opts["rev"])
    if not revrange:
        raise util.Abort(_("Please specify a revision"))

    start = revrange[0]
    end = revrange[-1]

    revs = find_revisions(start, end, repo)

    if not revs:
        raise util.Abort(_("The revision %s is not an ancestor of %s\n") % (start, end))
    elif len(revs) == 1:
        raise util.Abort(_("Please specify a start and an end revision"))

    verify_user(ui, repo, revs)

    no_children(ui, repo, end)

    has_parent(ui, repo, start)

    verify_pending_commits(repo)

    squash_revisions(ui, repo, revs, start, end)

    for r in revs:
        ui.status("rev: %s, owner: %s\n" % (repo[r], ui.username()))