##// END OF EJS Templates
fsmonitor: refresh pywatchman with upstream...
fsmonitor: refresh pywatchman with upstream This commit vendors pywatchman commit 259dc66dc9591f9b7ce76d0275bb1065f390c9b1 from upstream without modifications. The previously vendored pywatchman from changeset 16f4b341288d was from Git commit c77452. This commit effectively undoes the following Mercurial changesets: * dd35abc409ee fsmonitor: correct an error message * b1f62cd39b5c fsmonitor: layer on another hack in bser.c for os.stat() compat (issue5811) * c31ce080eb75 py3: convert arguments, cwd and env to native strings when spawning subprocess * 876494fd967d cleanup: delete lots of unused local variables * 57264906a996 watchman: add the possibility to set the exact watchman binary location The newly-vendored code has support for specifying the binary location, so 57264906a996 does not need applied. But we do need to modify our code to specify a proper argument name. 876494fd967d is not important, so it will be ignored. c31ce080eb75 globally changed the code base to always pass str to subprocess. But pywatchman's code is Python 3 clean, so we don't need to do this. This leaves dd35abc409ee and b1f62cd39b5c, which will be re-applied in subsequent commits. Differential Revision: https://phab.mercurial-scm.org/D7201

File last commit:

r43347:687b865b default
r43703:6469c23a stable
Show More
closehead.py
95 lines | 2.7 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.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 testedwith = b'ships-with-hg-core'
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029
commitopts = cmdutil.commitopts
commitopts2 = cmdutil.commitopts2
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 commitopts3 = [(b'r', b'rev', [], _(b'revision to check'), _(b'REV'))]
Augie Fackler
formatting: blacken the codebase...
r43346
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029
Augie Fackler
formatting: blacken the codebase...
r43346 @command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'close-head|close-heads',
Augie Fackler
formatting: blacken the codebase...
r43346 commitopts + commitopts2 + commitopts3,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'[OPTION]... [REV]...'),
rdamazio@google.com
help: assigning categories to existing commands...
r40329 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
Augie Fackler
formatting: blacken the codebase...
r43346 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.
"""
Augie Fackler
formatting: blacken the codebase...
r43346
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029 def docommit(rev):
Augie Fackler
formatting: blacken the codebase...
r43346 cctx = context.memctx(
repo,
parents=[rev, None],
text=message,
files=[],
filectxfn=None,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 user=opts.get(b'user'),
date=opts.get(b'date'),
Augie Fackler
formatting: blacken the codebase...
r43346 extra=extra,
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 tr = repo.transaction(b'commit')
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029 ret = repo.commitctx(cctx, True)
bookmarks.update(repo, [rev, None], ret)
cctx.markcommitted(ret)
tr.close()
opts = pycompat.byteskwargs(opts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revs += tuple(opts.get(b'rev', []))
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029 revs = scmutil.revrange(repo, revs)
if not revs:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no revisions specified'))
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029
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:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'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:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"no commit message specified with -l or -m"))
extra = {b'close': b'1'}
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029
with repo.wlock(), repo.lock():
for rev in revs:
r = repo[rev]
branch = r.branch()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extra[b'branch'] = branch
Joerg Sonnenberger
extensions: new closehead module for closing arbitrary heads...
r40029 docommit(r)
return 0