##// END OF EJS Templates
phabricator: treat non-utf-8 text files as binary as phabricator requires...
phabricator: treat non-utf-8 text files as binary as phabricator requires Phabricator can't cope with text files that are not UTF-8, so requires them to be submitted as binary files instead. This has the unfortunate effect of making them practically unreviewable in Phabricator since it will only display the separate versions of the file in other views, not a diff. `phabread`ing such submissions are similar, since it will just output the binary patch, but `hg import` copes with it fine and `hg diff` afterwards will show the actual changes. It is still a marked improvement over trying to submit them as text, which just leads to corruption (Phabricator will either output ? or HTML entities for non-UTF-8 characters, depending on context). Running decode on the whole file like this seems slightly unfortunate, but I'm not aware of a better way. Needs to be done to p1() version as well to detect conversions to UTF-8. Differential Revision: https://phab.mercurial-scm.org/D7054

File last commit:

r43387:8ff1ecfa default
r43557:06a33a50 default
Show More
mq.py
4288 lines | 142.4 KiB | text/x-python | PythonLexer
Marti Raudsepp
mq: Cleanup: update outdated file header.
r6187 # mq.py - patch queues for mercurial
mason@suse.com
Add mq extension
r1808 #
Vadim Gelfer
update copyrights.
r2859 # Copyright 2005, 2006 Chris Mason <mason@suse.com>
mason@suse.com
Add mq extension
r1808 #
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
mason@suse.com
Add mq extension
r1808
Dirkjan Ochtman
extensions: fix up description lines some more
r8932 '''manage a stack of patches
Vadim Gelfer
help: add help to mq extension
r2554
This extension lets you work with a stack of patches in a Mercurial
Martin Geisler
Change double spaces to single spaces in help texts.
r7983 repository. It manages two stacks of patches - all known patches, and
Vadim Gelfer
help: add help to mq extension
r2554 applied patches (subset of known patches).
Known patches are represented as patch files in the .hg/patches
Martin Geisler
Change double spaces to single spaces in help texts.
r7983 directory. Applied patches are both patch files and changesets.
Vadim Gelfer
help: add help to mq extension
r2554
Yuya Nishihara
help: uppercase command placeholder...
r30879 Common tasks (use :hg:`help COMMAND` for more details)::
Vadim Gelfer
help: add help to mq extension
r2554
Martin Geisler
commands: use minirst parser when displaying help
r9157 create new patch qnew
import existing patch qimport
Vadim Gelfer
help: add help to mq extension
r2554
Martin Geisler
commands: use minirst parser when displaying help
r9157 print patch series qseries
print applied patches qapplied
Vadim Gelfer
help: add help to mq extension
r2554
Martin Geisler
commands: use minirst parser when displaying help
r9157 add known patch to applied stack qpush
remove patch from applied stack qpop
refresh contents of top applied patch qrefresh
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190
By default, mq will automatically use git patches when required to
avoid losing file mode changes, copy records, binary files or empty
timeless@mozdev.org
spelling: behaviour -> behavior
r26098 files creations or deletions. This behavior can be configured with::
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190
[mq]
git = auto/keep/yes/no
If set to 'keep', mq will obey the [diff] section configuration while
preserving existing git patches upon qrefresh. If set to 'yes' or
'no', mq will override the [diff] section and always generate git or
regular patches, possibly losing data in the second case.
Martin Geisler
mq: mention qqueue in module docstring
r11234
Matt Mackall
mq: fix secret description in help
r16040 It may be desirable for mq changesets to be kept in the secret phase (see
Matt Mackall
mq: add secret setting
r16017 :hg:`help phases`), which can be enabled with the following setting::
[mq]
secret = True
Martin Geisler
mq: mention qqueue in module docstring
r11234 You will by default be managing a patch queue named "patches". You can
create other, independent patch queues with the :hg:`qqueue` command.
Patrick Mezard
mq: introduce mq.check setting...
r16656
If the working directory contains uncommitted files, qpush, qpop and
qgoto abort immediately. If -f/--force is used, the changes are
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 discarded. Setting::
Patrick Mezard
mq: introduce mq.check setting...
r16656
[mq]
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 keepchanges = True
make them behave as if --keep-changes were passed, and non-conflicting
Patrick Mezard
mq: introduce mq.check setting...
r16656 local changes will be tolerated and preserved. If incompatible options
such as -f/--force or --exact are passed, this setting is ignored.
Pierre-Yves David
mq: extract strip function as its standalone extension (issue3824)...
r19826
This extension used to provide a strip command. This command now lives
in the strip extension.
Vadim Gelfer
help: add help to mq extension
r2554 '''
Yuya Nishihara
doctest: use print_function and convert bytes to unicode where needed
r34139 from __future__ import absolute_import, print_function
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127
import errno
import os
import re
import shutil
Matt Mackall
Simplify i18n imports
r3891 from mercurial.i18n import _
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 from mercurial.node import (
bin,
hex,
nullid,
nullrev,
short,
)
Gregory Szorc
py3: manually import getattr where it is needed...
r43359 from mercurial.pycompat import (
Gregory Szorc
py3: manually import pycompat.delattr where it is needed...
r43360 delattr,
Gregory Szorc
py3: manually import getattr where it is needed...
r43359 getattr,
open,
)
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 from mercurial import (
cmdutil,
commands,
Augie Fackler
mq: refer to dirstateguard by its new name
r30489 dirstateguard,
Augie Fackler
python3: wrap all uses of <exception>.strerror with strtolocal...
r34024 encoding,
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 error,
extensions,
hg,
localrepo,
lock as lockmod,
Yuya Nishihara
cmdutil: drop aliases for logcmdutil functions (API)...
r35906 logcmdutil,
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 patch as patchmod,
phases,
Pulkit Goyal
py3: use pycompat.getcwd() instead of os.getcwd()...
r30519 pycompat,
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 registrar,
Yuya Nishihara
revset: split language services to revsetlang module (API)...
r31024 revsetlang,
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 scmutil,
Yuya Nishihara
revset: import set classes directly from smartset module...
r31023 smartset,
Yuya Nishihara
subrepo: split non-core functions to new module...
r36026 subrepoutil,
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 util,
Pierre-Yves David
vfs: use 'vfs' module directly in 'hgext.mq'...
r31243 vfs as vfsmod,
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127 )
Yuya Nishihara
stringutil: bulk-replace call sites to point to new module...
r37102 from mercurial.utils import (
dateutil,
stringutil,
)
Pulkit Goyal
py3: make hgext/mq.py use absolute_import
r29127
release = lockmod.release
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 seriesopts = [(b's', b'summary', None, _(b'print first line of patch header'))]
Martin Geisler
mq: use cmdutil.command decorator
r14298
cmdtable = {}
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 command = registrar.command(cmdtable)
Augie Fackler
extensions: change magic "shipped with hg" string...
r29841 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
Augie Fackler
extensions: document that `testedwith = 'internal'` is special...
r25186 # 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'
Martin Geisler
mq: use cmdutil.command decorator
r14298
Boris Feld
configitems: register the 'mq.git' config
r34182 configtable = {}
configitem = registrar.configitem(configtable)
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'mq', b'git', default=b'auto',
Boris Feld
configitems: register the 'mq.git' config
r34182 )
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'mq', b'keepchanges', default=False,
Boris Feld
configitems: register the 'mq.keepchanges' config
r34183 )
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'mq', b'plain', default=False,
Boris Feld
configitems: register the 'mq.plain' config
r34184 )
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'mq', b'secret', default=False,
Boris Feld
configitems: register the 'mq.secret' config
r34185 )
Boris Feld
configitems: register the 'mq.git' config
r34182
Mads Kiilerich
spelling: random spell checker fixes
r19951 # force load strip extension formerly included in mq and import some utility
Pierre-Yves David
mq: prepare a strip extension for extraction...
r19822 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 stripext = extensions.find(b'strip')
Pierre-Yves David
mq: prepare a strip extension for extraction...
r19822 except KeyError:
# note: load is lazy so we could avoid the try-except,
Mads Kiilerich
spelling: random spell checker fixes
r19951 # but I (marmoute) prefer this explicit code.
Pierre-Yves David
mq: prepare a strip extension for extraction...
r19822 class dummyui(object):
def debug(self, msg):
pass
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
mq: implement log() on dummyui...
r41031 def log(self, event, msgfmt, *msgargs, **opts):
pass
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 stripext = extensions.load(dummyui(), b'strip', b'')
Pierre-Yves David
mq: prepare a strip extension for extraction...
r19822
Pierre-Yves David
strip: move the strip helper function for mq to strip...
r19825 strip = stripext.strip
Martin von Zweigbergk
strip: move checksubstate() to mq (its only caller)...
r42692
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
strip: move checksubstate() to mq (its only caller)...
r42692 def checksubstate(repo, baserev=None):
'''return list of subrepos at a different revision than substate.
Abort if any subrepos have uncommitted changes.'''
inclsubs = []
wctx = repo[None]
if baserev:
bctx = repo[baserev]
else:
bctx = wctx.p1()
for s in sorted(wctx.substate):
wctx.sub(s).bailifchanged(True)
if s not in bctx.substate or bctx.sub(s).dirty():
inclsubs.append(s)
return inclsubs
Pierre-Yves David
strip: move checksubstate from mq to strip...
r19823
Augie Fackler
formatting: blacken the codebase...
r43346
Patrick Mezard
Enforce unixish style for all generated patch names....
r4037 # Patch names looks like unix-file names.
# They must be joinable with queue directory and result in the patch path.
normname = util.normpath
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
use new style classes
r8778 class statusentry(object):
Benoit Boissinot
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
r10682 def __init__(self, node, name):
self.node, self.name = node, name
Augie Fackler
mq: fix up statusentry to be both repr()-able and bytes()-able...
r35860
def __bytes__(self):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return hex(self.node) + b':' + self.name
Brendan Cully
Use StatusEntry class instead of repeated status line parsing....
r2780
Augie Fackler
mq: fix up statusentry to be both repr()-able and bytes()-able...
r35860 __str__ = encoding.strmethod(__bytes__)
__repr__ = encoding.strmethod(__bytes__)
Augie Fackler
formatting: blacken the codebase...
r43346
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 # The order of the headers in 'hg export' HG patches:
HGHEADERS = [
Augie Fackler
formatting: blacken the codebase...
r43346 # '# HG changeset patch',
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'# User ',
b'# Date ',
b'# ',
b'# Branch ',
b'# Node ID ',
b'# Parent ', # can occur twice for merges - but that is not relevant for mq
Augie Fackler
formatting: blacken the codebase...
r43346 ]
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 # The order of headers in plain 'mail style' patches:
PLAINHEADERS = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'from': 0,
b'date': 1,
b'subject': 2,
Augie Fackler
formatting: blacken the codebase...
r43346 }
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546
def inserthgheader(lines, header, value):
"""Assuming lines contains a HG patch header, add a header line with value.
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> try: inserthgheader([], b'# Date ', b'z')
Yuya Nishihara
doctest: upgrade old-style "except" clause
r34140 ... except ValueError as inst: print("oops")
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 oops
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> inserthgheader([b'# HG changeset patch'], b'# Date ', b'z')
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 ['# HG changeset patch', '# Date z']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> inserthgheader([b'# HG changeset patch', b''], b'# Date ', b'z')
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 ['# HG changeset patch', '# Date z', '']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> inserthgheader([b'# HG changeset patch', b'# User y'], b'# Date ', b'z')
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 ['# HG changeset patch', '# User y', '# Date z']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> inserthgheader([b'# HG changeset patch', b'# Date x', b'# User y'],
... b'# User ', b'z')
Mads Kiilerich
mq: fix update of headers that occur in the "wrong" order...
r23412 ['# HG changeset patch', '# Date x', '# User z']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> inserthgheader([b'# HG changeset patch', b'# Date y'], b'# Date ', b'z')
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 ['# HG changeset patch', '# Date z']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> inserthgheader([b'# HG changeset patch', b'', b'# Date y'],
... b'# Date ', b'z')
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 ['# HG changeset patch', '# Date z', '', '# Date y']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> inserthgheader([b'# HG changeset patch', b'# Parent y'],
... b'# Date ', b'z')
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 ['# HG changeset patch', '# Date z', '# Parent y']
"""
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 start = lines.index(b'# HG changeset patch') + 1
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 newindex = HGHEADERS.index(header)
Mads Kiilerich
mq: fix update of headers that occur in the "wrong" order...
r23412 bestpos = len(lines)
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 for i in range(start, len(lines)):
line = lines[i]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not line.startswith(b'# '):
Mads Kiilerich
mq: fix update of headers that occur in the "wrong" order...
r23412 bestpos = min(bestpos, i)
break
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 for lineindex, h in enumerate(HGHEADERS):
if line.startswith(h):
if lineindex == newindex:
lines[i] = header + value
Mads Kiilerich
mq: fix update of headers that occur in the "wrong" order...
r23412 return lines
if lineindex > newindex:
bestpos = min(bestpos, i)
Augie Fackler
formatting: blacken the codebase...
r43346 break # next line
Mads Kiilerich
mq: fix update of headers that occur in the "wrong" order...
r23412 lines.insert(bestpos, header + value)
Mads Kiilerich
mq: refactor patchheader header ordering to match export (BC)...
r22546 return lines
Augie Fackler
formatting: blacken the codebase...
r43346
Mads Kiilerich
mq: introduce insertplainheader - same naive implementation as before
r23345 def insertplainheader(lines, header, value):
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 """For lines containing a plain patch header, add a header line with value.
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> insertplainheader([], b'Date', b'z')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 ['Date: z']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> insertplainheader([b''], b'Date', b'z')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 ['Date: z', '']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> insertplainheader([b'x'], b'Date', b'z')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 ['Date: z', '', 'x']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> insertplainheader([b'From: y', b'x'], b'Date', b'z')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 ['From: y', 'Date: z', '', 'x']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> insertplainheader([b' date : x', b' from : y', b''], b'From', b'z')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 [' date : x', 'From: z', '']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> insertplainheader([b'', b'Date: y'], b'Date', b'z')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 ['Date: z', '', 'Date: y']
Yuya Nishihara
doctest: bulk-replace string literals with b'' for Python 3...
r34133 >>> insertplainheader([b'foo: bar', b'DATE: z', b'x'], b'From', b'y')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 ['From: y', 'foo: bar', 'DATE: z', '', 'x']
"""
newprio = PLAINHEADERS[header.lower()]
bestpos = len(lines)
for i, line in enumerate(lines):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b':' in line:
lheader = line.split(b':', 1)[0].strip().lower()
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 lprio = PLAINHEADERS.get(lheader, newprio + 1)
if lprio == newprio:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lines[i] = b'%s: %s' % (header, value)
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 return lines
if lprio > newprio and i < bestpos:
bestpos = i
else:
if line:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lines.insert(i, b'')
Mads Kiilerich
mq: smarter handling of plain headers...
r23442 if i < bestpos:
bestpos = i
break
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lines.insert(bestpos, b'%s: %s' % (header, value))
Mads Kiilerich
mq: introduce insertplainheader - same naive implementation as before
r23345 return lines
Augie Fackler
formatting: blacken the codebase...
r43346
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 class patchheader(object):
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 def __init__(self, pf, plainmode=False):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 def eatdiff(lines):
while lines:
l = lines[-1]
Augie Fackler
formatting: blacken the codebase...
r43346 if (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 l.startswith(b"diff -")
or l.startswith(b"Index:")
or l.startswith(b"===========")
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 del lines[-1]
else:
break
Augie Fackler
formatting: blacken the codebase...
r43346
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 def eatempty(lines):
while lines:
Benoit Boissinot
mq: don't use regexp when not necessary
r10688 if not lines[-1].strip():
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 del lines[-1]
else:
break
message = []
comments = []
user = None
date = None
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 parent = None
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 format = None
subject = None
Steve Borho
mq: record more data in patchheader class (no behavior changes)...
r13229 branch = None
nodeid = None
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 diffstart = 0
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 for line in open(pf, b'rb'):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 line = line.rstrip()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if line.startswith(b'diff --git') or (
diffstart and line.startswith(b'+++ ')
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 diffstart = 2
break
Augie Fackler
formatting: blacken the codebase...
r43346 diffstart = 0 # reset
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if line.startswith(b"--- "):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 diffstart = 1
continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif format == b"hgpatch":
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 # parse values when importing the result of an hg export
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if line.startswith(b"# User "):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 user = line[7:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif line.startswith(b"# Date "):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 date = line[7:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif line.startswith(b"# Parent "):
Augie Fackler
formatting: blacken the codebase...
r43346 parent = line[9:].lstrip() # handle double trailing space
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif line.startswith(b"# Branch "):
Steve Borho
mq: record more data in patchheader class (no behavior changes)...
r13229 branch = line[9:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif line.startswith(b"# Node ID "):
Steve Borho
mq: record more data in patchheader class (no behavior changes)...
r13229 nodeid = line[10:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif not line.startswith(b"# ") and line:
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 message.append(line)
format = None
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif line == b'# HG changeset patch':
David Soria Parra
mq: Parse commit message after we find start of changeset patch...
r9287 message = []
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 format = b"hgpatch"
elif format != b"tagdone" and (
line.startswith(b"Subject: ") or line.startswith(b"subject: ")
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 subject = line[9:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 format = b"tag"
elif format != b"tagdone" and (
line.startswith(b"From: ") or line.startswith(b"from: ")
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 user = line[6:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 format = b"tag"
elif format != b"tagdone" and (
line.startswith(b"Date: ") or line.startswith(b"date: ")
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 date = line[6:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 format = b"tag"
elif format == b"tag" and line == b"":
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 # when looking for tags (subject: from: etc) they
# end once you find a blank line in the source
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 format = b"tagdone"
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 elif message or line:
message.append(line)
comments.append(line)
eatdiff(message)
eatdiff(comments)
Steve Borho
mq: record more data in patchheader class (no behavior changes)...
r13229 # Remember the exact starting line of the patch diffs before consuming
# empty lines, for external use by TortoiseHg and others
self.diffstartline = len(comments)
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 eatempty(message)
eatempty(comments)
# make sure message isn't empty
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if format and format.startswith(b"tag") and subject:
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 message.insert(0, subject)
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 self.message = message
self.comments = comments
self.user = user
self.date = date
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 self.parent = parent
Steve Borho
mq: record more data in patchheader class (no behavior changes)...
r13229 # nodeid and branch are for external use by TortoiseHg and others
self.nodeid = nodeid
self.branch = branch
Cédric Duval
mq: initializing patchheader class directly from patch content...
r8653 self.haspatch = diffstart > 1
Augie Fackler
formatting: blacken the codebase...
r43346 self.plainmode = (
plainmode
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 or b'# HG changeset patch' not in self.comments
Augie Fackler
formatting: blacken the codebase...
r43346 and any(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 c.startswith(b'Date: ') or c.startswith(b'From: ')
Augie Fackler
formatting: blacken the codebase...
r43346 for c in self.comments
)
)
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399
def setuser(self, user):
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 inserthgheader(self.comments, b'# User ', user)
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 except ValueError:
if self.plainmode:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 insertplainheader(self.comments, b'From', user)
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 tmp = [b'# HG changeset patch', b'# User ' + user]
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 self.comments = tmp + self.comments
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 self.user = user
def setdate(self, date):
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 inserthgheader(self.comments, b'# Date ', date)
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 except ValueError:
if self.plainmode:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 insertplainheader(self.comments, b'Date', date)
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 tmp = [b'# HG changeset patch', b'# Date ' + date]
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 self.comments = tmp + self.comments
Yann E. MORIN
mq: add the date with qrefresh, even if missing (issue1768)...
r9337 self.date = date
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 def setparent(self, parent):
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 inserthgheader(self.comments, b'# Parent ', parent)
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 except ValueError:
if not self.plainmode:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 tmp = [b'# HG changeset patch', b'# Parent ' + parent]
Mads Kiilerich
mq: drop updateheader - inserthgheader and insertplainheader is enough
r23443 self.comments = tmp + self.comments
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 self.parent = parent
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 def setmessage(self, message):
if self.comments:
self._delmsg()
self.message = [message]
Mads Kiilerich
mq: when setting message in plain mode, separate it from header (issue4453)...
r23344 if message:
if self.plainmode and self.comments and self.comments[-1]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.comments.append(b'')
Mads Kiilerich
mq: when setting message in plain mode, separate it from header (issue4453)...
r23344 self.comments.append(message)
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399
Pulkit Goyal
py3: add __bytes__() for mq.patchheader and make sure __str__ returns str...
r35934 def __bytes__(self):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 s = b'\n'.join(self.comments).rstrip()
Mads Kiilerich
mq: simplify patchheader handling of the empty line before the diff...
r22522 if not s:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b''
return s + b'\n\n'
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399
Pulkit Goyal
py3: add __bytes__() for mq.patchheader and make sure __str__ returns str...
r35934 __str__ = encoding.strmethod(__bytes__)
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 def _delmsg(self):
'''Remove existing message, keeping the rest of the comments fields.
If comments contains 'subject: ', message will prepend
the field and a blank line.'''
if self.message:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 subj = b'subject: ' + self.message[0].lower()
Gregory Szorc
global: use pycompat.xrange()...
r38806 for i in pycompat.xrange(len(self.comments)):
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 if subj == self.comments[i].lower():
del self.comments[i]
self.message = self.message[2:]
break
ci = 0
Martin Geisler
replace "i in range(len(xs))" with "i, x in enumerate(xs)"...
r8632 for mi in self.message:
while mi != self.comments[ci]:
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 ci += 1
del self.comments[ci]
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
merge with stable
r16102 def newcommit(repo, phase, *args, **kwargs):
Pierre-Yves David
mq: rename secretcommit to newcommit...
r16057 """helper dedicated to ensure a commit respect mq.secret setting
It should be used instead of repo.commit inside the mq source for operation
creating new changeset.
Pierre-Yves David
mq: have mq create secret changeset only
r15926 """
Pierre-Yves David
clfilter: ensure that mq performs commits on unfiltered repos
r18010 repo = repo.unfiltered()
Patrick Mezard
mq: ensure all mq commits are made with secretcommit()...
r16100 if phase is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if repo.ui.configbool(b'mq', b'secret'):
Patrick Mezard
mq: ensure all mq commits are made with secretcommit()...
r16100 phase = phases.secret
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 overrides = {(b'ui', b'allowemptycommit'): True}
Patrick Mezard
mq: ensure all mq commits are made with secretcommit()...
r16100 if phase is not None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 overrides[(b'phases', b'new-commit')] = phase
with repo.ui.configoverride(overrides, b'mq'):
repo.ui.setconfig(b'ui', b'allowemptycommit', True)
Pierre-Yves David
mq: have mq create secret changeset only
r15926 return repo.commit(*args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
Patrick Mezard
mq: introduce qpush --check...
r16654 class AbortNoCleanup(error.Abort):
pass
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
use new style classes
r8778 class queue(object):
Simon Heimberg
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)...
r19064 def __init__(self, ui, baseui, path, patchdir=None):
mason@suse.com
Add mq extension
r1808 self.basepath = path
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 with open(os.path.join(path, b'patches.queue'), r'rb') as fh:
Gregory Szorc
py3: open patches.queue in binary mode...
r36124 cur = fh.read().rstrip()
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 if not cur:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 curpath = os.path.join(path, b'patches')
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 curpath = os.path.join(path, b'patches-' + cur)
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 except IOError:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 curpath = os.path.join(path, b'patches')
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 self.path = patchdir or curpath
Pierre-Yves David
vfs: use 'vfs' module directly in 'hgext.mq'...
r31243 self.opener = vfsmod.vfs(self.path)
mason@suse.com
Add mq extension
r1808 self.ui = ui
Simon Heimberg
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)...
r19064 self.baseui = baseui
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = False
self.seriesdirty = False
Vishakh H
mq: qimport cleanup on fail (issue2214)...
r11462 self.added = []
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.seriespath = b"series"
self.statuspath = b"status"
self.guardspath = b"guards"
Adrian Buehlmann
mq: rename active_guards to activeguards
r14590 self.activeguards = None
Adrian Buehlmann
mq: rename guards_dirty to guardsdirty
r14591 self.guardsdirty = False
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 # Handle mq.git as a bool with extended values
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 gitmode = ui.config(b'mq', b'git').lower()
Yuya Nishihara
stringutil: bulk-replace call sites to point to new module...
r37102 boolmode = stringutil.parsebool(gitmode)
Boris Feld
configitems: register the 'mq.git' config
r34182 if boolmode is not None:
if boolmode:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 gitmode = b'yes'
Jordi Gutiérrez Hermoso
style: kill ersatz if-else ternary operators...
r24306 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 gitmode = b'no'
Boris Feld
configitems: register the 'mq.git' config
r34182 self.gitmode = gitmode
Matt Mackall
mq: tweak config reading to make check-config happy...
r25827 # deprecated config: mq.plain
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.plainmode = ui.configbool(b'mq', b'plain')
David Soria Parra
shelve: allow shelving of a change with an mq patch applied...
r19856 self.checkapplied = True
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Simon Heimberg
mq: only read files when needed...
r8524 @util.propertycache
def applied(self):
Idan Kamara
mq: eliminate explicit checks for file existence
r15258 def parselines(lines):
for l in lines:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 entry = l.split(b':', 1)
Idan Kamara
mq: eliminate explicit checks for file existence
r15258 if len(entry) > 1:
n, name = entry
yield statusentry(bin(n), name)
elif l.strip():
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'malformated mq status line: %s\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % stringutil.pprint(entry)
)
Idan Kamara
mq: eliminate explicit checks for file existence
r15258 # else we ignore empty lines
Augie Fackler
formatting: blacken the codebase...
r43346
Idan Kamara
mq: eliminate explicit checks for file existence
r15258 try:
Adrian Buehlmann
mq: rename status_path to statuspath
r14588 lines = self.opener.read(self.statuspath).splitlines()
Pierre-Yves David
mq: gracefully handle malformated status file...
r13507 return list(parselines(lines))
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except IOError as e:
Idan Kamara
mq: eliminate explicit checks for file existence
r15258 if e.errno == errno.ENOENT:
return []
raise
Simon Heimberg
mq: only read files when needed...
r8524
@util.propertycache
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 def fullseries(self):
Idan Kamara
mq: eliminate explicit checks for file existence
r15258 try:
Mads Kiilerich
mq: minor cleanup
r15878 return self.opener.read(self.seriespath).splitlines()
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except IOError as e:
Idan Kamara
mq: eliminate explicit checks for file existence
r15258 if e.errno == errno.ENOENT:
return []
raise
Simon Heimberg
mq: only read files when needed...
r8524
@util.propertycache
def series(self):
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Simon Heimberg
mq: only read files when needed...
r8524 return self.series
@util.propertycache
Adrian Buehlmann
mq: rename series_guards to seriesguards
r14573 def seriesguards(self):
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Adrian Buehlmann
mq: rename series_guards to seriesguards
r14573 return self.seriesguards
mason@suse.com
Add mq extension
r1808
Simon Heimberg
mq: new method invalidate...
r8525 def invalidate(self):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 for a in b'applied fullseries series seriesguards'.split():
Simon Heimberg
mq: new method invalidate...
r8525 if a in self.__dict__:
delattr(self, a)
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = False
self.seriesdirty = False
Adrian Buehlmann
mq: rename guards_dirty to guardsdirty
r14591 self.guardsdirty = False
Adrian Buehlmann
mq: rename active_guards to activeguards
r14590 self.activeguards = None
Simon Heimberg
mq: new method invalidate...
r8525
Mads Kiilerich
mq: create non-lossy patches, also with custom global diff configuration...
r34092 def diffopts(self, opts=None, patchfn=None, plain=False):
"""Return diff options tweaked for this mq use, possibly upgrading to
git format, and possibly plain and without lossy options."""
Augie Fackler
formatting: blacken the codebase...
r43346 diffopts = patchmod.difffeatureopts(
self.ui,
opts,
git=True,
whitespace=not plain,
formatchanging=not plain,
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if self.gitmode == b'auto':
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 diffopts.upgrade = True
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif self.gitmode == b'keep':
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 pass
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif self.gitmode in (b'yes', b'no'):
diffopts.git = self.gitmode == b'yes'
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 else:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'mq.git option can be auto/keep/yes/no got %s')
Augie Fackler
formatting: blacken the codebase...
r43346 % self.gitmode
)
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 if patchfn:
Patrick Mezard
mq: preserve --git flag when merging patches...
r10185 diffopts = self.patchopts(diffopts, patchfn)
return diffopts
Patrick Mezard
mq: preserve --git flag when folding patches...
r10186 def patchopts(self, diffopts, *patches):
Patrick Mezard
mq: preserve --git flag when merging patches...
r10185 """Return a copy of input diff options with git set to true if
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 referenced patch is a git patch and should be preserved as such.
Patrick Mezard
mq: preserve --git flag when merging patches...
r10185 """
diffopts = diffopts.copy()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not diffopts.git and self.gitmode == b'keep':
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 for patchfn in patches:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 patchf = self.opener(patchfn, b'r')
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 # if the patch was a git patch, refresh it as a git patch
Augie Fackler
formatting: blacken the codebase...
r43346 diffopts.git = any(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 line.startswith(b'diff --git') for line in patchf
Augie Fackler
formatting: blacken the codebase...
r43346 )
Patrick Mezard
mq: upgrade to git patch when necessary (issue767)
r10190 patchf.close()
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 return diffopts
Vadim Gelfer
refactor text diff/patch code....
r2874
Vadim Gelfer
mq: add join method
r2819 def join(self, *p):
return os.path.join(self.path, *p)
Adrian Buehlmann
mq: rename find_series to findseries
r14574 def findseries(self, patch):
Benoit Boissinot
mq: find_series() simplify and don't use regexps
r10685 def matchpatch(l):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 l = l.split(b'#', 1)[0]
Benoit Boissinot
mq: find_series() simplify and don't use regexps
r10685 return l.strip() == patch
Augie Fackler
formatting: blacken the codebase...
r43346
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 for index, l in enumerate(self.fullseries):
Benoit Boissinot
mq: find_series() simplify and don't use regexps
r10685 if matchpatch(l):
return index
mason@suse.com
Add mq extension
r1808 return None
Pulkit Goyal
py3: add b'' to regular expressions which are raw strings...
r35145 guard_re = re.compile(br'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 def parseseries(self):
mason@suse.com
Add mq extension
r1808 self.series = []
Adrian Buehlmann
mq: rename series_guards to seriesguards
r14573 self.seriesguards = []
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 for l in self.fullseries:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 h = l.find(b'#')
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if h == -1:
patch = l
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 comment = b''
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 elif h == 0:
continue
else:
patch = l[:h]
comment = l[h:]
patch = patch.strip()
if patch:
Brendan Cully
mq: bail out if a patch appears more than once in the series file....
r3184 if patch in self.series:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'%s appears more than once in %s')
Augie Fackler
formatting: blacken the codebase...
r43346 % (patch, self.join(self.seriespath))
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 self.series.append(patch)
Adrian Buehlmann
mq: rename series_guards to seriesguards
r14573 self.seriesguards.append(self.guard_re.findall(comment))
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Adrian Buehlmann
mq: rename check_guard to checkguard
r14576 def checkguard(self, guard):
Patrick Mezard
mq: make qselect fail properly on an empty guard
r6607 if not guard:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return _(b'guard cannot be an empty string')
bad_chars = b'# \t\r\n\f'
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 first = guard[0]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if first in b'-+':
return _(b'guard %r starts with invalid character: %r') % (
Augie Fackler
formatting: blacken the codebase...
r43346 guard,
first,
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 for c in bad_chars:
if c in guard:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return _(b'invalid character in guard %r: %r') % (guard, c)
Thomas Arendsen Hein
Whitespace/Tab cleanup
r3223
Adrian Buehlmann
mq: rename set_active to setactive
r14578 def setactive(self, guards):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 for guard in guards:
Adrian Buehlmann
mq: rename check_guard to checkguard
r14576 bad = self.checkguard(guard)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if bad:
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(bad)
Matt Mackall
replace util.sort with sorted built-in...
r8209 guards = sorted(set(guards))
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.debug(b'active guards: %s\n' % b' '.join(guards))
Adrian Buehlmann
mq: rename active_guards to activeguards
r14590 self.activeguards = guards
Adrian Buehlmann
mq: rename guards_dirty to guardsdirty
r14591 self.guardsdirty = True
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
def active(self):
Adrian Buehlmann
mq: rename active_guards to activeguards
r14590 if self.activeguards is None:
self.activeguards = []
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 try:
Adrian Buehlmann
mq: rename guards_path to guardspath
r14589 guards = self.opener.read(self.guardspath).split()
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except IOError as err:
Matt Mackall
many, many trivial check-code fixups
r10282 if err.errno != errno.ENOENT:
raise
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 guards = []
for i, guard in enumerate(guards):
Adrian Buehlmann
mq: rename check_guard to checkguard
r14576 bad = self.checkguard(guard)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if bad:
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'%s:%d: %s\n'
% (self.join(self.guardspath), i + 1, bad)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
Adrian Buehlmann
mq: rename active_guards to activeguards
r14590 self.activeguards.append(guard)
return self.activeguards
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Adrian Buehlmann
mq: rename set_guards to setguards
r14577 def setguards(self, idx, guards):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 for g in guards:
if len(g) < 2:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'guard %r too short') % g)
if g[0] not in b'-+':
raise error.Abort(_(b'guard %r starts with invalid char') % g)
Adrian Buehlmann
mq: rename check_guard to checkguard
r14576 bad = self.checkguard(g[1:])
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if bad:
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(bad)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 drop = self.guard_re.sub(b'', self.fullseries[idx])
self.fullseries[idx] = drop + b''.join([b' #' + g for g in guards])
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Adrian Buehlmann
mq: rename series_dirty to seriesdirty
r14593 self.seriesdirty = True
Thomas Arendsen Hein
Whitespace/Tab cleanup
r3223
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 def pushable(self, idx):
Gregory Szorc
py3: compare against bytes instead of str...
r36123 if isinstance(idx, bytes):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 idx = self.series.index(idx)
Adrian Buehlmann
mq: rename series_guards to seriesguards
r14573 patchguards = self.seriesguards[idx]
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if not patchguards:
return True, None
guards = self.active()
Augie Fackler
formatting: blacken the codebase...
r43346 exactneg = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 g for g in patchguards if g.startswith(b'-') and g[1:] in guards
Augie Fackler
formatting: blacken the codebase...
r43346 ]
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if exactneg:
Augie Fackler
mq: use stringutil.pprint instead of pycompat.byterepr...
r39084 return False, stringutil.pprint(exactneg[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pos = [g for g in patchguards if g.startswith(b'+')]
Vadim Gelfer
mq: apply patch is any posative guard matches...
r2850 exactpos = [g for g in pos if g[1:] in guards]
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if pos:
Vadim Gelfer
mq: apply patch is any posative guard matches...
r2850 if exactpos:
Augie Fackler
mq: use stringutil.pprint instead of pycompat.byterepr...
r39084 return True, stringutil.pprint(exactpos[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return False, b' '.join([stringutil.pprint(p) for p in pos])
return True, b''
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Adrian Buehlmann
mq: rename explain_pushable to explainpushable
r14579 def explainpushable(self, idx, all_patches=False):
Jordi Gutiérrez Hermoso
style: kill ersatz if-else ternary operators...
r24306 if all_patches:
write = self.ui.write
else:
write = self.ui.warn
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if all_patches or self.ui.verbose:
Pulkit Goyal
py3: use bytes instead of str in isinstance()...
r37539 if isinstance(idx, bytes):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 idx = self.series.index(idx)
pushable, why = self.pushable(idx)
if all_patches and pushable:
if why is None:
Augie Fackler
formatting: blacken the codebase...
r43346 write(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'allowing %s - no guards in effect\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % self.series[idx]
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
if not why:
Augie Fackler
formatting: blacken the codebase...
r43346 write(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'allowing %s - no matching negative guards\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % self.series[idx]
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
Augie Fackler
formatting: blacken the codebase...
r43346 write(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'allowing %s - guarded by %s\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % (self.series[idx], why)
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if not pushable:
Vadim Gelfer
mq: make guards more strict, add tests
r2829 if why:
Augie Fackler
formatting: blacken the codebase...
r43346 write(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'skipping %s - guarded by %s\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % (self.series[idx], why)
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
Augie Fackler
formatting: blacken the codebase...
r43346 write(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'skipping %s - no matching guards\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % self.series[idx]
)
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 def savedirty(self):
Adrian Buehlmann
mq: rename write_list to writelist
r14594 def writelist(items, path):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fp = self.opener(path, b'wb')
Vadim Gelfer
mq: simplify save_dirty
r2772 for i in items:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fp.write(b"%s\n" % i)
Vadim Gelfer
mq: simplify save_dirty
r2772 fp.close()
Augie Fackler
formatting: blacken the codebase...
r43346
Adrian Buehlmann
mq: rename applied_dirty to applieddirty
r14592 if self.applieddirty:
Augie Fackler
mq: use bytes() instead of str() to encode statusentries for writing...
r35862 writelist(map(bytes, self.applied), self.statuspath)
Mads Kiilerich
mq: only save dirty files once when savedirty is called multiple times
r15883 self.applieddirty = False
Adrian Buehlmann
mq: rename series_dirty to seriesdirty
r14593 if self.seriesdirty:
Adrian Buehlmann
mq: rename write_list to writelist
r14594 writelist(self.fullseries, self.seriespath)
Mads Kiilerich
mq: only save dirty files once when savedirty is called multiple times
r15883 self.seriesdirty = False
Adrian Buehlmann
mq: rename guards_dirty to guardsdirty
r14591 if self.guardsdirty:
Adrian Buehlmann
mq: rename write_list to writelist
r14594 writelist(self.activeguards, self.guardspath)
Mads Kiilerich
mq: only save dirty files once when savedirty is called multiple times
r15883 self.guardsdirty = False
Nicolas Dumazet
mq: qrepo.add(mq.added) inside save_dirty inside of doing it manually...
r11546 if self.added:
qrepo = self.qrepo()
if qrepo:
Dan Villiom Podlaski Christiansen
mq: silence spurious output....
r12658 qrepo[None].add(f for f in self.added if f not in qrepo[None])
Nicolas Dumazet
mq: qrepo.add(mq.added) inside save_dirty inside of doing it manually...
r11546 self.added = []
mason@suse.com
Add mq extension
r1808
Brendan Cully
Remove undo log after mq operations that rollback would break
r4207 def removeundo(self, repo):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 undo = repo.sjoin(b'undo')
Brendan Cully
Remove undo log after mq operations that rollback would break
r4207 if not os.path.exists(undo):
return
try:
os.unlink(undo)
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except OSError as inst:
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'error removing undo: %s\n') % stringutil.forcebytestr(inst)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Brendan Cully
Remove undo log after mq operations that rollback would break
r4207
Patrick Mezard
mq: backup local changes in qpush --force...
r16634 def backup(self, repo, files, copy=False):
Patrick Mezard
mq: backup local changes in qpop --force (issue3433)
r16633 # backup local changes in --force case
for f in sorted(files):
absf = repo.wjoin(f)
if os.path.lexists(absf):
Martin von Zweigbergk
mq: migrate to scmutil.backuppath()...
r41748 absorig = scmutil.backuppath(self.ui, repo, f)
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.note(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'saving current version of %s as %s\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % (f, os.path.relpath(absorig))
)
Martin von Zweigbergk
mq: always show relative path to .orig backup...
r41732
Patrick Mezard
mq: backup local changes in qpush --force...
r16634 if copy:
Christian Delahousse
mq: let the user choose where .orig files are kept...
r26943 util.copyfile(absf, absorig)
Patrick Mezard
mq: backup local changes in qpush --force...
r16634 else:
Christian Delahousse
mq: let the user choose where .orig files are kept...
r26943 util.rename(absf, absorig)
Patrick Mezard
mq: backup local changes in qpop --force (issue3433)
r16633
Augie Fackler
formatting: blacken the codebase...
r43346 def printdiff(
self,
repo,
diffopts,
node1,
node2=None,
files=None,
fp=None,
changes=None,
opts=None,
):
Pierre-Yves David
mq: explicitly tests for None...
r31432 if opts is None:
opts = {}
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 stat = opts.get(b'stat')
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(repo[node1], files, opts)
Augie Fackler
formatting: blacken the codebase...
r43346 logcmdutil.diffordiffstat(
self.ui, repo, diffopts, node1, node2, m, changes, stat, fp
)
Vadim Gelfer
refactor text diff/patch code....
r2874
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 def mergeone(self, repo, mergeq, head, patch, rev, diffopts):
mason@suse.com
Add mq extension
r1808 # first try just applying the patch
Augie Fackler
formatting: blacken the codebase...
r43346 (err, n) = self.apply(
repo, [patch], update_status=False, strict=True, merge=rev
)
mason@suse.com
Add mq extension
r1808
if err == 0:
return (err, n)
if n is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"apply failed for patch %s") % patch)
self.ui.warn(_(b"patch didn't work out, merging %s\n") % patch)
mason@suse.com
Add mq extension
r1808
# apply failed, strip away that rev and merge.
Matt Mackall
Make repo locks recursive, eliminate all passing of lock/wlock
r4917 hg.clean(repo, head)
Jordi Gutiérrez Hermoso
strip: remove -b/--backup codepaths...
r22057 strip(self.ui, repo, [n], update=False, backup=False)
mason@suse.com
Add mq extension
r1808
Matt Mackall
use repo[changeid] to get a changectx
r6747 ctx = repo[rev]
Matt Mackall
Make repo locks recursive, eliminate all passing of lock/wlock
r4917 ret = hg.merge(repo, rev)
mason@suse.com
Add mq extension
r1808 if ret:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"update returned %d") % ret)
Matt Mackall
merge with stable
r16102 n = newcommit(repo, None, ctx.description(), ctx.user(), force=True)
Martin Geisler
use 'x is None' instead of 'x == None'...
r8527 if n is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"repo commit failed"))
mason@suse.com
Add mq extension
r1808 try:
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph = patchheader(mergeq.join(patch), self.plainmode)
Brodie Rao
cleanup: replace naked excepts with except Exception: ...
r16689 except Exception:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"unable to read %s") % patch)
mason@suse.com
Add mq extension
r1808
Patrick Mezard
mq: preserve --git flag when merging patches...
r10185 diffopts = self.patchopts(diffopts, patch)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 patchf = self.opener(patch, b"w")
Pulkit Goyal
py3: use bytes() instead of str()...
r36685 comments = bytes(ph)
mason@suse.com
Add mq extension
r1808 if comments:
patchf.write(comments)
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 self.printdiff(repo, diffopts, head, n, fp=patchf)
mason@suse.com
Add mq extension
r1808 patchf.close()
Brendan Cully
Remove undo log after mq operations that rollback would break
r4207 self.removeundo(repo)
mason@suse.com
Add mq extension
r1808 return (0, n)
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
mason@suse.com
Add mq extension
r1808 def qparents(self, repo, rev=None):
Pierre-Yves David
mq: document repo.mq.qparents...
r19816 """return the mq handled parent or p1
In some case where mq get himself in being the parent of a merge the
Mads Kiilerich
spelling: random spell checker fixes
r19951 appropriate parent may be p2.
Pierre-Yves David
mq: document repo.mq.qparents...
r19816 (eg: an in progress merge started with mq disabled)
If no parent are managed by mq, p1 is returned.
"""
mason@suse.com
Add mq extension
r1808 if rev is None:
(p1, p2) = repo.dirstate.parents()
Matt Mackall
mq: remove import of revlog
r7639 if p2 == nullid:
mason@suse.com
Add mq extension
r1808 return p1
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if not self.applied:
mason@suse.com
Add mq extension
r1808 return None
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 return self.applied[-1].node
p1, p2 = repo.changelog.parents(rev)
Benoit Boissinot
mq: simplify qparents calculation
r10680 if p2 != nullid and p2 in [x.node for x in self.applied]:
return p2
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 return p1
mason@suse.com
Add mq extension
r1808
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 def mergepatch(self, repo, mergeq, series, diffopts):
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if not self.applied:
mason@suse.com
Add mq extension
r1808 # each of the patches merged in will have two parents. This
# can confuse the qrefresh, qdiff, and strip code because it
# needs to know which parent is actually in the patch queue.
# so, we insert a merge marker with only one parent. This way
# the first patch in the queue is never a merge patch
#
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pname = b".hg.patches.merge.marker"
n = newcommit(repo, None, b'[mq]: merge marker', force=True)
Brendan Cully
Remove undo log after mq operations that rollback would break
r4207 self.removeundo(repo)
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 self.applied.append(statusentry(n, pname))
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = True
mason@suse.com
Add mq extension
r1808
head = self.qparents(repo)
for patch in series:
Chris Mason
mq: patch naming shortcuts...
r2696 patch = mergeq.lookup(patch, strict=True)
mason@suse.com
Add mq extension
r1808 if not patch:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"patch %s does not exist\n") % patch)
mason@suse.com
Add mq extension
r1808 return (1, None)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 pushable, reason = self.pushable(patch)
if not pushable:
Adrian Buehlmann
mq: rename explain_pushable to explainpushable
r14579 self.explainpushable(patch, all_patches=True)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 continue
mason@suse.com
Add mq extension
r1808 info = mergeq.isapplied(patch)
if not info:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"patch %s is not applied\n") % patch)
mason@suse.com
Add mq extension
r1808 return (1, None)
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 rev = info[1]
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 err, head = self.mergeone(repo, mergeq, head, patch, rev, diffopts)
mason@suse.com
Add mq extension
r1808 if head:
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 self.applied.append(statusentry(head, patch))
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = True
mason@suse.com
Add mq extension
r1808 if err:
return (err, head)
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 self.savedirty()
mason@suse.com
Add mq extension
r1808 return (0, head)
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748 def patch(self, repo, patchfile):
'''Apply patchfile to the working directory.
timeless
Generally replace "file name" with "filename" in help and comments.
r8761 patchfile: name of patch file'''
Patrick Mezard
patch: turn patch() touched files dict into a set
r14564 files = set()
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748 try:
Augie Fackler
formatting: blacken the codebase...
r43346 fuzz = patchmod.patch(
self.ui, repo, patchfile, strip=1, files=files, eolmode=None
)
Patrick Mezard
patch: make patch()/internalpatch() always update the dirstate
r14260 return (True, list(files), fuzz)
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except Exception as inst:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.note(stringutil.forcebytestr(inst) + b'\n')
Brendan Cully
Unify mq and hg patch invocation....
r2919 if not self.ui.verbose:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"patch failed, unable to continue (try -v)\n"))
Dan Villiom Podlaski Christiansen
mq: don't suppress patch tracebacks when applying patches
r15085 self.ui.traceback()
Patrick Mezard
patch: make patch()/internalpatch() always update the dirstate
r14260 return (False, list(files), False)
Benoit Boissinot
mq: codingstyle
r2796
Augie Fackler
formatting: blacken the codebase...
r43346 def apply(
self,
repo,
series,
list=False,
update_status=True,
strict=False,
patchdir=None,
merge=None,
all_files=None,
tobackup=None,
keepchanges=False,
):
FUJIWARA Katsunori
dirstate: remove meaningless dirstateguard...
r26578 wlock = lock = tr = None
Bryan O'Sullivan
MQ: tidy up if a qpush is interrupted....
r4418 try:
Matt Mackall
Make repo locks recursive, eliminate all passing of lock/wlock
r4917 wlock = repo.wlock()
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 lock = repo.lock()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 tr = repo.transaction(b"qpush")
Bryan O'Sullivan
MQ: tidy up if a qpush is interrupted....
r4418 try:
Augie Fackler
formatting: blacken the codebase...
r43346 ret = self._apply(
repo,
series,
list,
update_status,
strict,
patchdir,
merge,
all_files=all_files,
tobackup=tobackup,
keepchanges=keepchanges,
)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 tr.close()
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 self.savedirty()
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 return ret
Patrick Mezard
mq: introduce qpush --check...
r16654 except AbortNoCleanup:
tr.close()
self.savedirty()
Matt Mackall
mq: avoid silent failure when single patch doesn't apply (issue4604)...
r24826 raise
Augie Fackler
formatting: blacken the codebase...
r43346 except: # re-raises
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 try:
tr.abort()
finally:
Mads Kiilerich
mq: use .invalidate to cancel dirty mq state when cancelling transaction...
r15881 self.invalidate()
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 raise
finally:
FUJIWARA Katsunori
dirstate: remove meaningless dirstateguard...
r26578 release(tr, lock, wlock)
Alexis S. L. Carvalho
mq: really remove undo after a qpush (and after a strip)...
r5527 self.removeundo(repo)
Bryan O'Sullivan
MQ: tidy up if a qpush is interrupted....
r4418
Augie Fackler
formatting: blacken the codebase...
r43346 def _apply(
self,
repo,
series,
list=False,
update_status=True,
strict=False,
patchdir=None,
merge=None,
all_files=None,
tobackup=None,
keepchanges=False,
):
Patrick Mezard
mq: backup local changes in qpush --force...
r16634 """returns (error, hash)
error = 1 for unable to read, 2 for patch failed, 3 for patch
fuzz. tobackup is None or a set of files to backup before they
are modified by a patch.
"""
mason@suse.com
Add mq extension
r1808 # TODO unify with commands.py
if not patchdir:
patchdir = self.path
err = 0
n = None
Brendan Cully
Teach mq about git patches
r2934 for patchname in series:
pushable, reason = self.pushable(patchname)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if not pushable:
Adrian Buehlmann
mq: rename explain_pushable to explainpushable
r14579 self.explainpushable(patchname, all_patches=True)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.status(_(b"applying %s\n") % patchname)
Brendan Cully
Teach mq about git patches
r2934 pf = os.path.join(patchdir, patchname)
mason@suse.com
Add mq extension
r1808
try:
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph = patchheader(self.join(patchname), self.plainmode)
Idan Kamara
mq: loosen except clause when reading patch headers
r14239 except IOError:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"unable to read %s\n") % patchname)
mason@suse.com
Add mq extension
r1808 err = 1
break
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 message = ph.message
mason@suse.com
Add mq extension
r1808 if not message:
Martin Geisler
mq: mark strings that should not be translated
r12849 # The commit message should not be translated
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message = b"imported patch %s\n" % patchname
mason@suse.com
Add mq extension
r1808 else:
if list:
Martin Geisler
mq: mark strings that should not be translated
r12849 # The commit message should not be translated
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message.append(b"\nimported patch %s" % patchname)
message = b'\n'.join(message)
mason@suse.com
Add mq extension
r1808
Matt Mackall
mq: handle empty patches more gracefully (issue1501)
r7782 if ph.haspatch:
Patrick Mezard
mq: backup local changes in qpush --force...
r16634 if tobackup:
touched = patchmod.changedfiles(self.ui, repo, pf)
touched = set(touched) & tobackup
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 if touched and keepchanges:
Patrick Mezard
mq: introduce qpush --check...
r16654 raise AbortNoCleanup(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"conflicting local changes found"),
hint=_(b"did you forget to qrefresh?"),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Patrick Mezard
mq: backup local changes in qpush --force...
r16634 self.backup(repo, touched, copy=True)
tobackup = tobackup - touched
Matt Mackall
mq: handle empty patches more gracefully (issue1501)
r7782 (patcherr, files, fuzz) = self.patch(repo, pf)
Benoit Boissinot
mq: all_files can be a set, remove dangerous default values
r10661 if all_files is not None:
all_files.update(files)
Matt Mackall
mq: handle empty patches more gracefully (issue1501)
r7782 patcherr = not patcherr
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"patch %s is empty\n") % patchname)
Matt Mackall
mq: handle empty patches more gracefully (issue1501)
r7782 patcherr, files, fuzz = 0, [], 0
mason@suse.com
Add mq extension
r1808
Brendan Cully
Teach mq about git patches
r2934 if merge and files:
Alexis S. L. Carvalho
mq: don't abort when merging a patch that removes files
r4332 # Mark as removed/merged and update dirstate parent info
removed = []
merged = []
for f in files:
Patrick Mezard
Use lexists() instead of exists() where appropriate
r12344 if os.path.lexists(repo.wjoin(f)):
Alexis S. L. Carvalho
mq: don't abort when merging a patch that removes files
r4332 merged.append(f)
else:
removed.append(f)
Augie Fackler
mq: migrate to context manager for changing dirstate parents
r32347 with repo.dirstate.parentchange():
for f in removed:
repo.dirstate.remove(f)
for f in merged:
repo.dirstate.merge(f)
Martin von Zweigbergk
cleanup: use p1() instead of parents() when we only need the first parent...
r41444 p1 = repo.dirstate.p1()
Augie Fackler
mq: migrate to context manager for changing dirstate parents
r32347 repo.setparents(p1, merge)
Matt Mackall
match: remove files arg from repo.status and friends
r6603
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if all_files and b'.hgsubstate' in all_files:
Mads Kiilerich
mq: repo['.'] is not a wctx, repo[None] is...
r20959 wctx = repo[None]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pctx = repo[b'.']
Angel Ezquerra
mq: update subrepos when applying / unapplying patches that change .hgsubstate...
r19638 overwrite = False
Augie Fackler
formatting: blacken the codebase...
r43346 mergedsubstate = subrepoutil.submerge(
repo, pctx, wctx, wctx, overwrite
)
Angel Ezquerra
mq: update subrepos when applying / unapplying patches that change .hgsubstate...
r19638 files += mergedsubstate.keys()
Matt Mackall
scmutil: drop aliases in cmdutil for match functions
r14322 match = scmutil.matchfiles(repo, files or [])
Martin von Zweigbergk
repo: don't look up context for tip node if it's not needed...
r39931 oldtip = repo.changelog.tip()
Augie Fackler
formatting: blacken the codebase...
r43346 n = newcommit(
repo, None, message, ph.user, ph.date, match=match, force=True
)
Martin von Zweigbergk
repo: don't look up context for tip node if it's not needed...
r39931 if repo.changelog.tip() == oldtip:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(
_(b"qpush exactly duplicates child changeset")
)
Martin Geisler
use 'x is None' instead of 'x == None'...
r8527 if n is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"repository commit failed"))
mason@suse.com
Add mq extension
r1808
if update_status:
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 self.applied.append(statusentry(n, patchname))
mason@suse.com
Add mq extension
r1808
if patcherr:
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"patch failed, rejects left in working directory\n")
Augie Fackler
formatting: blacken the codebase...
r43346 )
Dirkjan Ochtman
mq: fix error message for qpush inexistent-patch (issue1702)
r8875 err = 2
mason@suse.com
Add mq extension
r1808 break
if fuzz and strict:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"fuzz found when applying patch, stopping\n"))
Dirkjan Ochtman
mq: fix error message for qpush inexistent-patch (issue1702)
r8875 err = 3
mason@suse.com
Add mq extension
r1808 break
return (err, n)
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 def _cleanup(self, patches, numrevs, keep=False):
if not keep:
r = self.qrepo()
if r:
Matt Mackall
context: make forget work like commands.forget...
r14435 r[None].forget(patches)
for p in patches:
Mads Kiilerich
mq: don't fail when removing a patch without patch file from series file
r18067 try:
os.unlink(self.join(p))
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except OSError as inst:
Mads Kiilerich
mq: don't fail when removing a patch without patch file from series file
r18067 if inst.errno != errno.ENOENT:
raise
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833
Pierre-Yves David
mq: turn changeset draft on qfinish (except if qparent is secret)...
r15920 qfinished = []
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 if numrevs:
Pierre-Yves David
mq: prevent traceback when qfinish patches not in series....
r14010 qfinished = self.applied[:numrevs]
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 del self.applied[:numrevs]
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = True
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833
Pierre-Yves David
mq: prevent traceback when qfinish patches not in series....
r14010 unknown = []
Pulkit Goyal
py3: workaround comparing NoneType and integers...
r37543 sortedseries = []
for p in patches:
idx = self.findseries(p)
if idx is None:
sortedseries.append((-1, p))
else:
sortedseries.append((idx, p))
sortedseries.sort(reverse=True)
for (i, p) in sortedseries:
if i != -1:
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 del self.fullseries[i]
Pierre-Yves David
mq: prevent traceback when qfinish patches not in series....
r14010 else:
unknown.append(p)
if unknown:
if numrevs:
Augie Fackler
formatting: blacken the codebase...
r43346 rev = dict((entry.name, entry.node) for entry in qfinished)
Pierre-Yves David
mq: prevent traceback when qfinish patches not in series....
r14010 for p in unknown:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b'revision %s refers to unknown patches: %s\n')
Pierre-Yves David
mq: prevent traceback when qfinish patches not in series....
r14010 self.ui.warn(msg % (short(rev[p]), p))
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b'unknown patches: %s\n')
raise error.Abort(b''.join(msg % p for p in unknown))
Pierre-Yves David
mq: prevent traceback when qfinish patches not in series....
r14010
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.seriesdirty = True
Pierre-Yves David
mq: turn changeset draft on qfinish (except if qparent is secret)...
r15920 return [entry.node for entry in qfinished]
Dirkjan Ochtman
mq: introduce the qfinish command
r6645
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 def _revpatches(self, repo, revs):
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 firstrev = repo[self.applied[0].node].rev()
Dirkjan Ochtman
mq: introduce the qfinish command
r6645 patches = []
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 for i, rev in enumerate(revs):
Dirkjan Ochtman
mq: warn about finalizing patches without cset message
r8832
Dirkjan Ochtman
mq: introduce the qfinish command
r6645 if rev < firstrev:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'revision %d is not managed') % rev)
Dirkjan Ochtman
mq: warn about finalizing patches without cset message
r8832
ctx = repo[rev]
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 base = self.applied[i].node
Dirkjan Ochtman
mq: warn about finalizing patches without cset message
r8832 if ctx.node() != base:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b'cannot delete revision %d above applied patches')
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(msg % rev)
Dirkjan Ochtman
mq: warn about finalizing patches without cset message
r8832
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 patch = self.applied[i].name
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 for fmt in (b'[mq]: %s', b'imported patch %s'):
Dirkjan Ochtman
mq: warn about finalizing patches without cset message
r8832 if ctx.description() == fmt % patch:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b'patch %s finalized without changeset message\n')
Dirkjan Ochtman
mq: warn about finalizing patches without cset message
r8832 repo.ui.status(msg % patch)
break
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 patches.append(patch)
return patches
Dirkjan Ochtman
mq: introduce the qfinish command
r6645
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 def finish(self, repo, revs):
Pierre-Yves David
qfinish: do not set secret changeset to draft if mq.secret=false...
r16029 # Manually trigger phase computation to ensure phasedefaults is
# executed before we remove the patches.
Patrick Mezard
phases: introduce phasecache...
r16657 repo._phasecache
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 patches = self._revpatches(repo, sorted(revs))
Pierre-Yves David
mq: turn changeset draft on qfinish (except if qparent is secret)...
r15920 qfinished = self._cleanup(patches, len(patches))
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if qfinished and repo.ui.configbool(b'mq', b'secret'):
Pierre-Yves David
qfinish: do not set secret changeset to draft if mq.secret=false...
r16029 # only use this logic when the secret option is added
Pierre-Yves David
mq: turn changeset draft on qfinish (except if qparent is secret)...
r15920 oldqbase = repo[qfinished[0]]
Boris Feld
mq: use the newcommitphase utility...
r34563 tphase = phases.newcommitphase(repo.ui)
Pierre-Yves David
qfinish: comply with the phases.new-commit option in secret mode (issue3335)...
r16290 if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 with repo.transaction(b'qfinish') as tr:
Pierre-Yves David
phase: add a transaction argument to advanceboundary...
r22069 phases.advanceboundary(repo, tr, tphase, qfinished)
Dirkjan Ochtman
mq: introduce the qfinish command
r6645
Brendan Cully
mq: add qdelete --forget option...
r3088 def delete(self, repo, patches, opts):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not patches and not opts.get(b'rev'):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'qdelete requires at least one revision or patch name')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Brendan Cully
mq: require patch argument or revision for qdelete
r4736
Greg Ward
mq: make 'qdelete <patchidx>' work again....
r11365 realpatches = []
Brendan Cully
Allow qdel to delete multiple patches.
r2905 for patch in patches:
patch = self.lookup(patch, strict=True)
info = self.isapplied(patch)
Brendan Cully
mq: change qdel --forget to --rev; accept any revision symbol
r3373 if info:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"cannot delete applied patch %s") % patch)
Brendan Cully
Allow qdel to delete multiple patches.
r2905 if patch not in self.series:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"patch %s not in series file") % patch)
Dan Villiom Podlaski Christiansen
mq: handle deleting the same patch twice in one command (issue2427)
r12655 if patch not in realpatches:
realpatches.append(patch)
Brendan Cully
mq: change qdel --forget to --rev; accept any revision symbol
r3373
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 numrevs = 0
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'rev'):
Brendan Cully
mq: change qdel --forget to --rev; accept any revision symbol
r3373 if not self.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no patches applied'))
revs = scmutil.revrange(repo, opts.get(b'rev'))
Pierre-Yves David
mq: use `revs.sort()` to ensure the set is ascending...
r22803 revs.sort()
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 revpatches = self._revpatches(repo, revs)
Greg Ward
mq: make 'qdelete <patchidx>' work again....
r11365 realpatches += revpatches
Dirkjan Ochtman
mq: unify code for qdel -r and qfin
r8833 numrevs = len(revpatches)
Brendan Cully
Allow qdel to delete multiple patches.
r2905
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self._cleanup(realpatches, numrevs, opts.get(b'keep'))
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Adrian Buehlmann
mq: rename check_toppatch to checktoppatch
r14581 def checktoppatch(self, repo):
Mads Kiilerich
mq: checktoppatch should only check if p1 is qtip...
r18343 '''check that working directory is at qtip'''
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if self.applied:
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 top = self.applied[-1].node
Patrick Mezard
mq: qdiff with the same diff options than qrefresh (issue1350)...
r10191 patch = self.applied[-1].name
Mads Kiilerich
mq: checktoppatch should only check if p1 is qtip...
r18343 if repo.dirstate.p1() != top:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"working directory revision is not qtip"))
Patrick Mezard
mq: qdiff with the same diff options than qrefresh (issue1350)...
r10191 return top, patch
return None, None
FUJIWARA Katsunori
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh...
r17152 def putsubstate2changes(self, substatestate, changes):
for files in changes[:3]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'.hgsubstate' in files:
Augie Fackler
formatting: blacken the codebase...
r43346 return # already listed up
FUJIWARA Katsunori
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh...
r17152 # not yet listed up
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if substatestate in b'a?':
changes[1].append(b'.hgsubstate')
elif substatestate in b'r':
changes[2].append(b'.hgsubstate')
Augie Fackler
formatting: blacken the codebase...
r43346 else: # modified
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 changes[0].append(b'.hgsubstate')
FUJIWARA Katsunori
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh...
r17152
Pierre-Yves David
mq: simplifies the refresh hint in checklocalchanges...
r19812 def checklocalchanges(self, repo, force=False, refresh=True):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 excsuffix = b''
Idan Kamara
mq: allow to qpop/push with a dirty working copy (issue2780)...
r14256 if refresh:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 excsuffix = b', qrefresh first'
Pierre-Yves David
mq: simplifies the refresh hint in checklocalchanges...
r19812 # plain versions for i18n tool to detect them
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"local changes found, qrefresh first")
_(b"local changed subrepos found, qrefresh first")
Martin von Zweigbergk
mq: remove dependency on strip's checklocalchanges()...
r42689
s = repo.status()
if not force:
Taapas Agrawal
mq: fix for merge detection methods...
r42800 cmdutil.checkunfinished(repo)
Martin von Zweigbergk
mq: remove dependency on strip's checklocalchanges()...
r42689 if s.modified or s.added or s.removed or s.deleted:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"local changes found") # i18n tool detection
raise error.Abort(_(b"local changes found" + excsuffix))
Martin von Zweigbergk
mq: remove dependency on strip's checklocalchanges()...
r42689 if checksubstate(repo):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"local changed subrepos found") # i18n tool detection
raise error.Abort(
_(b"local changed subrepos found" + excsuffix)
)
Taapas Agrawal
mq: fix for merge detection methods...
r42800 else:
cmdutil.checkunfinished(repo, skipmerge=True)
Martin von Zweigbergk
mq: remove dependency on strip's checklocalchanges()...
r42689 return s
Brendan Cully
mq: support qnew -I/-X and file name lists
r4713
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _reserved = (b'series', b'status', b'guards', b'.', b'..')
Augie Fackler
formatting: blacken the codebase...
r43346
Adrian Buehlmann
mq: rename check_reserved_name to checkreservedname
r14584 def checkreservedname(self, name):
Idan Kamara
mq: be more explicit on invalid patch name message
r14054 if name in self._reserved:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'"%s" cannot be used as the name of a patch') % name
Augie Fackler
formatting: blacken the codebase...
r43346 )
Yuya Nishihara
mq: reject new patch name containing leading/trailing whitespace...
r31556 if name != name.strip():
# whitespace is stripped by parseseries()
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'patch name cannot begin or end with whitespace')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 for prefix in (b'.hg', b'.mq'):
Idan Kamara
mq: be more explicit on invalid patch name message
r14054 if name.startswith(prefix):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'patch name cannot begin with "%s"') % prefix
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 for c in (b'#', b':', b'\r', b'\n'):
Idan Kamara
mq: be more explicit on invalid patch name message
r14054 if c in name:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'%r cannot be used in the name of a patch')
Augie Fackler
formatting: blacken the codebase...
r43346 % pycompat.bytestr(c)
)
Idan Kamara
mq: be more explicit on invalid patch name message
r14054
Idan Kamara
mq: wrap patch file name checks in a function
r14422 def checkpatchname(self, name, force=False):
Adrian Buehlmann
mq: rename check_reserved_name to checkreservedname
r14584 self.checkreservedname(name)
Idan Kamara
mq: wrap patch file name checks in a function
r14422 if not force and os.path.exists(self.join(name)):
if os.path.isdir(self.join(name)):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'"%s" already exists as a directory') % name
Augie Fackler
formatting: blacken the codebase...
r43346 )
Idan Kamara
mq: wrap patch file name checks in a function
r14422 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'patch "%s" already exists') % name)
Alexis S. L. Carvalho
mq: don't allow patches with some reserved names...
r5981
Mads Kiilerich
mq: refactor makepatchname into class method
r27918 def makepatchname(self, title, fallbackname):
"""Return a suitable filename for title, adding a suffix to make
it unique in the existing list"""
Gregory Szorc
global: use raw strings for regular expressions with escapes...
r41673 namebase = re.sub(br'[\s\W_]+', b'_', title.lower()).strip(b'_')
Augie Fackler
formatting: blacken the codebase...
r43346 namebase = namebase[:75] # avoid too long name (issue5117)
Mads Kiilerich
mq: check for reserved patch name with qimport -r (issue5033)...
r27919 if namebase:
try:
self.checkreservedname(namebase)
except error.Abort:
namebase = fallbackname
else:
Mads Kiilerich
mq: refactor makepatchname into class method
r27918 namebase = fallbackname
name = namebase
i = 0
Mads Kiilerich
mq: check for reserved patch name with qimport -r (issue5033)...
r27919 while True:
if name not in self.fullseries:
try:
self.checkpatchname(name)
break
except error.Abort:
pass
Mads Kiilerich
mq: refactor makepatchname into class method
r27918 i += 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 name = b'%s__%d' % (namebase, i)
Mads Kiilerich
mq: refactor makepatchname into class method
r27918 return name
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 def checkkeepchanges(self, keepchanges, force):
if force and keepchanges:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'cannot use both --force and --keep-changes'))
Patrick Mezard
mq: introduce qpush --check...
r16654
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 def new(self, repo, patchfn, *pats, **opts):
Brendan Cully
mq: do not invoke editor until just before patch creation. Closes issue1346.
r7157 """options:
msg: a string or a no-argument function returning a string
"""
Pulkit Goyal
py3: use pycompat.byteskwargs() to fix keyword arguments handling...
r36405 opts = pycompat.byteskwargs(opts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = opts.get(b'msg')
edit = opts.get(b'edit')
editform = opts.get(b'editform', b'mq.qnew')
user = opts.get(b'user')
date = opts.get(b'date')
Thomas Arendsen Hein
Fix bad behaviour when specifying an invalid date (issue700)...
r6139 if date:
Boris Feld
util: extract all date-related utils in utils/dateutil module...
r36625 date = dateutil.parsedate(date)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 diffopts = self.diffopts({b'git': opts.get(b'git')}, plain=True)
if opts.get(b'checkname', True):
Idan Kamara
record: check patch name is valid before prompting in qrecord
r14424 self.checkpatchname(patchfn)
Pierre-Yves David
mq: extract checksubstate from the queue class...
r19813 inclsubs = checksubstate(repo)
Kevin Bullock
mq: update .hgsubstate if subrepos are clean (issue2499)...
r13174 if inclsubs:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 substatestate = repo.dirstate[b'.hgsubstate']
if opts.get(b'include') or opts.get(b'exclude') or pats:
Brendan Cully
mq: abort qnew -f if any file in an explicit list cannot be read
r7161 # detect missing files in pats
def badfn(f, msg):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if f != b'.hgsubstate': # .hgsubstate is auto-created
raise error.Abort(b'%s: %s' % (f, msg))
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
mq: use the optional badfn argument when building a matcher
r25469 match = scmutil.match(repo[None], pats, opts, badfn=badfn)
FUJIWARA Katsunori
mq: use list of already known target files instead of matching object for diff...
r16366 changes = repo.status(match=match)
Brendan Cully
mq: support qnew -I/-X and file name lists
r4713 else:
FUJIWARA Katsunori
mq: use list of already known target files instead of matching object for diff...
r16366 changes = self.checklocalchanges(repo, force=True)
FUJIWARA Katsunori
mq: omit ".hgsubstate" from qnew/qrefresh target list for consistent node hash...
r20786 commitfiles = list(inclsubs)
for files in changes[:3]:
FUJIWARA Katsunori
localrepo: omit ".hgsubstate" also from "added" files...
r20827 commitfiles.extend(files)
FUJIWARA Katsunori
mq: omit ".hgsubstate" from qnew/qrefresh target list for consistent node hash...
r20786 match = scmutil.matchfiles(repo, commitfiles)
Augie Fackler
qnew: ignore force option...
r10372 if len(repo[None].parents()) > 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'cannot manage merge changesets'))
Adrian Buehlmann
mq: rename check_toppatch to checktoppatch
r14581 self.checktoppatch(repo)
Adrian Buehlmann
mq: rename full_series_end to fullseriesend
r14585 insert = self.fullseriesend()
Bryan O'Sullivan
with: use context manager for wlock in qnew
r27827 with repo.wlock():
Martin Geisler
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
r12878 try:
# if patch file write fails, abort early
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 p = self.opener(patchfn, b"w")
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except IOError as e:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'cannot write patch "%s": %s')
Augie Fackler
formatting: blacken the codebase...
r43346 % (patchfn, encoding.strtolocal(e.strerror))
)
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 defaultmsg = b"[mq]: %s" % patchfn
FUJIWARA Katsunori
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22003 editor = cmdutil.getcommiteditor(editform=editform)
FUJIWARA Katsunori
mq: fold the code path to invoke editor into specific logic (qnew)...
r21420 if edit:
Augie Fackler
formatting: blacken the codebase...
r43346
FUJIWARA Katsunori
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)...
r21421 def finishdesc(desc):
FUJIWARA Katsunori
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21234 if desc.rstrip():
return desc
else:
return defaultmsg
Augie Fackler
formatting: blacken the codebase...
r43346
FUJIWARA Katsunori
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)...
r21421 # i18n: this message is shown in editor with "HG: " prefix
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extramsg = _(b'Leave message empty to use default message.')
Augie Fackler
formatting: blacken the codebase...
r43346 editor = cmdutil.getcommiteditor(
finishdesc=finishdesc,
extramsg=extramsg,
editform=editform,
)
FUJIWARA Katsunori
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21234 commitmsg = msg
else:
commitmsg = msg or defaultmsg
Augie Fackler
formatting: blacken the codebase...
r43346 n = newcommit(
repo,
None,
commitmsg,
user,
date,
match=match,
force=True,
editor=editor,
)
Martin Geisler
use 'x is None' instead of 'x == None'...
r8527 if n is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"repo commit failed"))
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 try:
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 self.fullseries[insert:insert] = [patchfn]
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 self.applied.append(statusentry(n, patchfn))
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.seriesdirty = True
self.applieddirty = True
FUJIWARA Katsunori
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21234 nctx = repo[n]
Mads Kiilerich
mq: write headers of new patches using patchheader
r22547 ph = patchheader(self.join(patchfn), self.plainmode)
if user:
ph.setuser(user)
if date:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ph.setdate(b'%d %d' % date)
Mads Kiilerich
mq: write headers of new patches using patchheader
r22547 ph.setparent(hex(nctx.p1().node()))
msg = nctx.description().strip()
if msg == defaultmsg.strip():
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = b''
Mads Kiilerich
mq: write headers of new patches using patchheader
r22547 ph.setmessage(msg)
Pulkit Goyal
py3: use bytes instead of str...
r35966 p.write(bytes(ph))
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 if commitfiles:
parent = self.qparents(repo, n)
FUJIWARA Katsunori
mq: use list of already known target files instead of matching object for diff...
r16366 if inclsubs:
FUJIWARA Katsunori
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh...
r17152 self.putsubstate2changes(substatestate, changes)
Augie Fackler
formatting: blacken the codebase...
r43346 chunks = patchmod.diff(
repo,
node1=parent,
node2=n,
changes=changes,
opts=diffopts,
)
Dirkjan Ochtman
patch: turn patch.diff() into a generator...
r7308 for chunk in chunks:
p.write(chunk)
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 p.close()
r = self.qrepo()
Matt Mackall
many, many trivial check-code fixups
r10282 if r:
Dirkjan Ochtman
move working dir/dirstate methods from localrepo to workingctx
r11303 r[None].add([patchfn])
Augie Fackler
formatting: blacken the codebase...
r43346 except: # re-raises
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 repo.rollback()
raise
Benoit Boissinot
remove unused variables
r7280 except Exception:
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 patchpath = self.join(patchfn)
try:
os.unlink(patchpath)
Brodie Rao
cleanup: replace naked excepts with more specific ones
r16688 except OSError:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b'error unlinking %s\n') % patchpath)
Brendan Cully
mq: heavy rearrangement of qnew to make it recover reliably from errors....
r7162 raise
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 self.removeundo(repo)
mason@suse.com
Add mq extension
r1808
def isapplied(self, patch):
"""returns (index, rev, patch)"""
Martin Geisler
replace "i in range(len(xs))" with "i, x in enumerate(xs)"...
r8632 for i, a in enumerate(self.applied):
Brendan Cully
Use StatusEntry class instead of repeated status line parsing....
r2780 if a.name == patch:
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 return (i, a.node, a.name)
mason@suse.com
Add mq extension
r1808 return None
Thomas Arendsen Hein
Whitespace/Tab cleanup
r3223 # if the exact patch name does not exist, we try a few
Chris Mason
mq: patch naming shortcuts...
r2696 # variations. If strict is passed, we try only #1
#
Mads Kiilerich
mq: fix corner cases for handling of patch 0 in qselect...
r15256 # 1) a number (as string) to indicate an offset in the series file
Chris Mason
mq: patch naming shortcuts...
r2696 # 2) a unique substring of the patch name was given
# 3) patchname[-+]num to indicate an offset in the series file
def lookup(self, patch, strict=False):
Adrian Buehlmann
mq: rename partial_name to partialname
r14595 def partialname(s):
Chris Mason
mq: patch naming shortcuts...
r2696 if s in self.series:
return s
Vadim Gelfer
mq: print matches if patch name not unique
r2765 matches = [x for x in self.series if s in x]
if len(matches) > 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b'patch name "%s" is ambiguous:\n') % s)
Vadim Gelfer
mq: print matches if patch name not unique
r2765 for m in matches:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(b' %s\n' % m)
Vadim Gelfer
mq: print matches if patch name not unique
r2765 return None
if matches:
return matches[0]
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if self.series and self.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if s == b'qtip':
Mads Kiilerich
check-code: there must also be whitespace between ')' and operator...
r18054 return self.series[self.seriesend(True) - 1]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if s == b'qbase':
Chris Mason
mq: patch naming shortcuts...
r2696 return self.series[0]
return None
Jason Orendorff
mq: don't warn about ambiguous patch name when using patch index (issue1439)
r7568
if patch in self.series:
return patch
Chris Mason
mq: patch naming shortcuts...
r2696
Vadim Gelfer
mq: add join method
r2819 if not os.path.isfile(self.join(patch)):
mason@suse.com
Add mq extension
r1808 try:
sno = int(patch)
Matt Mackall
many, many trivial check-code fixups
r10282 except (ValueError, OverflowError):
Chris Mason
mq: patch naming shortcuts...
r2696 pass
else:
Jason Orendorff
mq: don't warn about ambiguous patch name when using patch index (issue1439)
r7568 if -len(self.series) <= sno < len(self.series):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 return self.series[sno]
Jason Orendorff
mq: don't warn about ambiguous patch name when using patch index (issue1439)
r7568
Chris Mason
mq: patch naming shortcuts...
r2696 if not strict:
Adrian Buehlmann
mq: rename partial_name to partialname
r14595 res = partialname(patch)
Chris Mason
mq: patch naming shortcuts...
r2696 if res:
return res
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 minus = patch.rfind(b'-')
Thomas Arendsen Hein
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
r3082 if minus >= 0:
Adrian Buehlmann
mq: rename partial_name to partialname
r14595 res = partialname(patch[:minus])
Chris Mason
mq: patch naming shortcuts...
r2696 if res:
i = self.series.index(res)
try:
Augie Fackler
formatting: blacken the codebase...
r43346 off = int(patch[minus + 1 :] or 1)
Matt Mackall
many, many trivial check-code fixups
r10282 except (ValueError, OverflowError):
Chris Mason
mq: patch naming shortcuts...
r2696 pass
else:
if i - off >= 0:
return self.series[i - off]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 plus = patch.rfind(b'+')
Thomas Arendsen Hein
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
r3082 if plus >= 0:
Adrian Buehlmann
mq: rename partial_name to partialname
r14595 res = partialname(patch[:plus])
Chris Mason
mq: patch naming shortcuts...
r2696 if res:
i = self.series.index(res)
try:
Augie Fackler
formatting: blacken the codebase...
r43346 off = int(patch[plus + 1 :] or 1)
Matt Mackall
many, many trivial check-code fixups
r10282 except (ValueError, OverflowError):
Chris Mason
mq: patch naming shortcuts...
r2696 pass
else:
if i + off < len(self.series):
return self.series[i + off]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"patch %s not in series") % patch)
mason@suse.com
Add mq extension
r1808
Augie Fackler
formatting: blacken the codebase...
r43346 def push(
self,
repo,
patch=None,
force=False,
list=False,
mergeq=None,
all=False,
move=False,
exact=False,
nobackup=False,
keepchanges=False,
):
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 self.checkkeepchanges(keepchanges, force)
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 diffopts = self.diffopts()
Bryan O'Sullivan
with: use context manager for wlock in qpush
r27828 with repo.wlock():
Kevin Bullock
mq: prefer a loop to a double-for list comprehension...
r20119 heads = []
Pulkit Goyal
branchcache: rename itervalues() to iterheads()...
r42169 for hs in repo.branchmap().iterheads():
Kevin Bullock
mq: prefer a loop to a double-for list comprehension...
r20119 heads.extend(hs)
Dirkjan Ochtman
mq: don't warn on qpush against a branch head
r10362 if not heads:
heads = [nullid]
Matt Mackall
misc: replace .parents()[0] with p1()
r13878 if repo.dirstate.p1() not in heads and not exact:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.status(_(b"(working directory not at a head)\n"))
Matt Mackall
mq: warn when applying a patch to somewhere other than tip
r6340
Adrian Buehlmann
mq: eliminate warning on qpush with empty series...
r8795 if not self.series:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b'no patches in series\n'))
Adrian Buehlmann
mq: eliminate warning on qpush with empty series...
r8795 return 0
Brendan Cully
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
r7398
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 # Suppose our series file is: A B C and the current 'top'
# patch is B. qpush C should be performed (moving forward)
# qpush B is a NOP (no change) qpush A is an error (can't
# go backwards with qpush)
if patch:
Mads Kiilerich
mq: cleanup of lookup - handling of None is not relevant...
r15257 patch = self.lookup(patch)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 info = self.isapplied(patch)
Afuna
mq: catch attempt to qpush to an earlier patch (issue2587)...
r13369 if info and info[0] >= len(self.applied) - 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(
_(b'qpush: %s is already at the top\n') % patch
)
Gilles Moris
mq: explicit exit code when patch is already on top
r11439 return 0
Afuna
mq: catch attempt to qpush to an earlier patch (issue2587)...
r13369
Brendan Cully
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
r7398 pushable, reason = self.pushable(patch)
Afuna
mq: catch attempt to qpush to an earlier patch (issue2587)...
r13369 if pushable:
Adrian Buehlmann
mq: rename series_end to seriesend
r14586 if self.series.index(patch) < self.seriesend():
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"cannot push to a previous patch: %s") % patch
Augie Fackler
formatting: blacken the codebase...
r43346 )
Afuna
mq: catch attempt to qpush to an earlier patch (issue2587)...
r13369 else:
Brendan Cully
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
r7398 if reason:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 reason = _(b'guarded by %s') % reason
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 reason = _(b'no matching guards')
self.ui.warn(
_(b"cannot push '%s' - %s\n") % (patch, reason)
)
Brendan Cully
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
r7398 return 1
elif all:
patch = self.series[-1]
if self.isapplied(patch):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b'all patches are currently applied\n'))
Brendan Cully
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
r7398 return 0
Ben Thomas
Modify qpush/qpop idempotent operations to return success...
r4100
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 # Following the above example, starting at 'top' of B:
# qpush should be performed (pushes C), but a subsequent
# qpush without an argument is an error (nothing to
# apply). This allows a loop of "...while hg qpush..." to
# work as it detects an error when done
Adrian Buehlmann
mq: rename series_end to seriesend
r14586 start = self.seriesend()
Brendan Cully
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
r7398 if start == len(self.series):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b'patch series already fully applied\n'))
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 return 1
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 if not force and not keepchanges:
Idan Kamara
backout of d04ba50e104d: allow to qpop/push with a dirty working copy...
r14732 self.checklocalchanges(repo, refresh=self.applied)
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Steve Losh
mq: add an '-e/--exact' option to qpush...
r13033 if exact:
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 if keepchanges:
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"cannot use --exact and --keep-changes together")
Augie Fackler
formatting: blacken the codebase...
r43346 )
Steve Losh
mq: add an '-e/--exact' option to qpush...
r13033 if move:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'cannot use --exact and --move together')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Steve Losh
mq: add an '-e/--exact' option to qpush...
r13033 if self.applied:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'cannot push --exact with applied patches')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Steve Losh
mq: add an '-e/--exact' option to qpush...
r13033 root = self.series[start]
target = patchheader(self.join(root), self.plainmode).parent
if not target:
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"%s does not have a parent recorded") % root
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not repo[target] == repo[b'.']:
Steve Losh
mq: add an '-e/--exact' option to qpush...
r13033 hg.update(repo, target)
Mads Kiilerich
mq: qpush --move, reorder patch series and apply only the patch...
r11064 if move:
Gilles Moris
qpush --move: move the right patch even with comment lines...
r11715 if not patch:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"please specify the patch to move"))
Mads Kiilerich
mq: fix qpush --move with comments in series file between applied patches...
r16303 for fullstart, rpn in enumerate(self.fullseries):
# strip markers for patch guards
if self.guard_re.split(rpn, 1)[0] == self.series[start]:
break
for i, rpn in enumerate(self.fullseries[fullstart:]):
Gilles Moris
qpush --move: move the right patch even with comment lines...
r11715 # strip markers for patch guards
if self.guard_re.split(rpn, 1)[0] == patch:
break
Mads Kiilerich
mq: fix qpush --move with comments in series file between applied patches...
r16303 index = fullstart + i
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 assert index < len(self.fullseries)
fullpatch = self.fullseries[index]
del self.fullseries[index]
Mads Kiilerich
mq: fix qpush --move with comments in series file between applied patches...
r16303 self.fullseries.insert(fullstart, fullpatch)
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.seriesdirty = True
self.applieddirty = True
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 if start > 0:
Adrian Buehlmann
mq: rename check_toppatch to checktoppatch
r14581 self.checktoppatch(repo)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 if not patch:
patch = self.series[start]
end = start + 1
Bryan O'Sullivan
MQ: tidy up if a qpush is interrupted....
r4418 else:
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 end = self.series.index(patch, start) + 1
Dirkjan Ochtman
mq: fix error message for qpush inexistent-patch (issue1702)
r8875
Patrick Mezard
mq: backup local changes in qpush --force...
r16634 tobackup = set()
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 if (not nobackup and force) or keepchanges:
Martin von Zweigbergk
strip: make checklocalchanges() return full status tuple...
r22925 status = self.checklocalchanges(repo, force=True)
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 if keepchanges:
Augie Fackler
formatting: blacken the codebase...
r43346 tobackup.update(
status.modified
+ status.added
+ status.removed
+ status.deleted
)
Patrick Mezard
mq: introduce qpush --check...
r16654 else:
Martin von Zweigbergk
strip: make checklocalchanges() return full status tuple...
r22925 tobackup.update(status.modified + status.added)
Patrick Mezard
mq: backup local changes in qpush --force...
r16634
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 s = self.series[start:end]
Benoit Boissinot
mq: all_files can be a set, remove dangerous default values
r10661 all_files = set()
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 try:
if mergeq:
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 ret = self.mergepatch(repo, mergeq, s, diffopts)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 else:
Augie Fackler
formatting: blacken the codebase...
r43346 ret = self.apply(
repo,
s,
list,
all_files=all_files,
tobackup=tobackup,
keepchanges=keepchanges,
)
Matt Mackall
mq: avoid silent failure when single patch doesn't apply (issue4604)...
r24826 except AbortNoCleanup:
raise
Augie Fackler
formatting: blacken the codebase...
r43346 except: # re-raises
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b'cleaning up working directory...\n'))
Augie Fackler
formatting: blacken the codebase...
r43346 cmdutil.revert(
self.ui,
repo,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo[b'.'],
Augie Fackler
formatting: blacken the codebase...
r43346 repo.dirstate.parents(),
no_backup=True,
)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 # only remove unknown files that we know we touched or
# created while patching
Benoit Boissinot
mq: avoid a (potentially expensive) repo.status(unknown=True) call
r10662 for f in all_files:
if f not in repo.dirstate:
Mads Kiilerich
vfs: use repo.wvfs.unlinkpath
r31309 repo.wvfs.unlinkpath(f, ignoremissing=True)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b'done\n'))
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 raise
Dirkjan Ochtman
mq: fix error message for qpush inexistent-patch (issue1702)
r8875
Benoit Allard
mq: fix traceback for qpush inexistant-patch with no patch applied
r9590 if not self.applied:
return ret[0]
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 top = self.applied[-1].name
Dirkjan Ochtman
mq: fix error message for qpush inexistent-patch (issue1702)
r8875 if ret[0] and ret[0] > 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b"errors during apply, please fix and qrefresh %s\n")
Dirkjan Ochtman
mq: fix error message for qpush inexistent-patch (issue1702)
r8875 self.ui.write(msg % top)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.write(_(b"now at: %s\n") % top)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 return ret[0]
Dirkjan Ochtman
mq: fix error message for qpush inexistent-patch (issue1702)
r8875
Augie Fackler
formatting: blacken the codebase...
r43346 def pop(
self,
repo,
patch=None,
force=False,
update=True,
all=False,
nobackup=False,
keepchanges=False,
):
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 self.checkkeepchanges(keepchanges, force)
Bryan O'Sullivan
with: use context manager for wlock in qpop
r27829 with repo.wlock():
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 if patch:
# index, rev, patch
info = self.isapplied(patch)
if not info:
patch = self.lookup(patch)
info = self.isapplied(patch)
if not info:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"patch %s is not applied") % patch)
Ben Thomas
Modify qpush/qpop idempotent operations to return success...
r4100
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if not self.applied:
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 # Allow qpop -a to work repeatedly,
# but not qpop without an argument
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"no patches applied\n"))
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 return not all
mason@suse.com
Add mq extension
r1808
Dirkjan Ochtman
mq: refactor the pop code to be more readable and allow more changes
r7620 if all:
start = 0
elif patch:
start = info[0] + 1
else:
start = len(self.applied) - 1
if start >= len(self.applied):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"qpop: %s is already at the top\n") % patch)
Dirkjan Ochtman
mq: refactor the pop code to be more readable and allow more changes
r7620 return
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 if not update:
parents = repo.dirstate.parents()
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 rr = [x.node for x in self.applied]
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 for p in parents:
if p in rr:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"qpop: forcing dirstate update\n"))
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 update = True
Dirkjan Ochtman
mq: allow qpop if popped revisions are not working dir parents
r7621 else:
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 parents = [p.node() for p in repo[None].parents()]
Augie Fackler
formatting: blacken the codebase...
r43346 update = any(
entry.node in parents for entry in self.applied[start:]
)
mason@suse.com
Add mq extension
r1808
Patrick Mezard
mq: backup local changes in qpop --force (issue3433)
r16633 tobackup = set()
if update:
Martin von Zweigbergk
strip: make checklocalchanges() return full status tuple...
r22925 s = self.checklocalchanges(repo, force=force or keepchanges)
Patrick Mezard
mq: introduce qpop --check...
r16653 if force:
if not nobackup:
Martin von Zweigbergk
strip: make checklocalchanges() return full status tuple...
r22925 tobackup.update(s.modified + s.added)
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 elif keepchanges:
Augie Fackler
formatting: blacken the codebase...
r43346 tobackup.update(
s.modified + s.added + s.removed + s.deleted
)
Idan Kamara
backout of d04ba50e104d: allow to qpop/push with a dirty working copy...
r14732
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = True
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 end = len(self.applied)
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 rev = self.applied[start].node
Alexis S. L. Carvalho
mq: pop/refresh: avoid losing revisions not managed by mq...
r5980
Dirkjan Ochtman
mq: allow qpop if popped revisions are not working dir parents
r7621 try:
heads = repo.changelog.heads(rev)
Matt Mackall
mq: remove import of revlog
r7639 except error.LookupError:
Dirkjan Ochtman
mq: allow qpop if popped revisions are not working dir parents
r7621 node = short(rev)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'trying to pop unknown node %s') % node)
Dirkjan Ochtman
mq: allow qpop if popped revisions are not working dir parents
r7621
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 if heads != [self.applied[-1].node]:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"popping would remove a revision not "
b"managed by this patch queue"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Pierre-Yves David
mq: prevent rewriting operation on public changeset...
r16048 if not repo[self.applied[-1].node].mutable():
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"popping would remove a public revision"),
hint=_(b"see 'hg help phases' for details"),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Alexis S. L. Carvalho
mq: pop/refresh: avoid losing revisions not managed by mq...
r5980
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 # we know there are no local changes, so we can make a simplified
# form of hg.update.
if update:
qp = self.qparents(repo, rev)
Benoit Boissinot
mq: simplify and use context API
r10663 ctx = repo[qp]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 m, a, r, d = repo.status(qp, b'.')[:4]
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 if d:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"deletions found between repo revs"))
Patrick Mezard
mq: backup local changes in qpop --force (issue3433)
r16633
Patrick Mezard
mq: introduce qpop --check...
r16653 tobackup = set(a + m + r) & tobackup
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 if keepchanges and tobackup:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"local changes found, qrefresh first"))
Patrick Mezard
mq: introduce qpop --check...
r16653 self.backup(repo, tobackup)
Augie Fackler
mq: migrate to context manager for changing dirstate parents
r32347 with repo.dirstate.parentchange():
for f in a:
repo.wvfs.unlinkpath(f, ignoremissing=True)
repo.dirstate.drop(f)
for f in m + r:
fctx = ctx[f]
repo.wwrite(f, fctx.data(), fctx.flags())
repo.dirstate.normal(f)
repo.setparents(qp, nullid)
Mads Kiilerich
mq: qpop now tells which patches are popped...
r9110 for patch in reversed(self.applied[start:end]):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.status(_(b"popping %s\n") % patch.name)
Alexis S. L. Carvalho
qpop/qrefresh: update self.applied before calling strip...
r5987 del self.applied[start:end]
Jordi Gutiérrez Hermoso
strip: remove -b/--backup codepaths...
r22057 strip(self.ui, repo, [rev], update=False, backup=False)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 for s, state in repo[b'.'].substate.items():
repo[b'.'].sub(s).get(state)
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if self.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.write(_(b"now at: %s\n") % self.applied[-1].name)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.write(_(b"patch queue now empty\n"))
mason@suse.com
Add mq extension
r1808
Brendan Cully
Fix test-mq-qdiff; add -I and -X options to qdiff
r2937 def diff(self, repo, pats, opts):
Adrian Buehlmann
mq: rename check_toppatch to checktoppatch
r14581 top, patch = self.checktoppatch(repo)
mason@suse.com
Add mq extension
r1808 if not top:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.write(_(b"no patches applied\n"))
mason@suse.com
Add mq extension
r1808 return
qp = self.qparents(repo, top)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'reverse'):
Yannick Gingras
diff: add --inverse option...
r9725 node1, node2 = None, qp
else:
node1, node2 = qp, None
Patrick Mezard
mq: qdiff with the same diff options than qrefresh (issue1350)...
r10191 diffopts = self.diffopts(opts, patch)
Patrick Mezard
mq: stop caching and sharing diff options...
r10184 self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts)
mason@suse.com
Add mq extension
r1808
Brendan Cully
allow qrefresh to take a list of files; closes #96.
r2938 def refresh(self, repo, pats=None, **opts):
Pulkit Goyal
py3: use pycompat.byteskwargs() to fix keyword arguments handling...
r36405 opts = pycompat.byteskwargs(opts)
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if not self.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.write(_(b"no patches applied\n"))
Bryan O'Sullivan
qrefresh: exit with status 1 if no patches applied.
r3004 return 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = opts.get(b'msg', b'').rstrip()
edit = opts.get(b'edit')
editform = opts.get(b'editform', b'mq.qrefresh')
newuser = opts.get(b'user')
newdate = opts.get(b'date')
Thomas Arendsen Hein
Fix bad behaviour when specifying an invalid date (issue700)...
r6139 if newdate:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 newdate = b'%d %d' % dateutil.parsedate(newdate)
mason@suse.com
Add mq extension
r1808 wlock = repo.wlock()
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 try:
Adrian Buehlmann
mq: rename check_toppatch to checktoppatch
r14581 self.checktoppatch(repo)
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 (top, patchfn) = (self.applied[-1].node, self.applied[-1].name)
Alexis S. L. Carvalho
mq: pop/refresh: avoid losing revisions not managed by mq...
r5980 if repo.changelog.heads(top) != [top]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(
_(b"cannot qrefresh a revision with children")
)
Pierre-Yves David
mq: prevent rewriting operation on public changeset...
r16048 if not repo[top].mutable():
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"cannot qrefresh public revision"),
hint=_(b"see 'hg help phases' for details"),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366
FUJIWARA Katsunori
mq: check subrepo synchronizations against parent of workdir or other appropriate context...
r17153 cparents = repo.changelog.parents(top)
patchparent = self.qparents(repo, top)
Martin von Zweigbergk
mq: avoid a silly conversion from binary nodeid to hex...
r37399 inclsubs = checksubstate(repo, patchparent)
FUJIWARA Katsunori
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh...
r17152 if inclsubs:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 substatestate = repo.dirstate[b'.hgsubstate']
Kevin Bullock
mq: update .hgsubstate if subrepos are clean (issue2499)...
r13174
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph = patchheader(self.join(patchfn), self.plainmode)
Augie Fackler
formatting: blacken the codebase...
r43346 diffopts = self.diffopts(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 {b'git': opts.get(b'git')}, patchfn, plain=True
Augie Fackler
formatting: blacken the codebase...
r43346 )
peter.arrenbrecht@gmail.com
mq: add --currentuser and --user options to qnew and qrefresh...
r5673 if newuser:
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 ph.setuser(newuser)
Peter Arrenbrecht
mq: add --currentdate and --date options to qnew and qrefresh...
r5788 if newdate:
Brendan Cully
mq: create patch header class to abstract header manipulation
r7399 ph.setdate(newdate)
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph.setparent(hex(patchparent))
Brendan Cully
mq: truncate patch just before rewriting header
r5180
Brendan Cully
mq: use atomictempfiles during patch refresh
r7400 # only commit new patch when write is complete
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 patchf = self.opener(patchfn, b'w', atomictemp=True)
Brendan Cully
mq: use atomictempfiles during patch refresh
r7400
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # update the dirstate in place, strip off the qtip commit
# and then commit.
#
# this should really read:
Martin Geisler
mq: fix comment to reflect change in efbee27415ab
r13005 # mm, dd, aa = repo.status(top, patchparent)[:3]
Mads Kiilerich
fix wording and not-completely-trivial spelling errors and bad docstrings
r17425 # but we do it backwards to take advantage of manifest/changelog
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # caching against the next repo.status call
Kevin Bullock
mq: clean up unused variable in qrefresh...
r13004 mm, aa, dd = repo.status(patchparent, top)[:3]
Martin von Zweigbergk
mq: slightly modernize by using context object...
r41945 ctx = repo[top]
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 aaa = aa[:]
Martin von Zweigbergk
cleanup: rename "matchfn" to "match" where obviously a matcher...
r34085 match1 = scmutil.match(repo[None], pats, opts)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # in short mode, we only diff the files included in the
# patch already plus specified files
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'short'):
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # if amending a patch, we start with existing
# files plus specified files - unfiltered
Martin von Zweigbergk
cleanup: rename "matchfn" to "match" where obviously a matcher...
r34085 match = scmutil.matchfiles(repo, mm + aa + dd + match1.files())
Mads Kiilerich
fix trivial spelling errors
r17424 # filter with include/exclude options
Martin von Zweigbergk
cleanup: rename "matchfn" to "match" where obviously a matcher...
r34085 match1 = scmutil.match(repo[None], opts=opts)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 else:
Matt Mackall
scmutil: drop aliases in cmdutil for match functions
r14322 match = scmutil.matchall(repo)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 m, a, r, d = repo.status(match=match)[:4]
Nicolas Dumazet
mq: use sets instead of lists for speed...
r12948 mm = set(mm)
aa = set(aa)
dd = set(dd)
mason@suse.com
Add mq extension
r1808
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # we might end up with files that were added between
# qtip and the dirstate parent, but then changed in the
# local dirstate. in this case, we want them to only
# show up in the added section
for x in m:
if x not in aa:
Nicolas Dumazet
mq: use sets instead of lists for speed...
r12948 mm.add(x)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # we might end up with files added by the local dirstate that
# were deleted by the patch. In this case, they should only
# show up in the changed section.
for x in a:
if x in dd:
Nicolas Dumazet
mq: use sets instead of lists for speed...
r12948 dd.remove(x)
mm.add(x)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 else:
Nicolas Dumazet
mq: use sets instead of lists for speed...
r12948 aa.add(x)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # make sure any files deleted in the local dirstate
# are not in the add or change column of the patch
forget = []
for x in d + r:
if x in aa:
Nicolas Dumazet
mq: use sets instead of lists for speed...
r12948 aa.remove(x)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 forget.append(x)
continue
Nicolas Dumazet
mq: use sets instead of lists for speed...
r12948 else:
mm.discard(x)
dd.add(x)
m = list(mm)
r = list(dd)
a = list(aa)
Durham Goode
mq: fix qrefresh case sensitivity (issue3271)...
r17888
Mads Kiilerich
spelling: fix some minor issues found by spell checker
r18644 # create 'match' that includes the files to be recommitted.
Martin von Zweigbergk
cleanup: rename "matchfn" to "match" where obviously a matcher...
r34085 # apply match1 via repo.status to ensure correct case handling.
cm, ca, cr, cd = repo.status(patchparent, match=match1)[:4]
Durham Goode
mq: fix qrefresh case sensitivity (issue3271)...
r17888 allmatches = set(cm + ca + cr + cd)
refreshchanges = [x.intersection(allmatches) for x in (mm, aa, dd)]
files = set(inclsubs)
for x in refreshchanges:
FUJIWARA Katsunori
localrepo: omit ".hgsubstate" also from "added" files...
r20827 files.update(x)
Durham Goode
mq: fix qrefresh case sensitivity (issue3271)...
r17888 match = scmutil.matchfiles(repo, files)
David Soria Parra
mq: update bookmarks during qrefresh...
r17730 bmlist = repo[top].bookmarks()
mason@suse.com
Add mq extension
r1808
FUJIWARA Katsunori
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)...
r24997 dsguard = None
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 dsguard = dirstateguard.dirstateguard(repo, b'mq.refresh')
Patrick Mezard
Merge with crew-stable
r10368 if diffopts.git or diffopts.upgrade:
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 copies = {}
for dst in a:
src = repo.dirstate.copied(dst)
# during qfold, the source file for copies may
# be removed. Treat this as a simple add.
if src is not None and src in repo.dirstate:
copies.setdefault(src, []).append(dst)
repo.dirstate.add(dst)
# remember the copies between patchparent and qtip
for dst in aaa:
Martin von Zweigbergk
mq: get copy source from context object instead of from filelog...
r41946 src = ctx[dst].copysource()
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 if src:
Martin von Zweigbergk
mq: get copy source from context object instead of from filelog...
r41946 copies.setdefault(src, []).extend(
Augie Fackler
formatting: blacken the codebase...
r43346 copies.get(dst, [])
)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 if dst in a:
Martin von Zweigbergk
mq: get copy source from context object instead of from filelog...
r41946 copies[src].append(dst)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # we can't copy a file created by the patch itself
if dst in copies:
del copies[dst]
Gregory Szorc
py3: define and use pycompat.iteritems() for hgext/...
r43375 for src, dsts in pycompat.iteritems(copies):
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 for dst in dsts:
repo.dirstate.copy(src, dst)
else:
for dst in a:
repo.dirstate.add(dst)
# Drop useless copy information
for f in list(repo.dirstate.copies()):
repo.dirstate.copy(None, f)
for f in r:
repo.dirstate.remove(f)
# if the patch excludes a modified file, mark that
# file with mtime=0 so status can see it.
mm = []
Gregory Szorc
global: use pycompat.xrange()...
r38806 for i in pycompat.xrange(len(m) - 1, -1, -1):
Martin von Zweigbergk
cleanup: rename "matchfn" to "match" where obviously a matcher...
r34085 if not match1(m[i]):
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 mm.append(m[i])
del m[i]
for f in m:
repo.dirstate.normal(f)
for f in mm:
repo.dirstate.normallookup(f)
for f in forget:
Matt Mackall
dirstate: rename forget to drop...
r14434 repo.dirstate.drop(f)
mason@suse.com
Add mq extension
r1808
Martin von Zweigbergk
mq: slightly modernize by using context object...
r41945 user = ph.user or ctx.user()
peter.arrenbrecht@gmail.com
mq: add --currentuser and --user options to qnew and qrefresh...
r5673
Pierre-Yves David
qrefresh: keep changeset phase during refresh
r16026 oldphase = repo[top].phase()
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 # assumes strip can roll itself back if interrupted
Patrick Mezard
localrepo: add setparents() to adjust dirstate copies (issue3407)...
r16551 repo.setparents(*cparents)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 self.applied.pop()
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = True
Jordi Gutiérrez Hermoso
strip: remove -b/--backup codepaths...
r22057 strip(self.ui, repo, [top], update=False, backup=False)
FUJIWARA Katsunori
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)...
r24997 dsguard.close()
finally:
release(dsguard)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366
try:
# might be nice to attempt to roll back strip after this
Patrick Mezard
mq: ensure all mq commits are made with secretcommit()...
r16100
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 defaultmsg = b"[mq]: %s" % patchfn
FUJIWARA Katsunori
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22003 editor = cmdutil.getcommiteditor(editform=editform)
FUJIWARA Katsunori
mq: fold the code paths to invoke editor into specific logic (qrefresh/qfold)...
r21422 if edit:
Augie Fackler
formatting: blacken the codebase...
r43346
FUJIWARA Katsunori
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qrefresh/qfold)...
r21423 def finishdesc(desc):
FUJIWARA Katsunori
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21236 if desc.rstrip():
ph.setmessage(desc)
return desc
return defaultmsg
Augie Fackler
formatting: blacken the codebase...
r43346
FUJIWARA Katsunori
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qrefresh/qfold)...
r21423 # i18n: this message is shown in editor with "HG: " prefix
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extramsg = _(b'Leave message empty to use default message.')
Augie Fackler
formatting: blacken the codebase...
r43346 editor = cmdutil.getcommiteditor(
finishdesc=finishdesc,
extramsg=extramsg,
editform=editform,
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message = msg or b"\n".join(ph.message)
FUJIWARA Katsunori
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21236 elif not msg:
FUJIWARA Katsunori
qrefresh: relocate message/patch-header handling to delay message determination...
r21235 if not ph.message:
FUJIWARA Katsunori
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21236 message = defaultmsg
FUJIWARA Katsunori
qrefresh: relocate message/patch-header handling to delay message determination...
r21235 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message = b"\n".join(ph.message)
FUJIWARA Katsunori
qrefresh: relocate message/patch-header handling to delay message determination...
r21235 else:
message = msg
ph.setmessage(msg)
Patrick Mezard
mq: ensure all mq commits are made with secretcommit()...
r16100 # Ensure we create a new changeset in the same phase than
# the old one.
Laurent Charignon
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write...
r27001 lock = tr = None
try:
lock = repo.lock()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 tr = repo.transaction(b'mq')
Augie Fackler
formatting: blacken the codebase...
r43346 n = newcommit(
repo,
oldphase,
message,
user,
ph.date,
match=match,
force=True,
editor=editor,
)
Laurent Charignon
mq: indentation change to make the next patch more legible...
r27000 # only write patch after a successful commit
c = [list(x) for x in refreshchanges]
if inclsubs:
self.putsubstate2changes(substatestate, c)
Augie Fackler
formatting: blacken the codebase...
r43346 chunks = patchmod.diff(
repo, patchparent, changes=c, opts=diffopts
)
Pulkit Goyal
py3: use bytes instead of str...
r35966 comments = bytes(ph)
Laurent Charignon
mq: indentation change to make the next patch more legible...
r27000 if comments:
patchf.write(comments)
for chunk in chunks:
patchf.write(chunk)
patchf.close()
marks = repo._bookmarks
Boris Feld
bookmark: use 'applychanges' in the mq extension
r33489 marks.applychanges(repo, tr, [(bm, n) for bm in bmlist])
Laurent Charignon
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write...
r27001 tr.close()
Laurent Charignon
mq: indentation change to make the next patch more legible...
r27000
self.applied.append(statusentry(n, patchfn))
Laurent Charignon
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write...
r27001 finally:
Pierre-Yves David
mq: release lock after transaction in qrefresh...
r30070 lockmod.release(tr, lock)
Augie Fackler
formatting: blacken the codebase...
r43346 except: # re-raises
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 ctx = repo[cparents[0]]
repo.dirstate.rebuild(ctx.node(), ctx.manifest())
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 self.savedirty()
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'qrefresh interrupted while patch was popped! '
b'(revert --all, qpush to recover)\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Dan Villiom Podlaski Christiansen
mq: remove qrefresh slow path (issue2025)...
r10366 raise
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 finally:
Ronny Pfannschmidt
switch lock releasing in the extensions from gc to explicit
r8112 wlock.release()
Brendan Cully
mq: recover more gracefully from interrupted qrefresh (issue1216)
r7401 self.removeundo(repo)
mason@suse.com
Add mq extension
r1808
def init(self, repo, create=False):
Alexis S. L. Carvalho
mq: qinit -c creates a repo even after a regular qinit
r4071 if not create and os.path.isdir(self.path):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"patch queue directory already exists"))
Alexis S. L. Carvalho
mq: qinit -c creates a repo even after a regular qinit
r4071 try:
os.mkdir(self.path)
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except OSError as inst:
Alexis S. L. Carvalho
mq: qinit -c creates a repo even after a regular qinit
r4071 if inst.errno != errno.EEXIST or not create:
raise
mason@suse.com
Add mq extension
r1808 if create:
return self.qrepo(create=True)
def unapplied(self, repo, patch=None):
if patch and patch not in self.series:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"patch %s is not in series file") % patch)
mason@suse.com
Add mq extension
r1808 if not patch:
Adrian Buehlmann
mq: rename series_end to seriesend
r14586 start = self.seriesend()
mason@suse.com
Add mq extension
r1808 else:
start = self.series.index(patch) + 1
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 unapplied = []
Gregory Szorc
global: use pycompat.xrange()...
r38806 for i in pycompat.xrange(start, len(self.series)):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 pushable, reason = self.pushable(i)
if pushable:
unapplied.append((i, self.series[i]))
Adrian Buehlmann
mq: rename explain_pushable to explainpushable
r14579 self.explainpushable(i)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 return unapplied
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Augie Fackler
formatting: blacken the codebase...
r43346 def qseries(
self,
repo,
missing=None,
start=0,
length=None,
status=None,
summary=False,
):
Brodie Rao
qseries: make use of output labeling
r10824 def displayname(pfx, patchname, state):
Dan Villiom Podlaski Christiansen
mq: only highlight/label patch name for qseries....
r10932 if pfx:
self.ui.write(pfx)
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 if summary:
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph = patchheader(self.join(patchname), self.plainmode)
Jordi Gutiérrez Hermoso
style: kill ersatz if-else ternary operators...
r24306 if ph.message:
msg = ph.message[0]
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = b''
Jordi Gutiérrez Hermoso
style: kill ersatz if-else ternary operators...
r24306
Dan Villiom Podlaski Christiansen
mq: use ui.formatted() instead of ui.plain().
r11327 if self.ui.formatted():
Augie Fackler
termwidth: move to ui.ui from util
r12689 width = self.ui.termwidth() - len(pfx) - len(patchname) - 2
Dan Villiom Podlaski Christiansen
qseries: don't truncate the patch name (issue1912)...
r9874 if width > 0:
Yuya Nishihara
stringutil: bulk-replace call sites to point to new module...
r37102 msg = stringutil.ellipsis(msg, width)
Dan Villiom Podlaski Christiansen
qseries: don't truncate the patch name (issue1912)...
r9874 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = b''
self.ui.write(patchname, label=b'qseries.' + state)
self.ui.write(b': ')
self.ui.write(msg, label=b'qseries.message.' + state)
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.write(patchname, label=b'qseries.' + state)
self.ui.write(b'\n')
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183
Martin von Zweigbergk
cleanup: use set literals where possible...
r42224 applied = {p.name for p in self.applied}
Thomas Arendsen Hein
Simplified qseries and hg qapplied to fix some bugs caused by optimization:...
r4239 if length is None:
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 length = len(self.series) - start
mason@suse.com
Add mq extension
r1808 if not missing:
Dan Villiom Podlaski Christiansen
mq: align columns in verbose qseries output.
r9016 if self.ui.verbose:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 idxwidth = len(b"%d" % (start + length - 1))
Gregory Szorc
global: use pycompat.xrange()...
r38806 for i in pycompat.xrange(start, start + length):
Thomas Arendsen Hein
Simplified qseries and hg qapplied to fix some bugs caused by optimization:...
r4239 patch = self.series[i]
if patch in applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 char, state = b'A', b'applied'
Thomas Arendsen Hein
Simplified qseries and hg qapplied to fix some bugs caused by optimization:...
r4239 elif self.pushable(i)[0]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 char, state = b'U', b'unapplied'
Thomas Arendsen Hein
Simplified qseries and hg qapplied to fix some bugs caused by optimization:...
r4239 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 char, state = b'G', b'guarded'
pfx = b''
mason@suse.com
Add mq extension
r1808 if self.ui.verbose:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pfx = b'%*d %s ' % (idxwidth, i, char)
Brodie Rao
qseries: make use of output labeling
r10824 elif status and status != char:
Thomas Arendsen Hein
Fix issue443: inconsistent output of "hg qunapplied -v"...
r4238 continue
Brodie Rao
qseries: make use of output labeling
r10824 displayname(pfx, patch, state)
mason@suse.com
Add mq extension
r1808 else:
Benoit Boissinot
mq: fix variables shadowing builtin
r2794 msng_list = []
mason@suse.com
Add mq extension
r1808 for root, dirs, files in os.walk(self.path):
Augie Fackler
formatting: blacken the codebase...
r43346 d = root[len(self.path) + 1 :]
mason@suse.com
Add mq extension
r1808 for f in files:
fl = os.path.join(d, f)
Augie Fackler
formatting: blacken the codebase...
r43346 if (
fl not in self.series
and fl
not in (
self.statuspath,
self.seriespath,
self.guardspath,
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 and not fl.startswith(b'.')
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Benoit Boissinot
mq: fix variables shadowing builtin
r2794 msng_list.append(fl)
Matt Mackall
replace util.sort with sorted built-in...
r8209 for x in sorted(msng_list):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pfx = self.ui.verbose and b'D ' or b''
displayname(pfx, x, b'missing')
mason@suse.com
Add mq extension
r1808
def issaveline(self, l):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if l.name == b'.hg.patches.save.line':
mason@suse.com
Add mq extension
r1808 return True
def qrepo(self, create=False):
Simon Heimberg
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)...
r19064 ui = self.baseui.copy()
Yuya Nishihara
mq: copy pager attributes back to qrepo.ui...
r34919 # copy back attributes set by ui.pager()
if self.ui.pageractive and not ui.pageractive:
ui.pageractive = self.ui.pageractive
# internal config: ui.formatted
Augie Fackler
formatting: blacken the codebase...
r43346 ui.setconfig(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'ui',
b'formatted',
self.ui.config(b'ui', b'formatted'),
b'mqpager',
Augie Fackler
formatting: blacken the codebase...
r43346 )
ui.setconfig(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'ui',
b'interactive',
self.ui.config(b'ui', b'interactive'),
b'mqpager',
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if create or os.path.isdir(self.join(b".hg")):
Mads Kiilerich
mq: don't inherit default and default-push paths with --mq (issue2333)...
r11965 return hg.repository(ui, path=self.path, create=create)
mason@suse.com
Add mq extension
r1808
def restore(self, repo, rev, delete=None, qupdate=None):
Benoit Boissinot
mq: use context API
r10681 desc = repo[rev].description().strip()
mason@suse.com
Add mq extension
r1808 lines = desc.splitlines()
i = 0
datastart = None
series = []
applied = []
qpp = None
Martin Geisler
replace "i in range(len(xs))" with "i, x in enumerate(xs)"...
r8632 for i, line in enumerate(lines):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if line == b'Patch Data:':
mason@suse.com
Add mq extension
r1808 datastart = i + 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif line.startswith(b'Dirstate:'):
Martin Geisler
replace "i in range(len(xs))" with "i, x in enumerate(xs)"...
r8632 l = line.rstrip()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 l = l[10:].split(b' ')
Matt Mackall
many, many trivial check-code fixups
r10282 qpp = [bin(x) for x in l]
Martin Geisler
code style: prefer 'is' and 'is not' tests with singletons
r13031 elif datastart is not None:
Martin Geisler
replace "i in range(len(xs))" with "i, x in enumerate(xs)"...
r8632 l = line.rstrip()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 n, name = l.split(b':', 1)
Benoit Boissinot
mq: qsave creates entries with the left part empty (':patchname')
r10683 if n:
applied.append(statusentry(bin(n), name))
Brendan Cully
mq: don't write applied patches into series twice in restore
r3185 else:
Benoit Boissinot
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
r10682 series.append(l)
Martin Geisler
use 'x is None' instead of 'x == None'...
r8527 if datastart is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"no saved patch data found\n"))
mason@suse.com
Add mq extension
r1808 return 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"restoring status: %s\n") % lines[0])
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 self.fullseries = series
mason@suse.com
Add mq extension
r1808 self.applied = applied
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.seriesdirty = True
self.applieddirty = True
mason@suse.com
Add mq extension
r1808 heads = repo.changelog.heads()
if delete:
if rev not in heads:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"save entry has children, leaving it alone\n"))
mason@suse.com
Add mq extension
r1808 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"removing save entry %s\n") % short(rev))
mason@suse.com
Add mq extension
r1808 pp = repo.dirstate.parents()
if rev in pp:
update = True
else:
update = False
Jordi Gutiérrez Hermoso
strip: remove -b/--backup codepaths...
r22057 strip(self.ui, repo, [rev], update=update, backup=False)
mason@suse.com
Add mq extension
r1808 if qpp:
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"saved queue repository parents: %s %s\n")
Augie Fackler
formatting: blacken the codebase...
r43346 % (short(qpp[0]), short(qpp[1]))
)
mason@suse.com
Add mq extension
r1808 if qupdate:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.status(_(b"updating queue directory\n"))
mason@suse.com
Add mq extension
r1808 r = self.qrepo()
if not r:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"unable to load queue repository\n"))
mason@suse.com
Add mq extension
r1808 return 1
Matt Mackall
Introduce update helper functions: update, merge, clean, and revert
r2808 hg.clean(r, qpp[0])
mason@suse.com
Add mq extension
r1808
def save(self, repo, msg=None):
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if not self.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"save: no patches applied, exiting\n"))
mason@suse.com
Add mq extension
r1808 return 1
if self.issaveline(self.applied[-1]):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"status is already saved\n"))
mason@suse.com
Add mq extension
r1808 return 1
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
mason@suse.com
Add mq extension
r1808 if not msg:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b"hg patches saved state")
mason@suse.com
Add mq extension
r1808 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = b"hg patches: " + msg.rstrip(b'\r\n')
mason@suse.com
Add mq extension
r1808 r = self.qrepo()
if r:
pp = r.dirstate.parents()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg += b"\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1]))
msg += b"\n\nPatch Data:\n"
msg += b''.join(b'%s\n' % x for x in self.applied)
msg += b''.join(b':%s\n' % x for x in self.fullseries)
Benoit Boissinot
mq: simplify commit message generation
r10679 n = repo.commit(msg, force=True)
mason@suse.com
Add mq extension
r1808 if not n:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"repo commit failed\n"))
mason@suse.com
Add mq extension
r1808 return 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.applied.append(statusentry(n, b'.hg.patches.save.line'))
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 self.applieddirty = True
Matt Mackall
Merge with -stable, fix small test failure
r4209 self.removeundo(repo)
mason@suse.com
Add mq extension
r1808
Adrian Buehlmann
mq: rename full_series_end to fullseriesend
r14585 def fullseriesend(self):
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if self.applied:
Brendan Cully
Use StatusEntry class instead of repeated status line parsing....
r2780 p = self.applied[-1].name
Adrian Buehlmann
mq: rename find_series to findseries
r14574 end = self.findseries(p)
Martin Geisler
use 'x is None' instead of 'x == None'...
r8527 if end is None:
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 return len(self.fullseries)
Chris Mason
mq: fix qnew and qimport to deal with series file comments...
r2698 return end + 1
return 0
Adrian Buehlmann
mq: rename series_end to seriesend
r14586 def seriesend(self, all_patches=False):
Patrick Mezard
mq: fix qtop failure when the series ends with guarded patches.
r4406 """If all_patches is False, return the index of the next pushable patch
in the series, or the series length. If all_patches is True, return the
index of the first patch past the last applied one.
"""
mason@suse.com
Add mq extension
r1808 end = 0
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
mq: rename next() to nextpatch() to avoid confusing a future check-code patch...
r19500 def nextpatch(start):
Benoit Boissinot
mq: use xrange/enumerate instead of += 1
r10687 if all_patches or start >= len(self.series):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 return start
Gregory Szorc
global: use pycompat.xrange()...
r38806 for i in pycompat.xrange(start, len(self.series)):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 p, reason = self.pushable(i)
if p:
Patrick Mezard
mq: fix qnext when all remaining patches are guarded...
r16063 return i
Adrian Buehlmann
mq: rename explain_pushable to explainpushable
r14579 self.explainpushable(i)
Patrick Mezard
mq: fix qnext when all remaining patches are guarded...
r16063 return len(self.series)
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
mq: don't use len(list) unless necessary
r10686 if self.applied:
Brendan Cully
Use StatusEntry class instead of repeated status line parsing....
r2780 p = self.applied[-1].name
mason@suse.com
Add mq extension
r1808 try:
end = self.series.index(p)
except ValueError:
return 0
Augie Fackler
mq: rename next() to nextpatch() to avoid confusing a future check-code patch...
r19500 return nextpatch(end + 1)
return nextpatch(end)
mason@suse.com
Add mq extension
r1808
def appliedname(self, index):
Brendan Cully
Use StatusEntry class instead of repeated status line parsing....
r2780 pname = self.applied[index].name
mason@suse.com
Add mq extension
r1808 if not self.ui.verbose:
"Mathieu Clabaut "
mq: uniform verbose display of patche[s]....
r2677 p = pname
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 p = (b"%d" % self.series.index(pname)) + b" " + pname
mason@suse.com
Add mq extension
r1808 return p
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Augie Fackler
formatting: blacken the codebase...
r43346 def qimport(
self,
repo,
files,
patchname=None,
rev=None,
existing=None,
force=None,
git=False,
):
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 def checkseries(patchname):
if patchname in self.series:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'patch %s is already in the series file') % patchname
Augie Fackler
formatting: blacken the codebase...
r43346 )
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141
if rev:
if files:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'option "-r" not valid when importing files')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 rev = scmutil.revrange(repo, rev)
Alejandro Santos
compat: use 'key' argument instead of 'cmp' when sorting a list
r9032 rev.sort(reverse=True)
Thomas Arendsen Hein
mq: abort if no files or revisions are specified for qimport
r16987 elif not files:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no files or revisions specified'))
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 if (len(files) > 1 or len(rev) > 1) and patchname:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'option "-n" not valid when importing multiple patches')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Patrick Mezard
mq: make qimport --push push all imported patches (issue3130)...
r16119 imported = []
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 if rev:
# If mq patches are applied, we can only import revisions
# that form a linear path to qbase.
# Otherwise, they should form a linear path to a head.
Pierre-Yves David
qimport: use `first` and `last` instead of direct indexing...
r22821 heads = repo.changelog.heads(repo.changelog.node(rev.first()))
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 if len(heads) > 1:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'revision %d is the root of more than one branch')
Augie Fackler
formatting: blacken the codebase...
r43346 % rev.last()
)
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 if self.applied:
Pierre-Yves David
qimport: use `first` and `last` instead of direct indexing...
r22821 base = repo.changelog.node(rev.first())
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 if base in [n.node for n in self.applied]:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'revision %d is already managed') % rev.first()
Augie Fackler
formatting: blacken the codebase...
r43346 )
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 if heads != [self.applied[-1].node]:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'revision %d is not the parent of the queue')
Augie Fackler
formatting: blacken the codebase...
r43346 % rev.first()
)
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 base = repo.changelog.rev(self.applied[0].node)
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 lastparent = repo.changelog.parentrevs(base)[0]
else:
Pierre-Yves David
qimport: use `first` and `last` instead of direct indexing...
r22821 if heads != [repo.changelog.node(rev.first())]:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'revision %d has unmanaged children') % rev.first()
Augie Fackler
formatting: blacken the codebase...
r43346 )
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 lastparent = None
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 diffopts = self.diffopts({b'git': git})
with repo.transaction(b'qimport') as tr:
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049 for r in rev:
if not repo[r].mutable():
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'revision %d is not mutable') % r,
hint=_(b"see 'hg help phases' " b'for details'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049 p1, p2 = repo.changelog.parentrevs(r)
n = repo.changelog.node(r)
if p2 != nullrev:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'cannot import merge revision %d') % r
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049 if lastparent and lastparent != r:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'revision %d is not the parent of %d')
Augie Fackler
formatting: blacken the codebase...
r43346 % (r, lastparent)
)
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049 lastparent = p1
if not patchname:
Mads Kiilerich
mq: refactor makepatchname into class method
r27918 patchname = self.makepatchname(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo[r].description().split(b'\n', 1)[0],
b'%d.diff' % r,
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049 checkseries(patchname)
self.checkpatchname(patchname, force)
self.fullseries.insert(0, patchname)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 with self.opener(patchname, b"w") as fp:
Yuya Nishihara
export: extract function to write patch to file object (API)...
r37621 cmdutil.exportfile(repo, [n], fp, opts=diffopts)
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049
se = statusentry(n, patchname)
self.applied.insert(0, se)
self.added.append(patchname)
imported.append(patchname)
patchname = None
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if rev and repo.ui.configbool(b'mq', b'secret'):
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049 # if we added anything with --rev, move the secret root
Pierre-Yves David
phase: add a transaction argument to retractboundary...
r22070 phases.retractboundary(repo, tr, phases.secret, [n])
Pierre-Yves David
mq: wrap qimport phase movement in a transaction...
r22049 self.parseseries()
self.applieddirty = True
self.seriesdirty = True
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141
Benoit Boissinot
mq: use xrange/enumerate instead of += 1
r10687 for i, filename in enumerate(files):
mason@suse.com
Add mq extension
r1808 if existing:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if filename == b'-':
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'-e is incompatible with import from -')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Nicolas Dumazet
mq: support "qimport --existing --name renametothis thatexistingpatch"...
r11699 filename = normname(filename)
Adrian Buehlmann
mq: rename check_reserved_name to checkreservedname
r14584 self.checkreservedname(filename)
Matt Mackall
mq: fix qimport url check
r20402 if util.url(filename).islocal():
Matt Mackall
qimport: allow importing URLs
r20394 originpath = self.join(filename)
if not os.path.isfile(originpath):
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"patch %s does not exist") % filename
Augie Fackler
formatting: blacken the codebase...
r43346 )
Nicolas Dumazet
mq: support "qimport --existing --name renametothis thatexistingpatch"...
r11699
if patchname:
Idan Kamara
mq: use checkpatchname...
r14423 self.checkpatchname(patchname, force)
Nicolas Dumazet
mq: support "qimport --existing --name renametothis thatexistingpatch"...
r11699
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.write(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'renaming %s to %s\n') % (filename, patchname)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Patrick Mezard
mq: fix qimport --name --existing --force on win32...
r11701 util.rename(originpath, self.join(patchname))
Nicolas Dumazet
mq: support "qimport --existing --name renametothis thatexistingpatch"...
r11699 else:
patchname = filename
mason@suse.com
Add mq extension
r1808 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if filename == b'-' and not patchname:
raise error.Abort(
_(b'need --name to import a patch from -')
)
Idan Kamara
mq: check patch name is valid before reading imported file
r14395 elif not patchname:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 patchname = normname(
os.path.basename(filename.rstrip(b'/'))
)
Idan Kamara
mq: use checkpatchname...
r14423 self.checkpatchname(patchname, force)
mason@suse.com
Add mq extension
r1808 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if filename == b'-':
Idan Kamara
mq: use ui.fin when importing patch from '-'
r14636 text = self.ui.fin.read()
Brendan Cully
mq: support qimport -
r3547 else:
Siddharth Agarwal
url: use open and not url.open for local files (issue3624)
r17887 fp = hg.openpath(self.ui, filename)
Dan Villiom Podlaski Christiansen
explicitly close files...
r13400 text = fp.read()
fp.close()
Benoit Boissinot
Catch both IOError and OSError, fix regression introduced by 8046f0a070a6
r7421 except (OSError, IOError):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"unable to read file %s") % filename)
patchf = self.opener(patchname, b"w")
mason@suse.com
Add mq extension
r1808 patchf.write(text)
Dan Villiom Podlaski Christiansen
explicitly close files...
r13400 patchf.close()
Brendan Cully
mq: make qimport -f work properly. Closes issue1255....
r7160 if not force:
checkseries(patchname)
if patchname not in self.series:
Adrian Buehlmann
mq: rename full_series_end to fullseriesend
r14585 index = self.fullseriesend() + i
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 self.fullseries[index:index] = [patchname]
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 self.parseseries()
Adrian Buehlmann
mq: rename series_dirty to seriesdirty
r14593 self.seriesdirty = True
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.ui.warn(_(b"adding %s to series file\n") % patchname)
Vishakh H
mq: qimport cleanup on fail (issue2214)...
r11462 self.added.append(patchname)
Patrick Mezard
mq: make qimport --push push all imported patches (issue3130)...
r16119 imported.append(patchname)
Brendan Cully
qimport: rename patch to patchname to avoid shadowing module
r3133 patchname = None
mason@suse.com
Add mq extension
r1808
André Sintzoff
mq: remove undo after a qimport
r13409 self.removeundo(repo)
Patrick Mezard
mq: make qimport --push push all imported patches (issue3130)...
r16119 return imported
André Sintzoff
mq: remove undo after a qimport
r13409
Augie Fackler
formatting: blacken the codebase...
r43346
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 def fixkeepchangesopts(ui, opts):
Augie Fackler
formatting: blacken the codebase...
r43346 if (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 not ui.configbool(b'mq', b'keepchanges')
or opts.get(b'force')
or opts.get(b'exact')
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Patrick Mezard
mq: introduce mq.check setting...
r16656 return opts
opts = dict(opts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 opts[b'keep_changes'] = True
Patrick Mezard
mq: introduce mq.check setting...
r16656 return opts
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qdelete|qremove|qrm",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'k', b'keep', None, _(b'keep patch file')),
(
b'r',
b'rev',
[],
_(b'stop managing a revision (DEPRECATED)'),
_(b'REV'),
),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qdelete [-k] [PATCH]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Brendan Cully
mq: change qdel --forget to --rev; accept any revision symbol
r3373 def delete(ui, repo, *patches, **opts):
Brendan Cully
Allow qdel to delete multiple patches.
r2905 """remove patches from queue
Brendan Cully
Add -f option to qdelete, to remove patch file.
r2752
Olav Reinert
mq: Document that qdel requires exact patch identifiers
r15798 The patches must not be applied, and at least one patch is required. Exact
patch identifiers must be given. With -k/--keep, the patch files are
preserved in the patch directory.
Cédric Duval
mq: no longer mention the deprecated qdelete's --revision option...
r8904
To stop managing a patch and move it into permanent history,
Martin Geisler
mq: use hg reST role some more
r11307 use the :hg:`qfinish` command."""
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
Pulkit Goyal
py3: use pycompat.byteskwargs() to convert opts keys to bytes...
r36295 q.delete(repo, patches, pycompat.byteskwargs(opts))
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
mason@suse.com
Add mq extension
r1808 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qapplied",
[(b'1', b'last', None, _(b'show only the preceding applied patch'))]
Augie Fackler
formatting: blacken the codebase...
r43346 + seriesopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qapplied [-1] [-s] [PATCH]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def applied(ui, repo, patch=None, **opts):
Erik Zielke
mq: added return 0 on success...
r12538 """print the patches already applied
Returns 0 on success."""
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 q = repo.mq
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 if patch:
if patch not in q.series:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"patch %s is not in series file") % patch)
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 end = q.series.index(patch) + 1
else:
Adrian Buehlmann
mq: rename series_end to seriesend
r14586 end = q.seriesend(True)
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'last') and not end:
ui.write(_(b"no patches applied\n"))
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364 return 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'last') and end == 1:
ui.write(_(b"only one patch applied\n"))
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364 return 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'last'):
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364 start = end - 2
end = 1
else:
start = 0
Augie Fackler
formatting: blacken the codebase...
r43346 q.qseries(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo, length=end, start=start, status=b'A', summary=opts.get(b'summary')
Augie Fackler
formatting: blacken the codebase...
r43346 )
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qunapplied",
[(b'1', b'first', None, _(b'show only the first patch'))] + seriesopts,
_(b'hg qunapplied [-1] [-s] [PATCH]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def unapplied(ui, repo, patch=None, **opts):
Erik Zielke
mq: added return 0 on success...
r12538 """print the patches not yet applied
Returns 0 on success."""
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 q = repo.mq
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 if patch:
if patch not in q.series:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"patch %s is not in series file") % patch)
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 start = q.series.index(patch) + 1
else:
Adrian Buehlmann
mq: rename series_end to seriesend
r14586 start = q.seriesend(True)
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if start == len(q.series) and opts.get(b'first'):
ui.write(_(b"all patches applied\n"))
Dirkjan Ochtman
mq: add options to qapplied/qunapplied to act like qprev/qnext
r9364 return 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'first'):
Jordi Gutiérrez Hermoso
style: kill ersatz if-else ternary operators...
r24306 length = 1
else:
length = None
Augie Fackler
formatting: blacken the codebase...
r43346 q.qseries(
repo,
start=start,
length=length,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 status=b'U',
summary=opts.get(b'summary'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qimport",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'e', b'existing', None, _(b'import file in patch directory')),
(b'n', b'name', b'', _(b'name of patch file'), _(b'NAME')),
(b'f', b'force', None, _(b'overwrite existing files')),
Augie Fackler
formatting: blacken the codebase...
r43346 (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'r',
b'rev',
Augie Fackler
formatting: blacken the codebase...
r43346 [],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'place existing revisions under mq control'),
_(b'REV'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'g', b'git', None, _(b'use git extended diff format')),
(b'P', b'push', None, _(b'qpush after importing')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_IMPORT_EXPORT,
)
mason@suse.com
Add mq extension
r1808 def qimport(ui, repo, *filename, **opts):
Matt Mackall
mq: expand qimport summary
r16152 """import a patch or existing changeset
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 The patch is inserted into the series after the last applied
patch. If no patches have been applied, qimport prepends the patch
Adrian Buehlmann
mq: qimport: explain insertion point in doc string
r6634 to the series.
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 The patch will have the same name as its source file unless you
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 give it a new one with -n/--name.
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 You can register an existing patch inside the patch directory with
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 the -e/--existing flag.
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 With -f/--force, an existing patch of the same name will be
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 overwritten.
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 An existing changeset may be placed under mq control with -r/--rev
Matt Mackall
mq: remove reference to tip
r19397 (e.g. qimport --rev . -n patch will place the current revision
under mq control). With -g/--git, patches imported with --rev will
use the git diff format. See the diffs help topic for information
on why this is important for preserving rename/copy information
and permission changes. Use :hg:`qfinish` to remove changesets
from mq control.
David Frey
Update qimport help explaining how to read a patch from stdin (Issue371)
r8075
To import a patch from standard input, pass - as the patch file.
When importing from standard input, a patch name must be specified
using the --name flag.
Nicolas Dumazet
mq: document possible combination of -e and -n for qimport
r11700
Nicolas Dumazet
mq: correct qimport documentation
r11706 To import an existing patch while renaming it::
Nicolas Dumazet
mq: document possible combination of -e and -n for qimport
r11700
hg qimport -e existing-patch -n new-name
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 if import succeeded.
Brendan Cully
mq: Add --rev argument to qimport, to adopt existing changesets.
r3141 """
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Augie Fackler
formatting: blacken the codebase...
r43346 with repo.lock(): # cause this may move phase
Pierre-Yves David
qimport: when mq.secret=True set qimported revision as secret
r16027 q = repo.mq
try:
Patrick Mezard
mq: make qimport --push push all imported patches (issue3130)...
r16119 imported = q.qimport(
Augie Fackler
formatting: blacken the codebase...
r43346 repo,
filename,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 patchname=opts.get(b'name'),
existing=opts.get(b'existing'),
force=opts.get(b'force'),
rev=opts.get(b'rev'),
git=opts.get(b'git'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
qimport: when mq.secret=True set qimported revision as secret
r16027 finally:
q.savedirty()
Pierre-Yves David
mq: qimport need wlock for --push - do that after releasing lock...
r16681
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if imported and opts.get(b'push') and not opts.get(b'rev'):
Pierre-Yves David
mq: qimport need wlock for --push - do that after releasing lock...
r16681 return q.push(repo, imported[-1])
mason@suse.com
Add mq extension
r1808 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
Brendan Cully
mq: unify implementation of qinit and init -Q
r10480 def qinit(ui, repo, create):
"""initialize a new queue repository
Brendan Cully
Add more verbose help text to mq commands.
r2754
Brendan Cully
mq: unify implementation of qinit and init -Q
r10480 This command also creates a series file for ordering patches, and
an mq-specific .hgignore file in the queue repository, to exclude
Erik Zielke
mq: added return 0 on success...
r12538 the status and guards files (these contain mostly transient state).
Returns 0 if initialization succeeded."""
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
Brendan Cully
mq: unify implementation of qinit and init -Q
r10480 r = q.init(repo, create)
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
mason@suse.com
Add mq extension
r1808 if r:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not os.path.exists(r.wjoin(b'.hgignore')):
fp = r.wvfs(b'.hgignore', b'w')
fp.write(b'^\\.hg\n')
fp.write(b'^\\.mq\n')
fp.write(b'syntax: glob\n')
fp.write(b'status\n')
fp.write(b'guards\n')
Alexis S. L. Carvalho
mq: qinit -c creates a repo even after a regular qinit
r4071 fp.close()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not os.path.exists(r.wjoin(b'series')):
r.wvfs(b'series', b'w').close()
r[None].add([b'.hgignore', b'series'])
Alexis S. L. Carvalho
mq: qinit -c creates a repo even after a regular qinit
r4071 commands.add(ui, r)
mason@suse.com
Add mq extension
r1808 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qinit",
[(b'c', b'create-repo', None, _(b'create queue repository'))],
_(b'hg qinit [-c]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_REPO_CREATION,
helpbasic=True,
)
Brendan Cully
mq: unify implementation of qinit and init -Q
r10480 def init(ui, repo, **opts):
"""init a new queue repository (DEPRECATED)
The queue repository is unversioned by default. If
-c/--create-repo is specified, qinit will create a separate nested
repository for patches (qinit -c may also be run later to convert
an unversioned patch repository into a versioned one). You can use
qcommit to commit changes to this queue repository.
This command is deprecated. Without -c, it's implied by other relevant
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 commands. With -c, use :hg:`init --mq` instead."""
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 return qinit(ui, repo, create=opts.get(r'create_repo'))
Brendan Cully
mq: unify implementation of qinit and init -Q
r10480
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qclone",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'pull', None, _(b'use pull protocol to copy metadata')),
Augie Fackler
formatting: blacken the codebase...
r43346 (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'U',
b'noupdate',
Augie Fackler
formatting: blacken the codebase...
r43346 None,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'do not update the new working directories'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'',
b'uncompressed',
None,
_(b'use uncompressed transfer (fast over LAN)'),
),
(
b'p',
b'patches',
b'',
_(b'location of source patch repository'),
_(b'REPO'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
]
+ cmdutil.remoteopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qclone [OPTION]... SOURCE [DEST]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_REPO_CREATION,
norepo=True,
)
Vadim Gelfer
mq: add qclone command
r2720 def clone(ui, source, dest=None, **opts):
'''clone main and patch repository at same time
Martin Geisler
Change double spaces to single spaces in help texts.
r7983 If source is local, destination will have no patches applied. If
Vadim Gelfer
mq: add qclone command
r2720 source is remote, this command can not check if patches are
applied in source, so cannot guarantee that patches are not
Martin Geisler
Change double spaces to single spaces in help texts.
r7983 applied in destination. If you clone remote repository, be sure
Vadim Gelfer
mq: add qclone command
r2720 before that it has no patches applied.
Source patch repository is looked for in <src>/.hg/patches by
Martin Geisler
Change double spaces to single spaces in help texts.
r7983 default. Use -p <url> to change.
Brendan Cully
mq: improve qclone error handling when patch directory is not a repository.
r4862
timeless
Spell Mercurial as a proper noun
r8760 The patch directory must be a nested Mercurial repository, as
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 would be created by :hg:`init --mq`.
Erik Zielke
mq: added return 0 on success...
r12538
Return 0 on success.
Vadim Gelfer
mq: add qclone command
r2720 '''
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Augie Fackler
formatting: blacken the codebase...
r43346
Alexis S. L. Carvalho
avoid double slash problem mentioned in issue695
r5226 def patchdir(repo):
Pierre-Yves David
qclone: add a few comment and blank line...
r15921 """compute a patch repo url from a repo object"""
Alexis S. L. Carvalho
avoid double slash problem mentioned in issue695
r5226 url = repo.url()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if url.endswith(b'/'):
Alexis S. L. Carvalho
avoid double slash problem mentioned in issue695
r5226 url = url[:-1]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return url + b'/.hg/patches'
Pierre-Yves David
qclone: add a few comment and blank line...
r15921
# main repo (destination and sources)
Vadim Gelfer
mq: add qclone command
r2720 if dest is None:
dest = hg.defaultdest(source)
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 sr = hg.peer(ui, opts, ui.expandpath(source))
Pierre-Yves David
qclone: add a few comment and blank line...
r15921
# patches repo (source only)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'patches'):
patchespath = ui.expandpath(opts.get(b'patches'))
John Mulligan
mq: allow qclone's -p option to use path alias...
r7729 else:
patchespath = patchdir(sr)
Brendan Cully
mq: improve qclone error handling when patch directory is not a repository.
r4862 try:
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 hg.peer(ui, opts, patchespath)
Matt Mackall
error: move repo errors...
r7637 except error.RepoError:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'versioned patch repository not found (see init --mq)')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Vadim Gelfer
mq: add qclone command
r2720 qbase, destrev = None, None
if sr.local():
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 repo = sr.local()
if repo.mq.applied and repo[qbase].phase() != phases.secret:
qbase = repo.mq.applied[0].node
Vadim Gelfer
mq: add qclone command
r2720 if not hg.islocal(dest):
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 heads = set(repo.heads())
destrev = list(heads.difference(repo.heads(qbase)))
destrev.append(repo.changelog.parents(qbase)[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif sr.capable(b'lookup'):
Alexis S. L. Carvalho
qclone: do not abort if remote hasn't enabled mq (issue1040)
r6380 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 qbase = sr.lookup(b'qbase')
Matt Mackall
error: move repo errors...
r7637 except error.RepoError:
Alexis S. L. Carvalho
qclone: do not abort if remote hasn't enabled mq (issue1040)
r6380 pass
Pierre-Yves David
qclone: add a few comment and blank line...
r15921
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(_(b'cloning main repository\n'))
Augie Fackler
formatting: blacken the codebase...
r43346 sr, dr = hg.clone(
ui,
opts,
sr.url(),
dest,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pull=opts.get(b'pull'),
Augie Fackler
formatting: blacken the codebase...
r43346 revs=destrev,
update=False,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 stream=opts.get(b'uncompressed'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
qclone: add a few comment and blank line...
r15921
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(_(b'cloning patch repository\n'))
Augie Fackler
formatting: blacken the codebase...
r43346 hg.clone(
ui,
opts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 opts.get(b'patches') or patchdir(sr),
Augie Fackler
formatting: blacken the codebase...
r43346 patchdir(dr),
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pull=opts.get(b'pull'),
update=not opts.get(b'noupdate'),
stream=opts.get(b'uncompressed'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
qclone: add a few comment and blank line...
r15921
Vadim Gelfer
mq: add qclone command
r2720 if dr.local():
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 repo = dr.local()
Vadim Gelfer
mq: add qclone command
r2720 if qbase:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.note(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(
b'stripping applied patches from destination '
b'repository\n'
)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
mq: extract `mq.queue.strip`...
r19819 strip(ui, repo, [qbase], update=False, backup=None)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not opts.get(b'noupdate'):
ui.note(_(b'updating destination repository\n'))
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 hg.update(repo, repo.changelog.tip())
Vadim Gelfer
mq: add qclone command
r2720
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qcommit|qci",
commands.table[b"commit|ci"][1],
_(b'hg qcommit [OPTION]... [FILE]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_COMMITTING,
inferrepo=True,
)
mason@suse.com
Add mq extension
r1808 def commit(ui, repo, *pats, **opts):
Dirkjan Ochtman
mq: deprecate qinit and qcommit
r10361 """commit changes in the queue repository (DEPRECATED)
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 This command is deprecated; use :hg:`commit --mq` instead."""
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
mason@suse.com
Add mq extension
r1808 r = q.qrepo()
Matt Mackall
many, many trivial check-code fixups
r10282 if not r:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(b'no queue repository')
mason@suse.com
Add mq extension
r1808 commands.commit(r.ui, r, *pats, **opts)
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qseries",
[(b'm', b'missing', None, _(b'print patches not in series')),] + seriesopts,
_(b'hg qseries [-ms]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def series(ui, repo, **opts):
Erik Zielke
mq: added return 0 on success...
r12538 """print the entire series file
Returns 0 on success."""
Augie Fackler
formatting: blacken the codebase...
r43346 repo.mq.qseries(
repo, missing=opts.get(r'missing'), summary=opts.get(r'summary')
)
mason@suse.com
Add mq extension
r1808 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qtop",
Augie Fackler
formatting: blacken the codebase...
r43346 seriesopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qtop [-s]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def top(ui, repo, **opts):
Erik Zielke
mq: added return 0 on success...
r12538 """print the name of the current patch
Returns 0 on success."""
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 q = repo.mq
Jordi Gutiérrez Hermoso
style: kill ersatz if-else ternary operators...
r24306 if q.applied:
t = q.seriesend(True)
else:
t = 0
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 if t:
Augie Fackler
formatting: blacken the codebase...
r43346 q.qseries(
repo,
start=t - 1,
length=1,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 status=b'A',
Augie Fackler
formatting: blacken the codebase...
r43346 summary=opts.get(r'summary'),
)
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b"no patches applied\n"))
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 return 1
mason@suse.com
Add mq extension
r1808
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qnext",
Augie Fackler
formatting: blacken the codebase...
r43346 seriesopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qnext [-s]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def next(ui, repo, **opts):
Patrick Mezard
mq: fix qnext when all remaining patches are guarded...
r16063 """print the name of the next pushable patch
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success."""
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 q = repo.mq
Adrian Buehlmann
mq: rename series_end to seriesend
r14586 end = q.seriesend()
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 if end == len(q.series):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b"all patches applied\n"))
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 return 1
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 q.qseries(repo, start=end, length=1, summary=opts.get(r'summary'))
mason@suse.com
Add mq extension
r1808
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qprev",
Augie Fackler
formatting: blacken the codebase...
r43346 seriesopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qprev [-s]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def prev(ui, repo, **opts):
Patrick Mezard
mq: fix qapplied --last and qprev documentation (issue3282)...
r16188 """print the name of the preceding applied patch
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success."""
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 q = repo.mq
l = len(q.applied)
if l == 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b"only one patch applied\n"))
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 return 1
if not l:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b"no patches applied\n"))
Brendan Cully
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev...
r3183 return 1
Patrick Mezard
mq: make qprev return the previous applied patch (issue3245)...
r16064 idx = q.series.index(q.applied[-2].name)
Augie Fackler
formatting: blacken the codebase...
r43346 q.qseries(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo, start=idx, length=1, status=b'A', summary=opts.get(r'summary')
Augie Fackler
formatting: blacken the codebase...
r43346 )
mason@suse.com
Add mq extension
r1808
peter.arrenbrecht@gmail.com
mq: add --currentuser and --user options to qnew and qrefresh...
r5673 def setupheaderopts(ui, opts):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not opts.get(b'user') and opts.get(b'currentuser'):
opts[b'user'] = ui.username()
if not opts.get(b'date') and opts.get(b'currentdate'):
opts[b'date'] = b"%d %d" % dateutil.makedate()
peter.arrenbrecht@gmail.com
mq: add --currentuser and --user options to qnew and qrefresh...
r5673
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qnew",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
(b'f', b'force', None, _(b'import uncommitted changes (DEPRECATED)')),
(b'g', b'git', None, _(b'use git extended diff format')),
(b'U', b'currentuser', None, _(b'add "From: <current user>" to patch')),
(b'u', b'user', b'', _(b'add "From: <USER>" to patch'), _(b'USER')),
(b'D', b'currentdate', None, _(b'add "Date: <current date>" to patch')),
(b'd', b'date', b'', _(b'add "Date: <DATE>" to patch'), _(b'DATE')),
Augie Fackler
formatting: blacken the codebase...
r43346 ]
+ cmdutil.walkopts
+ cmdutil.commitopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_COMMITTING,
helpbasic=True,
inferrepo=True,
)
Brendan Cully
mq: support qnew -I/-X and file name lists
r4713 def new(ui, repo, patch, *args, **opts):
Brendan Cully
Add more verbose help text to mq commands.
r2754 """create a new patch
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 qnew creates a new patch on top of the currently-applied patch (if
Wagner Bruna
mq: remove reference for deprecated -f option...
r10808 any). The patch will be initialized with any outstanding changes
in the working directory. You may also use -I/--include,
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 -X/--exclude, and/or a list of files after the patch name to add
only changes to matching files to the new patch, leaving the rest
as uncommitted modifications.
Brendan Cully
Add more verbose help text to mq commands.
r2754
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 -u/--user and -d/--date can be used to set the (given) user and
date, respectively. -U/--currentuser and -D/--currentdate set user
to current user and date to current date.
Dirkjan Ochtman
mq: reflow qnew help, add help for options
r7306
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 -e/--edit, -m/--message or -l/--logfile set the patch header as
well as the commit message. If none is specified, the header is
empty and the commit message is '[mq]: PATCH'.
Dirkjan Ochtman
help: commands supporting --git point to the gitdiffs topic (issue1352)
r7307
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 Use the -g/--git option to keep the patch in the git extended diff
Matt Mackall
update help on git diffs
r7387 format. Read the diffs help topic for more information on why this
is important for preserving permission changes and copy/rename
information.
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on successful creation of a new patch.
Dirkjan Ochtman
mq: reflow qnew help, add help for options
r7306 """
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Idan Kamara
cmdutil, logmessage: use ui.fin when reading from '-'
r14635 msg = cmdutil.logmessage(ui, opts)
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 opts[b'msg'] = msg
peter.arrenbrecht@gmail.com
mq: add --currentuser and --user options to qnew and qrefresh...
r5673 setupheaderopts(ui, opts)
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 q.new(repo, patch, *args, **pycompat.strkwargs(opts))
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
mason@suse.com
Add mq extension
r1808 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qrefresh",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
(b'g', b'git', None, _(b'use git extended diff format')),
Augie Fackler
formatting: blacken the codebase...
r43346 (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b's',
b'short',
Augie Fackler
formatting: blacken the codebase...
r43346 None,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'refresh only files already in the patch and specified files'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'U',
b'currentuser',
Augie Fackler
formatting: blacken the codebase...
r43346 None,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'add/update author field in patch with current user'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'u',
b'user',
b'',
_(b'add/update author field in patch with given user'),
_(b'USER'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'D',
b'currentdate',
Augie Fackler
formatting: blacken the codebase...
r43346 None,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'add/update date field in patch with current date'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'd',
b'date',
b'',
_(b'add/update date field in patch with given date'),
_(b'DATE'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
]
+ cmdutil.walkopts
+ cmdutil.commitopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_COMMITTING,
helpbasic=True,
inferrepo=True,
)
Brendan Cully
allow qrefresh to take a list of files; closes #96.
r2938 def refresh(ui, repo, *pats, **opts):
Brendan Cully
mq help text updates and speling fixes
r2940 """update the current patch
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 If any file patterns are provided, the refreshed patch will
contain only the modifications that match those patterns; the
remaining modifications will remain in the working directory.
Thomas Arendsen Hein
mq: Mention usage of hg add/remove/copy/rename in qrefresh help text.
r4048
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 If -s/--short is specified, files currently included in the patch
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 will be refreshed just like matched files and remain in the patch.
Mads Kiilerich
mq: Allow qrefresh --silent to take parameters...
r7113
Renato Cunha
mq: save qrefresh message for easy recovery in case it fails (issue2062)...
r11947 If -e/--edit is specified, Mercurial will start your configured editor for
you to enter a message. In case qrefresh fails, you will find a backup of
your message in ``.hg/last-message.txt``.
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 hg add/remove/copy/rename work as usual, though you might want to
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 use git-style patches (-g/--git or [diff] git=1) to track copies
and renames. See the diffs help topic for more information on the
git diff format.
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success.
Brendan Cully
mq help text updates and speling fixes
r2940 """
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
Idan Kamara
cmdutil, logmessage: use ui.fin when reading from '-'
r14635 message = cmdutil.logmessage(ui, opts)
peter.arrenbrecht@gmail.com
mq: add --currentuser and --user options to qnew and qrefresh...
r5673 setupheaderopts(ui, opts)
Bryan O'Sullivan
with: use context manager for wlock in qrefresh
r27830 with repo.wlock():
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 ret = q.refresh(repo, pats, msg=message, **pycompat.strkwargs(opts))
Yuya Nishihara
mq: make qrefresh/qfold keep wlock until saving patch status...
r14620 q.savedirty()
return ret
mason@suse.com
Add mq extension
r1808
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qdiff",
Augie Fackler
formatting: blacken the codebase...
r43346 cmdutil.diffopts + cmdutil.diffopts2 + cmdutil.walkopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qdiff [OPTION]... [FILE]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_FILE_CONTENTS,
helpbasic=True,
inferrepo=True,
)
Brendan Cully
Fix test-mq-qdiff; add -I and -X options to qdiff
r2937 def diff(ui, repo, *pats, **opts):
Dirkjan Ochtman
mq: expand help text for qdiff...
r6606 """diff of the current patch and subsequent modifications
Dirkjan Ochtman
mq: lose the trailing whitespace
r6621
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 Shows a diff which includes the current patch as well as any
changes which have been made in the working directory since the
last refresh (thus showing what the current patch would become
after a qrefresh).
Dirkjan Ochtman
mq: lose the trailing whitespace
r6621
Martin Geisler
Use hg role in help strings
r10973 Use :hg:`diff` if you only want to see the changes made since the
last qrefresh, or :hg:`export qtip` if you want to see changes
made by the current patch without including changes made since the
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 qrefresh.
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success.
Dirkjan Ochtman
mq: expand help text for qdiff...
r6606 """
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.pager(b'qdiff')
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 repo.mq.diff(repo, pats, pycompat.byteskwargs(opts))
mason@suse.com
Add mq extension
r1808 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'qfold',
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
(b'k', b'keep', None, _(b'keep folded patch files')),
Augie Fackler
formatting: blacken the codebase...
r43346 ]
+ cmdutil.commitopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
)
Brendan Cully
Add -m, -l, -e options to qfold.
r2753 def fold(ui, repo, *files, **opts):
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748 """fold the named patches into the current patch
Brendan Cully
Add -m, -l, -e options to qfold.
r2753
Brendan Cully
Add -f option to qfold; improve qfold documentation.
r2771 Patches must not yet be applied. Each patch will be successively
applied to the current patch in the order given. If all the
patches apply successfully, the current patch will be refreshed
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 with the new cumulative patch, and the folded patches will be
deleted. With -k/--keep, the folded patch files will not be
removed afterwards.
Brendan Cully
Add -f option to qfold; improve qfold documentation.
r2771
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 The header for each folded patch will be concatenated with the
Erik Zielke
mq: switched to `` around * * *...
r12755 current patch header, separated by a line of ``* * *``.
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success."""
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748 q = repo.mq
if not files:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'qfold requires at least one patch name'))
Adrian Buehlmann
mq: rename check_toppatch to checktoppatch
r14581 if not q.checktoppatch(repo)[0]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no patches applied'))
Adrian Buehlmann
mq: rename check_localchanges to checklocalchanges
r14583 q.checklocalchanges(repo)
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748
Idan Kamara
cmdutil, logmessage: use ui.fin when reading from '-'
r14635 message = cmdutil.logmessage(ui, opts)
Brendan Cully
Add -m, -l, -e options to qfold.
r2753
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 parent = q.lookup(b'qtip')
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748 patches = []
messages = []
for f in files:
Brendan Cully
Fix qfold after recent changes
r2936 p = q.lookup(f)
if p in patches or p == parent:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b'skipping already folded patch %s\n') % p)
Brendan Cully
Fix qfold after recent changes
r2936 if q.isapplied(p):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'qfold cannot fold already applied patch %s') % p
Augie Fackler
formatting: blacken the codebase...
r43346 )
Brendan Cully
Fix qfold after recent changes
r2936 patches.append(p)
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748
Brendan Cully
Fix qfold after recent changes
r2936 for p in patches:
Brendan Cully
Add -m, -l, -e options to qfold.
r2753 if not message:
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph = patchheader(q.join(p), q.plainmode)
Brendan Cully
mq: filter out empty commit messages in qfold
r7454 if ph.message:
messages.append(ph.message)
Brendan Cully
Fix qfold after recent changes
r2936 pf = q.join(p)
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748 (patchsuccess, files, fuzz) = q.patch(repo, pf)
if not patchsuccess:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'error folding patch %s') % p)
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748
Brendan Cully
Add -m, -l, -e options to qfold.
r2753 if not message:
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph = patchheader(q.join(parent), q.plainmode)
FUJIWARA Katsunori
mq: eliminate unused variable for test-check-pyflakes.t...
r21270 message = ph.message
Brendan Cully
Add -m, -l, -e options to qfold.
r2753 for msg in messages:
Mads Kiilerich
mq: don't add '* * *' separators when there is no commit message
r20053 if msg:
if message:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message.append(b'* * *')
Mads Kiilerich
mq: don't add '* * *' separators when there is no commit message
r20053 message.extend(msg)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message = b'\n'.join(message)
Brendan Cully
Add -m, -l, -e options to qfold.
r2753
Patrick Mezard
mq: preserve --git flag when folding patches...
r10186 diffopts = q.patchopts(q.diffopts(), *patches)
Bryan O'Sullivan
with: use context manager for wlock in qfold
r27831 with repo.wlock():
Augie Fackler
formatting: blacken the codebase...
r43346 q.refresh(
repo,
msg=message,
git=diffopts.git,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 edit=opts.get(b'edit'),
editform=b'mq.qfold',
Augie Fackler
formatting: blacken the codebase...
r43346 )
Yuya Nishihara
mq: make qrefresh/qfold keep wlock until saving patch status...
r14620 q.delete(repo, patches, opts)
q.savedirty()
Brendan Cully
New mq command qfold: Merge patches into the current patch....
r2748
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qgoto",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (
b'',
b'keep-changes',
None,
_(b'tolerate non-conflicting local changes'),
),
(b'f', b'force', None, _(b'overwrite any local changes')),
(b'', b'no-backup', None, _(b'do not save backup copies of files')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qgoto [OPTION]... PATCH'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Bryan O'Sullivan
mq: add qgoto command.
r4432 def goto(ui, repo, patch, **opts):
Erik Zielke
mq: added return 0 on success...
r12538 '''push or pop patches until named patch is at top of stack
Returns 0 on success.'''
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 opts = fixkeepchangesopts(ui, opts)
Bryan O'Sullivan
mq: add qgoto command.
r4432 q = repo.mq
patch = q.lookup(patch)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 nobackup = opts.get(b'no_backup')
keepchanges = opts.get(b'keep_changes')
Bryan O'Sullivan
mq: add qgoto command.
r4432 if q.isapplied(patch):
Augie Fackler
formatting: blacken the codebase...
r43346 ret = q.pop(
repo,
patch,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 force=opts.get(b'force'),
Augie Fackler
formatting: blacken the codebase...
r43346 nobackup=nobackup,
keepchanges=keepchanges,
)
Bryan O'Sullivan
mq: add qgoto command.
r4432 else:
Augie Fackler
formatting: blacken the codebase...
r43346 ret = q.push(
repo,
patch,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 force=opts.get(b'force'),
Augie Fackler
formatting: blacken the codebase...
r43346 nobackup=nobackup,
keepchanges=keepchanges,
)
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
Bryan O'Sullivan
mq: add qgoto command.
r4432 return ret
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qguard",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'l', b'list', None, _(b'list all patches and guards')),
(b'n', b'none', None, _(b'drop all guards')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 def guard(ui, repo, *args, **opts):
'''set or print guards for a patch
Brendan Cully
mq help text updates and speling fixes
r2940 Guards control whether a patch can be pushed. A patch with no
guards is always pushed. A patch with a positive guard ("+foo") is
Martin Geisler
mq: use hg reST role some more
r11307 pushed only if the :hg:`qselect` command has activated it. A patch with
a negative guard ("-foo") is never pushed if the :hg:`qselect` command
Brendan Cully
mq help text updates and speling fixes
r2940 has activated it.
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Brendan Cully
mq help text updates and speling fixes
r2940 With no arguments, print the currently active guards.
With arguments, set guards for the named patch.
Erik Zielke
Use note admonition
r12389
.. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Erik Zielke
Use note admonition
r12389 Specifying negative guards now requires '--'.
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Martin Geisler
mq: fix literal blocks in docstrings
r9824 To set guards on another patch::
Martin Geisler
mq: more instructive use of "--" in qguard help (issue2040)
r10476 hg qguard other.patch -- +2.6.17 -stable
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success.
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 '''
Augie Fackler
formatting: blacken the codebase...
r43346
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 def status(idx):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 guards = q.seriesguards[idx] or [b'unguarded']
Dan Villiom Podlaski Christiansen
qguard: label patch names by status when listing guards
r11819 if q.series[idx] in applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 state = b'applied'
Dan Villiom Podlaski Christiansen
qguard: label patch names by status when listing guards
r11819 elif q.pushable(idx)[0]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 state = b'unapplied'
Dan Villiom Podlaski Christiansen
qguard: label patch names by status when listing guards
r11819 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 state = b'guarded'
label = b'qguard.patch qguard.%s qseries.%s' % (state, state)
ui.write(b'%s: ' % ui.label(q.series[idx], label))
Dan Villiom Podlaski Christiansen
qguard: label patch names by status when listing guards
r11819
Brodie Rao
qguard: make use of output labeling
r10822 for i, guard in enumerate(guards):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if guard.startswith(b'+'):
ui.write(guard, label=b'qguard.positive')
elif guard.startswith(b'-'):
ui.write(guard, label=b'qguard.negative')
Brodie Rao
qguard: make use of output labeling
r10822 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(guard, label=b'qguard.unguarded')
Brodie Rao
qguard: make use of output labeling
r10822 if i != len(guards) - 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(b' ')
ui.write(b'\n')
Augie Fackler
formatting: blacken the codebase...
r43346
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 q = repo.mq
Dan Villiom Podlaski Christiansen
qguard: label patch names by status when listing guards
r11819 applied = set(p.name for p in q.applied)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 patch = None
args = list(args)
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 if opts.get(r'list'):
Pulkit Goyal
py3: fix kwargs handling in qgurad in hgext/mq.py...
r38060 if args or opts.get(r'none'):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'cannot mix -l/--list with options or arguments')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Gregory Szorc
global: use pycompat.xrange()...
r38806 for i in pycompat.xrange(len(q.series)):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 status(i)
return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not args or args[0][0:1] in b'-+':
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if not q.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no patches applied'))
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 patch = q.applied[-1].name
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if patch is None and args[0][0:1] not in b'-+':
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 patch = args.pop(0)
if patch is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no patch to work with'))
Pulkit Goyal
py3: fix kwargs handling in qgurad in hgext/mq.py...
r38060 if args or opts.get(r'none'):
Adrian Buehlmann
mq: rename find_series to findseries
r14574 idx = q.findseries(patch)
Christian Ebert
mq: abort cleanly when invalid patch name is given to qguard
r4133 if idx is None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no patch named %s') % patch)
Adrian Buehlmann
mq: rename set_guards to setguards
r14577 q.setguards(idx, args)
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
status(q.series.index(q.lookup(patch)))
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qheader",
Augie Fackler
formatting: blacken the codebase...
r43346 [],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qheader [PATCH]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Brendan Cully
Add command qheader to display the header of a given patch.
r2747 def header(ui, repo, patch=None):
Erik Zielke
mq: added return 0 on success...
r12538 """print the header of the topmost or specified patch
Returns 0 on success."""
Brendan Cully
Add command qheader to display the header of a given patch.
r2747 q = repo.mq
if patch:
patch = q.lookup(patch)
else:
if not q.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b'no patches applied\n'))
Bryan O'Sullivan
qheader: exit withh meaningful error code.
r3008 return 1
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 patch = q.lookup(b'qtip')
Steve Losh
mq: add parent node IDs to MQ patches on qrefresh/qnew...
r10397 ph = patchheader(q.join(patch), q.plainmode)
Brendan Cully
Add command qheader to display the header of a given patch.
r2747
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(b'\n'.join(ph.message) + b'\n')
Brendan Cully
Add command qheader to display the header of a given patch.
r2747
Augie Fackler
formatting: blacken the codebase...
r43346
mason@suse.com
Add mq extension
r1808 def lastsavename(path):
Benoit Boissinot
mq: fix variables shadowing builtin
r2794 (directory, base) = os.path.split(path)
names = os.listdir(directory)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 namere = re.compile(b"%s.([0-9]+)" % base)
Benoit Boissinot
mq: fix variables shadowing builtin
r2794 maxindex = None
mason@suse.com
Add mq extension
r1808 maxname = None
for f in names:
m = namere.match(f)
if m:
index = int(m.group(1))
Martin Geisler
use 'x is None' instead of 'x == None'...
r8527 if maxindex is None or index > maxindex:
Benoit Boissinot
mq: fix variables shadowing builtin
r2794 maxindex = index
mason@suse.com
Add mq extension
r1808 maxname = f
if maxname:
Benoit Boissinot
mq: fix variables shadowing builtin
r2794 return (os.path.join(directory, maxname), maxindex)
mason@suse.com
Add mq extension
r1808 return (None, None)
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Augie Fackler
formatting: blacken the codebase...
r43346
mason@suse.com
Add mq extension
r1808 def savename(path):
(last, index) = lastsavename(path)
if last is None:
index = 0
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 newpath = path + b".%d" % (index + 1)
mason@suse.com
Add mq extension
r1808 return newpath
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qpush",
Augie Fackler
formatting: blacken the codebase...
r43346 [
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'',
b'keep-changes',
None,
_(b'tolerate non-conflicting local changes'),
),
(b'f', b'force', None, _(b'apply on top of local changes')),
(
b'e',
b'exact',
Augie Fackler
formatting: blacken the codebase...
r43346 None,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'apply the target patch to its recorded parent'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'l', b'list', None, _(b'list patch name in commit text')),
(b'a', b'all', None, _(b'apply all patches')),
(b'm', b'merge', None, _(b'merge from another queue (DEPRECATED)')),
(b'n', b'name', b'', _(b'merge queue name (DEPRECATED)'), _(b'NAME')),
(
b'',
b'move',
None,
_(b'reorder patch series and apply only the patch'),
),
(b'', b'no-backup', None, _(b'do not save backup copies of files')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
helpbasic=True,
)
mason@suse.com
Add mq extension
r1808 def push(ui, repo, patch=None, **opts):
Dirkjan Ochtman
mq: add a little documentation on qpush -f
r6552 """push the next patch onto the stack
Dirkjan Ochtman
remove trailing spaces
r6553
Patrick Mezard
mq: introduce qpush --check...
r16654 By default, abort if the working directory contains uncommitted
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 changes. With --keep-changes, abort only if the uncommitted files
Patrick Mezard
mq: introduce qpush --check...
r16654 overlap with patched files. With -f/--force, backup and patch over
uncommitted changes.
Erik Zielke
mq: added return 0 on success...
r12538
Stefano Tortarolo
mq: fix typo in docstring
r13725 Return 0 on success.
Dirkjan Ochtman
mq: add a little documentation on qpush -f
r6552 """
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
mason@suse.com
Add mq extension
r1808 mergeq = None
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 opts = fixkeepchangesopts(ui, opts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'merge'):
if opts.get(b'name'):
newpath = repo.vfs.join(opts.get(b'name'))
mason@suse.com
Add mq extension
r1808 else:
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810 newpath, i = lastsavename(q.path)
mason@suse.com
Add mq extension
r1808 if not newpath:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"no saved queues found, please use -n\n"))
mason@suse.com
Add mq extension
r1808 return 1
Simon Heimberg
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)...
r19064 mergeq = queue(ui, repo.baseui, repo.path, newpath)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"merging with queue at: %s\n") % mergeq.path)
Augie Fackler
formatting: blacken the codebase...
r43346 ret = q.push(
repo,
patch,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 force=opts.get(b'force'),
list=opts.get(b'list'),
Augie Fackler
formatting: blacken the codebase...
r43346 mergeq=mergeq,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 all=opts.get(b'all'),
move=opts.get(b'move'),
exact=opts.get(b'exact'),
nobackup=opts.get(b'no_backup'),
keepchanges=opts.get(b'keep_changes'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
mason@suse.com
Add mq extension
r1808 return ret
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qpop",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'a', b'all', None, _(b'pop all patches')),
(b'n', b'name', b'', _(b'queue name to pop (DEPRECATED)'), _(b'NAME')),
(
b'',
b'keep-changes',
None,
_(b'tolerate non-conflicting local changes'),
),
(b'f', b'force', None, _(b'forget any local changes to patched files')),
(b'', b'no-backup', None, _(b'do not save backup copies of files')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qpop [-a] [-f] [PATCH | INDEX]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
helpbasic=True,
)
mason@suse.com
Add mq extension
r1808 def pop(ui, repo, patch=None, **opts):
Dirkjan Ochtman
mq: add correct documentation for qpop
r6611 """pop the current patch off the stack
Dirkjan Ochtman
mq: lose the trailing whitespace
r6621
Patrick Mezard
mq: introduce qpop --check...
r16653 Without argument, pops off the top of the patch stack. If given a
patch name, keeps popping off patches until the named patch is at
the top of the stack.
By default, abort if the working directory contains uncommitted
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 changes. With --keep-changes, abort only if the uncommitted files
Patrick Mezard
mq: introduce qpop --check...
r16653 overlap with patched files. With -f/--force, backup and discard
changes made to such files.
Erik Zielke
mq: added return 0 on success...
r12538
Return 0 on success.
Dirkjan Ochtman
mq: add correct documentation for qpop
r6611 """
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Patrick Mezard
mq: rename --check into --keep-changes...
r16733 opts = fixkeepchangesopts(ui, opts)
mason@suse.com
Add mq extension
r1808 localupdate = True
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'name'):
q = queue(ui, repo.baseui, repo.path, repo.vfs.join(opts.get(b'name')))
ui.warn(_(b'using patch queue: %s\n') % q.path)
mason@suse.com
Add mq extension
r1808 localupdate = False
else:
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
Augie Fackler
formatting: blacken the codebase...
r43346 ret = q.pop(
repo,
patch,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 force=opts.get(b'force'),
Augie Fackler
formatting: blacken the codebase...
r43346 update=localupdate,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 all=opts.get(b'all'),
nobackup=opts.get(b'no_backup'),
keepchanges=opts.get(b'keep_changes'),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
Alexis S. L. Carvalho
mq: propagate the return error of pop
r4099 return ret
mason@suse.com
Add mq extension
r1808
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qrename|qmv",
Augie Fackler
formatting: blacken the codebase...
r43346 [],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qrename PATCH1 [PATCH2]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Brendan Cully
New self-explanatory command qrename.
r2750 def rename(ui, repo, patch, name=None, **opts):
"""rename a patch
With one argument, renames the current patch to PATCH1.
Erik Zielke
mq: added return 0 on success...
r12538 With two arguments, renames PATCH1 to PATCH2.
Returns 0 on success."""
Brendan Cully
New self-explanatory command qrename.
r2750 q = repo.mq
if not name:
name = patch
patch = None
if patch:
patch = q.lookup(patch)
else:
if not q.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b'no patches applied\n'))
Brendan Cully
New self-explanatory command qrename.
r2750 return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 patch = q.lookup(b'qtip')
Brendan Cully
Make qrename handle directory targets; closes #333.
r3083 absdest = q.join(name)
if os.path.isdir(absdest):
Patrick Mezard
Enforce unixish style for all generated patch names....
r4037 name = normname(os.path.join(name, os.path.basename(patch)))
Brendan Cully
Make qrename handle directory targets; closes #333.
r3083 absdest = q.join(name)
Idan Kamara
mq: use checkpatchname...
r14423 q.checkpatchname(name)
Brendan Cully
New self-explanatory command qrename.
r2750
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(_(b'renaming %s to %s\n') % (patch, name))
Adrian Buehlmann
mq: rename find_series to findseries
r14574 i = q.findseries(patch)
Adrian Buehlmann
mq: rename full_series to fullseries
r14572 guards = q.guard_re.findall(q.fullseries[i])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 q.fullseries[i] = name + b''.join([b' #' + g for g in guards])
Adrian Buehlmann
mq: rename parse_series to parseseries
r14575 q.parseseries()
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 q.seriesdirty = True
Brendan Cully
New self-explanatory command qrename.
r2750
info = q.isapplied(patch)
if info:
Brendan Cully
Make mq camelcase consistent with the rest of hg.
r2818 q.applied[info[0]] = statusentry(info[1], name)
Mads Kiilerich
mq: consistently use boolean values for dirty flags
r15879 q.applieddirty = True
Brendan Cully
New self-explanatory command qrename.
r2750
Yuya Nishihara
mq: fixed ENOENT when qrename to new/directory.patch...
r11513 destdir = os.path.dirname(absdest)
if not os.path.isdir(destdir):
os.makedirs(destdir)
Vadim Gelfer
mq: add join method
r2819 util.rename(q.join(patch), absdest)
Brendan Cully
New self-explanatory command qrename.
r2750 r = q.qrepo()
Patrick Mezard
mq: qrename should not touch the dirstate if src is untracked (issue2460)
r12875 if r and patch in r.dirstate:
Dirkjan Ochtman
move working dir/dirstate methods from localrepo to workingctx
r11303 wctx = r[None]
Bryan O'Sullivan
with: use context manager in qrename
r27848 with r.wlock():
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if r.dirstate[patch] == b'a':
Matt Mackall
dirstate: rename forget to drop...
r14434 r.dirstate.drop(patch)
Weijun Wang
mq: handle added patch renaming correctly
r6648 r.dirstate.add(name)
else:
Dirkjan Ochtman
move working dir/dirstate methods from localrepo to workingctx
r11303 wctx.copy(patch, name)
Matt Mackall
context: make forget work like commands.forget...
r14435 wctx.forget([patch])
Brendan Cully
New self-explanatory command qrename.
r2750
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
Brendan Cully
New self-explanatory command qrename.
r2750
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qrestore",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'd', b'delete', None, _(b'delete save entry')),
(b'u', b'update', None, _(b'update queue working directory')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qrestore [-d] [-u] REV'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def restore(ui, repo, rev, **opts):
Dirkjan Ochtman
mq: deprecate qsave, qrestore and related options
r10360 """restore the queue state saved by a revision (DEPRECATED)
Dan Villiom Podlaski Christiansen
mq: fix the deprecation comment for qsave & qrestore....
r12352 This command is deprecated, use :hg:`rebase` instead."""
mason@suse.com
Add mq extension
r1808 rev = repo.lookup(rev)
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
Augie Fackler
formatting: blacken the codebase...
r43346 q.restore(
repo, rev, delete=opts.get(r'delete'), qupdate=opts.get(r'update')
)
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
mason@suse.com
Add mq extension
r1808 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qsave",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'c', b'copy', None, _(b'copy patch directory')),
(b'n', b'name', b'', _(b'copy directory name'), _(b'NAME')),
(b'e', b'empty', None, _(b'clear queue status file')),
(b'f', b'force', None, _(b'force copy')),
Augie Fackler
formatting: blacken the codebase...
r43346 ]
+ cmdutil.commitopts,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
mason@suse.com
Add mq extension
r1808 def save(ui, repo, **opts):
Dirkjan Ochtman
mq: deprecate qsave, qrestore and related options
r10360 """save current queue state (DEPRECATED)
Dan Villiom Podlaski Christiansen
mq: fix the deprecation comment for qsave & qrestore....
r12352 This command is deprecated, use :hg:`rebase` instead."""
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = repo.mq
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Idan Kamara
cmdutil, logmessage: use ui.fin when reading from '-'
r14635 message = cmdutil.logmessage(ui, opts)
"Mathieu Clabaut "
MQ: uniformise message and logfile option....
r2694 ret = q.save(repo, msg=message)
mason@suse.com
Add mq extension
r1808 if ret:
return ret
Augie Fackler
formatting: blacken the codebase...
r43346 q.savedirty() # save to .hg/patches before copying
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'copy'):
mason@suse.com
Add mq extension
r1808 path = q.path
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'name'):
newpath = os.path.join(q.basepath, opts.get(b'name'))
mason@suse.com
Add mq extension
r1808 if os.path.exists(newpath):
if not os.path.isdir(newpath):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'destination %s exists and is not a directory')
Augie Fackler
formatting: blacken the codebase...
r43346 % newpath
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not opts.get(b'force'):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'destination %s exists, use -f to force') % newpath
Augie Fackler
formatting: blacken the codebase...
r43346 )
mason@suse.com
Add mq extension
r1808 else:
newpath = savename(path)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"copy %s to %s\n") % (path, newpath))
mason@suse.com
Add mq extension
r1808 util.copyfiles(path, newpath)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'empty'):
Mads Kiilerich
mq: make qsave implementation more explicit...
r15880 del q.applied[:]
q.applieddirty = True
q.savedirty()
mason@suse.com
Add mq extension
r1808 return 0
Thomas Arendsen Hein
Whitespace, tab and formatting cleanups, mainly in mq.py
r1810
mason@suse.com
Add mq extension
r1808
Augie Fackler
formatting: blacken the codebase...
r43346 @command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qselect",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'n', b'none', None, _(b'disable all guards')),
(b's', b'series', None, _(b'list all guards in series file')),
(b'', b'pop', None, _(b'pop to before first guarded applied patch')),
(b'', b'reapply', None, _(b'pop, then reapply patches')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg qselect [OPTION]... [GUARD]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 def select(ui, repo, *args, **opts):
'''set or print guarded patches to push
Martin Geisler
mq: use hg reST role some more
r11307 Use the :hg:`qguard` command to set or print guards on patch, then use
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 qselect to tell mq which guards to use. A patch will be pushed if
it has no guards or any positive guards match the currently
selected guard, but will not be pushed if any negative guards
Martin Geisler
mq: fix literal blocks in docstrings
r9824 match the current guard. For example::
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
timeless@gmail.com
mq: fix qselect help for qguard
r13791 qguard foo.patch -- -stable (negative guard)
qguard bar.patch +stable (positive guard)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 qselect stable
Brendan Cully
mq help text updates and speling fixes
r2940 This activates the "stable" guard. mq will skip foo.patch (because
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 it has a negative match) but push bar.patch (because it has a
positive match).
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Brendan Cully
mq help text updates and speling fixes
r2940 With no arguments, prints the currently active guards.
With one argument, sets the active guard.
Thomas Arendsen Hein
Whitespace/Tab cleanup
r3223
Brendan Cully
mq help text updates and speling fixes
r2940 Use -n/--none to deactivate guards (no other arguments needed).
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 When no guards are active, patches with positive guards are
skipped and patches with negative guards are pushed.
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Brendan Cully
mq help text updates and speling fixes
r2940 qselect can change the guards on applied patches. It does not pop
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 guarded patches by default. Use --pop to pop back to the last
applied patch that is not guarded. Use --reapply (which implies
--pop) to push back to the current patch afterwards, but skip
guarded patches.
Vadim Gelfer
qselect: add --pop, --reapply options
r2844
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 Use -s/--series to print a list of all guards in the series file
Erik Zielke
mq: added return 0 on success...
r12538 (no other arguments needed). Use -v for more information.
Returns 0 on success.'''
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
q = repo.mq
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 guards = q.active()
FUJIWARA Katsunori
mq: report correct numbers for changing "number of guarded, applied patches"...
r22453 pushable = lambda i: q.pushable(q.applied[i].name)[0]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if args or opts.get(b'none'):
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 old_unapplied = q.unapplied(repo)
Augie Fackler
formatting: blacken the codebase...
r43346 old_guarded = [
i for i in pycompat.xrange(len(q.applied)) if not pushable(i)
]
Adrian Buehlmann
mq: rename set_active to setactive
r14578 q.setactive(args)
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if not args:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b'guards deactivated\n'))
if not opts.get(b'pop') and not opts.get(b'reapply'):
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 unapplied = q.unapplied(repo)
Augie Fackler
formatting: blacken the codebase...
r43346 guarded = [
i for i in pycompat.xrange(len(q.applied)) if not pushable(i)
]
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 if len(unapplied) != len(old_unapplied):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'number of unguarded, unapplied patches has '
b'changed from %d to %d\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
% (len(old_unapplied), len(unapplied))
)
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 if len(guarded) != len(old_guarded):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'number of guarded, applied patches has changed '
b'from %d to %d\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
% (len(old_guarded), len(guarded))
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'series'):
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 guards = {}
noguards = 0
Adrian Buehlmann
mq: rename series_guards to seriesguards
r14573 for gs in q.seriesguards:
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if not gs:
noguards += 1
for g in gs:
guards.setdefault(g, 0)
guards[g] += 1
if ui.verbose:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 guards[b'NONE'] = noguards
Pulkit Goyal
py3: explicitly convert result of dict.items() into list...
r36296 guards = list(guards.items())
Alejandro Santos
compat: use 'key' argument instead of 'cmp' when sorting a list
r9032 guards.sort(key=lambda x: x[0][1:])
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 if guards:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(_(b'guards in series file:\n'))
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 for guard, count in guards:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(b'%2d ' % count)
ui.write(guard, b'\n')
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(_(b'no guards in series file\n'))
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
if guards:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(_(b'active guards:\n'))
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 for g in guards:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(g, b'\n')
Vadim Gelfer
mq: new commands qselect, qguard...
r2821 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b'no active guards\n'))
reapply = opts.get(b'reapply') and q.applied and q.applied[-1].name
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 popped = False
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'pop') or opts.get(b'reapply'):
Gregory Szorc
global: use pycompat.xrange()...
r38806 for i in pycompat.xrange(len(q.applied)):
FUJIWARA Katsunori
mq: examine "pushable" of already applied patch correctly...
r22456 if not pushable(i):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b'popping guarded patches\n'))
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 popped = True
if i == 0:
q.pop(repo, all=True)
else:
FUJIWARA Katsunori
mq: pop correct patches when changing pushable-ness of already applied ones...
r22455 q.pop(repo, q.applied[i - 1].name)
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 break
if popped:
try:
if reapply:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b'reapplying unguarded patches\n'))
Vadim Gelfer
qselect: add --pop, --reapply options
r2844 q.push(repo, reapply)
finally:
Adrian Buehlmann
mq: rename save_dirty to savedirty
r14580 q.savedirty()
Vadim Gelfer
mq: new commands qselect, qguard...
r2821
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qfinish",
[(b'a', b'applied', None, _(b'finish all applied changesets'))],
_(b'hg qfinish [-a] [REV]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Dirkjan Ochtman
mq: introduce the qfinish command
r6645 def finish(ui, repo, *revrange, **opts):
"""move applied patches into repository history
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 Finishes the specified revisions (corresponding to applied
patches) by moving them out of mq control into regular repository
history.
Dirkjan Ochtman
mq: introduce the qfinish command
r6645
Martin Geisler
help texts: write command line switches as -a/--abc
r8076 Accepts a revision range or the -a/--applied option. If --applied
is specified, all applied mq revisions are removed from mq
control. Otherwise, the given revisions must be at the base of the
stack of applied patches.
Dirkjan Ochtman
mq: introduce the qfinish command
r6645
Martin Geisler
mq: word-wrap help texts at 70 characters
r7994 This can be especially useful if your changes have been applied to
an upstream repository, or if you are about to push your changes
to upstream.
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success.
Dirkjan Ochtman
mq: introduce the qfinish command
r6645 """
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 if not opts.get(r'applied') and not revrange:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no revisions specified'))
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 elif opts.get(r'applied'):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revrange = (b'qbase::qtip',) + revrange
Dirkjan Ochtman
mq: introduce the qfinish command
r6645
q = repo.mq
if not q.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b'no patches applied\n'))
Dirkjan Ochtman
mq: introduce the qfinish command
r6645 return 0
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 revs = scmutil.revrange(repo, revrange)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if repo[b'.'].rev() in revs and repo[None].files():
ui.warn(_(b'warning: uncommitted changes in the working directory\n'))
timeless@mozdev.org
spelling: responsibility
r17512 # queue.finish may changes phases but leave the responsibility to lock the
Pierre-Yves David
mq: turn changeset draft on qfinish (except if qparent is secret)...
r15920 # repo to the caller to avoid deadlock with wlock. This command code is
Mads Kiilerich
fix trivial spelling errors
r17424 # responsibility for this locking.
Bryan O'Sullivan
with: use context manager in qfinish
r27847 with repo.lock():
Pierre-Yves David
mq: turn changeset draft on qfinish (except if qparent is secret)...
r15920 q.finish(repo, revs)
q.savedirty()
Dirkjan Ochtman
mq: introduce the qfinish command
r6645 return 0
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"qqueue",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'l', b'list', False, _(b'list all available queues')),
(b'', b'active', False, _(b'print name of active queue')),
(b'c', b'create', False, _(b'create new queue')),
(b'', b'rename', False, _(b'rename active queue')),
(b'', b'delete', False, _(b'delete reference to queue')),
(b'', b'purge', False, _(b'delete queue, and remove patch dir')),
Augie Fackler
formatting: blacken the codebase...
r43346 ],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'[OPTION] [QUEUE]'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
)
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 def qqueue(ui, repo, name=None, **opts):
'''manage multiple patch queues
Supports switching between different patch queues, as well as creating
new patch queues and deleting existing ones.
Omitting a queue name or specifying -l/--list will show you the registered
queues - by default the "normal" patches queue is registered. The currently
"Yann E. MORIN"
mq/qqueue: print current queue name...
r14987 active queue will be marked with "(active)". Specifying --active will print
only the name of the active queue.
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229
To create a new queue, use -c/--create. The queue is automatically made
active, except in the case where there are applied patches from the
currently active queue in the repository. Then the queue will only be
created and switching will fail.
To delete an existing queue, use --delete. You cannot delete the currently
active queue.
Erik Zielke
mq: added return 0 on success...
r12538
Returns 0 on success.
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 '''
q = repo.mq
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _defaultqueue = b'patches'
_allqueues = b'patches.queues'
_activequeue = b'patches.queue'
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229
def _getcurrent():
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 cur = os.path.basename(q.path)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if cur.startswith(b'patches-'):
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 cur = cur[8:]
return cur
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229
def _noqueues():
try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh = repo.vfs(_allqueues, b'r')
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 fh.close()
except IOError:
return True
return False
def _getqueues():
current = _getcurrent()
try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh = repo.vfs(_allqueues, b'r')
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 queues = [queue.strip() for queue in fh if queue.strip()]
Dan Villiom Podlaski Christiansen
explicitly close files...
r13400 fh.close()
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 if current not in queues:
queues.append(current)
except IOError:
queues = [_defaultqueue]
return sorted(queues)
def _setactive(name):
if q.applied:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'new queue created, but cannot make active '
b'as patches are applied'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
"Yann E. MORIN"
mq/qqueue: split _setactive...
r11938 _setactivenocheck(name)
def _setactivenocheck(name):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh = repo.vfs(_activequeue, b'w')
if name != b'patches':
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 fh.write(name)
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 fh.close()
def _addqueue(name):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh = repo.vfs(_allqueues, b'a')
fh.write(b'%s\n' % (name,))
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 fh.close()
"Yann E. MORIN"
mq/qqueue: enable renaming of active queue
r11939 def _queuedir(name):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if name == b'patches':
return repo.vfs.join(b'patches')
"Yann E. MORIN"
mq/qqueue: enable renaming of active queue
r11939 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return repo.vfs.join(b'patches-' + name)
"Yann E. MORIN"
mq/qqueue: enable renaming of active queue
r11939
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 def _validname(name):
for n in name:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if n in b':\\/.':
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 return False
return True
"Yann E. MORIN"
mq/qqueue: commonalise the queue deletion code
r11966 def _delete(name):
if name not in existing:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'cannot delete queue that does not exist'))
"Yann E. MORIN"
mq/qqueue: commonalise the queue deletion code
r11966
current = _getcurrent()
if name == current:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'cannot delete currently active queue'))
fh = repo.vfs(b'patches.queues.new', b'w')
"Yann E. MORIN"
mq/qqueue: commonalise the queue deletion code
r11966 for queue in existing:
if queue == name:
continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh.write(b'%s\n' % (queue,))
"Yann E. MORIN"
mq/qqueue: commonalise the queue deletion code
r11966 fh.close()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.vfs.rename(b'patches.queues.new', _allqueues)
"Yann E. MORIN"
mq/qqueue: commonalise the queue deletion code
r11966
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 opts = pycompat.byteskwargs(opts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not name or opts.get(b'list') or opts.get(b'active'):
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 current = _getcurrent()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'active'):
ui.write(b'%s\n' % (current,))
"Yann E. MORIN"
mq/qqueue: print current queue name...
r14987 return
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 for queue in _getqueues():
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(b'%s' % (queue,))
"Yann E. MORIN"
mq/qqueue: --list does not print (active) with --quiet...
r11767 if queue == current and not ui.quiet:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b' (active)\n'))
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(b'\n')
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229 return
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270 if not _validname(name):
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'invalid queue name, may not contain the characters ":\\/."')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Henrik Stuart
mq: fix naming issues for qqueue directories
r11270
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 with repo.wlock():
existing = _getqueues()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'create'):
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 if name in existing:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'queue "%s" already exists') % name)
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 if _noqueues():
_addqueue(_defaultqueue)
_addqueue(name)
_setactive(name)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'rename'):
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 current = _getcurrent()
if name == current:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'can\'t rename "%s" to its current name') % name
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 if name in existing:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'queue "%s" already exists') % name)
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752
olddir = _queuedir(current)
newdir = _queuedir(name)
if os.path.exists(newdir):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'non-queue directory "%s" already exists') % newdir
Augie Fackler
formatting: blacken the codebase...
r43346 )
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh = repo.vfs(b'patches.queues.new', b'w')
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 for queue in existing:
if queue == current:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh.write(b'%s\n' % (name,))
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 if os.path.exists(olddir):
util.rename(olddir, newdir)
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fh.write(b'%s\n' % (queue,))
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 fh.close()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.vfs.rename(b'patches.queues.new', _allqueues)
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 _setactivenocheck(name)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'delete'):
"Yann E. MORIN"
mq/qqueue: add --purge option to delete a queue and its patch dir...
r11967 _delete(name)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'purge'):
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 if name in existing:
_delete(name)
qdir = _queuedir(name)
if os.path.exists(qdir):
shutil.rmtree(qdir)
else:
if name not in existing:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'use --create to create a new queue'))
Pierre-Yves David
mq: take wlock when 'qqueue' is doing write operations...
r29752 _setactive(name)
Henrik Stuart
mq: support multiple patch queues using qqueue
r11229
Augie Fackler
formatting: blacken the codebase...
r43346
Pierre-Yves David
mq: ensure mq changesets are set to secret when no phase data are found
r15928 def mqphasedefaults(repo, roots):
"""callback used to set mq changeset as secret when no phase data exists"""
if repo.mq.applied:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if repo.ui.configbool(b'mq', b'secret'):
Pierre-Yves David
mq: take mq.secret configuration into account when picking the default phase
r16028 mqphase = phases.secret
else:
mqphase = phases.draft
Augie Fackler
mq: pass qbase node instead of mq statusentry in phasedefaults...
r15972 qbase = repo[repo.mq.applied[0].node]
Pierre-Yves David
mq: take mq.secret configuration into account when picking the default phase
r16028 roots[mqphase].add(qbase.node())
Pierre-Yves David
mq: ensure mq changesets are set to secret when no phase data are found
r15928 return roots
Augie Fackler
formatting: blacken the codebase...
r43346
mason@suse.com
Add mq extension
r1808 def reposetup(ui, repo):
Brendan Cully
Make mq camelcase consistent with the rest of hg.
r2818 class mqrepo(repo.__class__):
Pierre-Yves David
mq: use an unfiltered property cache for the queue object...
r19395 @localrepo.unfilteredpropertycache
Simon Heimberg
mq: only read files when needed...
r8524 def mq(self):
Simon Heimberg
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)...
r19064 return queue(self.ui, self.baseui, self.path)
Simon Heimberg
mq: only read files when needed...
r8524
Yuya Nishihara
cmdserver: reload mq on each runcommand request to avoid corruption...
r20628 def invalidateall(self):
super(mqrepo, self).invalidateall()
Yuya Nishihara
py3: invalidate repository cache with system-string keys...
r40396 if localrepo.hasunfilteredcache(self, r'mq'):
Yuya Nishihara
cmdserver: recreate mq object on runcommand in case queue path was changed...
r20629 # recreate mq in case queue path was changed
Yuya Nishihara
py3: invalidate repository cache with system-string keys...
r40396 delattr(self.unfiltered(), r'mq')
Yuya Nishihara
cmdserver: reload mq on each runcommand request to avoid corruption...
r20628
Adrian Buehlmann
mq: rename abort_if_wdir_patched to abortifwdirpatched
r14596 def abortifwdirpatched(self, errmsg, force=False):
David Soria Parra
shelve: allow shelving of a change with an mq patch applied...
r19856 if self.mq.applied and self.mq.checkapplied and not force:
Martin Geisler
mq: forbid commit of merge involving mq patches
r13520 parents = self.dirstate.parents()
patches = [s.node for s in self.mq.applied]
Martin von Zweigbergk
mq: slightly simplify check for patched working copy...
r41418 if any(p in patches for p in parents):
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(errmsg)
Thomas Arendsen Hein
Whitespace/Tab cleanup
r3223
Augie Fackler
formatting: blacken the codebase...
r43346 def commit(
self,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 text=b"",
Augie Fackler
formatting: blacken the codebase...
r43346 user=None,
date=None,
match=None,
force=False,
editor=False,
extra=None,
):
Pierre-Yves David
mq: don't use mutable default argument value...
r31407 if extra is None:
extra = {}
Adrian Buehlmann
mq: rename abort_if_wdir_patched to abortifwdirpatched
r14596 self.abortifwdirpatched(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'cannot commit over an applied mq patch'), force
Augie Fackler
formatting: blacken the codebase...
r43346 )
return super(mqrepo, self).commit(
text, user, date, match, force, editor, extra
)
Brendan Cully
Disallow commit over an applied mq patch.
r2845
Pierre-Yves David
push: pass a `pushoperation` object to localrepo.checkpush...
r20924 def checkpush(self, pushop):
if self.mq.applied and self.mq.checkapplied and not pushop.force:
Pierre-Yves David
mq-safety: don't apply safety on non-outgoing changeset...
r15952 outapplied = [e.node for e in self.mq.applied]
Pierre-Yves David
push: pass a `pushoperation` object to localrepo.checkpush...
r20924 if pushop.revs:
Pierre-Yves David
mq-safety: don't apply safety on non-outgoing changeset...
r15952 # Assume applied patches have no non-patch descendants and
# are not on remote already. Filtering any changeset not
# pushed.
Pierre-Yves David
push: pass a `pushoperation` object to localrepo.checkpush...
r20924 heads = set(pushop.revs)
Pierre-Yves David
mq-safety: don't apply safety on non-outgoing changeset...
r15952 for node in reversed(outapplied):
if node in heads:
break
else:
outapplied.pop()
# looking for pushed and shared changeset
for node in outapplied:
Bryan O'Sullivan
mq: don't refer to a random name-captured repo object...
r17954 if self[node].phase() < phases.secret:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'source has mq patches applied'))
Pierre-Yves David
mq-safety: don't apply safety on non-outgoing changeset...
r15952 # no non-secret patches pushed
Pierre-Yves David
push: pass a `pushoperation` object to localrepo.checkpush...
r20924 super(mqrepo, self).checkpush(pushop)
Thomas Arendsen Hein
Whitespace/Tab cleanup
r3223
Greg Ward
localrepo: factor _findtags() out of tags() (issue548)....
r9145 def _findtags(self):
'''augment tags from base class with patch tags'''
result = super(mqrepo, self)._findtags()
Brendan Cully
Add mq patch names to tagscache instead of overriding lookup....
r2682
Brendan Cully
mq: replace module-wide repo hash with a repo attribute
r2724 q = self.mq
Brendan Cully
mq: do not hold a reference to repo in tags override...
r2723 if not q.applied:
Greg Ward
localrepo: factor _findtags() out of tags() (issue548)....
r9145 return result
Brendan Cully
Mq: modify repo.lookup to resolve applied patches too.
r2663
Benoit Boissinot
mq: avoid many hex/bin conversions, keep the binary node when possible
r10678 mqtags = [(patch.node, patch.name) for patch in q.applied]
Alexis S. L. Carvalho
mqrepo: don't abort if the status file has an unknown node
r5979
Matt Mackall
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)...
r13508 try:
Pierre-Yves David
clfilter: mq should not warn about filtered mq patches...
r18011 # for now ignore filtering business
self.unfiltered().changelog.rev(mqtags[-1][0])
Idan Kamara
mq: catch correct exception when calling changelog.rev()
r14600 except error.LookupError:
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'mq status file refers to unknown node %s\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % short(mqtags[-1][0])
)
Greg Ward
localrepo: factor _findtags() out of tags() (issue548)....
r9145 return result
Alexis S. L. Carvalho
mqrepo: don't abort if the status file has an unknown node
r5979
Pierre-Yves David
mq: comply with filtering when injecting fake tags (issue3812)...
r18662 # do not add fake tags for filtered revisions
included = self.changelog.hasnode
mqtags = [mqt for mqt in mqtags if included(mqt[0])]
if not mqtags:
return result
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 mqtags.append((mqtags[-1][0], b'qtip'))
mqtags.append((mqtags[0][0], b'qbase'))
mqtags.append((self.changelog.parents(mqtags[0][0])[0], b'qparent'))
Greg Ward
localrepo: factor _findtags() out of tags() (issue548)....
r9145 tags = result[0]
Brendan Cully
mq: do not hold a reference to repo in tags override...
r2723 for patch in mqtags:
Greg Ward
localrepo: factor _findtags() out of tags() (issue548)....
r9145 if patch[1] in tags:
Augie Fackler
formatting: blacken the codebase...
r43346 self.ui.warn(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'tag %s overrides mq patch of the same name\n')
Augie Fackler
formatting: blacken the codebase...
r43346 % patch[1]
)
Brendan Cully
mq: do not hold a reference to repo in tags override...
r2723 else:
Greg Ward
localrepo: factor _findtags() out of tags() (issue548)....
r9145 tags[patch[1]] = patch[0]
Brendan Cully
Add mq patch names to tagscache instead of overriding lookup....
r2682
Greg Ward
localrepo: factor _findtags() out of tags() (issue548)....
r9145 return result
Brendan Cully
Add qtip and qbase to mq qlookup.
r2664
Vadim Gelfer
mq: only add mq attribute to local repo
r2851 if repo.local():
repo.__class__ = mqrepo
mason@suse.com
Add mq extension
r1808
Pierre-Yves David
mq: ensure mq changesets are set to secret when no phase data are found
r15928 repo._phasedefaults.append(mqphasedefaults)
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
extensions: use new wrapper functions
r7216 def mqimport(orig, ui, repo, *args, **kwargs):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if util.safehasattr(repo, b'abortifwdirpatched') and not kwargs.get(
Augie Fackler
formatting: blacken the codebase...
r43346 r'no_commit', False
):
repo.abortifwdirpatched(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'cannot import over an applied patch'), kwargs.get(r'force')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Matt Mackall
extensions: use new wrapper functions
r7216 return orig(ui, repo, *args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
Brendan Cully
mq: make init -Q do what qinit -c did
r10402 def mqinit(orig, ui, *args, **kwargs):
Pulkit Goyal
py3: fix keyword arguments handling in mq...
r34506 mq = kwargs.pop(r'mq', None)
Brendan Cully
mq: make init -Q do what qinit -c did
r10402
if not mq:
return orig(ui, *args, **kwargs)
Cédric Duval
mq: fix init with nonexistent or non-local repository
r10691 if args:
repopath = args[0]
if not hg.islocal(repopath):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'only a local queue repository may be initialized')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Cédric Duval
mq: fix init with nonexistent or non-local repository
r10691 else:
Matt Harbison
py3: rename pycompat.getcwd() to encoding.getcwd() (API)...
r39843 repopath = cmdutil.findrepo(encoding.getcwd())
Cédric Duval
mq: fix init with nonexistent or non-local repository
r10691 if not repopath:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'there is no Mercurial repository here (.hg not found)')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Brendan Cully
mq: make init -Q do what qinit -c did
r10402 repo = hg.repository(ui, repopath)
Brendan Cully
mq: unify implementation of qinit and init -Q
r10480 return qinit(ui, repo, True)
Brendan Cully
mq: make init -Q do what qinit -c did
r10402
Augie Fackler
formatting: blacken the codebase...
r43346
Brendan Cully
mq: add --mq option to some commands...
r10359 def mqcommand(orig, ui, repo, *args, **kwargs):
"""Add --mq option to operate on patch repository instead of main"""
# some commands do not like getting unknown options
Pulkit Goyal
py3: convert key to str to make kwargs.pop work in mq...
r32193 mq = kwargs.pop(r'mq', None)
Brendan Cully
mq: add --mq option to some commands...
r10359
if not mq:
return orig(ui, repo, *args, **kwargs)
q = repo.mq
r = q.qrepo()
if not r:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'no queue repository'))
Brendan Cully
mq: incorporate mq repo config when using --mq...
r10407 return orig(r.ui, r, *args, **kwargs)
Brendan Cully
mq: add --mq option to some commands...
r10359
Augie Fackler
formatting: blacken the codebase...
r43346
Bryan O'Sullivan
mq: switch to new summary hook mechanism
r19212 def summaryhook(ui, repo):
Matt Mackall
mq: add a line to hg summary
r11107 q = repo.mq
m = []
a, u = len(q.applied), len(q.unapplied(repo))
if a:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 m.append(ui.label(_(b"%d applied"), b'qseries.applied') % a)
Matt Mackall
mq: add a line to hg summary
r11107 if u:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 m.append(ui.label(_(b"%d unapplied"), b'qseries.unapplied') % u)
Matt Mackall
mq: add a line to hg summary
r11107 if m:
FUJIWARA Katsunori
i18n: make column positioning message of MQ summary output translatable...
r17893 # i18n: column positioning for "hg summary"
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(_(b"mq: %s\n") % b', '.join(m))
Matt Mackall
mq: add a line to hg summary
r11107 else:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.note(_(b"mq: (empty queue)\n"))
Matt Mackall
mq: add a line to hg summary
r11107
Augie Fackler
formatting: blacken the codebase...
r43346
FUJIWARA Katsunori
revset: replace extpredicate by revsetpredicate of registrar...
r28394 revsetpredicate = registrar.revsetpredicate()
FUJIWARA Katsunori
revset: use delayregistrar to register predicate in extension easily...
r27586
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @revsetpredicate(b'mq()')
Idan Kamara
mq: add a 'mq()' revset predicate that returns applied mq csets
r14210 def revsetmq(repo, subset, x):
FUJIWARA Katsunori
revset: use delayregistrar to register predicate in extension easily...
r27586 """Changesets managed by MQ.
Idan Kamara
mq: add a 'mq()' revset predicate that returns applied mq csets
r14210 """
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 revsetlang.getargs(x, 0, 0, _(b"mq takes no arguments"))
Martin von Zweigbergk
cleanup: use set literals where possible...
r42224 applied = {repo[r.node].rev() for r in repo.mq.applied}
Yuya Nishihara
revset: import set classes directly from smartset module...
r31023 return smartset.baseset([r for r in subset if r in applied])
Idan Kamara
mq: add a 'mq()' revset predicate that returns applied mq csets
r14210
Augie Fackler
formatting: blacken the codebase...
r43346
Idan Kamara
mq: add a 'mq()' revset predicate that returns applied mq csets
r14210 # tell hggettext to extract docstrings from these functions:
i18nfunctions = [revsetmq]
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
mq: defer command wrapping to extsetup (API)...
r17101 def extsetup(ui):
# Ensure mq wrappers are called first, regardless of extension load order by
# NOT wrapping in uisetup() and instead deferring to init stage two here.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 mqopt = [(b'', b'mq', None, _(b"operate on patch repository"))]
extensions.wrapcommand(commands.table, b'import', mqimport)
cmdutil.summaryhooks.add(b'mq', summaryhook)
entry = extensions.wrapcommand(commands.table, b'init', mqinit)
Brendan Cully
mq: make init -Q do what qinit -c did
r10402 entry[1].extend(mqopt)
Dan Villiom Podlaski Christiansen
mq: extend support for the --mq argument to extension commands...
r12036 def dotable(cmdtable):
Gregory Szorc
py3: define and use pycompat.iteritems() for hgext/...
r43375 for cmd, entry in pycompat.iteritems(cmdtable):
Dan Villiom Podlaski Christiansen
mq: extend support for the --mq argument to extension commands...
r12036 cmd = cmdutil.parsealiases(cmd)[0]
Yuya Nishihara
dispatch: store norepo/optionalrepo/inferrepo attributes in function (API)...
r28313 func = entry[0]
Augie Fackler
dispatch: stop supporting non-use of @command...
r30485 if func.norepo:
Dan Villiom Podlaski Christiansen
mq: extend support for the --mq argument to extension commands...
r12036 continue
entry = extensions.wrapcommand(cmdtable, cmd, mqcommand)
entry[1].extend(mqopt)
dotable(commands.table)
for extname, extmodule in extensions.extensions():
if extmodule.__file__ != __file__:
dotable(getattr(extmodule, 'cmdtable', {}))
Brendan Cully
Prevent import over an applied patch (closes issue795)
r7142
Augie Fackler
formatting: blacken the codebase...
r43346
colortable = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'qguard.negative': b'red',
b'qguard.positive': b'yellow',
b'qguard.unguarded': b'green',
b'qseries.applied': b'blue bold underline',
b'qseries.guarded': b'black bold',
b'qseries.missing': b'red bold',
b'qseries.unapplied': b'black bold',
Augie Fackler
formatting: blacken the codebase...
r43346 }