Пример #1
0
 def commitfunc(ui, repo, message, match, opts):
     editor_ = False
     if editor:
         editor_ = cmdutil.getcommiteditor(editform="shelve.shelve", **opts)
     return repo.commit(
         message, ui.username(), opts.get("date"), match, editor=editor_, extra=extra
     )
Пример #2
0
 def commitfunc(ui, repo, message, match, opts):
     hasmq = util.safehasattr(repo, "mq")
     if hasmq:
         saved, repo.mq.checkapplied = repo.mq.checkapplied, False
     try:
         editor_ = False
         if editor:
             editor_ = cmdutil.getcommiteditor(editform="shelve.shelve",
                                               **opts)
         return repo.commit(
             message,
             ui.username(),
             opts.get("date"),
             match,
             editor=editor_,
             extra=extra,
         )
     finally:
         if hasmq:
             repo.mq.checkapplied = saved
Пример #3
0
def _dosign(ui, repo, *revs, **opts):
    mygpg = newgpg(ui, **opts)
    sigver = "0"
    sigmessage = ""

    date = opts.get("date")
    if date:
        opts["date"] = util.parsedate(date)

    if revs:
        nodes = [repo.lookup(n) for n in revs]
    else:
        nodes = [
            node for node in repo.dirstate.parents() if node != hgnode.nullid
        ]
        if len(nodes) > 1:
            raise error.Abort(
                _("uncommitted merge - please provide a "
                  "specific revision"))
        if not nodes:
            nodes = [repo.changelog.tip()]

    for n in nodes:
        hexnode = hgnode.hex(n)
        ui.write(_("signing %s\n") % (hgnode.short(n)))
        # build data
        data = node2txt(repo, n, sigver)
        sig = mygpg.sign(data)
        if not sig:
            raise error.Abort(_("error while signing"))
        sig = binascii.b2a_base64(sig)
        sig = sig.replace("\n", "")
        sigmessage += "%s %s %s\n" % (hexnode, sigver, sig)

    # write it
    if opts["local"]:
        repo.localvfs.append("localsigs", sigmessage)
        return

    if not opts["force"]:
        msigs = match.exact(repo.root, "", [".hgsigs"])
        if any(repo.status(match=msigs, unknown=True, ignored=True)):
            raise error.Abort(
                _("working copy of .hgsigs is changed "),
                hint=_("please commit .hgsigs manually"),
            )

    sigsfile = repo.wvfs(".hgsigs", "ab")
    sigsfile.write(sigmessage)
    sigsfile.close()

    if ".hgsigs" not in repo.dirstate:
        with repo.lock(), repo.transaction("add-signatures"):
            repo[None].add([".hgsigs"])

    if opts["no_commit"]:
        return

    message = opts["message"]
    if not message:
        # we don't translate commit messages
        message = "\n".join([
            "Added signature for changeset %s" % hgnode.short(n) for n in nodes
        ])
    try:
        editor = cmdutil.getcommiteditor(editform="gpg.sign", **opts)
        repo.commit(message,
                    opts["user"],
                    opts["date"],
                    match=msigs,
                    editor=editor)
    except ValueError as inst:
        raise error.Abort(str(inst))