예제 #1
0
파일: __init__.py 프로젝트: hotsphink/mqext
def qrefresh_wrapper(self, repo, *pats, **opts):
    mqmessage = opts.pop('mqmessage', None)
    mqcommit, q, r = mqcommit_info(self, repo, opts)

    diffstat = ""
    if mqcommit and mqmessage:
        if mqmessage.find("%s") != -1:
            buffer = StringIO.StringIO()
            m = cmdutil.match(repo, None, {})
            diffopts = mdiff.diffopts()
            cmdutil.diffordiffstat(self, repo, diffopts,
                                   repo.dirstate.parents()[0], None, m,
                                   stat=True, fp = buffer)
            diffstat = buffer.getvalue()
            buffer.close()

    mq.refresh(self, repo, *pats, **opts)

    if mqcommit and len(q.applied) > 0:
        patch = q.applied[-1].name
        if r is None:
            raise util.Abort("no patch repository found when using -Q option")
        mqmessage = mqmessage.replace("%p", patch)
        mqmessage = mqmessage.replace("%a", 'UPDATE')
        mqmessage = mqmessage.replace("%s", diffstat)
        commands.commit(r.ui, r, message=mqmessage)
예제 #2
0
def update_patch(ui, repo, rev, bug, update_patch, rename_patch, interactive):
    q = repo.mq
    try:
        rev = q.lookup(rev)
    except util.error.Abort:
        # If the patch is not coming from mq, don't complain that the name is not found
        update_patch = False
        rename_patch = False

    todo = []
    if rename_patch:
        todo.append("name")
    if update_patch:
        todo.append("description")
    if todo:
        if interactive and ui.prompt("Update patch " + " and ".join(todo) +
                                     " (y/n)?") != 'y':
            ui.write(_("Exiting without updating patch\n"))
            return

    if rename_patch:
        newname = str("bug-%s-%s" % (bug, re.sub(r'^bug-\d+-', '', rev)))
        if newname != rev:
            try:
                mq.rename(ui, repo, rev, newname)
            except:
                # mq.rename has a tendency to leave things in an inconsistent
                # state. Fix things up.
                q.invalidate()
                if os.path.exists(
                        q.join(newname)) and newname not in q.fullseries:
                    os.rename(q.join(newname), q.join(rev))
                raise
            rev = newname

    if update_patch:
        # Add "Bug nnnn - " to the beginning of the description
        ph = mq.patchheader(q.join(rev), q.plainmode)
        msg = [s.decode('utf-8') for s in ph.message]
        if not msg:
            msg = ["Bug %s patch" % bug]
        elif not BUG_RE.search(msg[0]):
            msg[0] = "Bug %s - %s" % (bug, msg[0])
        opts = {
            'git': True,
            'message': '\n'.join(msg).encode('utf-8'),
            'include': ["re:."]
        }
        mq.refresh(ui, repo, **opts)

    return rev
예제 #3
0
def update_patch(ui, repo, rev, bug, update_patch, rename_patch, interactive):
    q = repo.mq
    try:
        rev = q.lookup(rev)
    except util.error.Abort:
        # If the patch is not coming from mq, don't complain that the name is not found
        update_patch = False
        rename_patch = False

    todo = []
    if rename_patch:
        todo.append("name")
    if update_patch:
        todo.append("description")
    if todo:
        if interactive and ui.prompt("Update patch " + " and ".join(todo) + " (y/n)?") != 'y':
            ui.write(_("Exiting without updating patch\n"))
            return

    if rename_patch:
        newname = str("bug-%s-%s" % (bug, re.sub(r'^bug-\d+-', '', rev)))
        if newname != rev:
            try:
                mq.rename(ui, repo, rev, newname)
            except:
                # mq.rename has a tendency to leave things in an inconsistent
                # state. Fix things up.
                q.invalidate()
                if os.path.exists(q.join(newname)) and newname not in q.fullseries:
                    os.rename(q.join(newname), q.join(rev))
                raise
            rev = newname

    if update_patch:
        # Add "Bug nnnn - " to the beginning of the description
        ph = mq.patchheader(q.join(rev), q.plainmode)
        msg = [s.decode('utf-8') for s in ph.message]
        if not msg:
            msg = ["Bug %s patch" % bug]
        elif not BUG_RE.search(msg[0]):
            msg[0] = "Bug %s - %s" % (bug, msg[0])
        opts = {'git': True, 'message': '\n'.join(msg).encode('utf-8'), 'include': ["re:."]}
        mq.refresh(ui, repo, **opts)

    return rev