예제 #1
0
파일: shelve.py 프로젝트: simpkins/eden
def _commitworkingcopychanges(ui, repo, opts, tmpwctx):
    """Temporarily commit working copy changes before moving unshelve commit"""
    # Store pending changes in a commit and remember added in case a shelve
    # contains unknown files that are part of the pending change
    s = repo.status()
    addedbefore = frozenset(s.added)
    if not (s.modified or s.added or s.removed):
        return tmpwctx, addedbefore
    ui.status(
        _(
            "temporarily committing pending changes "
            "(restore with 'hg unshelve --abort')\n"
        )
    )
    commitfunc = getcommitfunc(extra=None, interactive=False, editor=False)
    tempopts = {}
    tempopts["message"] = "pending changes temporary commit"
    tempopts["date"] = opts.get("date")
    with ui.configoverride({("ui", "quiet"): True}):
        node = cmdutil.commit(ui, repo, commitfunc, [], tempopts)
    tmpwctx = repo[node]
    ui.debug(
        "temporary working copy commit: %s:%s\n" % (tmpwctx.rev(), nodemod.short(node))
    )
    return tmpwctx, addedbefore
예제 #2
0
파일: shelve.py 프로젝트: mitrandir77/eden
def _docreatecmd(ui, repo, pats, opts):
    wctx = repo[None]
    parents = wctx.parents()
    if len(parents) > 1:
        raise error.Abort(_("cannot shelve while merging"))
    parent = parents[0]
    origbranch = wctx.branch()

    if parent.node() != nodemod.nullid:
        desc = "shelve changes to: %s" % parent.description().split("\n", 1)[0]
    else:
        desc = "(changes in empty repository)"

    if not opts.get("message"):
        opts["message"] = desc

    activebookmark = None
    try:
        with repo.lock(), repo.transaction("commit", report=None):

            interactive = opts.get("interactive", False)
            includeunknown = opts.get(
                "unknown", False) and not opts.get("addremove", False)

            name = getshelvename(repo, parent, opts)
            activebookmark = _backupactivebookmark(repo)
            extra = {}
            if includeunknown:
                _includeunknownfiles(repo, pats, opts, extra)

            if _iswctxonnewbranch(repo) and not _isbareshelve(pats, opts):
                # In non-bare shelve we don't store newly created branch
                # at bundled commit
                repo.dirstate.setbranch(repo["."].branch())

            commitfunc = getcommitfunc(extra, interactive, editor=True)
            if not interactive:
                node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
            else:
                node = cmdutil.dorecord(ui, repo, commitfunc, None, False,
                                        cmdutil.recordfilter, *pats, **opts)
            if not node:
                _nothingtoshelvemessaging(ui, repo, pats, opts)
                return 1

            _hidenodes(repo, [node])
    except (KeyboardInterrupt, Exception):
        if activebookmark:
            bookmarks.activate(repo, activebookmark)
        raise

    _shelvecreatedcommit(ui, repo, node, name)

    if ui.formatted:
        desc = util.ellipsis(desc, ui.termwidth())
    ui.status(_("shelved as %s\n") % name)

    # current wc parent may be already obsolete because
    # it might have been created previously and shelve just
    # reuses it
    try:
        hg.update(repo, parent.node())
    except (KeyboardInterrupt, Exception):
        # failed to update to the original revision, which has left us on the
        # (hidden) shelve commit.  Move directly to the original commit by
        # updating the dirstate parents.
        repo.setparents(parent.node())
        raise
    finally:
        if origbranch != repo["."].branch() and not _isbareshelve(pats, opts):
            repo.dirstate.setbranch(origbranch)
        if activebookmark:
            bookmarks.activate(repo, activebookmark)