##// END OF EJS Templates
shelve: stop passing list of files to revert...
shelve: stop passing list of files to revert It seems to work just fine to not specify any files here. I suspect it looked the way it did for historical reasons. It apparently used to use merge instead of rebase until 1d7a36ff2615 (shelve: use rebase instead of merge (issue4068), 2013-10-23) and it makes sense to want to restrict the set of files then. I noticed this because of the files.extend(shelvectx.p1().files()). If the working copy was clean before, then shelvectx.p1() will be the working copy parent and that ended up adding all the files in that set. In our Google-internal Mercurial setup (including a FUSE) that was very noticeably slow when the working copy parent happened to have many files in large directories. This patch doesn't yet remove the call to shelvectx.p1().files(). We also use that set for deciding what to back up. I'm pretty sure it's safe to back up only the set of files we already back even if we no longer restrict the set of files to revert, so this patch should be safe on its own. Regardless, the next patch will delegate the backing-up to cmdutil.revert(). Incidentally, this also gets rid of a repo.pathto() that I had earlier wanted to get rid of. Differential Revision: https://phab.mercurial-scm.org/D6173

File last commit:

r40329:c303d65d default
r42204:46065855 default
Show More
closehead.py
84 lines | 2.6 KiB | text/x-python | PythonLexer
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029 # 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
Joerg Sonnenberger
closehead: fix close-head -r listification...
r40132 commitopts3 = [('r', 'rev', [],
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029 _('revision to check'), _('REV'))]
@command('close-head|close-heads', commitopts + commitopts2 + commitopts3,
rdamazio@google.com
help: assigning categories to existing commands...
r40329 _('[OPTION]... [REV]...'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
inferrepo=True)
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029 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:
Pulkit Goyal
py3: use '%d' for rev nums instead of '%s'...
r40264 raise error.Abort(_('revision is not an open head: %d') % rev)
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029
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