Exemplo n.º 1
0
Arquivo: split.py Projeto: jsoref/eden
 def commitextra(extra):
     if shouldrecordmutation[0]:
         mutation.record(
             repo,
             extra,
             [ctx.node()],
             "split",
             splitting=[c.node() for c in newcommits],
         )
Exemplo n.º 2
0
def metarewrite(repo, old, newbases, commitopts, copypreds=None):
    """Return (nodeid, created) where nodeid is the identifier of the
    changeset generated by the rewrite process, and created is True if
    nodeid was actually created. If created is False, nodeid
    references a changeset existing before the rewrite call.
    """
    wlock = lock = tr = None
    try:
        wlock = repo.wlock()
        lock = repo.lock()
        tr = repo.transaction("rewrite")
        updatebookmarks = bookmarksupdater(repo, old.node())

        message = cmdutil.logmessage(repo, commitopts)
        if not message:
            message = old.description()

        user = commitopts.get("user") or old.user()
        date = commitopts.get("date") or None  # old.date()
        extra = dict(commitopts.get("extra", old.extra()))
        extra["branch"] = old.branch()
        preds = [old.node()]
        mutop = "metaedit"
        if copypreds:
            preds.extend(copypreds)
            mutop = "metaedit-copy"
        mutation.record(repo, extra, preds, mutop)
        loginfo = {"predecessors": old.hex(), "mutation": mutop}

        new = context.metadataonlyctx(
            repo,
            old,
            parents=newbases,
            text=message,
            user=user,
            date=date,
            extra=extra,
            loginfo=loginfo,
        )

        if commitopts.get("edit"):
            new._text = cmdutil.commitforceeditor(repo, new, [])
        revcount = len(repo)
        newid = repo.commitctx(new)
        new = repo[newid]
        created = len(repo) != revcount
        updatebookmarks(newid)

        tr.close()
        return newid, created
    finally:
        lockmod.release(tr, lock, wlock)
Exemplo n.º 3
0
def mirrorwithmetadata(ctx, op):
    extra = ctx.extra().copy()
    extra[op + "_source"] = ctx.hex()
    mutinfo = mutation.record(ctx.repo(), extra, [ctx.node()], op)
    loginfo = {"predecessors": ctx.hex(), "mutation": op}
    return context.memctx.mirror(ctx,
                                 mutinfo=mutinfo,
                                 loginfo=loginfo,
                                 extra=extra)
Exemplo n.º 4
0
    def _pushsingleunchecked(ctx, commit, getcommitdatefn=None):
        """Return newly pushed node"""
        repo = ctx.repo()

        def getfilectx(repo, memctx, path):
            assert path in commit.filechanges
            entry = commit.filechanges[path]
            if entry is None:
                # deleted
                return None
            else:
                # changed or created
                mode, content, copysource = entry
                return context.memfilectx(
                    repo,
                    memctx,
                    path,
                    content,
                    islink=("l" in mode),
                    isexec=("x" in mode),
                    copied=copysource,
                )

        extra = commit.extra.copy()
        date = commit.date
        loginfo = {}

        orignode = commit.orignode
        if orignode:
            mutation.record(repo, extra, [orignode], "pushrebase")
            loginfo = {"predecessors": hex(orignode), "mutation": "pushrebase"}
            date = getcommitdatefn(repo.ui, hex(orignode), commit.date)

        return context.memctx(
            repo,
            [ctx.node(), nullid],
            commit.desc,
            sorted(commit.filechanges),
            getfilectx,
            commit.user,
            date,
            extra,
            loginfo=loginfo,
        ).commit()
Exemplo n.º 5
0
    def _commitsingle(self, memworkingcopy, ctx, p1=None):
        """(ctx, {path: content}, node) -> node. make a single commit

        the commit is a clone from ctx, with a (optionally) different p1, and
        different file contents replaced by memworkingcopy.
        """
        parents = p1 and (p1, node.nullid)
        extra = ctx.extra()
        mutation.record(self.repo, extra, [ctx.node()], "absorb")
        loginfo = {"checkoutidentifier": self.checkoutidentifier}
        mctx = overlaycontext(memworkingcopy,
                              ctx,
                              parents,
                              extra=extra,
                              loginfo=loginfo)
        # preserve phase
        with mctx.repo().ui.configoverride({
            ("phases", "new-commit"):
                ctx.phase()
        }):
            return mctx.commit()
Exemplo n.º 6
0
def rewrite(repo, old, updates, head, newbases, commitopts, mutop=None):
    """Return (nodeid, created) where nodeid is the identifier of the
    changeset generated by the rewrite process, and created is True if
    nodeid was actually created. If created is False, nodeid
    references a changeset existing before the rewrite call.
    """
    wlock = lock = tr = None
    try:
        wlock = repo.wlock()
        lock = repo.lock()
        tr = repo.transaction("rewrite")
        if len(old.parents()) > 1:  # XXX remove this unnecessary limitation.
            raise error.Abort(_("cannot amend merge changesets"))
        base = old.p1()
        updatebookmarks = bookmarksupdater(repo, [old.node()] +
                                           [u.node() for u in updates])

        # commit a new version of the old changeset, including the update
        # collect all files which might be affected
        files = set(old.files())
        for u in updates:
            files.update(u.files())

        # Recompute copies (avoid recording a -> b -> a)
        copied = copies.pathcopies(base, head)

        # prune files which were reverted by the updates
        def samefile(f):
            if f in head.manifest():
                a = head.filectx(f)
                if f in base.manifest():
                    b = base.filectx(f)
                    return a.data() == b.data() and a.flags() == b.flags()
                else:
                    return False
            else:
                return f not in base.manifest()

        files = [f for f in files if not samefile(f)]
        # commit version of these files as defined by head
        headmf = head.manifest()

        def filectxfn(repo, ctx, path):
            if path in headmf:
                fctx = head[path]
                flags = fctx.flags()
                mctx = context.memfilectx(
                    repo,
                    ctx,
                    fctx.path(),
                    fctx.data(),
                    islink="l" in flags,
                    isexec="x" in flags,
                    copied=copied.get(path),
                )
                return mctx
            return None

        message = cmdutil.logmessage(repo, commitopts)
        if not message:
            message = old.description()

        user = commitopts.get("user") or old.user()
        # TODO: In case not date is given, we should take the old commit date
        # if we are working one one changeset or mimic the fold behavior about
        # date
        date = commitopts.get("date") or None
        extra = dict(commitopts.get("extra", old.extra()))
        extra["branch"] = head.branch()
        mutation.record(repo, extra, [c.node() for c in updates], mutop)
        loginfo = {
            "predecessors": " ".join(c.hex() for c in updates),
            "mutation": mutop,
        }

        new = context.memctx(
            repo,
            parents=newbases,
            text=message,
            files=files,
            filectxfn=filectxfn,
            user=user,
            date=date,
            extra=extra,
            loginfo=loginfo,
        )

        if commitopts.get("edit"):
            new._text = cmdutil.commitforceeditor(repo, new, [])
        revcount = len(repo)
        newid = repo.commitctx(new)
        new = repo[newid]
        created = len(repo) != revcount
        updatebookmarks(newid)

        tr.close()
        return newid, created
    finally:
        lockmod.release(tr, lock, wlock)