##// END OF EJS Templates
phase: add an archived phase...
phase: add an archived phase This phase allows for hidden changesets in the "user space". It differs from the "internal" phase which is intended for internal by-product only. There have been discussions at the 4.8 sprint to use such phase to speedup cleanup after history rewriting operation. Shipping it in the same release as the 'internal-phase' groups the associated `requires` entry. The important bit is to have support for this phase in the earliest version of mercurial possible. Adding the UI to manipulate this new phase later seems fine. The current plan for archived usage and user interface are as follow. On a repository with internal-phase on and evolution off: * history rewriting command set rewritten changeset in the archived phase. (This mean updating the cleanupnodes method). * keep `hg unbundle .hg/strip-backup/X.hg` as a way to restore changeset for now (backup bundle need to contains phase data) * [maybe] add a `hg strip --soft` advance flag (a light way to expose the feature without getting in the way of a better UI) Mercurial 4.8 freeze is too close to get the above in by then. We don't introduce a new repository `requirement` as we reuse the one introduced with the 'archived' phase during the 4.8 cycle.

File last commit:

r40329:c303d65d default
r40463:49c7b701 stable
Show More
closehead.py
84 lines | 2.6 KiB | text/x-python | PythonLexer
# closehead.py - Close arbitrary heads without checking them out first
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
'''close arbitrary heads without checking them out first'''
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial import (
bookmarks,
cmdutil,
context,
error,
pycompat,
registrar,
scmutil,
)
cmdtable = {}
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
testedwith = 'ships-with-hg-core'
commitopts = cmdutil.commitopts
commitopts2 = cmdutil.commitopts2
commitopts3 = [('r', 'rev', [],
_('revision to check'), _('REV'))]
@command('close-head|close-heads', commitopts + commitopts2 + commitopts3,
_('[OPTION]... [REV]...'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
inferrepo=True)
def close_branch(ui, repo, *revs, **opts):
"""close the given head revisions
This is equivalent to checking out each revision in a clean tree and running
``hg commit --close-branch``, except that it doesn't change the working
directory.
The commit message must be specified with -l or -m.
"""
def docommit(rev):
cctx = context.memctx(repo, parents=[rev, None], text=message,
files=[], filectxfn=None, user=opts.get('user'),
date=opts.get('date'), extra=extra)
tr = repo.transaction('commit')
ret = repo.commitctx(cctx, True)
bookmarks.update(repo, [rev, None], ret)
cctx.markcommitted(ret)
tr.close()
opts = pycompat.byteskwargs(opts)
revs += tuple(opts.get('rev', []))
revs = scmutil.revrange(repo, revs)
if not revs:
raise error.Abort(_('no revisions specified'))
heads = []
for branch in repo.branchmap():
heads.extend(repo.branchheads(branch))
heads = set(repo[h].rev() for h in heads)
for rev in revs:
if rev not in heads:
raise error.Abort(_('revision is not an open head: %d') % rev)
message = cmdutil.logmessage(ui, opts)
if not message:
raise error.Abort(_("no commit message specified with -l or -m"))
extra = { 'close': '1' }
with repo.wlock(), repo.lock():
for rev in revs:
r = repo[rev]
branch = r.branch()
extra['branch'] = branch
docommit(r)
return 0