Mercurial > hg
annotate hgext/mq.py @ 40880:7cda0cacbbf6
util: implement pop() on lrucachedict
This moves __delitem__() to pop() as the requirement is pretty much the same,
and reimplement __delitem__() by using pop().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 04 Nov 2018 16:57:05 +0900 |
parents | dee73a97e132 |
children | 19178aeb9b43 |
rev | line source |
---|---|
6187
531f3e78c6f2
mq: Cleanup: update outdated file header.
Marti Raudsepp <marti@juffo.org>
parents:
6164
diff
changeset
|
1 # mq.py - patch queues for mercurial |
1808 | 2 # |
2859 | 3 # Copyright 2005, 2006 Chris Mason <mason@suse.com> |
1808 | 4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
1808 | 7 |
8932
f87884329419
extensions: fix up description lines some more
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8929
diff
changeset
|
8 '''manage a stack of patches |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
9 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
10 This extension lets you work with a stack of patches in a Mercurial |
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
11 repository. It manages two stacks of patches - all known patches, and |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
12 applied patches (subset of known patches). |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
13 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
14 Known patches are represented as patch files in the .hg/patches |
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
15 directory. Applied patches are both patch files and changesets. |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
16 |
30879
5fbf1da938a6
help: uppercase command placeholder
Yuya Nishihara <yuya@tcha.org>
parents:
30519
diff
changeset
|
17 Common tasks (use :hg:`help COMMAND` for more details):: |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
18 |
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9111
diff
changeset
|
19 create new patch qnew |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9111
diff
changeset
|
20 import existing patch qimport |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
21 |
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9111
diff
changeset
|
22 print patch series qseries |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9111
diff
changeset
|
23 print applied patches qapplied |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
24 |
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9111
diff
changeset
|
25 add known patch to applied stack qpush |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9111
diff
changeset
|
26 remove patch from applied stack qpop |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9111
diff
changeset
|
27 refresh contents of top applied patch qrefresh |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
28 |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
29 By default, mq will automatically use git patches when required to |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
30 avoid losing file mode changes, copy records, binary files or empty |
26098 | 31 files creations or deletions. This behavior can be configured with:: |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
32 |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
33 [mq] |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
34 git = auto/keep/yes/no |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
35 |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
36 If set to 'keep', mq will obey the [diff] section configuration while |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
37 preserving existing git patches upon qrefresh. If set to 'yes' or |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
38 'no', mq will override the [diff] section and always generate git or |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
39 regular patches, possibly losing data in the second case. |
11234
1ebe048902d9
mq: mention qqueue in module docstring
Martin Geisler <mg@lazybytes.net>
parents:
11230
diff
changeset
|
40 |
16040
c0b2986b37b8
mq: fix secret description in help
Matt Mackall <mpm@selenic.com>
parents:
16029
diff
changeset
|
41 It may be desirable for mq changesets to be kept in the secret phase (see |
16017 | 42 :hg:`help phases`), which can be enabled with the following setting:: |
43 | |
44 [mq] | |
45 secret = True | |
46 | |
11234
1ebe048902d9
mq: mention qqueue in module docstring
Martin Geisler <mg@lazybytes.net>
parents:
11230
diff
changeset
|
47 You will by default be managing a patch queue named "patches". You can |
1ebe048902d9
mq: mention qqueue in module docstring
Martin Geisler <mg@lazybytes.net>
parents:
11230
diff
changeset
|
48 create other, independent patch queues with the :hg:`qqueue` command. |
16656
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
49 |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
50 If the working directory contains uncommitted files, qpush, qpop and |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
51 qgoto abort immediately. If -f/--force is used, the changes are |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
52 discarded. Setting:: |
16656
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
53 |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
54 [mq] |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
55 keepchanges = True |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
56 |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
57 make them behave as if --keep-changes were passed, and non-conflicting |
16656
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
58 local changes will be tolerated and preserved. If incompatible options |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
59 such as -f/--force or --exact are passed, this setting is ignored. |
19826
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
60 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
61 This extension used to provide a strip command. This command now lives |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
62 in the strip extension. |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
63 ''' |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
64 |
34137
a8994d08e4a2
doctest: use print_function and convert bytes to unicode where needed
Yuya Nishihara <yuya@tcha.org>
parents:
34131
diff
changeset
|
65 from __future__ import absolute_import, print_function |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
66 |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
67 import errno |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
68 import os |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
69 import re |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
70 import shutil |
3891 | 71 from mercurial.i18n import _ |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
72 from mercurial.node import ( |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
73 bin, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
74 hex, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
75 nullid, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
76 nullrev, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
77 short, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
78 ) |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
79 from mercurial import ( |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
80 cmdutil, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
81 commands, |
30489
0ae83ede68c5
mq: refer to dirstateguard by its new name
Augie Fackler <augie@google.com>
parents:
30485
diff
changeset
|
82 dirstateguard, |
34022
d5b2beca16c0
python3: wrap all uses of <exception>.strerror with strtolocal
Augie Fackler <raf@durin42.com>
parents:
33489
diff
changeset
|
83 encoding, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
84 error, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
85 extensions, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
86 hg, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
87 localrepo, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
88 lock as lockmod, |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35844
diff
changeset
|
89 logcmdutil, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
90 patch as patchmod, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
91 phases, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30489
diff
changeset
|
92 pycompat, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
93 registrar, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
94 revsetlang, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
95 scmutil, |
31023
aea06029919e
revset: import set classes directly from smartset module
Yuya Nishihara <yuya@tcha.org>
parents:
30879
diff
changeset
|
96 smartset, |
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35948
diff
changeset
|
97 subrepoutil, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
98 util, |
31243
816bc3b35bac
vfs: use 'vfs' module directly in 'hgext.mq'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
99 vfs as vfsmod, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
100 ) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
101 from mercurial.utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
102 dateutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
103 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
104 ) |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
105 |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
106 release = lockmod.release |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
107 seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
108 |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
109 cmdtable = {} |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32193
diff
changeset
|
110 command = registrar.command(cmdtable) |
29841
d5883fd055c6
extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents:
29752
diff
changeset
|
111 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
25186
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
25149
diff
changeset
|
112 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
25149
diff
changeset
|
113 # be specifying the version(s) of Mercurial they are tested with, or |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
25149
diff
changeset
|
114 # leave the attribute unspecified. |
29841
d5883fd055c6
extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents:
29752
diff
changeset
|
115 testedwith = 'ships-with-hg-core' |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
116 |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
117 configtable = {} |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
118 configitem = registrar.configitem(configtable) |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
119 |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
120 configitem('mq', 'git', |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
121 default='auto', |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
122 ) |
34182
cac8c4e51951
configitems: register the 'mq.keepchanges' config
Boris Feld <boris.feld@octobus.net>
parents:
34181
diff
changeset
|
123 configitem('mq', 'keepchanges', |
cac8c4e51951
configitems: register the 'mq.keepchanges' config
Boris Feld <boris.feld@octobus.net>
parents:
34181
diff
changeset
|
124 default=False, |
cac8c4e51951
configitems: register the 'mq.keepchanges' config
Boris Feld <boris.feld@octobus.net>
parents:
34181
diff
changeset
|
125 ) |
34183
5c150b70d004
configitems: register the 'mq.plain' config
Boris Feld <boris.feld@octobus.net>
parents:
34182
diff
changeset
|
126 configitem('mq', 'plain', |
5c150b70d004
configitems: register the 'mq.plain' config
Boris Feld <boris.feld@octobus.net>
parents:
34182
diff
changeset
|
127 default=False, |
5c150b70d004
configitems: register the 'mq.plain' config
Boris Feld <boris.feld@octobus.net>
parents:
34182
diff
changeset
|
128 ) |
34184
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
129 configitem('mq', 'secret', |
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
130 default=False, |
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
131 ) |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
132 |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
19916
diff
changeset
|
133 # force load strip extension formerly included in mq and import some utility |
19822
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
134 try: |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
135 stripext = extensions.find('strip') |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
136 except KeyError: |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
137 # note: load is lazy so we could avoid the try-except, |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
19916
diff
changeset
|
138 # but I (marmoute) prefer this explicit code. |
19822
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
139 class dummyui(object): |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
140 def debug(self, msg): |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
141 pass |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
142 stripext = extensions.load(dummyui(), 'strip', '') |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
143 |
19825
4b4997068143
strip: move the strip helper function for mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19824
diff
changeset
|
144 strip = stripext.strip |
19823
6fb14d21fe9d
strip: move checksubstate from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19822
diff
changeset
|
145 checksubstate = stripext.checksubstate |
19824
237e40b2c1ff
strip: move checklocalchanges from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19823
diff
changeset
|
146 checklocalchanges = stripext.checklocalchanges |
237e40b2c1ff
strip: move checklocalchanges from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19823
diff
changeset
|
147 |
19823
6fb14d21fe9d
strip: move checksubstate from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19822
diff
changeset
|
148 |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
149 # Patch names looks like unix-file names. |
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
150 # They must be joinable with queue directory and result in the patch path. |
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
151 normname = util.normpath |
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
152 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8761
diff
changeset
|
153 class statusentry(object): |
10682
8ed350051896
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10681
diff
changeset
|
154 def __init__(self, node, name): |
8ed350051896
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10681
diff
changeset
|
155 self.node, self.name = node, name |
35842
9bce28609a95
mq: fix up statusentry to be both repr()-able and bytes()-able
Augie Fackler <augie@google.com>
parents:
35145
diff
changeset
|
156 |
9bce28609a95
mq: fix up statusentry to be both repr()-able and bytes()-able
Augie Fackler <augie@google.com>
parents:
35145
diff
changeset
|
157 def __bytes__(self): |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
158 return hex(self.node) + ':' + self.name |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
159 |
35842
9bce28609a95
mq: fix up statusentry to be both repr()-able and bytes()-able
Augie Fackler <augie@google.com>
parents:
35145
diff
changeset
|
160 __str__ = encoding.strmethod(__bytes__) |
9bce28609a95
mq: fix up statusentry to be both repr()-able and bytes()-able
Augie Fackler <augie@google.com>
parents:
35145
diff
changeset
|
161 __repr__ = encoding.strmethod(__bytes__) |
9bce28609a95
mq: fix up statusentry to be both repr()-able and bytes()-able
Augie Fackler <augie@google.com>
parents:
35145
diff
changeset
|
162 |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
163 # The order of the headers in 'hg export' HG patches: |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
164 HGHEADERS = [ |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
165 # '# HG changeset patch', |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
166 '# User ', |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
167 '# Date ', |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
168 '# ', |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
169 '# Branch ', |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
170 '# Node ID ', |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
171 '# Parent ', # can occur twice for merges - but that is not relevant for mq |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
172 ] |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
173 # The order of headers in plain 'mail style' patches: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
174 PLAINHEADERS = { |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
175 'from': 0, |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
176 'date': 1, |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
177 'subject': 2, |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
178 } |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
179 |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
180 def inserthgheader(lines, header, value): |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
181 """Assuming lines contains a HG patch header, add a header line with value. |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
182 >>> try: inserthgheader([], b'# Date ', b'z') |
34138
0f9936d80e01
doctest: upgrade old-style "except" clause
Yuya Nishihara <yuya@tcha.org>
parents:
34137
diff
changeset
|
183 ... except ValueError as inst: print("oops") |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
184 oops |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
185 >>> inserthgheader([b'# HG changeset patch'], b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
186 ['# HG changeset patch', '# Date z'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
187 >>> inserthgheader([b'# HG changeset patch', b''], b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
188 ['# HG changeset patch', '# Date z', ''] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
189 >>> inserthgheader([b'# HG changeset patch', b'# User y'], b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
190 ['# HG changeset patch', '# User y', '# Date z'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
191 >>> inserthgheader([b'# HG changeset patch', b'# Date x', b'# User y'], |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
192 ... b'# User ', b'z') |
23412
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
193 ['# HG changeset patch', '# Date x', '# User z'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
194 >>> inserthgheader([b'# HG changeset patch', b'# Date y'], b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
195 ['# HG changeset patch', '# Date z'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
196 >>> inserthgheader([b'# HG changeset patch', b'', b'# Date y'], |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
197 ... b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
198 ['# HG changeset patch', '# Date z', '', '# Date y'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
199 >>> inserthgheader([b'# HG changeset patch', b'# Parent y'], |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
200 ... b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
201 ['# HG changeset patch', '# Date z', '# Parent y'] |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
202 """ |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
203 start = lines.index('# HG changeset patch') + 1 |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
204 newindex = HGHEADERS.index(header) |
23412
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
205 bestpos = len(lines) |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
206 for i in range(start, len(lines)): |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
207 line = lines[i] |
23412
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
208 if not line.startswith('# '): |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
209 bestpos = min(bestpos, i) |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
210 break |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
211 for lineindex, h in enumerate(HGHEADERS): |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
212 if line.startswith(h): |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
213 if lineindex == newindex: |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
214 lines[i] = header + value |
23412
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
215 return lines |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
216 if lineindex > newindex: |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
217 bestpos = min(bestpos, i) |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
218 break # next line |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
219 lines.insert(bestpos, header + value) |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
220 return lines |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
221 |
23345
83cbf556babf
mq: introduce insertplainheader - same naive implementation as before
Mads Kiilerich <madski@unity3d.com>
parents:
23344
diff
changeset
|
222 def insertplainheader(lines, header, value): |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
223 """For lines containing a plain patch header, add a header line with value. |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
224 >>> insertplainheader([], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
225 ['Date: z'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
226 >>> insertplainheader([b''], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
227 ['Date: z', ''] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
228 >>> insertplainheader([b'x'], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
229 ['Date: z', '', 'x'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
230 >>> insertplainheader([b'From: y', b'x'], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
231 ['From: y', 'Date: z', '', 'x'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
232 >>> insertplainheader([b' date : x', b' from : y', b''], b'From', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
233 [' date : x', 'From: z', ''] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
234 >>> insertplainheader([b'', b'Date: y'], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
235 ['Date: z', '', 'Date: y'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
236 >>> insertplainheader([b'foo: bar', b'DATE: z', b'x'], b'From', b'y') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
237 ['From: y', 'foo: bar', 'DATE: z', '', 'x'] |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
238 """ |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
239 newprio = PLAINHEADERS[header.lower()] |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
240 bestpos = len(lines) |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
241 for i, line in enumerate(lines): |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
242 if ':' in line: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
243 lheader = line.split(':', 1)[0].strip().lower() |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
244 lprio = PLAINHEADERS.get(lheader, newprio + 1) |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
245 if lprio == newprio: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
246 lines[i] = '%s: %s' % (header, value) |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
247 return lines |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
248 if lprio > newprio and i < bestpos: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
249 bestpos = i |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
250 else: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
251 if line: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
252 lines.insert(i, '') |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
253 if i < bestpos: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
254 bestpos = i |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
255 break |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
256 lines.insert(bestpos, '%s: %s' % (header, value)) |
23345
83cbf556babf
mq: introduce insertplainheader - same naive implementation as before
Mads Kiilerich <madski@unity3d.com>
parents:
23344
diff
changeset
|
257 return lines |
83cbf556babf
mq: introduce insertplainheader - same naive implementation as before
Mads Kiilerich <madski@unity3d.com>
parents:
23344
diff
changeset
|
258 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
259 class patchheader(object): |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
260 def __init__(self, pf, plainmode=False): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
261 def eatdiff(lines): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
262 while lines: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
263 l = lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
264 if (l.startswith("diff -") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
265 l.startswith("Index:") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
266 l.startswith("===========")): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
267 del lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
268 else: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
269 break |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
270 def eatempty(lines): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
271 while lines: |
10688
d4d3a8a65248
mq: don't use regexp when not necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10687
diff
changeset
|
272 if not lines[-1].strip(): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
273 del lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
274 else: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
275 break |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
276 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
277 message = [] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
278 comments = [] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
279 user = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
280 date = None |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
281 parent = None |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
282 format = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
283 subject = None |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
284 branch = None |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
285 nodeid = None |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
286 diffstart = 0 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
287 |
35918
e35616bb6ede
py3: use open() instead of file()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35916
diff
changeset
|
288 for line in open(pf, 'rb'): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
289 line = line.rstrip() |
10730
4d6bd7b8b6d8
mq: allow lines starting with '--- ' in patch messages
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10691
diff
changeset
|
290 if (line.startswith('diff --git') |
4d6bd7b8b6d8
mq: allow lines starting with '--- ' in patch messages
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10691
diff
changeset
|
291 or (diffstart and line.startswith('+++ '))): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
292 diffstart = 2 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
293 break |
10730
4d6bd7b8b6d8
mq: allow lines starting with '--- ' in patch messages
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10691
diff
changeset
|
294 diffstart = 0 # reset |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
295 if line.startswith("--- "): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
296 diffstart = 1 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
297 continue |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
298 elif format == "hgpatch": |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
299 # parse values when importing the result of an hg export |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
300 if line.startswith("# User "): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
301 user = line[7:] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
302 elif line.startswith("# Date "): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
303 date = line[7:] |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
304 elif line.startswith("# Parent "): |
22521
3f948469bac0
mq: write '# Parent ' lines with two spaces like export does (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22520
diff
changeset
|
305 parent = line[9:].lstrip() # handle double trailing space |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
306 elif line.startswith("# Branch "): |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
307 branch = line[9:] |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
308 elif line.startswith("# Node ID "): |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
309 nodeid = line[10:] |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
310 elif not line.startswith("# ") and line: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
311 message.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
312 format = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
313 elif line == '# HG changeset patch': |
9287
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8948
diff
changeset
|
314 message = [] |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
315 format = "hgpatch" |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
316 elif (format != "tagdone" and (line.startswith("Subject: ") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
317 line.startswith("subject: "))): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
318 subject = line[9:] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
319 format = "tag" |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
320 elif (format != "tagdone" and (line.startswith("From: ") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
321 line.startswith("from: "))): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
322 user = line[6:] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
323 format = "tag" |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
324 elif (format != "tagdone" and (line.startswith("Date: ") or |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
325 line.startswith("date: "))): |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
326 date = line[6:] |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
327 format = "tag" |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
328 elif format == "tag" and line == "": |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
329 # when looking for tags (subject: from: etc) they |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
330 # end once you find a blank line in the source |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
331 format = "tagdone" |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
332 elif message or line: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
333 message.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
334 comments.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
335 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
336 eatdiff(message) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
337 eatdiff(comments) |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
338 # Remember the exact starting line of the patch diffs before consuming |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
339 # empty lines, for external use by TortoiseHg and others |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
340 self.diffstartline = len(comments) |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
341 eatempty(message) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
342 eatempty(comments) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
343 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
344 # make sure message isn't empty |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
345 if format and format.startswith("tag") and subject: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
346 message.insert(0, subject) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
347 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
348 self.message = message |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
349 self.comments = comments |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
350 self.user = user |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
351 self.date = date |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
352 self.parent = parent |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
353 # nodeid and branch are for external use by TortoiseHg and others |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
354 self.nodeid = nodeid |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
355 self.branch = branch |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
356 self.haspatch = diffstart > 1 |
22544
0d75ce895adc
mq: make patchheader .plainmode more reliable
Mads Kiilerich <madski@unity3d.com>
parents:
22522
diff
changeset
|
357 self.plainmode = (plainmode or |
0d75ce895adc
mq: make patchheader .plainmode more reliable
Mads Kiilerich <madski@unity3d.com>
parents:
22522
diff
changeset
|
358 '# HG changeset patch' not in self.comments and |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
25019
diff
changeset
|
359 any(c.startswith('Date: ') or |
22544
0d75ce895adc
mq: make patchheader .plainmode more reliable
Mads Kiilerich <madski@unity3d.com>
parents:
22522
diff
changeset
|
360 c.startswith('From: ') |
0d75ce895adc
mq: make patchheader .plainmode more reliable
Mads Kiilerich <madski@unity3d.com>
parents:
22522
diff
changeset
|
361 for c in self.comments)) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
362 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
363 def setuser(self, user): |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
364 try: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
365 inserthgheader(self.comments, '# User ', user) |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
366 except ValueError: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
367 if self.plainmode: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
368 insertplainheader(self.comments, 'From', user) |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
369 else: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
370 tmp = ['# HG changeset patch', '# User ' + user] |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
371 self.comments = tmp + self.comments |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
372 self.user = user |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
373 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
374 def setdate(self, date): |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
375 try: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
376 inserthgheader(self.comments, '# Date ', date) |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
377 except ValueError: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
378 if self.plainmode: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
379 insertplainheader(self.comments, 'Date', date) |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
380 else: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
381 tmp = ['# HG changeset patch', '# Date ' + date] |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
382 self.comments = tmp + self.comments |
9337
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
383 self.date = date |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
384 |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
385 def setparent(self, parent): |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
386 try: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
387 inserthgheader(self.comments, '# Parent ', parent) |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
388 except ValueError: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
389 if not self.plainmode: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
390 tmp = ['# HG changeset patch', '# Parent ' + parent] |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
391 self.comments = tmp + self.comments |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
392 self.parent = parent |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
393 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
394 def setmessage(self, message): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
395 if self.comments: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
396 self._delmsg() |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
397 self.message = [message] |
23344
6333412245ec
mq: when setting message in plain mode, separate it from header (issue4453)
Mads Kiilerich <madski@unity3d.com>
parents:
23128
diff
changeset
|
398 if message: |
6333412245ec
mq: when setting message in plain mode, separate it from header (issue4453)
Mads Kiilerich <madski@unity3d.com>
parents:
23128
diff
changeset
|
399 if self.plainmode and self.comments and self.comments[-1]: |
6333412245ec
mq: when setting message in plain mode, separate it from header (issue4453)
Mads Kiilerich <madski@unity3d.com>
parents:
23128
diff
changeset
|
400 self.comments.append('') |
6333412245ec
mq: when setting message in plain mode, separate it from header (issue4453)
Mads Kiilerich <madski@unity3d.com>
parents:
23128
diff
changeset
|
401 self.comments.append(message) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
402 |
35916
d41e41d11574
py3: add __bytes__() for mq.patchheader and make sure __str__ returns str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35888
diff
changeset
|
403 def __bytes__(self): |
22522
382c2be610dc
mq: simplify patchheader handling of the empty line before the diff
Mads Kiilerich <madski@unity3d.com>
parents:
22521
diff
changeset
|
404 s = '\n'.join(self.comments).rstrip() |
382c2be610dc
mq: simplify patchheader handling of the empty line before the diff
Mads Kiilerich <madski@unity3d.com>
parents:
22521
diff
changeset
|
405 if not s: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
406 return '' |
22522
382c2be610dc
mq: simplify patchheader handling of the empty line before the diff
Mads Kiilerich <madski@unity3d.com>
parents:
22521
diff
changeset
|
407 return s + '\n\n' |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
408 |
35916
d41e41d11574
py3: add __bytes__() for mq.patchheader and make sure __str__ returns str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35888
diff
changeset
|
409 __str__ = encoding.strmethod(__bytes__) |
d41e41d11574
py3: add __bytes__() for mq.patchheader and make sure __str__ returns str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35888
diff
changeset
|
410 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
411 def _delmsg(self): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
412 '''Remove existing message, keeping the rest of the comments fields. |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
413 If comments contains 'subject: ', message will prepend |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
414 the field and a blank line.''' |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
415 if self.message: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
416 subj = 'subject: ' + self.message[0].lower() |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
417 for i in pycompat.xrange(len(self.comments)): |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
418 if subj == self.comments[i].lower(): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
419 del self.comments[i] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
420 self.message = self.message[2:] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
421 break |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
422 ci = 0 |
8632
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
423 for mi in self.message: |
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
424 while mi != self.comments[ci]: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
425 ci += 1 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
426 del self.comments[ci] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
427 |
16102 | 428 def newcommit(repo, phase, *args, **kwargs): |
16057
db4b0532dbf2
mq: rename secretcommit to newcommit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16048
diff
changeset
|
429 """helper dedicated to ensure a commit respect mq.secret setting |
db4b0532dbf2
mq: rename secretcommit to newcommit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16048
diff
changeset
|
430 |
db4b0532dbf2
mq: rename secretcommit to newcommit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16048
diff
changeset
|
431 It should be used instead of repo.commit inside the mq source for operation |
db4b0532dbf2
mq: rename secretcommit to newcommit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16048
diff
changeset
|
432 creating new changeset. |
15926
f94513971767
mq: have mq create secret changeset only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15924
diff
changeset
|
433 """ |
18010
38b51a60a195
clfilter: ensure that mq performs commits on unfiltered repos
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17954
diff
changeset
|
434 repo = repo.unfiltered() |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
435 if phase is None: |
34184
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
436 if repo.ui.configbool('mq', 'secret'): |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
437 phase = phases.secret |
31460 | 438 overrides = {('ui', 'allowemptycommit'): True} |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
439 if phase is not None: |
31460 | 440 overrides[('phases', 'new-commit')] = phase |
441 with repo.ui.configoverride(overrides, 'mq'): | |
25019
672e0558aed1
mq: use ui.allowemptycommit to allow empty commits
Durham Goode <durham@fb.com>
parents:
24997
diff
changeset
|
442 repo.ui.setconfig('ui', 'allowemptycommit', True) |
15926
f94513971767
mq: have mq create secret changeset only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15924
diff
changeset
|
443 return repo.commit(*args, **kwargs) |
f94513971767
mq: have mq create secret changeset only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15924
diff
changeset
|
444 |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
445 class AbortNoCleanup(error.Abort): |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
446 pass |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
447 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8761
diff
changeset
|
448 class queue(object): |
19064
743daa601445
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)
Simon Heimberg <simohe@besonet.ch>
parents:
18958
diff
changeset
|
449 def __init__(self, ui, baseui, path, patchdir=None): |
1808 | 450 self.basepath = path |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
451 try: |
36107
bff95b002e33
py3: open patches.queue in binary mode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36106
diff
changeset
|
452 with open(os.path.join(path, 'patches.queue'), r'rb') as fh: |
bff95b002e33
py3: open patches.queue in binary mode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36106
diff
changeset
|
453 cur = fh.read().rstrip() |
bff95b002e33
py3: open patches.queue in binary mode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36106
diff
changeset
|
454 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
455 if not cur: |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
456 curpath = os.path.join(path, 'patches') |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
457 else: |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
458 curpath = os.path.join(path, 'patches-' + cur) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
459 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
460 curpath = os.path.join(path, 'patches') |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
461 self.path = patchdir or curpath |
31243
816bc3b35bac
vfs: use 'vfs' module directly in 'hgext.mq'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
462 self.opener = vfsmod.vfs(self.path) |
1808 | 463 self.ui = ui |
19064
743daa601445
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)
Simon Heimberg <simohe@besonet.ch>
parents:
18958
diff
changeset
|
464 self.baseui = baseui |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
465 self.applieddirty = False |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
466 self.seriesdirty = False |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
467 self.added = [] |
14587
5d3bb4460256
mq: rename series_path to seriespath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14586
diff
changeset
|
468 self.seriespath = "series" |
14588
bd3d75a03f80
mq: rename status_path to statuspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14587
diff
changeset
|
469 self.statuspath = "status" |
14589
7d59ee9e711b
mq: rename guards_path to guardspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14588
diff
changeset
|
470 self.guardspath = "guards" |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
471 self.activeguards = None |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
472 self.guardsdirty = False |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
473 # Handle mq.git as a bool with extended values |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
474 gitmode = ui.config('mq', 'git').lower() |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
475 boolmode = stringutil.parsebool(gitmode) |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
476 if boolmode is not None: |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
477 if boolmode: |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
478 gitmode = 'yes' |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
479 else: |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
480 gitmode = 'no' |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
481 self.gitmode = gitmode |
25827
0fdf2c304019
mq: tweak config reading to make check-config happy
Matt Mackall <mpm@selenic.com>
parents:
25660
diff
changeset
|
482 # deprecated config: mq.plain |
34183
5c150b70d004
configitems: register the 'mq.plain' config
Boris Feld <boris.feld@octobus.net>
parents:
34182
diff
changeset
|
483 self.plainmode = ui.configbool('mq', 'plain') |
19856
28b1b7b9b4a9
shelve: allow shelving of a change with an mq patch applied
David Soria Parra <dsp@experimentalworks.net>
parents:
19826
diff
changeset
|
484 self.checkapplied = True |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
485 |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
486 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
487 def applied(self): |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
488 def parselines(lines): |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
489 for l in lines: |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
490 entry = l.split(':', 1) |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
491 if len(entry) > 1: |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
492 n, name = entry |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
493 yield statusentry(bin(n), name) |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
494 elif l.strip(): |
38050
558e5504a4f8
py3: use stringutil.pprint() to format a list to print
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38049
diff
changeset
|
495 self.ui.warn(_('malformated mq status line: %s\n') % |
558e5504a4f8
py3: use stringutil.pprint() to format a list to print
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38049
diff
changeset
|
496 stringutil.pprint(entry)) |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
497 # else we ignore empty lines |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
498 try: |
14588
bd3d75a03f80
mq: rename status_path to statuspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14587
diff
changeset
|
499 lines = self.opener.read(self.statuspath).splitlines() |
13507
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
500 return list(parselines(lines)) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
501 except IOError as e: |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
502 if e.errno == errno.ENOENT: |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
503 return [] |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
504 raise |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
505 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
506 @util.propertycache |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
507 def fullseries(self): |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
508 try: |
15878 | 509 return self.opener.read(self.seriespath).splitlines() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
510 except IOError as e: |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
511 if e.errno == errno.ENOENT: |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
512 return [] |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
513 raise |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
514 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
515 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
516 def series(self): |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
517 self.parseseries() |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
518 return self.series |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
519 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
520 @util.propertycache |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
521 def seriesguards(self): |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
522 self.parseseries() |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
523 return self.seriesguards |
1808 | 524 |
8525
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
525 def invalidate(self): |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
526 for a in 'applied fullseries series seriesguards'.split(): |
8525
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
527 if a in self.__dict__: |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
528 delattr(self, a) |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
529 self.applieddirty = False |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
530 self.seriesdirty = False |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
531 self.guardsdirty = False |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
532 self.activeguards = None |
8525
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
533 |
34090
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
534 def diffopts(self, opts=None, patchfn=None, plain=False): |
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
535 """Return diff options tweaked for this mq use, possibly upgrading to |
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
536 git format, and possibly plain and without lossy options.""" |
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
537 diffopts = patchmod.difffeatureopts(self.ui, opts, |
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
538 git=True, whitespace=not plain, formatchanging=not plain) |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
539 if self.gitmode == 'auto': |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
540 diffopts.upgrade = True |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
541 elif self.gitmode == 'keep': |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
542 pass |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
543 elif self.gitmode in ('yes', 'no'): |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
544 diffopts.git = self.gitmode == 'yes' |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
545 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
546 raise error.Abort(_('mq.git option can be auto/keep/yes/no' |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
547 ' got %s') % self.gitmode) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
548 if patchfn: |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
549 diffopts = self.patchopts(diffopts, patchfn) |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
550 return diffopts |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
551 |
10186
296a0b14a686
mq: preserve --git flag when folding patches
Patrick Mezard <pmezard@gmail.com>
parents:
10185
diff
changeset
|
552 def patchopts(self, diffopts, *patches): |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
553 """Return a copy of input diff options with git set to true if |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
554 referenced patch is a git patch and should be preserved as such. |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
555 """ |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
556 diffopts = diffopts.copy() |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
557 if not diffopts.git and self.gitmode == 'keep': |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
558 for patchfn in patches: |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
559 patchf = self.opener(patchfn, 'r') |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
560 # if the patch was a git patch, refresh it as a git patch |
36342
02c35e640b3c
mq: don't reimplement any()
Martin von Zweigbergk <martinvonz@google.com>
parents:
36282
diff
changeset
|
561 diffopts.git = any(line.startswith('diff --git') |
02c35e640b3c
mq: don't reimplement any()
Martin von Zweigbergk <martinvonz@google.com>
parents:
36282
diff
changeset
|
562 for line in patchf) |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
563 patchf.close() |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
564 return diffopts |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2873
diff
changeset
|
565 |
2819 | 566 def join(self, *p): |
567 return os.path.join(self.path, *p) | |
568 | |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
569 def findseries(self, patch): |
10685
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
570 def matchpatch(l): |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
571 l = l.split('#', 1)[0] |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
572 return l.strip() == patch |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
573 for index, l in enumerate(self.fullseries): |
10685
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
574 if matchpatch(l): |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
575 return index |
1808 | 576 return None |
577 | |
35145
25c543944bc0
py3: add b'' to regular expressions which are raw strings
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34918
diff
changeset
|
578 guard_re = re.compile(br'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
579 |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
580 def parseseries(self): |
1808 | 581 self.series = [] |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
582 self.seriesguards = [] |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
583 for l in self.fullseries: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
584 h = l.find('#') |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
585 if h == -1: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
586 patch = l |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
587 comment = '' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
588 elif h == 0: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
589 continue |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
590 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
591 patch = l[:h] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
592 comment = l[h:] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
593 patch = patch.strip() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
594 if patch: |
3184
87b7ae306d54
mq: bail out if a patch appears more than once in the series file.
Brendan Cully <brendan@kublai.com>
parents:
3183
diff
changeset
|
595 if patch in self.series: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
596 raise error.Abort(_('%s appears more than once in %s') % |
14587
5d3bb4460256
mq: rename series_path to seriespath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14586
diff
changeset
|
597 (patch, self.join(self.seriespath))) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
598 self.series.append(patch) |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
599 self.seriesguards.append(self.guard_re.findall(comment)) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
600 |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
601 def checkguard(self, guard): |
6607
75b506f0e571
mq: make qselect fail properly on an empty guard
Patrick Mezard <pmezard@gmail.com>
parents:
6606
diff
changeset
|
602 if not guard: |
75b506f0e571
mq: make qselect fail properly on an empty guard
Patrick Mezard <pmezard@gmail.com>
parents:
6606
diff
changeset
|
603 return _('guard cannot be an empty string') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
604 bad_chars = '# \t\r\n\f' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
605 first = guard[0] |
8288
9de088320e9a
mq: simpler check of first character of guard name
Simon Heimberg <simohe@besonet.ch>
parents:
8225
diff
changeset
|
606 if first in '-+': |
9de088320e9a
mq: simpler check of first character of guard name
Simon Heimberg <simohe@besonet.ch>
parents:
8225
diff
changeset
|
607 return (_('guard %r starts with invalid character: %r') % |
9de088320e9a
mq: simpler check of first character of guard name
Simon Heimberg <simohe@besonet.ch>
parents:
8225
diff
changeset
|
608 (guard, first)) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
609 for c in bad_chars: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
610 if c in guard: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
611 return _('invalid character in guard %r: %r') % (guard, c) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
612 |
14578
28a2646f3b81
mq: rename set_active to setactive
Adrian Buehlmann <adrian@cadifra.com>
parents:
14577
diff
changeset
|
613 def setactive(self, guards): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
614 for guard in guards: |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
615 bad = self.checkguard(guard) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
616 if bad: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
617 raise error.Abort(bad) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8188
diff
changeset
|
618 guards = sorted(set(guards)) |
9467
4c041f1ee1b4
do not attempt to translate ui.debug output
Martin Geisler <mg@lazybytes.net>
parents:
9440
diff
changeset
|
619 self.ui.debug('active guards: %s\n' % ' '.join(guards)) |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
620 self.activeguards = guards |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
621 self.guardsdirty = True |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
622 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
623 def active(self): |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
624 if self.activeguards is None: |
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
625 self.activeguards = [] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
626 try: |
14589
7d59ee9e711b
mq: rename guards_path to guardspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14588
diff
changeset
|
627 guards = self.opener.read(self.guardspath).split() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
628 except IOError as err: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
629 if err.errno != errno.ENOENT: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
630 raise |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
631 guards = [] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
632 for i, guard in enumerate(guards): |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
633 bad = self.checkguard(guard) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
634 if bad: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
635 self.ui.warn('%s:%d: %s\n' % |
14589
7d59ee9e711b
mq: rename guards_path to guardspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14588
diff
changeset
|
636 (self.join(self.guardspath), i + 1, bad)) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
637 else: |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
638 self.activeguards.append(guard) |
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
639 return self.activeguards |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
640 |
14577
76357276662e
mq: rename set_guards to setguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14576
diff
changeset
|
641 def setguards(self, idx, guards): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
642 for g in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
643 if len(g) < 2: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
644 raise error.Abort(_('guard %r too short') % g) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
645 if g[0] not in '-+': |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
646 raise error.Abort(_('guard %r starts with invalid char') % g) |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
647 bad = self.checkguard(g[1:]) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
648 if bad: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
649 raise error.Abort(bad) |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
650 drop = self.guard_re.sub('', self.fullseries[idx]) |
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
651 self.fullseries[idx] = drop + ''.join([' #' + g for g in guards]) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
652 self.parseseries() |
14593
599a72895c0d
mq: rename series_dirty to seriesdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14592
diff
changeset
|
653 self.seriesdirty = True |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
654 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
655 def pushable(self, idx): |
36106
c33a99506e13
py3: compare against bytes instead of str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36032
diff
changeset
|
656 if isinstance(idx, bytes): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
657 idx = self.series.index(idx) |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
658 patchguards = self.seriesguards[idx] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
659 if not patchguards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
660 return True, None |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
661 guards = self.active() |
37520
fa6cdd6668e1
py3: use .startswith() instead of bytes[0]
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37381
diff
changeset
|
662 exactneg = [g for g in patchguards |
fa6cdd6668e1
py3: use .startswith() instead of bytes[0]
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37381
diff
changeset
|
663 if g.startswith('-') and g[1:] in guards] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
664 if exactneg: |
39049
b53ec524420b
mq: use stringutil.pprint instead of pycompat.byterepr
Augie Fackler <augie@google.com>
parents:
38783
diff
changeset
|
665 return False, stringutil.pprint(exactneg[0]) |
37520
fa6cdd6668e1
py3: use .startswith() instead of bytes[0]
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37381
diff
changeset
|
666 pos = [g for g in patchguards if g.startswith('+')] |
2850
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
667 exactpos = [g for g in pos if g[1:] in guards] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
668 if pos: |
2850
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
669 if exactpos: |
39049
b53ec524420b
mq: use stringutil.pprint instead of pycompat.byterepr
Augie Fackler <augie@google.com>
parents:
38783
diff
changeset
|
670 return True, stringutil.pprint(exactpos[0]) |
b53ec524420b
mq: use stringutil.pprint instead of pycompat.byterepr
Augie Fackler <augie@google.com>
parents:
38783
diff
changeset
|
671 return False, ' '.join([stringutil.pprint(p) for p in pos]) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
672 return True, '' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
673 |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
674 def explainpushable(self, idx, all_patches=False): |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
675 if all_patches: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
676 write = self.ui.write |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
677 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
678 write = self.ui.warn |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
679 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
680 if all_patches or self.ui.verbose: |
37521
2d00058ac2f8
py3: use bytes instead of str in isinstance()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37520
diff
changeset
|
681 if isinstance(idx, bytes): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
682 idx = self.series.index(idx) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
683 pushable, why = self.pushable(idx) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
684 if all_patches and pushable: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
685 if why is None: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
686 write(_('allowing %s - no guards in effect\n') % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
687 self.series[idx]) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
688 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
689 if not why: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
690 write(_('allowing %s - no matching negative guards\n') % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
691 self.series[idx]) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
692 else: |
14464
00256f689f9c
mq: print "'foo' 'bar'", not "['foo', 'bar']" when showing guards
Martin Geisler <mg@aragost.com>
parents:
14448
diff
changeset
|
693 write(_('allowing %s - guarded by %s\n') % |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
694 (self.series[idx], why)) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
695 if not pushable: |
2829
05316bb57d01
mq: make guards more strict, add tests
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2828
diff
changeset
|
696 if why: |
14464
00256f689f9c
mq: print "'foo' 'bar'", not "['foo', 'bar']" when showing guards
Martin Geisler <mg@aragost.com>
parents:
14448
diff
changeset
|
697 write(_('skipping %s - guarded by %s\n') % |
3870
22d18051f9e5
mq: fix explain_pushable for negative guards
Brendan Cully <brendan@kublai.com>
parents:
3857
diff
changeset
|
698 (self.series[idx], why)) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
699 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
700 write(_('skipping %s - no matching guards\n') % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
701 self.series[idx]) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
702 |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
703 def savedirty(self): |
14594
3752b5e1f4c4
mq: rename write_list to writelist
Adrian Buehlmann <adrian@cadifra.com>
parents:
14593
diff
changeset
|
704 def writelist(items, path): |
35843
512113eb9d26
mq: open status file et al in bytes mode
Augie Fackler <augie@google.com>
parents:
35842
diff
changeset
|
705 fp = self.opener(path, 'wb') |
2772
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
706 for i in items: |
5878
d39af2eabb8c
transform a bunch of print statements to appropriate ui calls
Matt Mackall <mpm@selenic.com>
parents:
5788
diff
changeset
|
707 fp.write("%s\n" % i) |
2772
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
708 fp.close() |
14592
fc94add69d9f
mq: rename applied_dirty to applieddirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14591
diff
changeset
|
709 if self.applieddirty: |
35844
522f868680ca
mq: use bytes() instead of str() to encode statusentries for writing
Augie Fackler <augie@google.com>
parents:
35843
diff
changeset
|
710 writelist(map(bytes, self.applied), self.statuspath) |
15883
91d99f02b26f
mq: only save dirty files once when savedirty is called multiple times
Mads Kiilerich <mads@kiilerich.com>
parents:
15882
diff
changeset
|
711 self.applieddirty = False |
14593
599a72895c0d
mq: rename series_dirty to seriesdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14592
diff
changeset
|
712 if self.seriesdirty: |
14594
3752b5e1f4c4
mq: rename write_list to writelist
Adrian Buehlmann <adrian@cadifra.com>
parents:
14593
diff
changeset
|
713 writelist(self.fullseries, self.seriespath) |
15883
91d99f02b26f
mq: only save dirty files once when savedirty is called multiple times
Mads Kiilerich <mads@kiilerich.com>
parents:
15882
diff
changeset
|
714 self.seriesdirty = False |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
715 if self.guardsdirty: |
14594
3752b5e1f4c4
mq: rename write_list to writelist
Adrian Buehlmann <adrian@cadifra.com>
parents:
14593
diff
changeset
|
716 writelist(self.activeguards, self.guardspath) |
15883
91d99f02b26f
mq: only save dirty files once when savedirty is called multiple times
Mads Kiilerich <mads@kiilerich.com>
parents:
15882
diff
changeset
|
717 self.guardsdirty = False |
11546
134eb1c97e94
mq: qrepo.add(mq.added) inside save_dirty inside of doing it manually
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11530
diff
changeset
|
718 if self.added: |
134eb1c97e94
mq: qrepo.add(mq.added) inside save_dirty inside of doing it manually
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11530
diff
changeset
|
719 qrepo = self.qrepo() |
134eb1c97e94
mq: qrepo.add(mq.added) inside save_dirty inside of doing it manually
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11530
diff
changeset
|
720 if qrepo: |
12658
97d7ee445e98
mq: silence spurious output.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12655
diff
changeset
|
721 qrepo[None].add(f for f in self.added if f not in qrepo[None]) |
11546
134eb1c97e94
mq: qrepo.add(mq.added) inside save_dirty inside of doing it manually
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11530
diff
changeset
|
722 self.added = [] |
1808 | 723 |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
724 def removeundo(self, repo): |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
725 undo = repo.sjoin('undo') |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
726 if not os.path.exists(undo): |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
727 return |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
728 try: |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
729 os.unlink(undo) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
730 except OSError as inst: |
36632
9e2866065982
py3: use util.forcevytestr to convert error to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36607
diff
changeset
|
731 self.ui.warn(_('error removing undo: %s\n') % |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
732 stringutil.forcebytestr(inst)) |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
733 |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
734 def backup(self, repo, files, copy=False): |
16633
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
735 # backup local changes in --force case |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
736 for f in sorted(files): |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
737 absf = repo.wjoin(f) |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
738 if os.path.lexists(absf): |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
739 self.ui.note(_('saving current version of %s as %s\n') % |
27651
07fc2f2134ba
origpath: move from cmdutil to scmutil
Siddharth Agarwal <sid0@fb.com>
parents:
27586
diff
changeset
|
740 (f, scmutil.origpath(self.ui, repo, f))) |
07fc2f2134ba
origpath: move from cmdutil to scmutil
Siddharth Agarwal <sid0@fb.com>
parents:
27586
diff
changeset
|
741 |
07fc2f2134ba
origpath: move from cmdutil to scmutil
Siddharth Agarwal <sid0@fb.com>
parents:
27586
diff
changeset
|
742 absorig = scmutil.origpath(self.ui, repo, absf) |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
743 if copy: |
26943
263edb591b72
mq: let the user choose where .orig files are kept
Christian Delahousse <cdelahousse@fb.com>
parents:
26831
diff
changeset
|
744 util.copyfile(absf, absorig) |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
745 else: |
26943
263edb591b72
mq: let the user choose where .orig files are kept
Christian Delahousse <cdelahousse@fb.com>
parents:
26831
diff
changeset
|
746 util.rename(absf, absorig) |
16633
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
747 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
748 def printdiff(self, repo, diffopts, node1, node2=None, files=None, |
31394
fd3d8eb7f545
mq: don't use mutable default argument value
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31333
diff
changeset
|
749 fp=None, changes=None, opts=None): |
31432
6e1c79578e5c
mq: explicitly tests for None
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31407
diff
changeset
|
750 if opts is None: |
6e1c79578e5c
mq: explicitly tests for None
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31407
diff
changeset
|
751 opts = {} |
9640
9e76232fbfbe
diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
9599
diff
changeset
|
752 stat = opts.get('stat') |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14636
diff
changeset
|
753 m = scmutil.match(repo[node1], files, opts) |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35844
diff
changeset
|
754 logcmdutil.diffordiffstat(self.ui, repo, diffopts, node1, node2, m, |
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35844
diff
changeset
|
755 changes, stat, fp) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2873
diff
changeset
|
756 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
757 def mergeone(self, repo, mergeq, head, patch, rev, diffopts): |
1808 | 758 # first try just applying the patch |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
759 (err, n) = self.apply(repo, [patch], update_status=False, |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
760 strict=True, merge=rev) |
1808 | 761 |
762 if err == 0: | |
763 return (err, n) | |
764 | |
765 if n is None: | |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
766 raise error.Abort(_("apply failed for patch %s") % patch) |
1808 | 767 |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
768 self.ui.warn(_("patch didn't work out, merging %s\n") % patch) |
1808 | 769 |
770 # apply failed, strip away that rev and merge. | |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
771 hg.clean(repo, head) |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
772 strip(self.ui, repo, [n], update=False, backup=False) |
1808 | 773 |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6668
diff
changeset
|
774 ctx = repo[rev] |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
775 ret = hg.merge(repo, rev) |
1808 | 776 if ret: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
777 raise error.Abort(_("update returned %d") % ret) |
16102 | 778 n = newcommit(repo, None, ctx.description(), ctx.user(), force=True) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
779 if n is None: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
780 raise error.Abort(_("repo commit failed")) |
1808 | 781 try: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
782 ph = patchheader(mergeq.join(patch), self.plainmode) |
16689
f366d4c2ff34
cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents:
16688
diff
changeset
|
783 except Exception: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
784 raise error.Abort(_("unable to read %s") % patch) |
1808 | 785 |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
786 diffopts = self.patchopts(diffopts, patch) |
1852
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
787 patchf = self.opener(patch, "w") |
36667
bcfc4e3b6548
py3: use bytes() instead of str()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36632
diff
changeset
|
788 comments = bytes(ph) |
1808 | 789 if comments: |
790 patchf.write(comments) | |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
791 self.printdiff(repo, diffopts, head, n, fp=patchf) |
1808 | 792 patchf.close() |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
793 self.removeundo(repo) |
1808 | 794 return (0, n) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
795 |
1808 | 796 def qparents(self, repo, rev=None): |
19816
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
797 """return the mq handled parent or p1 |
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
798 |
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
799 In some case where mq get himself in being the parent of a merge the |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
19916
diff
changeset
|
800 appropriate parent may be p2. |
19816
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
801 (eg: an in progress merge started with mq disabled) |
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
802 |
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
803 If no parent are managed by mq, p1 is returned. |
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
804 """ |
1808 | 805 if rev is None: |
806 (p1, p2) = repo.dirstate.parents() | |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
807 if p2 == nullid: |
1808 | 808 return p1 |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
809 if not self.applied: |
1808 | 810 return None |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
811 return self.applied[-1].node |
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
812 p1, p2 = repo.changelog.parents(rev) |
10680
45eb9b5dacf6
mq: simplify qparents calculation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10679
diff
changeset
|
813 if p2 != nullid and p2 in [x.node for x in self.applied]: |
45eb9b5dacf6
mq: simplify qparents calculation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10679
diff
changeset
|
814 return p2 |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
815 return p1 |
1808 | 816 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
817 def mergepatch(self, repo, mergeq, series, diffopts): |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
818 if not self.applied: |
1808 | 819 # each of the patches merged in will have two parents. This |
820 # can confuse the qrefresh, qdiff, and strip code because it | |
821 # needs to know which parent is actually in the patch queue. | |
822 # so, we insert a merge marker with only one parent. This way | |
823 # the first patch in the queue is never a merge patch | |
824 # | |
825 pname = ".hg.patches.merge.marker" | |
16102 | 826 n = newcommit(repo, None, '[mq]: merge marker', force=True) |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
827 self.removeundo(repo) |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
828 self.applied.append(statusentry(n, pname)) |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
829 self.applieddirty = True |
1808 | 830 |
831 head = self.qparents(repo) | |
832 | |
833 for patch in series: | |
2696 | 834 patch = mergeq.lookup(patch, strict=True) |
1808 | 835 if not patch: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
836 self.ui.warn(_("patch %s does not exist\n") % patch) |
1808 | 837 return (1, None) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
838 pushable, reason = self.pushable(patch) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
839 if not pushable: |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
840 self.explainpushable(patch, all_patches=True) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
841 continue |
1808 | 842 info = mergeq.isapplied(patch) |
843 if not info: | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
844 self.ui.warn(_("patch %s is not applied\n") % patch) |
1808 | 845 return (1, None) |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
846 rev = info[1] |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
847 err, head = self.mergeone(repo, mergeq, head, patch, rev, diffopts) |
1808 | 848 if head: |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
849 self.applied.append(statusentry(head, patch)) |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
850 self.applieddirty = True |
1808 | 851 if err: |
852 return (err, head) | |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
853 self.savedirty() |
1808 | 854 return (0, head) |
855 | |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
856 def patch(self, repo, patchfile): |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
857 '''Apply patchfile to the working directory. |
8761
0289f384e1e5
Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents:
8760
diff
changeset
|
858 patchfile: name of patch file''' |
14564
65f4512e40e4
patch: turn patch() touched files dict into a set
Patrick Mezard <pmezard@gmail.com>
parents:
14553
diff
changeset
|
859 files = set() |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
860 try: |
14260
00a881581400
patch: make patch()/internalpatch() always update the dirstate
Patrick Mezard <pmezard@gmail.com>
parents:
14259
diff
changeset
|
861 fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1, |
14382
2d16f15da7bd
patch: remove patch.patch() cwd argument
Patrick Mezard <pmezard@gmail.com>
parents:
14351
diff
changeset
|
862 files=files, eolmode=None) |
14260
00a881581400
patch: make patch()/internalpatch() always update the dirstate
Patrick Mezard <pmezard@gmail.com>
parents:
14259
diff
changeset
|
863 return (True, list(files), fuzz) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
864 except Exception as inst: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
865 self.ui.note(stringutil.forcebytestr(inst) + '\n') |
2919
b70740aefa4d
Unify mq and hg patch invocation.
Brendan Cully <brendan@kublai.com>
parents:
2905
diff
changeset
|
866 if not self.ui.verbose: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
867 self.ui.warn(_("patch failed, unable to continue (try -v)\n")) |
15085
110d6804bfc6
mq: don't suppress patch tracebacks when applying patches
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
15057
diff
changeset
|
868 self.ui.traceback() |
14260
00a881581400
patch: make patch()/internalpatch() always update the dirstate
Patrick Mezard <pmezard@gmail.com>
parents:
14259
diff
changeset
|
869 return (False, list(files), False) |
2796
4c39568007f9
mq: codingstyle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2795
diff
changeset
|
870 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
871 def apply(self, repo, series, list=False, update_status=True, |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
872 strict=False, patchdir=None, merge=None, all_files=None, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
873 tobackup=None, keepchanges=False): |
26578
8bd2759f1fa7
dirstate: remove meaningless dirstateguard
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26345
diff
changeset
|
874 wlock = lock = tr = None |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
875 try: |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
876 wlock = repo.wlock() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
877 lock = repo.lock() |
10881
a685011ed38e
localrepo: add desc parameter to transaction
Steve Borho <steve@borho.org>
parents:
10873
diff
changeset
|
878 tr = repo.transaction("qpush") |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
879 try: |
4970
30d4d8985dd8
transactions: avoid late tear-down (issue641)
Matt Mackall <mpm@selenic.com>
parents:
4917
diff
changeset
|
880 ret = self._apply(repo, series, list, update_status, |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
881 strict, patchdir, merge, all_files=all_files, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
882 tobackup=tobackup, keepchanges=keepchanges) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
883 tr.close() |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
884 self.savedirty() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
885 return ret |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
886 except AbortNoCleanup: |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
887 tr.close() |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
888 self.savedirty() |
24826
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
889 raise |
16705
c2d9ef43ff6c
check-code: ignore naked excepts with a "re-raise" comment
Brodie Rao <brodie@sf.io>
parents:
16699
diff
changeset
|
890 except: # re-raises |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
891 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
892 tr.abort() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
893 finally: |
15881
3862369cf9b9
mq: use .invalidate to cancel dirty mq state when cancelling transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15880
diff
changeset
|
894 self.invalidate() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
895 raise |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
896 finally: |
26578
8bd2759f1fa7
dirstate: remove meaningless dirstateguard
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26345
diff
changeset
|
897 release(tr, lock, wlock) |
5527
0b3f910dfd17
mq: really remove undo after a qpush (and after a strip)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5432
diff
changeset
|
898 self.removeundo(repo) |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
899 |
4970
30d4d8985dd8
transactions: avoid late tear-down (issue641)
Matt Mackall <mpm@selenic.com>
parents:
4917
diff
changeset
|
900 def _apply(self, repo, series, list=False, update_status=True, |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
901 strict=False, patchdir=None, merge=None, all_files=None, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
902 tobackup=None, keepchanges=False): |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
903 """returns (error, hash) |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
904 |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
905 error = 1 for unable to read, 2 for patch failed, 3 for patch |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
906 fuzz. tobackup is None or a set of files to backup before they |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
907 are modified by a patch. |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
908 """ |
1808 | 909 # TODO unify with commands.py |
910 if not patchdir: | |
911 patchdir = self.path | |
912 err = 0 | |
913 n = None | |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
914 for patchname in series: |
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
915 pushable, reason = self.pushable(patchname) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
916 if not pushable: |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
917 self.explainpushable(patchname, all_patches=True) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
918 continue |
9111
ac3f1e6696eb
mq: use ui.status when pushing and popping patches
Martin Geisler <mg@lazybytes.net>
parents:
9110
diff
changeset
|
919 self.ui.status(_("applying %s\n") % patchname) |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
920 pf = os.path.join(patchdir, patchname) |
1808 | 921 |
922 try: | |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
923 ph = patchheader(self.join(patchname), self.plainmode) |
14239
967be4bb42a7
mq: loosen except clause when reading patch headers
Idan Kamara <idankk86@gmail.com>
parents:
14210
diff
changeset
|
924 except IOError: |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
925 self.ui.warn(_("unable to read %s\n") % patchname) |
1808 | 926 err = 1 |
927 break | |
928 | |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
929 message = ph.message |
1808 | 930 if not message: |
12849
d966eb464888
mq: mark strings that should not be translated
Martin Geisler <mg@lazybytes.net>
parents:
12848
diff
changeset
|
931 # The commit message should not be translated |
10274
04207f5e7344
mq: Do not translate import message that are appended to commits.
David Soria Parra <dsp@php.net>
parents:
10263
diff
changeset
|
932 message = "imported patch %s\n" % patchname |
1808 | 933 else: |
934 if list: | |
12849
d966eb464888
mq: mark strings that should not be translated
Martin Geisler <mg@lazybytes.net>
parents:
12848
diff
changeset
|
935 # The commit message should not be translated |
10274
04207f5e7344
mq: Do not translate import message that are appended to commits.
David Soria Parra <dsp@php.net>
parents:
10263
diff
changeset
|
936 message.append("\nimported patch %s" % patchname) |
1808 | 937 message = '\n'.join(message) |
938 | |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
939 if ph.haspatch: |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
940 if tobackup: |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
941 touched = patchmod.changedfiles(self.ui, repo, pf) |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
942 touched = set(touched) & tobackup |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
943 if touched and keepchanges: |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
944 raise AbortNoCleanup( |
24826
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
945 _("conflicting local changes found"), |
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
946 hint=_("did you forget to qrefresh?")) |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
947 self.backup(repo, touched, copy=True) |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
948 tobackup = tobackup - touched |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
949 (patcherr, files, fuzz) = self.patch(repo, pf) |
10661
c4859aad1980
mq: all_files can be a set, remove dangerous default values
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10611
diff
changeset
|
950 if all_files is not None: |
c4859aad1980
mq: all_files can be a set, remove dangerous default values
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10611
diff
changeset
|
951 all_files.update(files) |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
952 patcherr = not patcherr |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
953 else: |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
954 self.ui.warn(_("patch %s is empty\n") % patchname) |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
955 patcherr, files, fuzz = 0, [], 0 |
1808 | 956 |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
957 if merge and files: |
4332
4e5e1638b165
mq: don't abort when merging a patch that removes files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4242
diff
changeset
|
958 # Mark as removed/merged and update dirstate parent info |
4e5e1638b165
mq: don't abort when merging a patch that removes files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4242
diff
changeset
|
959 removed = [] |
4e5e1638b165
mq: don't abort when merging a patch that removes files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4242
diff
changeset
|
960 merged = [] |
4e5e1638b165
mq: don't abort when merging a patch that removes files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4242
diff
changeset
|
961 for f in files: |
12344
b6173aee4a47
Use lexists() instead of exists() where appropriate
Patrick Mezard <pmezard@gmail.com>
parents:
12067
diff
changeset
|
962 if os.path.lexists(repo.wjoin(f)): |
4332
4e5e1638b165
mq: don't abort when merging a patch that removes files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4242
diff
changeset
|
963 merged.append(f) |
4e5e1638b165
mq: don't abort when merging a patch that removes files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4242
diff
changeset
|
964 else: |
4e5e1638b165
mq: don't abort when merging a patch that removes files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4242
diff
changeset
|
965 removed.append(f) |
32347
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
966 with repo.dirstate.parentchange(): |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
967 for f in removed: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
968 repo.dirstate.remove(f) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
969 for f in merged: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
970 repo.dirstate.merge(f) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
971 p1, p2 = repo.dirstate.parents() |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
972 repo.setparents(p1, merge) |
6603
41eb20cc1c02
match: remove files arg from repo.status and friends
Matt Mackall <mpm@selenic.com>
parents:
6602
diff
changeset
|
973 |
19638
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
974 if all_files and '.hgsubstate' in all_files: |
20959
b6e0616d08cb
mq: repo['.'] is not a wctx, repo[None] is
Mads Kiilerich <madski@unity3d.com>
parents:
20924
diff
changeset
|
975 wctx = repo[None] |
b6e0616d08cb
mq: repo['.'] is not a wctx, repo[None] is
Mads Kiilerich <madski@unity3d.com>
parents:
20924
diff
changeset
|
976 pctx = repo['.'] |
19638
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
977 overwrite = False |
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35948
diff
changeset
|
978 mergedsubstate = subrepoutil.submerge(repo, pctx, wctx, wctx, |
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35948
diff
changeset
|
979 overwrite) |
19638
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
980 files += mergedsubstate.keys() |
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
981 |
14322
a90131b85fd8
scmutil: drop aliases in cmdutil for match functions
Matt Mackall <mpm@selenic.com>
parents:
14319
diff
changeset
|
982 match = scmutil.matchfiles(repo, files or []) |
39895
1a184b727aff
repo: don't look up context for tip node if it's not needed
Martin von Zweigbergk <martinvonz@google.com>
parents:
39818
diff
changeset
|
983 oldtip = repo.changelog.tip() |
16102 | 984 n = newcommit(repo, None, message, ph.user, ph.date, match=match, |
985 force=True) | |
39895
1a184b727aff
repo: don't look up context for tip node if it's not needed
Martin von Zweigbergk <martinvonz@google.com>
parents:
39818
diff
changeset
|
986 if repo.changelog.tip() == oldtip: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
987 raise error.Abort(_("qpush exactly duplicates child changeset")) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
988 if n is None: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
989 raise error.Abort(_("repository commit failed")) |
1808 | 990 |
991 if update_status: | |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
992 self.applied.append(statusentry(n, patchname)) |
1808 | 993 |
994 if patcherr: | |
24365
f1eaf03dd608
commands: say "working directory" in full spelling
Yuya Nishihara <yuya@tcha.org>
parents:
24306
diff
changeset
|
995 self.ui.warn(_("patch failed, rejects left in working " |
f1eaf03dd608
commands: say "working directory" in full spelling
Yuya Nishihara <yuya@tcha.org>
parents:
24306
diff
changeset
|
996 "directory\n")) |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
997 err = 2 |
1808 | 998 break |
999 | |
1000 if fuzz and strict: | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1001 self.ui.warn(_("fuzz found when applying patch, stopping\n")) |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1002 err = 3 |
1808 | 1003 break |
1004 return (err, n) | |
1005 | |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1006 def _cleanup(self, patches, numrevs, keep=False): |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1007 if not keep: |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1008 r = self.qrepo() |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1009 if r: |
14435
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
1010 r[None].forget(patches) |
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
1011 for p in patches: |
18067
6f62e005781d
mq: don't fail when removing a patch without patch file from series file
Mads Kiilerich <mads@kiilerich.com>
parents:
18054
diff
changeset
|
1012 try: |
6f62e005781d
mq: don't fail when removing a patch without patch file from series file
Mads Kiilerich <mads@kiilerich.com>
parents:
18054
diff
changeset
|
1013 os.unlink(self.join(p)) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
1014 except OSError as inst: |
18067
6f62e005781d
mq: don't fail when removing a patch without patch file from series file
Mads Kiilerich <mads@kiilerich.com>
parents:
18054
diff
changeset
|
1015 if inst.errno != errno.ENOENT: |
6f62e005781d
mq: don't fail when removing a patch without patch file from series file
Mads Kiilerich <mads@kiilerich.com>
parents:
18054
diff
changeset
|
1016 raise |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1017 |
15920
885e0c71db9b
mq: turn changeset draft on qfinish (except if qparent is secret)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15883
diff
changeset
|
1018 qfinished = [] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1019 if numrevs: |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1020 qfinished = self.applied[:numrevs] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1021 del self.applied[:numrevs] |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1022 self.applieddirty = True |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1023 |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1024 unknown = [] |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1025 |
37525
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1026 sortedseries = [] |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1027 for p in patches: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1028 idx = self.findseries(p) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1029 if idx is None: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1030 sortedseries.append((-1, p)) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1031 else: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1032 sortedseries.append((idx, p)) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1033 |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1034 sortedseries.sort(reverse=True) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1035 for (i, p) in sortedseries: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1036 if i != -1: |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1037 del self.fullseries[i] |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1038 else: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1039 unknown.append(p) |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1040 |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1041 if unknown: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1042 if numrevs: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1043 rev = dict((entry.name, entry.node) for entry in qfinished) |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1044 for p in unknown: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1045 msg = _('revision %s refers to unknown patches: %s\n') |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1046 self.ui.warn(msg % (short(rev[p]), p)) |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1047 else: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1048 msg = _('unknown patches: %s\n') |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1049 raise error.Abort(''.join(msg % p for p in unknown)) |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1050 |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
1051 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1052 self.seriesdirty = True |
15920
885e0c71db9b
mq: turn changeset draft on qfinish (except if qparent is secret)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15883
diff
changeset
|
1053 return [entry.node for entry in qfinished] |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1054 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1055 def _revpatches(self, repo, revs): |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1056 firstrev = repo[self.applied[0].node].rev() |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1057 patches = [] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1058 for i, rev in enumerate(revs): |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1059 |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1060 if rev < firstrev: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1061 raise error.Abort(_('revision %d is not managed') % rev) |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1062 |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1063 ctx = repo[rev] |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1064 base = self.applied[i].node |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1065 if ctx.node() != base: |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1066 msg = _('cannot delete revision %d above applied patches') |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1067 raise error.Abort(msg % rev) |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1068 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1069 patch = self.applied[i].name |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1070 for fmt in ('[mq]: %s', 'imported patch %s'): |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1071 if ctx.description() == fmt % patch: |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1072 msg = _('patch %s finalized without changeset message\n') |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1073 repo.ui.status(msg % patch) |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1074 break |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1075 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1076 patches.append(patch) |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1077 return patches |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1078 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1079 def finish(self, repo, revs): |
16029
ee1c8385e5b0
qfinish: do not set secret changeset to draft if mq.secret=false
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16028
diff
changeset
|
1080 # Manually trigger phase computation to ensure phasedefaults is |
ee1c8385e5b0
qfinish: do not set secret changeset to draft if mq.secret=false
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16028
diff
changeset
|
1081 # executed before we remove the patches. |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16656
diff
changeset
|
1082 repo._phasecache |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1083 patches = self._revpatches(repo, sorted(revs)) |
15920
885e0c71db9b
mq: turn changeset draft on qfinish (except if qparent is secret)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15883
diff
changeset
|
1084 qfinished = self._cleanup(patches, len(patches)) |
34184
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
1085 if qfinished and repo.ui.configbool('mq', 'secret'): |
16029
ee1c8385e5b0
qfinish: do not set secret changeset to draft if mq.secret=false
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16028
diff
changeset
|
1086 # only use this logic when the secret option is added |
15920
885e0c71db9b
mq: turn changeset draft on qfinish (except if qparent is secret)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15883
diff
changeset
|
1087 oldqbase = repo[qfinished[0]] |
34562
c2d2e18f9700
mq: use the newcommitphase utility
Boris Feld <boris.feld@octobus.net>
parents:
34505
diff
changeset
|
1088 tphase = phases.newcommitphase(repo.ui) |
16290
9518cb55c822
qfinish: comply with the phases.new-commit option in secret mode (issue3335)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16278
diff
changeset
|
1089 if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase: |
27864
4b8e3ffee94f
with: use context manager for transaction in qfinish
Bryan O'Sullivan <bryano@fb.com>
parents:
27848
diff
changeset
|
1090 with repo.transaction('qfinish') as tr: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22057
diff
changeset
|
1091 phases.advanceboundary(repo, tr, tphase, qfinished) |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1092 |
3088
dc784839516d
mq: add qdelete --forget option
Brendan Cully <brendan@kublai.com>
parents:
3087
diff
changeset
|
1093 def delete(self, repo, patches, opts): |
4736
04b2c1e27c26
mq: require patch argument or revision for qdelete
Brendan Cully <brendan@kublai.com>
parents:
4730
diff
changeset
|
1094 if not patches and not opts.get('rev'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1095 raise error.Abort(_('qdelete requires at least one revision or ' |
4737
2ececafa5859
mq: more qdelete help text tweaks
Brendan Cully <brendan@kublai.com>
parents:
4736
diff
changeset
|
1096 'patch name')) |
4736
04b2c1e27c26
mq: require patch argument or revision for qdelete
Brendan Cully <brendan@kublai.com>
parents:
4730
diff
changeset
|
1097 |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
1098 realpatches = [] |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1099 for patch in patches: |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1100 patch = self.lookup(patch, strict=True) |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1101 info = self.isapplied(patch) |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1102 if info: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1103 raise error.Abort(_("cannot delete applied patch %s") % patch) |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1104 if patch not in self.series: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1105 raise error.Abort(_("patch %s not in series file") % patch) |
12655
5192b24f309c
mq: handle deleting the same patch twice in one command (issue2427)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12590
diff
changeset
|
1106 if patch not in realpatches: |
5192b24f309c
mq: handle deleting the same patch twice in one command (issue2427)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12590
diff
changeset
|
1107 realpatches.append(patch) |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1108 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1109 numrevs = 0 |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1110 if opts.get('rev'): |
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1111 if not self.applied: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1112 raise error.Abort(_('no patches applied')) |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14298
diff
changeset
|
1113 revs = scmutil.revrange(repo, opts.get('rev')) |
22803
31a591c3fecc
mq: use `revs.sort()` to ensure the set is ascending
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22547
diff
changeset
|
1114 revs.sort() |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1115 revpatches = self._revpatches(repo, revs) |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
1116 realpatches += revpatches |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1117 numrevs = len(revpatches) |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1118 |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
1119 self._cleanup(realpatches, numrevs, opts.get('keep')) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1120 |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1121 def checktoppatch(self, repo): |
18343
cfa731b45b75
mq: checktoppatch should only check if p1 is qtip
Mads Kiilerich <mads@kiilerich.com>
parents:
18342
diff
changeset
|
1122 '''check that working directory is at qtip''' |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1123 if self.applied: |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1124 top = self.applied[-1].node |
10191
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1125 patch = self.applied[-1].name |
18343
cfa731b45b75
mq: checktoppatch should only check if p1 is qtip
Mads Kiilerich <mads@kiilerich.com>
parents:
18342
diff
changeset
|
1126 if repo.dirstate.p1() != top: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1127 raise error.Abort(_("working directory revision is not qtip")) |
10191
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1128 return top, patch |
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1129 return None, None |
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1130 |
17152
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1131 def putsubstate2changes(self, substatestate, changes): |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1132 for files in changes[:3]: |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1133 if '.hgsubstate' in files: |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1134 return # already listed up |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1135 # not yet listed up |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1136 if substatestate in 'a?': |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1137 changes[1].append('.hgsubstate') |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1138 elif substatestate in 'r': |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1139 changes[2].append('.hgsubstate') |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1140 else: # modified |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1141 changes[0].append('.hgsubstate') |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1142 |
19812
5d6cfdc38a3d
mq: simplifies the refresh hint in checklocalchanges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19763
diff
changeset
|
1143 def checklocalchanges(self, repo, force=False, refresh=True): |
5d6cfdc38a3d
mq: simplifies the refresh hint in checklocalchanges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19763
diff
changeset
|
1144 excsuffix = '' |
14256
d04ba50e104d
mq: allow to qpop/push with a dirty working copy (issue2780)
Idan Kamara <idankk86@gmail.com>
parents:
14241
diff
changeset
|
1145 if refresh: |
26780 | 1146 excsuffix = ', qrefresh first' |
19812
5d6cfdc38a3d
mq: simplifies the refresh hint in checklocalchanges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19763
diff
changeset
|
1147 # plain versions for i18n tool to detect them |
26780 | 1148 _("local changes found, qrefresh first") |
1149 _("local changed subrepos found, qrefresh first") | |
19814
4495c6a272e0
mq: extract checklocalchanges from `mq.queue`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19813
diff
changeset
|
1150 return checklocalchanges(repo, force, excsuffix) |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
1151 |
14051
2b1226693c70
mq: add '.' and '..' to list of forbidden patch names
Idan Kamara <idankk86@gmail.com>
parents:
13791
diff
changeset
|
1152 _reserved = ('series', 'status', 'guards', '.', '..') |
14584
3343a74eea4e
mq: rename check_reserved_name to checkreservedname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14583
diff
changeset
|
1153 def checkreservedname(self, name): |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1154 if name in self._reserved: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1155 raise error.Abort(_('"%s" cannot be used as the name of a patch') |
5981
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
1156 % name) |
31556
448acdee9161
mq: reject new patch name containing leading/trailing whitespace
Yuya Nishihara <yuya@tcha.org>
parents:
31460
diff
changeset
|
1157 if name != name.strip(): |
448acdee9161
mq: reject new patch name containing leading/trailing whitespace
Yuya Nishihara <yuya@tcha.org>
parents:
31460
diff
changeset
|
1158 # whitespace is stripped by parseseries() |
448acdee9161
mq: reject new patch name containing leading/trailing whitespace
Yuya Nishihara <yuya@tcha.org>
parents:
31460
diff
changeset
|
1159 raise error.Abort(_('patch name cannot begin or end with ' |
448acdee9161
mq: reject new patch name containing leading/trailing whitespace
Yuya Nishihara <yuya@tcha.org>
parents:
31460
diff
changeset
|
1160 'whitespace')) |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1161 for prefix in ('.hg', '.mq'): |
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1162 if name.startswith(prefix): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1163 raise error.Abort(_('patch name cannot begin with "%s"') |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1164 % prefix) |
25454
b5a8bc09b0db
mq: ban \r and \n in patch names (issue4711)
Augie Fackler <augie@google.com>
parents:
25453
diff
changeset
|
1165 for c in ('#', ':', '\r', '\n'): |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1166 if c in name: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1167 raise error.Abort(_('%r cannot be used in the name of a patch') |
37559
c4a0626f6b6e
py3: use pycompat.bytestr() where repr in involved
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37525
diff
changeset
|
1168 % pycompat.bytestr(c)) |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1169 |
14422
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1170 def checkpatchname(self, name, force=False): |
14584
3343a74eea4e
mq: rename check_reserved_name to checkreservedname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14583
diff
changeset
|
1171 self.checkreservedname(name) |
14422
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1172 if not force and os.path.exists(self.join(name)): |
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1173 if os.path.isdir(self.join(name)): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1174 raise error.Abort(_('"%s" already exists as a directory') |
14422
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1175 % name) |
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1176 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1177 raise error.Abort(_('patch "%s" already exists') % name) |
5981
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
1178 |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1179 def makepatchname(self, title, fallbackname): |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1180 """Return a suitable filename for title, adding a suffix to make |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1181 it unique in the existing list""" |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1182 namebase = re.sub('[\s\W_]+', '_', title.lower()).strip('_') |
28388
b1d35e2e1af6
mq: restrict generated patch name to 75 characters (issue5117)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27919
diff
changeset
|
1183 namebase = namebase[:75] # avoid too long name (issue5117) |
27919
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1184 if namebase: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1185 try: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1186 self.checkreservedname(namebase) |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1187 except error.Abort: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1188 namebase = fallbackname |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1189 else: |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1190 namebase = fallbackname |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1191 name = namebase |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1192 i = 0 |
27919
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1193 while True: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1194 if name not in self.fullseries: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1195 try: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1196 self.checkpatchname(name) |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1197 break |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1198 except error.Abort: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1199 pass |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1200 i += 1 |
36032
f91b7f26c68a
py3: use "%d" instead of "%s" for integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36009
diff
changeset
|
1201 name = '%s__%d' % (namebase, i) |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1202 return name |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1203 |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1204 def checkkeepchanges(self, keepchanges, force): |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1205 if force and keepchanges: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1206 raise error.Abort(_('cannot use both --force and --keep-changes')) |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1207 |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1208 def new(self, repo, patchfn, *pats, **opts): |
7157
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
1209 """options: |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
1210 msg: a string or a no-argument function returning a string |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
1211 """ |
36387
dbf34d0ef9f6
py3: use pycompat.byteskwargs() to fix keyword arguments handling
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36343
diff
changeset
|
1212 opts = pycompat.byteskwargs(opts) |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
1213 msg = opts.get('msg') |
21420
d009f6555b81
mq: fold the code path to invoke editor into specific logic (qnew)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21270
diff
changeset
|
1214 edit = opts.get('edit') |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1215 editform = opts.get('editform', 'mq.qnew') |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
1216 user = opts.get('user') |
5788
4107e823dc2c
mq: add --currentdate and --date options to qnew and qrefresh
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5673
diff
changeset
|
1217 date = opts.get('date') |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1218 if date: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36389
diff
changeset
|
1219 date = dateutil.parsedate(date) |
34090
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
1220 diffopts = self.diffopts({'git': opts.get('git')}, plain=True) |
14424
4eb88d296f63
record: check patch name is valid before prompting in qrecord
Idan Kamara <idankk86@gmail.com>
parents:
14423
diff
changeset
|
1221 if opts.get('checkname', True): |
4eb88d296f63
record: check patch name is valid before prompting in qrecord
Idan Kamara <idankk86@gmail.com>
parents:
14423
diff
changeset
|
1222 self.checkpatchname(patchfn) |
19813
76796fe65bad
mq: extract checksubstate from the queue class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19812
diff
changeset
|
1223 inclsubs = checksubstate(repo) |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1224 if inclsubs: |
16366
913d1fa61398
mq: use list of already known target files instead of matching object for diff
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16365
diff
changeset
|
1225 substatestate = repo.dirstate['.hgsubstate'] |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
1226 if opts.get('include') or opts.get('exclude') or pats: |
7161
b420ef2c812b
mq: abort qnew -f if any file in an explicit list cannot be read
Brendan Cully <brendan@kublai.com>
parents:
7160
diff
changeset
|
1227 # detect missing files in pats |
b420ef2c812b
mq: abort qnew -f if any file in an explicit list cannot be read
Brendan Cully <brendan@kublai.com>
parents:
7160
diff
changeset
|
1228 def badfn(f, msg): |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1229 if f != '.hgsubstate': # .hgsubstate is auto-created |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1230 raise error.Abort('%s: %s' % (f, msg)) |
25469
cc3d94e5994e
mq: use the optional badfn argument when building a matcher
Matt Harbison <matt_harbison@yahoo.com>
parents:
25454
diff
changeset
|
1231 match = scmutil.match(repo[None], pats, opts, badfn=badfn) |
16366
913d1fa61398
mq: use list of already known target files instead of matching object for diff
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16365
diff
changeset
|
1232 changes = repo.status(match=match) |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
1233 else: |
16366
913d1fa61398
mq: use list of already known target files instead of matching object for diff
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16365
diff
changeset
|
1234 changes = self.checklocalchanges(repo, force=True) |
20786
d666da075b91
mq: omit ".hgsubstate" from qnew/qrefresh target list for consistent node hash
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20785
diff
changeset
|
1235 commitfiles = list(inclsubs) |
d666da075b91
mq: omit ".hgsubstate" from qnew/qrefresh target list for consistent node hash
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20785
diff
changeset
|
1236 for files in changes[:3]: |
20827
ca5dd216cb62
localrepo: omit ".hgsubstate" also from "added" files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20790
diff
changeset
|
1237 commitfiles.extend(files) |
20786
d666da075b91
mq: omit ".hgsubstate" from qnew/qrefresh target list for consistent node hash
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20785
diff
changeset
|
1238 match = scmutil.matchfiles(repo, commitfiles) |
10372
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
1239 if len(repo[None].parents()) > 1: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1240 raise error.Abort(_('cannot manage merge changesets')) |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1241 self.checktoppatch(repo) |
14585
74bf9c84cfd0
mq: rename full_series_end to fullseriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14584
diff
changeset
|
1242 insert = self.fullseriesend() |
27827
a5b168953013
with: use context manager for wlock in qnew
Bryan O'Sullivan <bryano@fb.com>
parents:
27651
diff
changeset
|
1243 with repo.wlock(): |
12878
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
1244 try: |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
1245 # if patch file write fails, abort early |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
1246 p = self.opener(patchfn, "w") |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
1247 except IOError as e: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1248 raise error.Abort(_('cannot write patch "%s": %s') |
34022
d5b2beca16c0
python3: wrap all uses of <exception>.strerror with strtolocal
Augie Fackler <raf@durin42.com>
parents:
33489
diff
changeset
|
1249 % (patchfn, encoding.strtolocal(e.strerror))) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1250 try: |
21234
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1251 defaultmsg = "[mq]: %s" % patchfn |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1252 editor = cmdutil.getcommiteditor(editform=editform) |
21420
d009f6555b81
mq: fold the code path to invoke editor into specific logic (qnew)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21270
diff
changeset
|
1253 if edit: |
21421
4941caa9f0f8
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21420
diff
changeset
|
1254 def finishdesc(desc): |
21234
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1255 if desc.rstrip(): |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1256 return desc |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1257 else: |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1258 return defaultmsg |
21421
4941caa9f0f8
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21420
diff
changeset
|
1259 # i18n: this message is shown in editor with "HG: " prefix |
4941caa9f0f8
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21420
diff
changeset
|
1260 extramsg = _('Leave message empty to use default message.') |
4941caa9f0f8
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21420
diff
changeset
|
1261 editor = cmdutil.getcommiteditor(finishdesc=finishdesc, |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1262 extramsg=extramsg, |
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1263 editform=editform) |
21234
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1264 commitmsg = msg |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1265 else: |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1266 commitmsg = msg or defaultmsg |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1267 |
16102 | 1268 n = newcommit(repo, None, commitmsg, user, date, match=match, |
21234
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1269 force=True, editor=editor) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
1270 if n is None: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1271 raise error.Abort(_("repo commit failed")) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1272 try: |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1273 self.fullseries[insert:insert] = [patchfn] |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1274 self.applied.append(statusentry(n, patchfn)) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
1275 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1276 self.seriesdirty = True |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1277 self.applieddirty = True |
21234
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1278 nctx = repo[n] |
22547
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1279 ph = patchheader(self.join(patchfn), self.plainmode) |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1280 if user: |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1281 ph.setuser(user) |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1282 if date: |
36389
469c7e146c8f
py3: use "%d" for integers instead of "%s"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36388
diff
changeset
|
1283 ph.setdate('%d %d' % date) |
22547
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1284 ph.setparent(hex(nctx.p1().node())) |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1285 msg = nctx.description().strip() |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1286 if msg == defaultmsg.strip(): |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1287 msg = '' |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1288 ph.setmessage(msg) |
35948
f87641bf4d23
py3: use bytes instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35918
diff
changeset
|
1289 p.write(bytes(ph)) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1290 if commitfiles: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1291 parent = self.qparents(repo, n) |
16366
913d1fa61398
mq: use list of already known target files instead of matching object for diff
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16365
diff
changeset
|
1292 if inclsubs: |
17152
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1293 self.putsubstate2changes(substatestate, changes) |
14241
45f7aa35f2fd
mq: don't hide the patch module
Idan Kamara <idankk86@gmail.com>
parents:
14239
diff
changeset
|
1294 chunks = patchmod.diff(repo, node1=parent, node2=n, |
16366
913d1fa61398
mq: use list of already known target files instead of matching object for diff
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16365
diff
changeset
|
1295 changes=changes, opts=diffopts) |
7308
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
1296 for chunk in chunks: |
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
1297 p.write(chunk) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1298 p.close() |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1299 r = self.qrepo() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1300 if r: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
1301 r[None].add([patchfn]) |
16705
c2d9ef43ff6c
check-code: ignore naked excepts with a "re-raise" comment
Brodie Rao <brodie@sf.io>
parents:
16699
diff
changeset
|
1302 except: # re-raises |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1303 repo.rollback() |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1304 raise |
7280
810ca383da9c
remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7271
diff
changeset
|
1305 except Exception: |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1306 patchpath = self.join(patchfn) |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1307 try: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1308 os.unlink(patchpath) |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16687
diff
changeset
|
1309 except OSError: |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1310 self.ui.warn(_('error unlinking %s\n') % patchpath) |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1311 raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1312 self.removeundo(repo) |
1808 | 1313 |
1314 def isapplied(self, patch): | |
1315 """returns (index, rev, patch)""" | |
8632
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
1316 for i, a in enumerate(self.applied): |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
1317 if a.name == patch: |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1318 return (i, a.node, a.name) |
1808 | 1319 return None |
1320 | |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
1321 # if the exact patch name does not exist, we try a few |
2696 | 1322 # variations. If strict is passed, we try only #1 |
1323 # | |
15256
8caf7a757afa
mq: fix corner cases for handling of patch 0 in qselect
Mads Kiilerich <mads@kiilerich.com>
parents:
15148
diff
changeset
|
1324 # 1) a number (as string) to indicate an offset in the series file |
2696 | 1325 # 2) a unique substring of the patch name was given |
1326 # 3) patchname[-+]num to indicate an offset in the series file | |
1327 def lookup(self, patch, strict=False): | |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1328 def partialname(s): |
2696 | 1329 if s in self.series: |
1330 return s | |
2765
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1331 matches = [x for x in self.series if s in x] |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1332 if len(matches) > 1: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1333 self.ui.warn(_('patch name "%s" is ambiguous:\n') % s) |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1334 for m in matches: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1335 self.ui.warn(' %s\n' % m) |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1336 return None |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1337 if matches: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1338 return matches[0] |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1339 if self.series and self.applied: |
2696 | 1340 if s == 'qtip': |
18054
b35e3364f94a
check-code: there must also be whitespace between ')' and operator
Mads Kiilerich <madski@unity3d.com>
parents:
18011
diff
changeset
|
1341 return self.series[self.seriesend(True) - 1] |
2696 | 1342 if s == 'qbase': |
1343 return self.series[0] | |
1344 return None | |
7568
12df451ce205
mq: don't warn about ambiguous patch name when using patch index (issue1439)
Jason Orendorff <jorendorff@mozilla.com>
parents:
7566
diff
changeset
|
1345 |
12df451ce205
mq: don't warn about ambiguous patch name when using patch index (issue1439)
Jason Orendorff <jorendorff@mozilla.com>
parents:
7566
diff
changeset
|
1346 if patch in self.series: |
12df451ce205
mq: don't warn about ambiguous patch name when using patch index (issue1439)
Jason Orendorff <jorendorff@mozilla.com>
parents:
7566
diff
changeset
|
1347 return patch |
2696 | 1348 |
2819 | 1349 if not os.path.isfile(self.join(patch)): |
1808 | 1350 try: |
1351 sno = int(patch) | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1352 except (ValueError, OverflowError): |
2696 | 1353 pass |
1354 else: | |
7568
12df451ce205
mq: don't warn about ambiguous patch name when using patch index (issue1439)
Jason Orendorff <jorendorff@mozilla.com>
parents:
7566
diff
changeset
|
1355 if -len(self.series) <= sno < len(self.series): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1356 return self.series[sno] |
7568
12df451ce205
mq: don't warn about ambiguous patch name when using patch index (issue1439)
Jason Orendorff <jorendorff@mozilla.com>
parents:
7566
diff
changeset
|
1357 |
2696 | 1358 if not strict: |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1359 res = partialname(patch) |
2696 | 1360 if res: |
1361 return res | |
3082
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1362 minus = patch.rfind('-') |
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1363 if minus >= 0: |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1364 res = partialname(patch[:minus]) |
2696 | 1365 if res: |
1366 i = self.series.index(res) | |
1367 try: | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1368 off = int(patch[minus + 1:] or 1) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1369 except (ValueError, OverflowError): |
2696 | 1370 pass |
1371 else: | |
1372 if i - off >= 0: | |
1373 return self.series[i - off] | |
3082
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1374 plus = patch.rfind('+') |
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1375 if plus >= 0: |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1376 res = partialname(patch[:plus]) |
2696 | 1377 if res: |
1378 i = self.series.index(res) | |
1379 try: | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1380 off = int(patch[plus + 1:] or 1) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1381 except (ValueError, OverflowError): |
2696 | 1382 pass |
1383 else: | |
1384 if i + off < len(self.series): | |
1385 return self.series[i + off] | |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1386 raise error.Abort(_("patch %s not in series") % patch) |
1808 | 1387 |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1388 def push(self, repo, patch=None, force=False, list=False, mergeq=None, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1389 all=False, move=False, exact=False, nobackup=False, |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1390 keepchanges=False): |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1391 self.checkkeepchanges(keepchanges, force) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1392 diffopts = self.diffopts() |
27828
823069f73ff9
with: use context manager for wlock in qpush
Bryan O'Sullivan <bryano@fb.com>
parents:
27827
diff
changeset
|
1393 with repo.wlock(): |
20119
1648e44edd8d
mq: prefer a loop to a double-for list comprehension
Kevin Bullock <kbullock@ringworld.org>
parents:
20053
diff
changeset
|
1394 heads = [] |
1648e44edd8d
mq: prefer a loop to a double-for list comprehension
Kevin Bullock <kbullock@ringworld.org>
parents:
20053
diff
changeset
|
1395 for hs in repo.branchmap().itervalues(): |
1648e44edd8d
mq: prefer a loop to a double-for list comprehension
Kevin Bullock <kbullock@ringworld.org>
parents:
20053
diff
changeset
|
1396 heads.extend(hs) |
10362
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1397 if not heads: |
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1398 heads = [nullid] |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13793
diff
changeset
|
1399 if repo.dirstate.p1() not in heads and not exact: |
8795
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1400 self.ui.status(_("(working directory not at a head)\n")) |
6340
949e607ac544
mq: warn when applying a patch to somewhere other than tip
Matt Mackall <mpm@selenic.com>
parents:
6217
diff
changeset
|
1401 |
8795
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1402 if not self.series: |
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1403 self.ui.warn(_('no patches in series\n')) |
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1404 return 0 |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1405 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1406 # Suppose our series file is: A B C and the current 'top' |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1407 # patch is B. qpush C should be performed (moving forward) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1408 # qpush B is a NOP (no change) qpush A is an error (can't |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1409 # go backwards with qpush) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1410 if patch: |
15257
a8555f9908d1
mq: cleanup of lookup - handling of None is not relevant
Mads Kiilerich <mads@kiilerich.com>
parents:
15256
diff
changeset
|
1411 patch = self.lookup(patch) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1412 info = self.isapplied(patch) |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1413 if info and info[0] >= len(self.applied) - 1: |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1414 self.ui.warn( |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1415 _('qpush: %s is already at the top\n') % patch) |
11439
778377be3662
mq: explicit exit code when patch is already on top
Gilles Moris <gilles.moris@free.fr>
parents:
11438
diff
changeset
|
1416 return 0 |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1417 |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1418 pushable, reason = self.pushable(patch) |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1419 if pushable: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
1420 if self.series.index(patch) < self.seriesend(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1421 raise error.Abort( |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1422 _("cannot push to a previous patch: %s") % patch) |
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1423 else: |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1424 if reason: |
14464
00256f689f9c
mq: print "'foo' 'bar'", not "['foo', 'bar']" when showing guards
Martin Geisler <mg@aragost.com>
parents:
14448
diff
changeset
|
1425 reason = _('guarded by %s') % reason |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1426 else: |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1427 reason = _('no matching guards') |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1428 self.ui.warn(_("cannot push '%s' - %s\n") % (patch, reason)) |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1429 return 1 |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1430 elif all: |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1431 patch = self.series[-1] |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1432 if self.isapplied(patch): |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1433 self.ui.warn(_('all patches are currently applied\n')) |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1434 return 0 |
4100
c30c922f907a
Modify qpush/qpop idempotent operations to return success
Ben Thomas <bthomas@virtualiron.com>
parents:
4099
diff
changeset
|
1435 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1436 # Following the above example, starting at 'top' of B: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1437 # qpush should be performed (pushes C), but a subsequent |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1438 # qpush without an argument is an error (nothing to |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1439 # apply). This allows a loop of "...while hg qpush..." to |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1440 # work as it detects an error when done |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
1441 start = self.seriesend() |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1442 if start == len(self.series): |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1443 self.ui.warn(_('patch series already fully applied\n')) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1444 return 1 |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1445 if not force and not keepchanges: |
14732
e9ed3506f066
backout of d04ba50e104d: allow to qpop/push with a dirty working copy
Idan Kamara <idankk86@gmail.com>
parents:
14671
diff
changeset
|
1446 self.checklocalchanges(repo, refresh=self.applied) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1447 |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1448 if exact: |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1449 if keepchanges: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1450 raise error.Abort( |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1451 _("cannot use --exact and --keep-changes together")) |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1452 if move: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1453 raise error.Abort(_('cannot use --exact and --move ' |
16683 | 1454 'together')) |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1455 if self.applied: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1456 raise error.Abort(_('cannot push --exact with applied ' |
16683 | 1457 'patches')) |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1458 root = self.series[start] |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1459 target = patchheader(self.join(root), self.plainmode).parent |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1460 if not target: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1461 raise error.Abort( |
16231
ce292f1379ba
i18n: fix all remaining uses of % inside _()
Matt Mackall <mpm@selenic.com>
parents:
16188
diff
changeset
|
1462 _("%s does not have a parent recorded") % root) |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1463 if not repo[target] == repo['.']: |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1464 hg.update(repo, target) |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1465 |
11064
590b1d6ef50b
mq: qpush --move, reorder patch series and apply only the patch
Mads Kiilerich <mads@kiilerich.com>
parents:
11050
diff
changeset
|
1466 if move: |
11715
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1467 if not patch: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1468 raise error.Abort(_("please specify the patch to move")) |
16303
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1469 for fullstart, rpn in enumerate(self.fullseries): |
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1470 # strip markers for patch guards |
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1471 if self.guard_re.split(rpn, 1)[0] == self.series[start]: |
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1472 break |
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1473 for i, rpn in enumerate(self.fullseries[fullstart:]): |
11715
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1474 # strip markers for patch guards |
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1475 if self.guard_re.split(rpn, 1)[0] == patch: |
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1476 break |
16303
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1477 index = fullstart + i |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1478 assert index < len(self.fullseries) |
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1479 fullpatch = self.fullseries[index] |
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1480 del self.fullseries[index] |
16303
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1481 self.fullseries.insert(fullstart, fullpatch) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
1482 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1483 self.seriesdirty = True |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1484 |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1485 self.applieddirty = True |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1486 if start > 0: |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1487 self.checktoppatch(repo) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1488 if not patch: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1489 patch = self.series[start] |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1490 end = start + 1 |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
1491 else: |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1492 end = self.series.index(patch, start) + 1 |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1493 |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1494 tobackup = set() |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1495 if (not nobackup and force) or keepchanges: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1496 status = self.checklocalchanges(repo, force=True) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1497 if keepchanges: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1498 tobackup.update(status.modified + status.added + |
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1499 status.removed + status.deleted) |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1500 else: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1501 tobackup.update(status.modified + status.added) |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1502 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1503 s = self.series[start:end] |
10661
c4859aad1980
mq: all_files can be a set, remove dangerous default values
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10611
diff
changeset
|
1504 all_files = set() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1505 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1506 if mergeq: |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1507 ret = self.mergepatch(repo, mergeq, s, diffopts) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1508 else: |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1509 ret = self.apply(repo, s, list, all_files=all_files, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1510 tobackup=tobackup, keepchanges=keepchanges) |
24826
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
1511 except AbortNoCleanup: |
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
1512 raise |
16705
c2d9ef43ff6c
check-code: ignore naked excepts with a "re-raise" comment
Brodie Rao <brodie@sf.io>
parents:
16699
diff
changeset
|
1513 except: # re-raises |
26654
30657909b2ba
mq: use cmdutil.revert instead of hg.revert
Matt Mackall <mpm@selenic.com>
parents:
26587
diff
changeset
|
1514 self.ui.warn(_('cleaning up working directory...\n')) |
30657909b2ba
mq: use cmdutil.revert instead of hg.revert
Matt Mackall <mpm@selenic.com>
parents:
26587
diff
changeset
|
1515 cmdutil.revert(self.ui, repo, repo['.'], |
30657909b2ba
mq: use cmdutil.revert instead of hg.revert
Matt Mackall <mpm@selenic.com>
parents:
26587
diff
changeset
|
1516 repo.dirstate.parents(), no_backup=True) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1517 # only remove unknown files that we know we touched or |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1518 # created while patching |
10662
e8e56d8377ab
mq: avoid a (potentially expensive) repo.status(unknown=True) call
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10661
diff
changeset
|
1519 for f in all_files: |
e8e56d8377ab
mq: avoid a (potentially expensive) repo.status(unknown=True) call
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10661
diff
changeset
|
1520 if f not in repo.dirstate: |
31309
8908f985570c
vfs: use repo.wvfs.unlinkpath
Mads Kiilerich <madski@unity3d.com>
parents:
31243
diff
changeset
|
1521 repo.wvfs.unlinkpath(f, ignoremissing=True) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1522 self.ui.warn(_('done\n')) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1523 raise |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1524 |
9590
07a62819b309
mq: fix traceback for qpush inexistant-patch with no patch applied
Benoit Allard <benoit@aeteurope.nl>
parents:
9588
diff
changeset
|
1525 if not self.applied: |
07a62819b309
mq: fix traceback for qpush inexistant-patch with no patch applied
Benoit Allard <benoit@aeteurope.nl>
parents:
9588
diff
changeset
|
1526 return ret[0] |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1527 top = self.applied[-1].name |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1528 if ret[0] and ret[0] > 1: |
26780 | 1529 msg = _("errors during apply, please fix and qrefresh %s\n") |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1530 self.ui.write(msg % top) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1531 else: |
7627 | 1532 self.ui.write(_("now at: %s\n") % top) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1533 return ret[0] |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1534 |
16635
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
1535 def pop(self, repo, patch=None, force=False, update=True, all=False, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1536 nobackup=False, keepchanges=False): |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1537 self.checkkeepchanges(keepchanges, force) |
27829
bab359a3cf49
with: use context manager for wlock in qpop
Bryan O'Sullivan <bryano@fb.com>
parents:
27828
diff
changeset
|
1538 with repo.wlock(): |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1539 if patch: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1540 # index, rev, patch |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1541 info = self.isapplied(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1542 if not info: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1543 patch = self.lookup(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1544 info = self.isapplied(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1545 if not info: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1546 raise error.Abort(_("patch %s is not applied") % patch) |
4100
c30c922f907a
Modify qpush/qpop idempotent operations to return success
Ben Thomas <bthomas@virtualiron.com>
parents:
4099
diff
changeset
|
1547 |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1548 if not self.applied: |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1549 # Allow qpop -a to work repeatedly, |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1550 # but not qpop without an argument |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1551 self.ui.warn(_("no patches applied\n")) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1552 return not all |
1808 | 1553 |
7620
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1554 if all: |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1555 start = 0 |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1556 elif patch: |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1557 start = info[0] + 1 |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1558 else: |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1559 start = len(self.applied) - 1 |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1560 |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1561 if start >= len(self.applied): |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1562 self.ui.warn(_("qpop: %s is already at the top\n") % patch) |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1563 return |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1564 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1565 if not update: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1566 parents = repo.dirstate.parents() |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1567 rr = [x.node for x in self.applied] |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1568 for p in parents: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1569 if p in rr: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1570 self.ui.warn(_("qpop: forcing dirstate update\n")) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1571 update = True |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1572 else: |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1573 parents = [p.node() for p in repo[None].parents()] |
36343
c8891cc3fa9e
mq: don't reimplement any()
Martin von Zweigbergk <martinvonz@google.com>
parents:
36342
diff
changeset
|
1574 update = any(entry.node in parents |
c8891cc3fa9e
mq: don't reimplement any()
Martin von Zweigbergk <martinvonz@google.com>
parents:
36342
diff
changeset
|
1575 for entry in self.applied[start:]) |
1808 | 1576 |
16633
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
1577 tobackup = set() |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
1578 if update: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1579 s = self.checklocalchanges(repo, force=force or keepchanges) |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1580 if force: |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1581 if not nobackup: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1582 tobackup.update(s.modified + s.added) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1583 elif keepchanges: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1584 tobackup.update(s.modified + s.added + |
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1585 s.removed + s.deleted) |
14732
e9ed3506f066
backout of d04ba50e104d: allow to qpop/push with a dirty working copy
Idan Kamara <idankk86@gmail.com>
parents:
14671
diff
changeset
|
1586 |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1587 self.applieddirty = True |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1588 end = len(self.applied) |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1589 rev = self.applied[start].node |
5980
dcda0c90125c
mq: pop/refresh: avoid losing revisions not managed by mq
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5979
diff
changeset
|
1590 |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1591 try: |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1592 heads = repo.changelog.heads(rev) |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
1593 except error.LookupError: |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1594 node = short(rev) |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1595 raise error.Abort(_('trying to pop unknown node %s') % node) |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1596 |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1597 if heads != [self.applied[-1].node]: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1598 raise error.Abort(_("popping would remove a revision not " |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1599 "managed by this patch queue")) |
16048
140b6282ac79
mq: prevent rewriting operation on public changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16043
diff
changeset
|
1600 if not repo[self.applied[-1].node].mutable(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1601 raise error.Abort( |
25411
d298805fb639
phases: rewrite "immutable changeset" to "public changeset"
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25186
diff
changeset
|
1602 _("popping would remove a public revision"), |
29968
0342bf292f73
mq: use single quotes in use warning
timeless <timeless@mozdev.org>
parents:
29841
diff
changeset
|
1603 hint=_("see 'hg help phases' for details")) |
5980
dcda0c90125c
mq: pop/refresh: avoid losing revisions not managed by mq
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5979
diff
changeset
|
1604 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1605 # we know there are no local changes, so we can make a simplified |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1606 # form of hg.update. |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1607 if update: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1608 qp = self.qparents(repo, rev) |
10663
85e81d9bfb7a
mq: simplify and use context API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10662
diff
changeset
|
1609 ctx = repo[qp] |
18342
de99de39ba28
mq: fix qpop of working directory parent patch when not at qtip
Mads Kiilerich <mads@kiilerich.com>
parents:
18217
diff
changeset
|
1610 m, a, r, d = repo.status(qp, '.')[:4] |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1611 if d: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1612 raise error.Abort(_("deletions found between repo revs")) |
16633
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
1613 |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1614 tobackup = set(a + m + r) & tobackup |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1615 if keepchanges and tobackup: |
26780 | 1616 raise error.Abort(_("local changes found, qrefresh first")) |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1617 self.backup(repo, tobackup) |
32347
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1618 with repo.dirstate.parentchange(): |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1619 for f in a: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1620 repo.wvfs.unlinkpath(f, ignoremissing=True) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1621 repo.dirstate.drop(f) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1622 for f in m + r: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1623 fctx = ctx[f] |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1624 repo.wwrite(f, fctx.data(), fctx.flags()) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1625 repo.dirstate.normal(f) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1626 repo.setparents(qp, nullid) |
9110
561ff8d9e4f0
mq: qpop now tells which patches are popped
Mads Kiilerich <mads@kiilerich.com>
parents:
9067
diff
changeset
|
1627 for patch in reversed(self.applied[start:end]): |
9111
ac3f1e6696eb
mq: use ui.status when pushing and popping patches
Martin Geisler <mg@lazybytes.net>
parents:
9110
diff
changeset
|
1628 self.ui.status(_("popping %s\n") % patch.name) |
5987
f2201aee3dc8
qpop/qrefresh: update self.applied before calling strip
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5981
diff
changeset
|
1629 del self.applied[start:end] |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
1630 strip(self.ui, repo, [rev], update=False, backup=False) |
19638
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
1631 for s, state in repo['.'].substate.items(): |
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
1632 repo['.'].sub(s).get(state) |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1633 if self.applied: |
7627 | 1634 self.ui.write(_("now at: %s\n") % self.applied[-1].name) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1635 else: |
7627 | 1636 self.ui.write(_("patch queue now empty\n")) |
1808 | 1637 |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
1638 def diff(self, repo, pats, opts): |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1639 top, patch = self.checktoppatch(repo) |
1808 | 1640 if not top: |
7627 | 1641 self.ui.write(_("no patches applied\n")) |
1808 | 1642 return |
1643 qp = self.qparents(repo, top) | |
9857
24bc6e414610
diff: change --inverse to --reverse
Martin Geisler <mg@lazybytes.net>
parents:
9824
diff
changeset
|
1644 if opts.get('reverse'): |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1645 node1, node2 = None, qp |
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1646 else: |
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1647 node1, node2 = qp, None |
10191
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1648 diffopts = self.diffopts(opts, patch) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1649 self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts) |
1808 | 1650 |
2938
5b7a118f5b6c
allow qrefresh to take a list of files; closes #96.
Brendan Cully <brendan@kublai.com>
parents:
2937
diff
changeset
|
1651 def refresh(self, repo, pats=None, **opts): |
36387
dbf34d0ef9f6
py3: use pycompat.byteskwargs() to fix keyword arguments handling
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36343
diff
changeset
|
1652 opts = pycompat.byteskwargs(opts) |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1653 if not self.applied: |
7627 | 1654 self.ui.write(_("no patches applied\n")) |
3004
ac74046f8f58
qrefresh: exit with status 1 if no patches applied.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2984
diff
changeset
|
1655 return 1 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1656 msg = opts.get('msg', '').rstrip() |
21422
edc6ced48d2d
mq: fold the code paths to invoke editor into specific logic (qrefresh/qfold)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21421
diff
changeset
|
1657 edit = opts.get('edit') |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1658 editform = opts.get('editform', 'mq.qrefresh') |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1659 newuser = opts.get('user') |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1660 newdate = opts.get('date') |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1661 if newdate: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36389
diff
changeset
|
1662 newdate = '%d %d' % dateutil.parsedate(newdate) |
1808 | 1663 wlock = repo.wlock() |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1664 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1665 try: |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1666 self.checktoppatch(repo) |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1667 (top, patchfn) = (self.applied[-1].node, self.applied[-1].name) |
5980
dcda0c90125c
mq: pop/refresh: avoid losing revisions not managed by mq
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5979
diff
changeset
|
1668 if repo.changelog.heads(top) != [top]: |
26780 | 1669 raise error.Abort(_("cannot qrefresh a revision with children")) |
16048
140b6282ac79
mq: prevent rewriting operation on public changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16043
diff
changeset
|
1670 if not repo[top].mutable(): |
26780 | 1671 raise error.Abort(_("cannot qrefresh public revision"), |
29968
0342bf292f73
mq: use single quotes in use warning
timeless <timeless@mozdev.org>
parents:
29841
diff
changeset
|
1672 hint=_("see 'hg help phases' for details")) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1673 |
17153
54da604fefee
mq: check subrepo synchronizations against parent of workdir or other appropriate context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17152
diff
changeset
|
1674 cparents = repo.changelog.parents(top) |
54da604fefee
mq: check subrepo synchronizations against parent of workdir or other appropriate context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17152
diff
changeset
|
1675 patchparent = self.qparents(repo, top) |
54da604fefee
mq: check subrepo synchronizations against parent of workdir or other appropriate context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17152
diff
changeset
|
1676 |
37381
76823340a899
mq: avoid a silly conversion from binary nodeid to hex
Martin von Zweigbergk <martinvonz@google.com>
parents:
37262
diff
changeset
|
1677 inclsubs = checksubstate(repo, patchparent) |
17152
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1678 if inclsubs: |
f287d4a62031
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17151
diff
changeset
|
1679 substatestate = repo.dirstate['.hgsubstate'] |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1680 |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
1681 ph = patchheader(self.join(patchfn), self.plainmode) |
34090
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
1682 diffopts = self.diffopts({'git': opts.get('git')}, patchfn, |
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
1683 plain=True) |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
1684 if newuser: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1685 ph.setuser(newuser) |
5788
4107e823dc2c
mq: add --currentdate and --date options to qnew and qrefresh
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5673
diff
changeset
|
1686 if newdate: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1687 ph.setdate(newdate) |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
1688 ph.setparent(hex(patchparent)) |
5180
5bbbd1f1d586
mq: truncate patch just before rewriting header
Brendan Cully <brendan@kublai.com>
parents:
4930
diff
changeset
|
1689 |
7400
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1690 # only commit new patch when write is complete |
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1691 patchf = self.opener(patchfn, 'w', atomictemp=True) |
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1692 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1693 # update the dirstate in place, strip off the qtip commit |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1694 # and then commit. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1695 # |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1696 # this should really read: |
13005
cffa35529706
mq: fix comment to reflect change in efbee27415ab
Martin Geisler <mg@aragost.com>
parents:
13004
diff
changeset
|
1697 # mm, dd, aa = repo.status(top, patchparent)[:3] |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17424
diff
changeset
|
1698 # but we do it backwards to take advantage of manifest/changelog |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1699 # caching against the next repo.status call |
13004
efbee27415ab
mq: clean up unused variable in qrefresh
Kevin Bullock <kbullock@ringworld.org>
parents:
12948
diff
changeset
|
1700 mm, aa, dd = repo.status(patchparent, top)[:3] |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1701 changes = repo.changelog.read(top) |
30369
d79c141fdf41
manifest: remove usages of manifest.read
Durham Goode <durham@fb.com>
parents:
30070
diff
changeset
|
1702 man = repo.manifestlog[changes[0]].read() |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1703 aaa = aa[:] |
34083
08346a8fa65f
cleanup: rename "matchfn" to "match" where obviously a matcher
Martin von Zweigbergk <martinvonz@google.com>
parents:
34022
diff
changeset
|
1704 match1 = scmutil.match(repo[None], pats, opts) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1705 # in short mode, we only diff the files included in the |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1706 # patch already plus specified files |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1707 if opts.get('short'): |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1708 # if amending a patch, we start with existing |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1709 # files plus specified files - unfiltered |
34083
08346a8fa65f
cleanup: rename "matchfn" to "match" where obviously a matcher
Martin von Zweigbergk <martinvonz@google.com>
parents:
34022
diff
changeset
|
1710 match = scmutil.matchfiles(repo, mm + aa + dd + match1.files()) |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17191
diff
changeset
|
1711 # filter with include/exclude options |
34083
08346a8fa65f
cleanup: rename "matchfn" to "match" where obviously a matcher
Martin von Zweigbergk <martinvonz@google.com>
parents:
34022
diff
changeset
|
1712 match1 = scmutil.match(repo[None], opts=opts) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1713 else: |
14322
a90131b85fd8
scmutil: drop aliases in cmdutil for match functions
Matt Mackall <mpm@selenic.com>
parents:
14319
diff
changeset
|
1714 match = scmutil.matchall(repo) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1715 m, a, r, d = repo.status(match=match)[:4] |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1716 mm = set(mm) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1717 aa = set(aa) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1718 dd = set(dd) |
1808 | 1719 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1720 # we might end up with files that were added between |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1721 # qtip and the dirstate parent, but then changed in the |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1722 # local dirstate. in this case, we want them to only |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1723 # show up in the added section |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1724 for x in m: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1725 if x not in aa: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1726 mm.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1727 # we might end up with files added by the local dirstate that |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1728 # were deleted by the patch. In this case, they should only |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1729 # show up in the changed section. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1730 for x in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1731 if x in dd: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1732 dd.remove(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1733 mm.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1734 else: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1735 aa.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1736 # make sure any files deleted in the local dirstate |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1737 # are not in the add or change column of the patch |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1738 forget = [] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1739 for x in d + r: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1740 if x in aa: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1741 aa.remove(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1742 forget.append(x) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1743 continue |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1744 else: |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1745 mm.discard(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1746 dd.add(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1747 |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1748 m = list(mm) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1749 r = list(dd) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1750 a = list(aa) |
17888
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1751 |
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18371
diff
changeset
|
1752 # create 'match' that includes the files to be recommitted. |
34083
08346a8fa65f
cleanup: rename "matchfn" to "match" where obviously a matcher
Martin von Zweigbergk <martinvonz@google.com>
parents:
34022
diff
changeset
|
1753 # apply match1 via repo.status to ensure correct case handling. |
08346a8fa65f
cleanup: rename "matchfn" to "match" where obviously a matcher
Martin von Zweigbergk <martinvonz@google.com>
parents:
34022
diff
changeset
|
1754 cm, ca, cr, cd = repo.status(patchparent, match=match1)[:4] |
17888
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1755 allmatches = set(cm + ca + cr + cd) |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1756 refreshchanges = [x.intersection(allmatches) for x in (mm, aa, dd)] |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1757 |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1758 files = set(inclsubs) |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1759 for x in refreshchanges: |
20827
ca5dd216cb62
localrepo: omit ".hgsubstate" also from "added" files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20790
diff
changeset
|
1760 files.update(x) |
17888
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1761 match = scmutil.matchfiles(repo, files) |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1762 |
17730
6c6987761e42
mq: update bookmarks during qrefresh
David Soria Parra <dsp@php.net>
parents:
17708
diff
changeset
|
1763 bmlist = repo[top].bookmarks() |
1808 | 1764 |
24997
12f3c7144a39
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24996
diff
changeset
|
1765 dsguard = None |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1766 try: |
30489
0ae83ede68c5
mq: refer to dirstateguard by its new name
Augie Fackler <augie@google.com>
parents:
30485
diff
changeset
|
1767 dsguard = dirstateguard.dirstateguard(repo, 'mq.refresh') |
10368 | 1768 if diffopts.git or diffopts.upgrade: |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1769 copies = {} |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1770 for dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1771 src = repo.dirstate.copied(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1772 # during qfold, the source file for copies may |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1773 # be removed. Treat this as a simple add. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1774 if src is not None and src in repo.dirstate: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1775 copies.setdefault(src, []).append(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1776 repo.dirstate.add(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1777 # remember the copies between patchparent and qtip |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1778 for dst in aaa: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1779 f = repo.file(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1780 src = f.renamed(man[dst]) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1781 if src: |
10368 | 1782 copies.setdefault(src[0], []).extend( |
1783 copies.get(dst, [])) | |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1784 if dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1785 copies[src[0]].append(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1786 # we can't copy a file created by the patch itself |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1787 if dst in copies: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1788 del copies[dst] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1789 for src, dsts in copies.iteritems(): |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1790 for dst in dsts: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1791 repo.dirstate.copy(src, dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1792 else: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1793 for dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1794 repo.dirstate.add(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1795 # Drop useless copy information |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1796 for f in list(repo.dirstate.copies()): |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1797 repo.dirstate.copy(None, f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1798 for f in r: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1799 repo.dirstate.remove(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1800 # if the patch excludes a modified file, mark that |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1801 # file with mtime=0 so status can see it. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1802 mm = [] |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
1803 for i in pycompat.xrange(len(m) - 1, -1, -1): |
34083
08346a8fa65f
cleanup: rename "matchfn" to "match" where obviously a matcher
Martin von Zweigbergk <martinvonz@google.com>
parents:
34022
diff
changeset
|
1804 if not match1(m[i]): |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1805 mm.append(m[i]) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1806 del m[i] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1807 for f in m: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1808 repo.dirstate.normal(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1809 for f in mm: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1810 repo.dirstate.normallookup(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1811 for f in forget: |
14434
cc8c09855d19
dirstate: rename forget to drop
Matt Mackall <mpm@selenic.com>
parents:
14424
diff
changeset
|
1812 repo.dirstate.drop(f) |
1808 | 1813 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1814 user = ph.user or changes[1] |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
1815 |
16026
31c02546e6de
qrefresh: keep changeset phase during refresh
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16017
diff
changeset
|
1816 oldphase = repo[top].phase() |
31c02546e6de
qrefresh: keep changeset phase during refresh
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16017
diff
changeset
|
1817 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1818 # assumes strip can roll itself back if interrupted |
16551
ebf6d38c9063
localrepo: add setparents() to adjust dirstate copies (issue3407)
Patrick Mezard <patrick@mezard.eu>
parents:
16428
diff
changeset
|
1819 repo.setparents(*cparents) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1820 self.applied.pop() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1821 self.applieddirty = True |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
1822 strip(self.ui, repo, [top], update=False, backup=False) |
24997
12f3c7144a39
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24996
diff
changeset
|
1823 dsguard.close() |
12f3c7144a39
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24996
diff
changeset
|
1824 finally: |
12f3c7144a39
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24996
diff
changeset
|
1825 release(dsguard) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1826 |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1827 try: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1828 # might be nice to attempt to roll back strip after this |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
1829 |
21236
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1830 defaultmsg = "[mq]: %s" % patchfn |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1831 editor = cmdutil.getcommiteditor(editform=editform) |
21422
edc6ced48d2d
mq: fold the code paths to invoke editor into specific logic (qrefresh/qfold)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21421
diff
changeset
|
1832 if edit: |
21423
7d408720453d
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qrefresh/qfold)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21422
diff
changeset
|
1833 def finishdesc(desc): |
21236
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1834 if desc.rstrip(): |
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1835 ph.setmessage(desc) |
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1836 return desc |
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1837 return defaultmsg |
21423
7d408720453d
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qrefresh/qfold)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21422
diff
changeset
|
1838 # i18n: this message is shown in editor with "HG: " prefix |
7d408720453d
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qrefresh/qfold)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21422
diff
changeset
|
1839 extramsg = _('Leave message empty to use default message.') |
7d408720453d
mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qrefresh/qfold)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21422
diff
changeset
|
1840 editor = cmdutil.getcommiteditor(finishdesc=finishdesc, |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1841 extramsg=extramsg, |
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1842 editform=editform) |
21236
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1843 message = msg or "\n".join(ph.message) |
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1844 elif not msg: |
21235
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
1845 if not ph.message: |
21236
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1846 message = defaultmsg |
21235
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
1847 else: |
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
1848 message = "\n".join(ph.message) |
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
1849 else: |
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
1850 message = msg |
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
1851 ph.setmessage(msg) |
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
1852 |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
1853 # Ensure we create a new changeset in the same phase than |
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
1854 # the old one. |
27001
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
1855 lock = tr = None |
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
1856 try: |
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
1857 lock = repo.lock() |
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
1858 tr = repo.transaction('mq') |
27000
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1859 n = newcommit(repo, oldphase, message, user, ph.date, |
21236
49148d7868df
qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21235
diff
changeset
|
1860 match=match, force=True, editor=editor) |
27000
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1861 # only write patch after a successful commit |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1862 c = [list(x) for x in refreshchanges] |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1863 if inclsubs: |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1864 self.putsubstate2changes(substatestate, c) |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1865 chunks = patchmod.diff(repo, patchparent, |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1866 changes=c, opts=diffopts) |
35948
f87641bf4d23
py3: use bytes instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35918
diff
changeset
|
1867 comments = bytes(ph) |
27000
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1868 if comments: |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1869 patchf.write(comments) |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1870 for chunk in chunks: |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1871 patchf.write(chunk) |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1872 patchf.close() |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1873 |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1874 marks = repo._bookmarks |
33489
870560c759ed
bookmark: use 'applychanges' in the mq extension
Boris Feld <boris.feld@octobus.net>
parents:
32375
diff
changeset
|
1875 marks.applychanges(repo, tr, [(bm, n) for bm in bmlist]) |
27001
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
1876 tr.close() |
27000
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1877 |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
1878 self.applied.append(statusentry(n, patchfn)) |
27001
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
1879 finally: |
30070
3006d0d26ad3
mq: release lock after transaction in qrefresh
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29968
diff
changeset
|
1880 lockmod.release(tr, lock) |
16705
c2d9ef43ff6c
check-code: ignore naked excepts with a "re-raise" comment
Brodie Rao <brodie@sf.io>
parents:
16699
diff
changeset
|
1881 except: # re-raises |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1882 ctx = repo[cparents[0]] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1883 repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
1884 self.savedirty() |
26780 | 1885 self.ui.warn(_('qrefresh interrupted while patch was popped! ' |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1886 '(revert --all, qpush to recover)\n')) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1887 raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1888 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
1889 wlock.release() |
7401
41e87b4d0c9d
mq: recover more gracefully from interrupted qrefresh (issue1216)
Brendan Cully <brendan@kublai.com>
parents:
7400
diff
changeset
|
1890 self.removeundo(repo) |
1808 | 1891 |
1892 def init(self, repo, create=False): | |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1893 if not create and os.path.isdir(self.path): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1894 raise error.Abort(_("patch queue directory already exists")) |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1895 try: |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1896 os.mkdir(self.path) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
1897 except OSError as inst: |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1898 if inst.errno != errno.EEXIST or not create: |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1899 raise |
1808 | 1900 if create: |
1901 return self.qrepo(create=True) | |
1902 | |
1903 def unapplied(self, repo, patch=None): | |
1904 if patch and patch not in self.series: | |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1905 raise error.Abort(_("patch %s is not in series file") % patch) |
1808 | 1906 if not patch: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
1907 start = self.seriesend() |
1808 | 1908 else: |
1909 start = self.series.index(patch) + 1 | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1910 unapplied = [] |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
1911 for i in pycompat.xrange(start, len(self.series)): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1912 pushable, reason = self.pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1913 if pushable: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1914 unapplied.append((i, self.series[i])) |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
1915 self.explainpushable(i) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1916 return unapplied |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1917 |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1918 def qseries(self, repo, missing=None, start=0, length=None, status=None, |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1919 summary=False): |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1920 def displayname(pfx, patchname, state): |
10932
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1921 if pfx: |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1922 self.ui.write(pfx) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1923 if summary: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
1924 ph = patchheader(self.join(patchname), self.plainmode) |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
1925 if ph.message: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
1926 msg = ph.message[0] |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
1927 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
1928 msg = '' |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
1929 |
11327
6c469f2f9f12
mq: use ui.formatted() instead of ui.plain().
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11321
diff
changeset
|
1930 if self.ui.formatted(): |
12689
c52c629ce19e
termwidth: move to ui.ui from util
Augie Fackler <durin42@gmail.com>
parents:
12682
diff
changeset
|
1931 width = self.ui.termwidth() - len(pfx) - len(patchname) - 2 |
9874
c51494c53841
qseries: don't truncate the patch name (issue1912)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9867
diff
changeset
|
1932 if width > 0: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
1933 msg = stringutil.ellipsis(msg, width) |
9874
c51494c53841
qseries: don't truncate the patch name (issue1912)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9867
diff
changeset
|
1934 else: |
c51494c53841
qseries: don't truncate the patch name (issue1912)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9867
diff
changeset
|
1935 msg = '' |
10932
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1936 self.ui.write(patchname, label='qseries.' + state) |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1937 self.ui.write(': ') |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1938 self.ui.write(msg, label='qseries.message.' + state) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1939 else: |
10932
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1940 self.ui.write(patchname, label='qseries.' + state) |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1941 self.ui.write('\n') |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1942 |
8152
08e1baf924ca
replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
1943 applied = set([p.name for p in self.applied]) |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1944 if length is None: |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1945 length = len(self.series) - start |
1808 | 1946 if not missing: |
9016
894c5b4be275
mq: align columns in verbose qseries output.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
8948
diff
changeset
|
1947 if self.ui.verbose: |
36668
e77cee5de1c7
py3: use b"%d" to covert integer to bytes instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36667
diff
changeset
|
1948 idxwidth = len("%d" % (start + length - 1)) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
1949 for i in pycompat.xrange(start, start + length): |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1950 patch = self.series[i] |
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1951 if patch in applied: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1952 char, state = 'A', 'applied' |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1953 elif self.pushable(i)[0]: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1954 char, state = 'U', 'unapplied' |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1955 else: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1956 char, state = 'G', 'guarded' |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1957 pfx = '' |
1808 | 1958 if self.ui.verbose: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1959 pfx = '%*d %s ' % (idxwidth, i, char) |
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1960 elif status and status != char: |
4238
ce6c364ebb2a
Fix issue443: inconsistent output of "hg qunapplied -v"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4173
diff
changeset
|
1961 continue |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1962 displayname(pfx, patch, state) |
1808 | 1963 else: |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
1964 msng_list = [] |
1808 | 1965 for root, dirs, files in os.walk(self.path): |
1966 d = root[len(self.path) + 1:] | |
1967 for f in files: | |
1968 fl = os.path.join(d, f) | |
1852
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
1969 if (fl not in self.series and |
14588
bd3d75a03f80
mq: rename status_path to statuspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14587
diff
changeset
|
1970 fl not in (self.statuspath, self.seriespath, |
14589
7d59ee9e711b
mq: rename guards_path to guardspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14588
diff
changeset
|
1971 self.guardspath) |
1852
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
1972 and not fl.startswith('.')): |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
1973 msng_list.append(fl) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8188
diff
changeset
|
1974 for x in sorted(msng_list): |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1975 pfx = self.ui.verbose and ('D ') or '' |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1976 displayname(pfx, x, 'missing') |
1808 | 1977 |
1978 def issaveline(self, l): | |
2816
52516e48e3f3
Update qsave to use StatusEntry; don't throw exception on bad status lines.
Brendan Cully <brendan@kublai.com>
parents:
2804
diff
changeset
|
1979 if l.name == '.hg.patches.save.line': |
1808 | 1980 return True |
1981 | |
1982 def qrepo(self, create=False): | |
19064
743daa601445
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)
Simon Heimberg <simohe@besonet.ch>
parents:
18958
diff
changeset
|
1983 ui = self.baseui.copy() |
34918
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1984 # copy back attributes set by ui.pager() |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1985 if self.ui.pageractive and not ui.pageractive: |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1986 ui.pageractive = self.ui.pageractive |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1987 # internal config: ui.formatted |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1988 ui.setconfig('ui', 'formatted', |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1989 self.ui.config('ui', 'formatted'), 'mqpager') |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1990 ui.setconfig('ui', 'interactive', |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
1991 self.ui.config('ui', 'interactive'), 'mqpager') |
2819 | 1992 if create or os.path.isdir(self.join(".hg")): |
11965
77f1f206e135
mq: don't inherit default and default-push paths with --mq (issue2333)
Mads Kiilerich <mads@kiilerich.com>
parents:
11715
diff
changeset
|
1993 return hg.repository(ui, path=self.path, create=create) |
1808 | 1994 |
1995 def restore(self, repo, rev, delete=None, qupdate=None): | |
10681
3f6a6407a3c7
mq: use context API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10680
diff
changeset
|
1996 desc = repo[rev].description().strip() |
1808 | 1997 lines = desc.splitlines() |
1998 i = 0 | |
1999 datastart = None | |
2000 series = [] | |
2001 applied = [] | |
2002 qpp = None | |
8632
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
2003 for i, line in enumerate(lines): |
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
2004 if line == 'Patch Data:': |
1808 | 2005 datastart = i + 1 |
8632
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
2006 elif line.startswith('Dirstate:'): |
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
2007 l = line.rstrip() |
1808 | 2008 l = l[10:].split(' ') |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2009 qpp = [bin(x) for x in l] |
13031
3da456d0c885
code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler <mg@aragost.com>
parents:
13005
diff
changeset
|
2010 elif datastart is not None: |
8632
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
2011 l = line.rstrip() |
10683
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
2012 n, name = l.split(':', 1) |
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
2013 if n: |
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
2014 applied.append(statusentry(bin(n), name)) |
3185
b3e103c388fc
mq: don't write applied patches into series twice in restore
Brendan Cully <brendan@kublai.com>
parents:
3184
diff
changeset
|
2015 else: |
10682
8ed350051896
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10681
diff
changeset
|
2016 series.append(l) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
2017 if datastart is None: |
16929
4b02d7006169
mq: lowercase warning messages
Martin Geisler <mg@aragost.com>
parents:
16867
diff
changeset
|
2018 self.ui.warn(_("no saved patch data found\n")) |
1808 | 2019 return 1 |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2020 self.ui.warn(_("restoring status: %s\n") % lines[0]) |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
2021 self.fullseries = series |
1808 | 2022 self.applied = applied |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
2023 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
2024 self.seriesdirty = True |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
2025 self.applieddirty = True |
1808 | 2026 heads = repo.changelog.heads() |
2027 if delete: | |
2028 if rev not in heads: | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2029 self.ui.warn(_("save entry has children, leaving it alone\n")) |
1808 | 2030 else: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2031 self.ui.warn(_("removing save entry %s\n") % short(rev)) |
1808 | 2032 pp = repo.dirstate.parents() |
2033 if rev in pp: | |
2034 update = True | |
2035 else: | |
2036 update = False | |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
2037 strip(self.ui, repo, [rev], update=update, backup=False) |
1808 | 2038 if qpp: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2039 self.ui.warn(_("saved queue repository parents: %s %s\n") % |
6217
fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents:
6195
diff
changeset
|
2040 (short(qpp[0]), short(qpp[1]))) |
1808 | 2041 if qupdate: |
12848
f7f1a146f407
qrestore: trying to improve the English
timeless <timeless@gmail.com>
parents:
12775
diff
changeset
|
2042 self.ui.status(_("updating queue directory\n")) |
1808 | 2043 r = self.qrepo() |
2044 if not r: | |
16929
4b02d7006169
mq: lowercase warning messages
Martin Geisler <mg@aragost.com>
parents:
16867
diff
changeset
|
2045 self.ui.warn(_("unable to load queue repository\n")) |
1808 | 2046 return 1 |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2804
diff
changeset
|
2047 hg.clean(r, qpp[0]) |
1808 | 2048 |
2049 def save(self, repo, msg=None): | |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
2050 if not self.applied: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2051 self.ui.warn(_("save: no patches applied, exiting\n")) |
1808 | 2052 return 1 |
2053 if self.issaveline(self.applied[-1]): | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2054 self.ui.warn(_("status is already saved\n")) |
1808 | 2055 return 1 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2056 |
1808 | 2057 if not msg: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2058 msg = _("hg patches saved state") |
1808 | 2059 else: |
2060 msg = "hg patches: " + msg.rstrip('\r\n') | |
2061 r = self.qrepo() | |
2062 if r: | |
2063 pp = r.dirstate.parents() | |
6217
fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents:
6195
diff
changeset
|
2064 msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1])) |
1808 | 2065 msg += "\n\nPatch Data:\n" |
10679
35abaea778dc
mq: simplify commit message generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10678
diff
changeset
|
2066 msg += ''.join('%s\n' % x for x in self.applied) |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
2067 msg += ''.join(':%s\n' % x for x in self.fullseries) |
10679
35abaea778dc
mq: simplify commit message generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10678
diff
changeset
|
2068 n = repo.commit(msg, force=True) |
1808 | 2069 if not n: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2070 self.ui.warn(_("repo commit failed\n")) |
1808 | 2071 return 1 |
10684
485c1d7f8a77
mq: fix coding style (missing space)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10683
diff
changeset
|
2072 self.applied.append(statusentry(n, '.hg.patches.save.line')) |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
2073 self.applieddirty = True |
4209
dbc3846c09a1
Merge with -stable, fix small test failure
Matt Mackall <mpm@selenic.com>
parents:
4207
diff
changeset
|
2074 self.removeundo(repo) |
1808 | 2075 |
14585
74bf9c84cfd0
mq: rename full_series_end to fullseriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14584
diff
changeset
|
2076 def fullseriesend(self): |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
2077 if self.applied: |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
2078 p = self.applied[-1].name |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
2079 end = self.findseries(p) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
2080 if end is None: |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
2081 return len(self.fullseries) |
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
2082 return end + 1 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
2083 return 0 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
2084 |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2085 def seriesend(self, all_patches=False): |
4406
f700ea2b0689
mq: fix qtop failure when the series ends with guarded patches.
Patrick Mezard <pmezard@gmail.com>
parents:
4341
diff
changeset
|
2086 """If all_patches is False, return the index of the next pushable patch |
f700ea2b0689
mq: fix qtop failure when the series ends with guarded patches.
Patrick Mezard <pmezard@gmail.com>
parents:
4341
diff
changeset
|
2087 in the series, or the series length. If all_patches is True, return the |
f700ea2b0689
mq: fix qtop failure when the series ends with guarded patches.
Patrick Mezard <pmezard@gmail.com>
parents:
4341
diff
changeset
|
2088 index of the first patch past the last applied one. |
f700ea2b0689
mq: fix qtop failure when the series ends with guarded patches.
Patrick Mezard <pmezard@gmail.com>
parents:
4341
diff
changeset
|
2089 """ |
1808 | 2090 end = 0 |
19500
a96565abbd59
mq: rename next() to nextpatch() to avoid confusing a future check-code patch
Augie Fackler <raf@durin42.com>
parents:
19481
diff
changeset
|
2091 def nextpatch(start): |
10687
583adcf63f80
mq: use xrange/enumerate instead of += 1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10686
diff
changeset
|
2092 if all_patches or start >= len(self.series): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2093 return start |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
2094 for i in pycompat.xrange(start, len(self.series)): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2095 p, reason = self.pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2096 if p: |
16063
c36db39b3fee
mq: fix qnext when all remaining patches are guarded
Patrick Mezard <pmezard@gmail.com>
parents:
16048
diff
changeset
|
2097 return i |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
2098 self.explainpushable(i) |
16063
c36db39b3fee
mq: fix qnext when all remaining patches are guarded
Patrick Mezard <pmezard@gmail.com>
parents:
16048
diff
changeset
|
2099 return len(self.series) |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
2100 if self.applied: |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
2101 p = self.applied[-1].name |
1808 | 2102 try: |
2103 end = self.series.index(p) | |
2104 except ValueError: | |
2105 return 0 | |
19500
a96565abbd59
mq: rename next() to nextpatch() to avoid confusing a future check-code patch
Augie Fackler <raf@durin42.com>
parents:
19481
diff
changeset
|
2106 return nextpatch(end + 1) |
a96565abbd59
mq: rename next() to nextpatch() to avoid confusing a future check-code patch
Augie Fackler <raf@durin42.com>
parents:
19481
diff
changeset
|
2107 return nextpatch(end) |
1808 | 2108 |
2109 def appliedname(self, index): | |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
2110 pname = self.applied[index].name |
1808 | 2111 if not self.ui.verbose: |
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
2112 p = pname |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
2113 else: |
36668
e77cee5de1c7
py3: use b"%d" to covert integer to bytes instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36667
diff
changeset
|
2114 p = ("%d" % self.series.index(pname)) + " " + pname |
1808 | 2115 return p |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2116 |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2117 def qimport(self, repo, files, patchname=None, rev=None, existing=None, |
3691
79151c94c3b4
mq: add --git option to qimport -r
Brendan Cully <brendan@kublai.com>
parents:
3685
diff
changeset
|
2118 force=None, git=False): |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2119 def checkseries(patchname): |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2120 if patchname in self.series: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2121 raise error.Abort(_('patch %s is already in the series file') |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2122 % patchname) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2123 |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2124 if rev: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2125 if files: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2126 raise error.Abort(_('option "-r" not valid when importing ' |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2127 'files')) |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14298
diff
changeset
|
2128 rev = scmutil.revrange(repo, rev) |
9032
1fa80c5428b8
compat: use 'key' argument instead of 'cmp' when sorting a list
Alejandro Santos <alejolp@alejolp.com>
parents:
9016
diff
changeset
|
2129 rev.sort(reverse=True) |
16987
54295c87eefc
mq: abort if no files or revisions are specified for qimport
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16929
diff
changeset
|
2130 elif not files: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2131 raise error.Abort(_('no files or revisions specified')) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2132 if (len(files) > 1 or len(rev) > 1) and patchname: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2133 raise error.Abort(_('option "-n" not valid when importing multiple ' |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2134 'patches')) |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2135 imported = [] |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2136 if rev: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2137 # If mq patches are applied, we can only import revisions |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2138 # that form a linear path to qbase. |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2139 # Otherwise, they should form a linear path to a head. |
22821
5d4c17d11d7e
qimport: use `first` and `last` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22819
diff
changeset
|
2140 heads = repo.changelog.heads(repo.changelog.node(rev.first())) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2141 if len(heads) > 1: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2142 raise error.Abort(_('revision %d is the root of more than one ' |
22819
602aa2b98628
mq: use `last` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22803
diff
changeset
|
2143 'branch') % rev.last()) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2144 if self.applied: |
22821
5d4c17d11d7e
qimport: use `first` and `last` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22819
diff
changeset
|
2145 base = repo.changelog.node(rev.first()) |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
2146 if base in [n.node for n in self.applied]: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2147 raise error.Abort(_('revision %d is already managed') |
23128
b6f7cf47f5d1
mq: do not call [0] on revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22925
diff
changeset
|
2148 % rev.first()) |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
2149 if heads != [self.applied[-1].node]: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2150 raise error.Abort(_('revision %d is not the parent of ' |
22821
5d4c17d11d7e
qimport: use `first` and `last` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22819
diff
changeset
|
2151 'the queue') % rev.first()) |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
2152 base = repo.changelog.rev(self.applied[0].node) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2153 lastparent = repo.changelog.parentrevs(base)[0] |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2154 else: |
22821
5d4c17d11d7e
qimport: use `first` and `last` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22819
diff
changeset
|
2155 if heads != [repo.changelog.node(rev.first())]: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2156 raise error.Abort(_('revision %d has unmanaged children') |
22821
5d4c17d11d7e
qimport: use `first` and `last` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22819
diff
changeset
|
2157 % rev.first()) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2158 lastparent = None |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2159 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
2160 diffopts = self.diffopts({'git': git}) |
27865
f6979b8f33c1
with: use context manager for transaction in qimport
Bryan O'Sullivan <bryano@fb.com>
parents:
27864
diff
changeset
|
2161 with repo.transaction('qimport') as tr: |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2162 for r in rev: |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2163 if not repo[r].mutable(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2164 raise error.Abort(_('revision %d is not mutable') % r, |
29968
0342bf292f73
mq: use single quotes in use warning
timeless <timeless@mozdev.org>
parents:
29841
diff
changeset
|
2165 hint=_("see 'hg help phases' " |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2166 'for details')) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2167 p1, p2 = repo.changelog.parentrevs(r) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2168 n = repo.changelog.node(r) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2169 if p2 != nullrev: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2170 raise error.Abort(_('cannot import merge revision %d') |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2171 % r) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2172 if lastparent and lastparent != r: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2173 raise error.Abort(_('revision %d is not the parent of ' |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2174 '%d') |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2175 % (r, lastparent)) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2176 lastparent = p1 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2177 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2178 if not patchname: |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
2179 patchname = self.makepatchname( |
27513
707cdf2c3700
mq: use fallback patch name if no alpha-numeric in summary line (issue5025)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26831
diff
changeset
|
2180 repo[r].description().split('\n', 1)[0], |
707cdf2c3700
mq: use fallback patch name if no alpha-numeric in summary line (issue5025)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26831
diff
changeset
|
2181 '%d.diff' % r) |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2182 checkseries(patchname) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2183 self.checkpatchname(patchname, force) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2184 self.fullseries.insert(0, patchname) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2185 |
37603
678d760c71ff
export: extract function to write patch to file object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37559
diff
changeset
|
2186 with self.opener(patchname, "w") as fp: |
678d760c71ff
export: extract function to write patch to file object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37559
diff
changeset
|
2187 cmdutil.exportfile(repo, [n], fp, opts=diffopts) |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2188 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2189 se = statusentry(n, patchname) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2190 self.applied.insert(0, se) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2191 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2192 self.added.append(patchname) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2193 imported.append(patchname) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2194 patchname = None |
34184
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
2195 if rev and repo.ui.configbool('mq', 'secret'): |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2196 # if we added anything with --rev, move the secret root |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
2197 phases.retractboundary(repo, tr, phases.secret, [n]) |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2198 self.parseseries() |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2199 self.applieddirty = True |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2200 self.seriesdirty = True |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2201 |
10687
583adcf63f80
mq: use xrange/enumerate instead of += 1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10686
diff
changeset
|
2202 for i, filename in enumerate(files): |
1808 | 2203 if existing: |
3547 | 2204 if filename == '-': |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2205 raise error.Abort(_('-e is incompatible with import from -') |
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2206 ) |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2207 filename = normname(filename) |
14584
3343a74eea4e
mq: rename check_reserved_name to checkreservedname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14583
diff
changeset
|
2208 self.checkreservedname(filename) |
20402 | 2209 if util.url(filename).islocal(): |
20394
a817964e7fdf
qimport: allow importing URLs
Matt Mackall <mpm@selenic.com>
parents:
20119
diff
changeset
|
2210 originpath = self.join(filename) |
a817964e7fdf
qimport: allow importing URLs
Matt Mackall <mpm@selenic.com>
parents:
20119
diff
changeset
|
2211 if not os.path.isfile(originpath): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2212 raise error.Abort( |
20402 | 2213 _("patch %s does not exist") % filename) |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2214 |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2215 if patchname: |
14423 | 2216 self.checkpatchname(patchname, force) |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2217 |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2218 self.ui.write(_('renaming %s to %s\n') |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2219 % (filename, patchname)) |
11701
84fb29f5e0d2
mq: fix qimport --name --existing --force on win32
Patrick Mezard <pmezard@gmail.com>
parents:
11700
diff
changeset
|
2220 util.rename(originpath, self.join(patchname)) |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2221 else: |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2222 patchname = filename |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2223 |
1808 | 2224 else: |
14395
dc961471efde
mq: check patch name is valid before reading imported file
Idan Kamara <idankk86@gmail.com>
parents:
14382
diff
changeset
|
2225 if filename == '-' and not patchname: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2226 raise error.Abort(_('need --name to import a patch from -')) |
14395
dc961471efde
mq: check patch name is valid before reading imported file
Idan Kamara <idankk86@gmail.com>
parents:
14382
diff
changeset
|
2227 elif not patchname: |
14396
170747a3e139
mq: strip all leading slashes from url when importing
Idan Kamara <idankk86@gmail.com>
parents:
14395
diff
changeset
|
2228 patchname = normname(os.path.basename(filename.rstrip('/'))) |
14423 | 2229 self.checkpatchname(patchname, force) |
1808 | 2230 try: |
3547 | 2231 if filename == '-': |
14636
b98063487a6f
mq: use ui.fin when importing patch from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14635
diff
changeset
|
2232 text = self.ui.fin.read() |
3547 | 2233 else: |
17887
0e2846b2482c
url: use open and not url.open for local files (issue3624)
Siddharth Agarwal <sid0@fb.com>
parents:
17773
diff
changeset
|
2234 fp = hg.openpath(self.ui, filename) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
2235 text = fp.read() |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
2236 fp.close() |
7421
4c4324476be6
Catch both IOError and OSError, fix regression introduced by 8046f0a070a6
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7414
diff
changeset
|
2237 except (OSError, IOError): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2238 raise error.Abort(_("unable to read file %s") % filename) |
3133
15fde1970003
qimport: rename patch to patchname to avoid shadowing module
Brendan Cully <brendan@kublai.com>
parents:
3091
diff
changeset
|
2239 patchf = self.opener(patchname, "w") |
1808 | 2240 patchf.write(text) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
2241 patchf.close() |
7160
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
2242 if not force: |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
2243 checkseries(patchname) |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
2244 if patchname not in self.series: |
14585
74bf9c84cfd0
mq: rename full_series_end to fullseriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14584
diff
changeset
|
2245 index = self.fullseriesend() + i |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
2246 self.fullseries[index:index] = [patchname] |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
2247 self.parseseries() |
14593
599a72895c0d
mq: rename series_dirty to seriesdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14592
diff
changeset
|
2248 self.seriesdirty = True |
7597
81f68565281c
mq, i18n: mark strings for translation
Martin Geisler <mg@daimi.au.dk>
parents:
7454
diff
changeset
|
2249 self.ui.warn(_("adding %s to series file\n") % patchname) |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
2250 self.added.append(patchname) |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2251 imported.append(patchname) |
3133
15fde1970003
qimport: rename patch to patchname to avoid shadowing module
Brendan Cully <brendan@kublai.com>
parents:
3091
diff
changeset
|
2252 patchname = None |
1808 | 2253 |
13409
9e5df8719ad4
mq: remove undo after a qimport
André Sintzoff <andre.sintzoff@gmail.com>
parents:
13400
diff
changeset
|
2254 self.removeundo(repo) |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2255 return imported |
13409
9e5df8719ad4
mq: remove undo after a qimport
André Sintzoff <andre.sintzoff@gmail.com>
parents:
13400
diff
changeset
|
2256 |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2257 def fixkeepchangesopts(ui, opts): |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2258 if (not ui.configbool('mq', 'keepchanges') or opts.get('force') |
16656
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2259 or opts.get('exact')): |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2260 return opts |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2261 opts = dict(opts) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2262 opts['keep_changes'] = True |
16656
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2263 return opts |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2264 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2265 @command("qdelete|qremove|qrm", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2266 [('k', 'keep', None, _('keep patch file')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2267 ('r', 'rev', [], |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2268 _('stop managing a revision (DEPRECATED)'), _('REV'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2269 _('hg qdelete [-k] [PATCH]...'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2270 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
2271 def delete(ui, repo, *patches, **opts): |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
2272 """remove patches from queue |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
2273 |
15798
e6c44dbe902f
mq: Document that qdel requires exact patch identifiers
Olav Reinert <seroton10@gmail.com>
parents:
15322
diff
changeset
|
2274 The patches must not be applied, and at least one patch is required. Exact |
e6c44dbe902f
mq: Document that qdel requires exact patch identifiers
Olav Reinert <seroton10@gmail.com>
parents:
15322
diff
changeset
|
2275 patch identifiers must be given. With -k/--keep, the patch files are |
e6c44dbe902f
mq: Document that qdel requires exact patch identifiers
Olav Reinert <seroton10@gmail.com>
parents:
15322
diff
changeset
|
2276 preserved in the patch directory. |
8904
8be38b624902
mq: no longer mention the deprecated qdelete's --revision option
Cédric Duval <cedricduval@free.fr>
parents:
8894
diff
changeset
|
2277 |
8be38b624902
mq: no longer mention the deprecated qdelete's --revision option
Cédric Duval <cedricduval@free.fr>
parents:
8894
diff
changeset
|
2278 To stop managing a patch and move it into permanent history, |
11307
7f72031d4047
mq: use hg reST role some more
Martin Geisler <mg@aragost.com>
parents:
11303
diff
changeset
|
2279 use the :hg:`qfinish` command.""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2280 q = repo.mq |
36281
d822f3fb6be8
py3: use pycompat.byteskwargs() to convert opts keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36107
diff
changeset
|
2281 q.delete(repo, patches, pycompat.byteskwargs(opts)) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2282 q.savedirty() |
1808 | 2283 return 0 |
2284 | |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2285 @command("qapplied", |
16188
6b52963ced73
mq: fix qapplied --last and qprev documentation (issue3282)
Patrick Mezard <patrick@mezard.eu>
parents:
16119
diff
changeset
|
2286 [('1', 'last', None, _('show only the preceding applied patch')) |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2287 ] + seriesopts, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2288 _('hg qapplied [-1] [-s] [PATCH]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2289 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 2290 def applied(ui, repo, patch=None, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2291 """print the patches already applied |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2292 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2293 Returns 0 on success.""" |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2294 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2295 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2296 opts = pycompat.byteskwargs(opts) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2297 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2298 if patch: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2299 if patch not in q.series: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2300 raise error.Abort(_("patch %s is not in series file") % patch) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2301 end = q.series.index(patch) + 1 |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2302 else: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2303 end = q.seriesend(True) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2304 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2305 if opts.get('last') and not end: |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2306 ui.write(_("no patches applied\n")) |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2307 return 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2308 elif opts.get('last') and end == 1: |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2309 ui.write(_("only one patch applied\n")) |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2310 return 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2311 elif opts.get('last'): |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2312 start = end - 2 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2313 end = 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2314 else: |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2315 start = 0 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2316 |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2317 q.qseries(repo, length=end, start=start, status='A', |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2318 summary=opts.get('summary')) |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2319 |
1808 | 2320 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2321 @command("qunapplied", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2322 [('1', 'first', None, _('show only the first patch'))] + seriesopts, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2323 _('hg qunapplied [-1] [-s] [PATCH]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2324 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 2325 def unapplied(ui, repo, patch=None, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2326 """print the patches not yet applied |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2327 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2328 Returns 0 on success.""" |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2329 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2330 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2331 opts = pycompat.byteskwargs(opts) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2332 if patch: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2333 if patch not in q.series: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2334 raise error.Abort(_("patch %s is not in series file") % patch) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2335 start = q.series.index(patch) + 1 |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2336 else: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2337 start = q.seriesend(True) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2338 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2339 if start == len(q.series) and opts.get('first'): |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2340 ui.write(_("all patches applied\n")) |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2341 return 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2342 |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2343 if opts.get('first'): |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2344 length = 1 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2345 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2346 length = None |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2347 q.qseries(repo, start=start, length=length, status='U', |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2348 summary=opts.get('summary')) |
1808 | 2349 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2350 @command("qimport", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2351 [('e', 'existing', None, _('import file in patch directory')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2352 ('n', 'name', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2353 _('name of patch file'), _('NAME')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2354 ('f', 'force', None, _('overwrite existing files')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2355 ('r', 'rev', [], |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2356 _('place existing revisions under mq control'), _('REV')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2357 ('g', 'git', None, _('use git extended diff format')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2358 ('P', 'push', None, _('qpush after importing'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2359 _('hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2360 helpcategory=command.CATEGORY_IMPORT_EXPORT) |
1808 | 2361 def qimport(ui, repo, *filename, **opts): |
16152
816211dfa3a5
mq: expand qimport summary
Matt Mackall <mpm@selenic.com>
parents:
16128
diff
changeset
|
2362 """import a patch or existing changeset |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2363 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2364 The patch is inserted into the series after the last applied |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2365 patch. If no patches have been applied, qimport prepends the patch |
6634
d6caebe9c293
mq: qimport: explain insertion point in doc string
Adrian Buehlmann <adrian@cadifra.com>
parents:
6627
diff
changeset
|
2366 to the series. |
d6caebe9c293
mq: qimport: explain insertion point in doc string
Adrian Buehlmann <adrian@cadifra.com>
parents:
6627
diff
changeset
|
2367 |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2368 The patch will have the same name as its source file unless you |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2369 give it a new one with -n/--name. |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2370 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2371 You can register an existing patch inside the patch directory with |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2372 the -e/--existing flag. |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2373 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2374 With -f/--force, an existing patch of the same name will be |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2375 overwritten. |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2376 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2377 An existing changeset may be placed under mq control with -r/--rev |
19397
42fc6c7c4ad5
mq: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
19395
diff
changeset
|
2378 (e.g. qimport --rev . -n patch will place the current revision |
42fc6c7c4ad5
mq: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
19395
diff
changeset
|
2379 under mq control). With -g/--git, patches imported with --rev will |
42fc6c7c4ad5
mq: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
19395
diff
changeset
|
2380 use the git diff format. See the diffs help topic for information |
42fc6c7c4ad5
mq: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
19395
diff
changeset
|
2381 on why this is important for preserving rename/copy information |
42fc6c7c4ad5
mq: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
19395
diff
changeset
|
2382 and permission changes. Use :hg:`qfinish` to remove changesets |
42fc6c7c4ad5
mq: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
19395
diff
changeset
|
2383 from mq control. |
8075
1f0a5a5fff43
Update qimport help explaining how to read a patch from stdin (Issue371)
David Frey <dpfrey@shaw.ca>
parents:
8028
diff
changeset
|
2384 |
1f0a5a5fff43
Update qimport help explaining how to read a patch from stdin (Issue371)
David Frey <dpfrey@shaw.ca>
parents:
8028
diff
changeset
|
2385 To import a patch from standard input, pass - as the patch file. |
1f0a5a5fff43
Update qimport help explaining how to read a patch from stdin (Issue371)
David Frey <dpfrey@shaw.ca>
parents:
8028
diff
changeset
|
2386 When importing from standard input, a patch name must be specified |
1f0a5a5fff43
Update qimport help explaining how to read a patch from stdin (Issue371)
David Frey <dpfrey@shaw.ca>
parents:
8028
diff
changeset
|
2387 using the --name flag. |
11700
52c863295754
mq: document possible combination of -e and -n for qimport
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11699
diff
changeset
|
2388 |
11706
5fdf08b6b50c
mq: correct qimport documentation
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11701
diff
changeset
|
2389 To import an existing patch while renaming it:: |
11700
52c863295754
mq: document possible combination of -e and -n for qimport
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11699
diff
changeset
|
2390 |
52c863295754
mq: document possible combination of -e and -n for qimport
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11699
diff
changeset
|
2391 hg qimport -e existing-patch -n new-name |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2392 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2393 Returns 0 if import succeeded. |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2394 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2395 opts = pycompat.byteskwargs(opts) |
27832
1e38b9d731c4
with: use context manager for lock in qimport
Bryan O'Sullivan <bryano@fb.com>
parents:
27831
diff
changeset
|
2396 with repo.lock(): # cause this may move phase |
16027
29ea059be33c
qimport: when mq.secret=True set qimported revision as secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16026
diff
changeset
|
2397 q = repo.mq |
29ea059be33c
qimport: when mq.secret=True set qimported revision as secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16026
diff
changeset
|
2398 try: |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2399 imported = q.qimport( |
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2400 repo, filename, patchname=opts.get('name'), |
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2401 existing=opts.get('existing'), force=opts.get('force'), |
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2402 rev=opts.get('rev'), git=opts.get('git')) |
16027
29ea059be33c
qimport: when mq.secret=True set qimported revision as secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16026
diff
changeset
|
2403 finally: |
29ea059be33c
qimport: when mq.secret=True set qimported revision as secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16026
diff
changeset
|
2404 q.savedirty() |
16681
0128cdb846d9
mq: qimport need wlock for --push - do that after releasing lock
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16635
diff
changeset
|
2405 |
0128cdb846d9
mq: qimport need wlock for --push - do that after releasing lock
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16635
diff
changeset
|
2406 if imported and opts.get('push') and not opts.get('rev'): |
0128cdb846d9
mq: qimport need wlock for --push - do that after releasing lock
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16635
diff
changeset
|
2407 return q.push(repo, imported[-1]) |
1808 | 2408 return 0 |
2409 | |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2410 def qinit(ui, repo, create): |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2411 """initialize a new queue repository |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
2412 |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2413 This command also creates a series file for ordering patches, and |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2414 an mq-specific .hgignore file in the queue repository, to exclude |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2415 the status and guards files (these contain mostly transient state). |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2416 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2417 Returns 0 if initialization succeeded.""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2418 q = repo.mq |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2419 r = q.init(repo, create) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2420 q.savedirty() |
1808 | 2421 if r: |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
2422 if not os.path.exists(r.wjoin('.hgignore')): |
23879
b88278a308c6
localrepo: remove all external users of localrepo.wopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23877
diff
changeset
|
2423 fp = r.wvfs('.hgignore', 'w') |
6034
83633602e2c5
qinit -c: add ^\.hg and ^\.mq to .hgignore
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6027
diff
changeset
|
2424 fp.write('^\\.hg\n') |
83633602e2c5
qinit -c: add ^\.hg and ^\.mq to .hgignore
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6027
diff
changeset
|
2425 fp.write('^\\.mq\n') |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
2426 fp.write('syntax: glob\n') |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
2427 fp.write('status\n') |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
2428 fp.write('guards\n') |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
2429 fp.close() |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
2430 if not os.path.exists(r.wjoin('series')): |
23879
b88278a308c6
localrepo: remove all external users of localrepo.wopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23877
diff
changeset
|
2431 r.wvfs('series', 'w').close() |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
2432 r[None].add(['.hgignore', 'series']) |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
2433 commands.add(ui, r) |
1808 | 2434 return 0 |
2435 | |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2436 @command("qinit", |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2437 [('c', 'create-repo', None, _('create queue repository'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2438 _('hg qinit [-c]'), |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2439 helpcategory=command.CATEGORY_REPO_CREATION, |
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2440 helpbasic=True) |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2441 def init(ui, repo, **opts): |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2442 """init a new queue repository (DEPRECATED) |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2443 |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2444 The queue repository is unversioned by default. If |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2445 -c/--create-repo is specified, qinit will create a separate nested |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2446 repository for patches (qinit -c may also be run later to convert |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2447 an unversioned patch repository into a versioned one). You can use |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2448 qcommit to commit changes to this queue repository. |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2449 |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2450 This command is deprecated. Without -c, it's implied by other relevant |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11121
diff
changeset
|
2451 commands. With -c, use :hg:`init --mq` instead.""" |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2452 return qinit(ui, repo, create=opts.get(r'create_repo')) |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2453 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2454 @command("qclone", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2455 [('', 'pull', None, _('use pull protocol to copy metadata')), |
16683 | 2456 ('U', 'noupdate', None, |
2457 _('do not update the new working directories')), | |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2458 ('', 'uncompressed', None, |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2459 _('use uncompressed transfer (fast over LAN)')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2460 ('p', 'patches', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2461 _('location of source patch repository'), _('REPO')), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32347
diff
changeset
|
2462 ] + cmdutil.remoteopts, |
21771
0f3353776038
mq: define norepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21714
diff
changeset
|
2463 _('hg qclone [OPTION]... SOURCE [DEST]'), |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2464 helpcategory=command.CATEGORY_REPO_CREATION, |
21771
0f3353776038
mq: define norepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21714
diff
changeset
|
2465 norepo=True) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2466 def clone(ui, source, dest=None, **opts): |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2467 '''clone main and patch repository at same time |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2468 |
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
2469 If source is local, destination will have no patches applied. If |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2470 source is remote, this command can not check if patches are |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2471 applied in source, so cannot guarantee that patches are not |
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
2472 applied in destination. If you clone remote repository, be sure |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2473 before that it has no patches applied. |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2474 |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2475 Source patch repository is looked for in <src>/.hg/patches by |
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
2476 default. Use -p <url> to change. |
4862
cba10652a901
mq: improve qclone error handling when patch directory is not a repository.
Brendan Cully <brendan@kublai.com>
parents:
4737
diff
changeset
|
2477 |
8760
bf17aeafb869
Spell Mercurial as a proper noun
timeless <timeless@gmail.com>
parents:
8711
diff
changeset
|
2478 The patch directory must be a nested Mercurial repository, as |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11121
diff
changeset
|
2479 would be created by :hg:`init --mq`. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2480 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2481 Return 0 on success. |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2482 ''' |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2483 opts = pycompat.byteskwargs(opts) |
5226
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2484 def patchdir(repo): |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2485 """compute a patch repo url from a repo object""" |
5226
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2486 url = repo.url() |
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2487 if url.endswith('/'): |
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2488 url = url[:-1] |
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2489 return url + '/.hg/patches' |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2490 |
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2491 # main repo (destination and sources) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2492 if dest is None: |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2493 dest = hg.defaultdest(source) |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2494 sr = hg.peer(ui, opts, ui.expandpath(source)) |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2495 |
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2496 # patches repo (source only) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2497 if opts.get('patches'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2498 patchespath = ui.expandpath(opts.get('patches')) |
7729
dd08e1e0cea1
mq: allow qclone's -p option to use path alias
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7639
diff
changeset
|
2499 else: |
dd08e1e0cea1
mq: allow qclone's -p option to use path alias
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7639
diff
changeset
|
2500 patchespath = patchdir(sr) |
4862
cba10652a901
mq: improve qclone error handling when patch directory is not a repository.
Brendan Cully <brendan@kublai.com>
parents:
4737
diff
changeset
|
2501 try: |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2502 hg.peer(ui, opts, patchespath) |
7637 | 2503 except error.RepoError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2504 raise error.Abort(_('versioned patch repository not found' |
10690
ea85c01c7835
mq: no longer refer to deprecated qinit -c command
Cédric Duval <cedricduval@free.fr>
parents:
10689
diff
changeset
|
2505 ' (see init --mq)')) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2506 qbase, destrev = None, None |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2507 if sr.local(): |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2508 repo = sr.local() |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2509 if repo.mq.applied and repo[qbase].phase() != phases.secret: |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2510 qbase = repo.mq.applied[0].node |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2511 if not hg.islocal(dest): |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2512 heads = set(repo.heads()) |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2513 destrev = list(heads.difference(repo.heads(qbase))) |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2514 destrev.append(repo.changelog.parents(qbase)[0]) |
6164
0c2b443fb3c3
mq: make qclone ask remote source repo for qbase using lookup protocol
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6139
diff
changeset
|
2515 elif sr.capable('lookup'): |
6380
a632a9a57821
qclone: do not abort if remote hasn't enabled mq (issue1040)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6340
diff
changeset
|
2516 try: |
a632a9a57821
qclone: do not abort if remote hasn't enabled mq (issue1040)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6340
diff
changeset
|
2517 qbase = sr.lookup('qbase') |
7637 | 2518 except error.RepoError: |
6380
a632a9a57821
qclone: do not abort if remote hasn't enabled mq (issue1040)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6340
diff
changeset
|
2519 pass |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2520 |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2521 ui.note(_('cloning main repository\n')) |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14529
diff
changeset
|
2522 sr, dr = hg.clone(ui, opts, sr.url(), dest, |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2523 pull=opts.get('pull'), |
37262
54435fd09f1d
clone: rename "rev" to "revs" since there can be many
Martin von Zweigbergk <martinvonz@google.com>
parents:
37084
diff
changeset
|
2524 revs=destrev, |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2525 update=False, |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2526 stream=opts.get('uncompressed')) |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2527 |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2528 ui.note(_('cloning patch repository\n')) |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14529
diff
changeset
|
2529 hg.clone(ui, opts, opts.get('patches') or patchdir(sr), patchdir(dr), |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2530 pull=opts.get('pull'), update=not opts.get('noupdate'), |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2531 stream=opts.get('uncompressed')) |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2532 |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2533 if dr.local(): |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2534 repo = dr.local() |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2535 if qbase: |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2536 ui.note(_('stripping applied patches from destination ' |
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2537 'repository\n')) |
19819
f0fc4d5797e1
mq: extract `mq.queue.strip`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19818
diff
changeset
|
2538 strip(ui, repo, [qbase], update=False, backup=None) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2539 if not opts.get('noupdate'): |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2540 ui.note(_('updating destination repository\n')) |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2541 hg.update(repo, repo.changelog.tip()) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2542 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2543 @command("qcommit|qci", |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2544 commands.table["commit|ci"][1], |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2545 _('hg qcommit [OPTION]... [FILE]...'), |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2546 helpcategory=command.CATEGORY_COMMITTING, |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2547 inferrepo=True) |
1808 | 2548 def commit(ui, repo, *pats, **opts): |
10361
49cd2e7fd91c
mq: deprecate qinit and qcommit
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10360
diff
changeset
|
2549 """commit changes in the queue repository (DEPRECATED) |
49cd2e7fd91c
mq: deprecate qinit and qcommit
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10360
diff
changeset
|
2550 |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11121
diff
changeset
|
2551 This command is deprecated; use :hg:`commit --mq` instead.""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2552 q = repo.mq |
1808 | 2553 r = q.qrepo() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2554 if not r: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2555 raise error.Abort('no queue repository') |
1808 | 2556 commands.commit(r.ui, r, *pats, **opts) |
2557 | |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2558 @command("qseries", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2559 [('m', 'missing', None, _('print patches not in series')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2560 ] + seriesopts, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2561 _('hg qseries [-ms]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2562 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 2563 def series(ui, repo, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2564 """print the entire series file |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2565 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2566 Returns 0 on success.""" |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2567 repo.mq.qseries(repo, missing=opts.get(r'missing'), |
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2568 summary=opts.get(r'summary')) |
1808 | 2569 return 0 |
2570 | |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2571 @command("qtop", seriesopts, _('hg qtop [-s]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2572 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 2573 def top(ui, repo, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2574 """print the name of the current patch |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2575 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2576 Returns 0 on success.""" |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2577 q = repo.mq |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2578 if q.applied: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2579 t = q.seriesend(True) |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2580 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2581 t = 0 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2582 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2583 if t: |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2584 q.qseries(repo, start=t - 1, length=1, status='A', |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2585 summary=opts.get(r'summary')) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2586 else: |
7627 | 2587 ui.write(_("no patches applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2588 return 1 |
1808 | 2589 |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2590 @command("qnext", seriesopts, _('hg qnext [-s]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2591 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 2592 def next(ui, repo, **opts): |
16063
c36db39b3fee
mq: fix qnext when all remaining patches are guarded
Patrick Mezard <pmezard@gmail.com>
parents:
16048
diff
changeset
|
2593 """print the name of the next pushable patch |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2594 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2595 Returns 0 on success.""" |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2596 q = repo.mq |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2597 end = q.seriesend() |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2598 if end == len(q.series): |
7627 | 2599 ui.write(_("all patches applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2600 return 1 |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2601 q.qseries(repo, start=end, length=1, summary=opts.get(r'summary')) |
1808 | 2602 |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2603 @command("qprev", seriesopts, _('hg qprev [-s]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2604 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 2605 def prev(ui, repo, **opts): |
16188
6b52963ced73
mq: fix qapplied --last and qprev documentation (issue3282)
Patrick Mezard <patrick@mezard.eu>
parents:
16119
diff
changeset
|
2606 """print the name of the preceding applied patch |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2607 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2608 Returns 0 on success.""" |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2609 q = repo.mq |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2610 l = len(q.applied) |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2611 if l == 1: |
7627 | 2612 ui.write(_("only one patch applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2613 return 1 |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2614 if not l: |
7627 | 2615 ui.write(_("no patches applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2616 return 1 |
16064
7e5a281a082c
mq: make qprev return the previous applied patch (issue3245)
Patrick Mezard <pmezard@gmail.com>
parents:
16063
diff
changeset
|
2617 idx = q.series.index(q.applied[-2].name) |
7e5a281a082c
mq: make qprev return the previous applied patch (issue3245)
Patrick Mezard <pmezard@gmail.com>
parents:
16063
diff
changeset
|
2618 q.qseries(repo, start=idx, length=1, status='A', |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2619 summary=opts.get(r'summary')) |
1808 | 2620 |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2621 def setupheaderopts(ui, opts): |
9733
f16ec85f125c
mq: do not call ui.username unless it is necessary
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
2622 if not opts.get('user') and opts.get('currentuser'): |
f16ec85f125c
mq: do not call ui.username unless it is necessary
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
2623 opts['user'] = ui.username() |
f16ec85f125c
mq: do not call ui.username unless it is necessary
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
2624 if not opts.get('date') and opts.get('currentdate'): |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36389
diff
changeset
|
2625 opts['date'] = "%d %d" % dateutil.makedate() |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2626 |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2627 @command("qnew", |
21952
3838b910fa6b
doc: unify help text for "--edit" option
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21786
diff
changeset
|
2628 [('e', 'edit', None, _('invoke editor on commit messages')), |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2629 ('f', 'force', None, _('import uncommitted changes (DEPRECATED)')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2630 ('g', 'git', None, _('use git extended diff format')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2631 ('U', 'currentuser', None, _('add "From: <current user>" to patch')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2632 ('u', 'user', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2633 _('add "From: <USER>" to patch'), _('USER')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2634 ('D', 'currentdate', None, _('add "Date: <current date>" to patch')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2635 ('d', 'date', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2636 _('add "Date: <DATE>" to patch'), _('DATE')) |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32347
diff
changeset
|
2637 ] + cmdutil.walkopts + cmdutil.commitopts, |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2638 _('hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...'), |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2639 helpcategory=command.CATEGORY_COMMITTING, helpbasic=True, |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2640 inferrepo=True) |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
2641 def new(ui, repo, patch, *args, **opts): |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
2642 """create a new patch |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
2643 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2644 qnew creates a new patch on top of the currently-applied patch (if |
10808
1ebba857b371
mq: remove reference for deprecated -f option
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10770
diff
changeset
|
2645 any). The patch will be initialized with any outstanding changes |
1ebba857b371
mq: remove reference for deprecated -f option
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10770
diff
changeset
|
2646 in the working directory. You may also use -I/--include, |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2647 -X/--exclude, and/or a list of files after the patch name to add |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2648 only changes to matching files to the new patch, leaving the rest |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2649 as uncommitted modifications. |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
2650 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2651 -u/--user and -d/--date can be used to set the (given) user and |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2652 date, respectively. -U/--currentuser and -D/--currentdate set user |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2653 to current user and date to current date. |
7306
8e46e59aaf4c
mq: reflow qnew help, add help for options
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7297
diff
changeset
|
2654 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2655 -e/--edit, -m/--message or -l/--logfile set the patch header as |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2656 well as the commit message. If none is specified, the header is |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2657 empty and the commit message is '[mq]: PATCH'. |
7307
56380212d630
help: commands supporting --git point to the gitdiffs topic (issue1352)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7306
diff
changeset
|
2658 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2659 Use the -g/--git option to keep the patch in the git extended diff |
7387 | 2660 format. Read the diffs help topic for more information on why this |
2661 is important for preserving permission changes and copy/rename | |
2662 information. | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2663 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2664 Returns 0 on successful creation of a new patch. |
7306
8e46e59aaf4c
mq: reflow qnew help, add help for options
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7297
diff
changeset
|
2665 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2666 opts = pycompat.byteskwargs(opts) |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
2667 msg = cmdutil.logmessage(ui, opts) |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2668 q = repo.mq |
7157
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
2669 opts['msg'] = msg |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2670 setupheaderopts(ui, opts) |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2671 q.new(repo, patch, *args, **pycompat.strkwargs(opts)) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2672 q.savedirty() |
1808 | 2673 return 0 |
2674 | |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2675 @command("qrefresh", |
21952
3838b910fa6b
doc: unify help text for "--edit" option
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21786
diff
changeset
|
2676 [('e', 'edit', None, _('invoke editor on commit messages')), |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2677 ('g', 'git', None, _('use git extended diff format')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2678 ('s', 'short', None, |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2679 _('refresh only files already in the patch and specified files')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2680 ('U', 'currentuser', None, |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2681 _('add/update author field in patch with current user')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2682 ('u', 'user', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2683 _('add/update author field in patch with given user'), _('USER')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2684 ('D', 'currentdate', None, |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2685 _('add/update date field in patch with current date')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2686 ('d', 'date', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2687 _('add/update date field in patch with given date'), _('DATE')) |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32347
diff
changeset
|
2688 ] + cmdutil.walkopts + cmdutil.commitopts, |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2689 _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...'), |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2690 helpcategory=command.CATEGORY_COMMITTING, helpbasic=True, |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2691 inferrepo=True) |
2938
5b7a118f5b6c
allow qrefresh to take a list of files; closes #96.
Brendan Cully <brendan@kublai.com>
parents:
2937
diff
changeset
|
2692 def refresh(ui, repo, *pats, **opts): |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2693 """update the current patch |
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2694 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2695 If any file patterns are provided, the refreshed patch will |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2696 contain only the modifications that match those patterns; the |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2697 remaining modifications will remain in the working directory. |
4048
5d6b3fa62736
mq: Mention usage of hg add/remove/copy/rename in qrefresh help text.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4040
diff
changeset
|
2698 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2699 If -s/--short is specified, files currently included in the patch |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2700 will be refreshed just like matched files and remain in the patch. |
7113
f7fc5f5ecd62
mq: Allow qrefresh --silent to take parameters
Mads Kiilerich <mads@kiilerich.com>
parents:
7002
diff
changeset
|
2701 |
11947
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2702 If -e/--edit is specified, Mercurial will start your configured editor for |
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2703 you to enter a message. In case qrefresh fails, you will find a backup of |
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2704 your message in ``.hg/last-message.txt``. |
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2705 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2706 hg add/remove/copy/rename work as usual, though you might want to |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2707 use git-style patches (-g/--git or [diff] git=1) to track copies |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2708 and renames. See the diffs help topic for more information on the |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2709 git diff format. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2710 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2711 Returns 0 on success. |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2712 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2713 opts = pycompat.byteskwargs(opts) |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2714 q = repo.mq |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
2715 message = cmdutil.logmessage(ui, opts) |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2716 setupheaderopts(ui, opts) |
27830
1c5941542f24
with: use context manager for wlock in qrefresh
Bryan O'Sullivan <bryano@fb.com>
parents:
27829
diff
changeset
|
2717 with repo.wlock(): |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2718 ret = q.refresh(repo, pats, msg=message, **pycompat.strkwargs(opts)) |
14620
2b9c32929e62
mq: make qrefresh/qfold keep wlock until saving patch status
Yuya Nishihara <yuya@tcha.org>
parents:
14600
diff
changeset
|
2719 q.savedirty() |
2b9c32929e62
mq: make qrefresh/qfold keep wlock until saving patch status
Yuya Nishihara <yuya@tcha.org>
parents:
14600
diff
changeset
|
2720 return ret |
1808 | 2721 |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2722 @command("qdiff", |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32347
diff
changeset
|
2723 cmdutil.diffopts + cmdutil.diffopts2 + cmdutil.walkopts, |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2724 _('hg qdiff [OPTION]... [FILE]...'), |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2725 helpcategory=command.CATEGORY_FILE_CONTENTS, helpbasic=True, |
21786
c85a0c3537b2
mq: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21771
diff
changeset
|
2726 inferrepo=True) |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
2727 def diff(ui, repo, *pats, **opts): |
6606
088ba40585b9
mq: expand help text for qdiff
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6561
diff
changeset
|
2728 """diff of the current patch and subsequent modifications |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
2729 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2730 Shows a diff which includes the current patch as well as any |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2731 changes which have been made in the working directory since the |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2732 last refresh (thus showing what the current patch would become |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2733 after a qrefresh). |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
2734 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10962
diff
changeset
|
2735 Use :hg:`diff` if you only want to see the changes made since the |
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10962
diff
changeset
|
2736 last qrefresh, or :hg:`export qtip` if you want to see changes |
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10962
diff
changeset
|
2737 made by the current patch without including changes made since the |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2738 qrefresh. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2739 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2740 Returns 0 on success. |
6606
088ba40585b9
mq: expand help text for qdiff
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6561
diff
changeset
|
2741 """ |
31033
861b070d92da
qdiff: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
31024
diff
changeset
|
2742 ui.pager('qdiff') |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2743 repo.mq.diff(repo, pats, pycompat.byteskwargs(opts)) |
1808 | 2744 return 0 |
2745 | |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2746 @command('qfold', |
21952
3838b910fa6b
doc: unify help text for "--edit" option
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21786
diff
changeset
|
2747 [('e', 'edit', None, _('invoke editor on commit messages')), |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2748 ('k', 'keep', None, _('keep folded patch files')), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32347
diff
changeset
|
2749 ] + cmdutil.commitopts, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2750 _('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2751 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2752 def fold(ui, repo, *files, **opts): |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2753 """fold the named patches into the current patch |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2754 |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
2755 Patches must not yet be applied. Each patch will be successively |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
2756 applied to the current patch in the order given. If all the |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
2757 patches apply successfully, the current patch will be refreshed |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2758 with the new cumulative patch, and the folded patches will be |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2759 deleted. With -k/--keep, the folded patch files will not be |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2760 removed afterwards. |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
2761 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2762 The header for each folded patch will be concatenated with the |
12755
db79d3627872
mq: switched to `` around * * *
Erik Zielke <ez@aragost.com>
parents:
12689
diff
changeset
|
2763 current patch header, separated by a line of ``* * *``. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2764 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2765 Returns 0 on success.""" |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2766 opts = pycompat.byteskwargs(opts) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2767 q = repo.mq |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2768 if not files: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2769 raise error.Abort(_('qfold requires at least one patch name')) |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
2770 if not q.checktoppatch(repo)[0]: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2771 raise error.Abort(_('no patches applied')) |
14583
28f87e14d923
mq: rename check_localchanges to checklocalchanges
Adrian Buehlmann <adrian@cadifra.com>
parents:
14582
diff
changeset
|
2772 q.checklocalchanges(repo) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2773 |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
2774 message = cmdutil.logmessage(ui, opts) |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2775 |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2776 parent = q.lookup('qtip') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2777 patches = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2778 messages = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2779 for f in files: |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2780 p = q.lookup(f) |
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2781 if p in patches or p == parent: |
16929
4b02d7006169
mq: lowercase warning messages
Martin Geisler <mg@aragost.com>
parents:
16867
diff
changeset
|
2782 ui.warn(_('skipping already folded patch %s\n') % p) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2783 if q.isapplied(p): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2784 raise error.Abort(_('qfold cannot fold already applied patch %s') |
16683 | 2785 % p) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2786 patches.append(p) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2787 |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2788 for p in patches: |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2789 if not message: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
2790 ph = patchheader(q.join(p), q.plainmode) |
7454
1d5ecaa47abb
mq: filter out empty commit messages in qfold
Brendan Cully <brendan@kublai.com>
parents:
7453
diff
changeset
|
2791 if ph.message: |
1d5ecaa47abb
mq: filter out empty commit messages in qfold
Brendan Cully <brendan@kublai.com>
parents:
7453
diff
changeset
|
2792 messages.append(ph.message) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2793 pf = q.join(p) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2794 (patchsuccess, files, fuzz) = q.patch(repo, pf) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2795 if not patchsuccess: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2796 raise error.Abort(_('error folding patch %s') % p) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2797 |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2798 if not message: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
2799 ph = patchheader(q.join(parent), q.plainmode) |
21270
8fd982139740
mq: eliminate unused variable for test-check-pyflakes.t
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21236
diff
changeset
|
2800 message = ph.message |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2801 for msg in messages: |
20053
2455e96ec73b
mq: don't add '* * *' separators when there is no commit message
Mads Kiilerich <madski@unity3d.com>
parents:
19997
diff
changeset
|
2802 if msg: |
2455e96ec73b
mq: don't add '* * *' separators when there is no commit message
Mads Kiilerich <madski@unity3d.com>
parents:
19997
diff
changeset
|
2803 if message: |
2455e96ec73b
mq: don't add '* * *' separators when there is no commit message
Mads Kiilerich <madski@unity3d.com>
parents:
19997
diff
changeset
|
2804 message.append('* * *') |
2455e96ec73b
mq: don't add '* * *' separators when there is no commit message
Mads Kiilerich <madski@unity3d.com>
parents:
19997
diff
changeset
|
2805 message.extend(msg) |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2806 message = '\n'.join(message) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2807 |
10186
296a0b14a686
mq: preserve --git flag when folding patches
Patrick Mezard <pmezard@gmail.com>
parents:
10185
diff
changeset
|
2808 diffopts = q.patchopts(q.diffopts(), *patches) |
27831
62f3126ef678
with: use context manager for wlock in qfold
Bryan O'Sullivan <bryano@fb.com>
parents:
27830
diff
changeset
|
2809 with repo.wlock(): |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
2810 q.refresh(repo, msg=message, git=diffopts.git, edit=opts.get('edit'), |
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
2811 editform='mq.qfold') |
14620
2b9c32929e62
mq: make qrefresh/qfold keep wlock until saving patch status
Yuya Nishihara <yuya@tcha.org>
parents:
14600
diff
changeset
|
2812 q.delete(repo, patches, opts) |
2b9c32929e62
mq: make qrefresh/qfold keep wlock until saving patch status
Yuya Nishihara <yuya@tcha.org>
parents:
14600
diff
changeset
|
2813 q.savedirty() |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2814 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2815 @command("qgoto", |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2816 [('', 'keep-changes', None, |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2817 _('tolerate non-conflicting local changes')), |
16655
6ca125af882f
mq: introduce qgoto --check
Patrick Mezard <patrick@mezard.eu>
parents:
16654
diff
changeset
|
2818 ('f', 'force', None, _('overwrite any local changes')), |
16635
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
2819 ('', 'no-backup', None, _('do not save backup copies of files'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2820 _('hg qgoto [OPTION]... PATCH'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2821 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2822 def goto(ui, repo, patch, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2823 '''push or pop patches until named patch is at top of stack |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2824 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2825 Returns 0 on success.''' |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2826 opts = pycompat.byteskwargs(opts) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2827 opts = fixkeepchangesopts(ui, opts) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2828 q = repo.mq |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2829 patch = q.lookup(patch) |
16635
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
2830 nobackup = opts.get('no_backup') |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2831 keepchanges = opts.get('keep_changes') |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2832 if q.isapplied(patch): |
16655
6ca125af882f
mq: introduce qgoto --check
Patrick Mezard <patrick@mezard.eu>
parents:
16654
diff
changeset
|
2833 ret = q.pop(repo, patch, force=opts.get('force'), nobackup=nobackup, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2834 keepchanges=keepchanges) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2835 else: |
16655
6ca125af882f
mq: introduce qgoto --check
Patrick Mezard <patrick@mezard.eu>
parents:
16654
diff
changeset
|
2836 ret = q.push(repo, patch, force=opts.get('force'), nobackup=nobackup, |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2837 keepchanges=keepchanges) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2838 q.savedirty() |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2839 return ret |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2840 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2841 @command("qguard", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2842 [('l', 'list', None, _('list all patches and guards')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2843 ('n', 'none', None, _('drop all guards'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2844 _('hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2845 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2846 def guard(ui, repo, *args, **opts): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2847 '''set or print guards for a patch |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2848 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2849 Guards control whether a patch can be pushed. A patch with no |
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2850 guards is always pushed. A patch with a positive guard ("+foo") is |
11307
7f72031d4047
mq: use hg reST role some more
Martin Geisler <mg@aragost.com>
parents:
11303
diff
changeset
|
2851 pushed only if the :hg:`qselect` command has activated it. A patch with |
7f72031d4047
mq: use hg reST role some more
Martin Geisler <mg@aragost.com>
parents:
11303
diff
changeset
|
2852 a negative guard ("-foo") is never pushed if the :hg:`qselect` command |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2853 has activated it. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2854 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2855 With no arguments, print the currently active guards. |
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2856 With arguments, set guards for the named patch. |
12389 | 2857 |
2858 .. note:: | |
19997
de16c673455b
documentation: add an extra newline after note directive
Simon Heimberg <simohe@besonet.ch>
parents:
19951
diff
changeset
|
2859 |
12389 | 2860 Specifying negative guards now requires '--'. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2861 |
9824
87c92b260710
mq: fix literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9733
diff
changeset
|
2862 To set guards on another patch:: |
87c92b260710
mq: fix literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9733
diff
changeset
|
2863 |
10476
3113736dbac5
mq: more instructive use of "--" in qguard help (issue2040)
Martin Geisler <mg@lazybytes.net>
parents:
10413
diff
changeset
|
2864 hg qguard other.patch -- +2.6.17 -stable |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2865 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2866 Returns 0 on success. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2867 ''' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2868 def status(idx): |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
2869 guards = q.seriesguards[idx] or ['unguarded'] |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2870 if q.series[idx] in applied: |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2871 state = 'applied' |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2872 elif q.pushable(idx)[0]: |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2873 state = 'unapplied' |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2874 else: |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2875 state = 'guarded' |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2876 label = 'qguard.patch qguard.%s qseries.%s' % (state, state) |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2877 ui.write('%s: ' % ui.label(q.series[idx], label)) |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2878 |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2879 for i, guard in enumerate(guards): |
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2880 if guard.startswith('+'): |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2881 ui.write(guard, label='qguard.positive') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2882 elif guard.startswith('-'): |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2883 ui.write(guard, label='qguard.negative') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2884 else: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2885 ui.write(guard, label='qguard.unguarded') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2886 if i != len(guards) - 1: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2887 ui.write(' ') |
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2888 ui.write('\n') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2889 q = repo.mq |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2890 applied = set(p.name for p in q.applied) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2891 patch = None |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2892 args = list(args) |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2893 if opts.get(r'list'): |
38049
88c2d0e639b1
py3: fix kwargs handling in qgurad in hgext/mq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37603
diff
changeset
|
2894 if args or opts.get(r'none'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2895 raise error.Abort(_('cannot mix -l/--list with options or ' |
16683 | 2896 'arguments')) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
2897 for i in pycompat.xrange(len(q.series)): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2898 status(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2899 return |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2900 if not args or args[0][0:1] in '-+': |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2901 if not q.applied: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2902 raise error.Abort(_('no patches applied')) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2903 patch = q.applied[-1].name |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2904 if patch is None and args[0][0:1] not in '-+': |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2905 patch = args.pop(0) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2906 if patch is None: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2907 raise error.Abort(_('no patch to work with')) |
38049
88c2d0e639b1
py3: fix kwargs handling in qgurad in hgext/mq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37603
diff
changeset
|
2908 if args or opts.get(r'none'): |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
2909 idx = q.findseries(patch) |
4133
a9ee6c53af8d
mq: abort cleanly when invalid patch name is given to qguard
Christian Ebert <blacktrash@gmx.net>
parents:
4090
diff
changeset
|
2910 if idx is None: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
2911 raise error.Abort(_('no patch named %s') % patch) |
14577
76357276662e
mq: rename set_guards to setguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14576
diff
changeset
|
2912 q.setguards(idx, args) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2913 q.savedirty() |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2914 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2915 status(q.series.index(q.lookup(patch))) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2916 |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2917 @command("qheader", [], _('hg qheader [PATCH]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2918 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2919 def header(ui, repo, patch=None): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2920 """print the header of the topmost or specified patch |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2921 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2922 Returns 0 on success.""" |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2923 q = repo.mq |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2924 |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2925 if patch: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2926 patch = q.lookup(patch) |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2927 else: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2928 if not q.applied: |
10510
f77f3383c666
i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10498
diff
changeset
|
2929 ui.write(_('no patches applied\n')) |
3008
c203ccd7d838
qheader: exit withh meaningful error code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3006
diff
changeset
|
2930 return 1 |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2931 patch = q.lookup('qtip') |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
2932 ph = patchheader(q.join(patch), q.plainmode) |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2933 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
2934 ui.write('\n'.join(ph.message) + '\n') |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2935 |
1808 | 2936 def lastsavename(path): |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2937 (directory, base) = os.path.split(path) |
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2938 names = os.listdir(directory) |
1808 | 2939 namere = re.compile("%s.([0-9]+)" % base) |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2940 maxindex = None |
1808 | 2941 maxname = None |
2942 for f in names: | |
2943 m = namere.match(f) | |
2944 if m: | |
2945 index = int(m.group(1)) | |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
2946 if maxindex is None or index > maxindex: |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2947 maxindex = index |
1808 | 2948 maxname = f |
2949 if maxname: | |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2950 return (os.path.join(directory, maxname), maxindex) |
1808 | 2951 return (None, None) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2952 |
1808 | 2953 def savename(path): |
2954 (last, index) = lastsavename(path) | |
2955 if last is None: | |
2956 index = 0 | |
2957 newpath = path + ".%d" % (index + 1) | |
2958 return newpath | |
2959 | |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2960 @command("qpush", |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2961 [('', 'keep-changes', None, |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2962 _('tolerate non-conflicting local changes')), |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
2963 ('f', 'force', None, _('apply on top of local changes')), |
16683 | 2964 ('e', 'exact', None, |
2965 _('apply the target patch to its recorded parent')), | |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2966 ('l', 'list', None, _('list patch name in commit text')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2967 ('a', 'all', None, _('apply all patches')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2968 ('m', 'merge', None, _('merge from another queue (DEPRECATED)')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2969 ('n', 'name', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
2970 _('merge queue name (DEPRECATED)'), _('NAME')), |
16635
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
2971 ('', 'move', None, |
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
2972 _('reorder patch series and apply only the patch')), |
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
2973 ('', 'no-backup', None, _('do not save backup copies of files'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
2974 _('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]'), |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2975 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
2976 helpbasic=True) |
1808 | 2977 def push(ui, repo, patch=None, **opts): |
6552
315b36ce6251
mq: add a little documentation on qpush -f
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6382
diff
changeset
|
2978 """push the next patch onto the stack |
6553
0bb76d168437
remove trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6552
diff
changeset
|
2979 |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
2980 By default, abort if the working directory contains uncommitted |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2981 changes. With --keep-changes, abort only if the uncommitted files |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
2982 overlap with patched files. With -f/--force, backup and patch over |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
2983 uncommitted changes. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2984 |
13725
6783f47d90dd
mq: fix typo in docstring
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
13632
diff
changeset
|
2985 Return 0 on success. |
6552
315b36ce6251
mq: add a little documentation on qpush -f
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6382
diff
changeset
|
2986 """ |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2987 q = repo.mq |
1808 | 2988 mergeq = None |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2989 |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2990 opts = pycompat.byteskwargs(opts) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2991 opts = fixkeepchangesopts(ui, opts) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2992 if opts.get('merge'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2993 if opts.get('name'): |
31333
f897a088377c
mq: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31312
diff
changeset
|
2994 newpath = repo.vfs.join(opts.get('name')) |
1808 | 2995 else: |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2996 newpath, i = lastsavename(q.path) |
1808 | 2997 if not newpath: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2998 ui.warn(_("no saved queues found, please use -n\n")) |
1808 | 2999 return 1 |
19064
743daa601445
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)
Simon Heimberg <simohe@besonet.ch>
parents:
18958
diff
changeset
|
3000 mergeq = queue(ui, repo.baseui, repo.path, newpath) |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
3001 ui.warn(_("merging with queue at: %s\n") % mergeq.path) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3002 ret = q.push(repo, patch, force=opts.get('force'), list=opts.get('list'), |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
3003 mergeq=mergeq, all=opts.get('all'), move=opts.get('move'), |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
3004 exact=opts.get('exact'), nobackup=opts.get('no_backup'), |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3005 keepchanges=opts.get('keep_changes')) |
1808 | 3006 return ret |
3007 | |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
3008 @command("qpop", |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3009 [('a', 'all', None, _('pop all patches')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3010 ('n', 'name', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3011 _('queue name to pop (DEPRECATED)'), _('NAME')), |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3012 ('', 'keep-changes', None, |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3013 _('tolerate non-conflicting local changes')), |
16635
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
3014 ('f', 'force', None, _('forget any local changes to patched files')), |
9d76320d8b99
mq: add --no-backup for qpush/qpop/qgoto
Patrick Mezard <patrick@mezard.eu>
parents:
16634
diff
changeset
|
3015 ('', 'no-backup', None, _('do not save backup copies of files'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3016 _('hg qpop [-a] [-f] [PATCH | INDEX]'), |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
3017 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
3018 helpbasic=True) |
1808 | 3019 def pop(ui, repo, patch=None, **opts): |
6611
f4c612da788d
mq: add correct documentation for qpop
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6610
diff
changeset
|
3020 """pop the current patch off the stack |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
3021 |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3022 Without argument, pops off the top of the patch stack. If given a |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3023 patch name, keeps popping off patches until the named patch is at |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3024 the top of the stack. |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3025 |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3026 By default, abort if the working directory contains uncommitted |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3027 changes. With --keep-changes, abort only if the uncommitted files |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3028 overlap with patched files. With -f/--force, backup and discard |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3029 changes made to such files. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3030 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3031 Return 0 on success. |
6611
f4c612da788d
mq: add correct documentation for qpop
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6610
diff
changeset
|
3032 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3033 opts = pycompat.byteskwargs(opts) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3034 opts = fixkeepchangesopts(ui, opts) |
1808 | 3035 localupdate = True |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3036 if opts.get('name'): |
31333
f897a088377c
mq: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31312
diff
changeset
|
3037 q = queue(ui, repo.baseui, repo.path, repo.vfs.join(opts.get('name'))) |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
3038 ui.warn(_('using patch queue: %s\n') % q.path) |
1808 | 3039 localupdate = False |
3040 else: | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
3041 q = repo.mq |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3042 ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate, |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3043 all=opts.get('all'), nobackup=opts.get('no_backup'), |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3044 keepchanges=opts.get('keep_changes')) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3045 q.savedirty() |
4099
cf5580c16b13
mq: propagate the return error of pop
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4096
diff
changeset
|
3046 return ret |
1808 | 3047 |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3048 @command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3049 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3050 def rename(ui, repo, patch, name=None, **opts): |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3051 """rename a patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3052 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3053 With one argument, renames the current patch to PATCH1. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3054 With two arguments, renames PATCH1 to PATCH2. |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3055 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3056 Returns 0 on success.""" |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3057 q = repo.mq |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3058 if not name: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3059 name = patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3060 patch = None |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3061 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3062 if patch: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3063 patch = q.lookup(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3064 else: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3065 if not q.applied: |
7627 | 3066 ui.write(_('no patches applied\n')) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3067 return |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3068 patch = q.lookup('qtip') |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
3069 absdest = q.join(name) |
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
3070 if os.path.isdir(absdest): |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
3071 name = normname(os.path.join(name, os.path.basename(patch))) |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
3072 absdest = q.join(name) |
14423 | 3073 q.checkpatchname(name) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3074 |
10510
f77f3383c666
i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10498
diff
changeset
|
3075 ui.note(_('renaming %s to %s\n') % (patch, name)) |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
3076 i = q.findseries(patch) |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
3077 guards = q.guard_re.findall(q.fullseries[i]) |
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
3078 q.fullseries[i] = name + ''.join([' #' + g for g in guards]) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
3079 q.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
3080 q.seriesdirty = True |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3081 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3082 info = q.isapplied(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3083 if info: |
2818
bdc067ff6cf5
Make mq camelcase consistent with the rest of hg.
Brendan Cully <brendan@kublai.com>
parents:
2816
diff
changeset
|
3084 q.applied[info[0]] = statusentry(info[1], name) |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
3085 q.applieddirty = True |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3086 |
11513
0c944b7af564
mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara <yuya@tcha.org>
parents:
11462
diff
changeset
|
3087 destdir = os.path.dirname(absdest) |
0c944b7af564
mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara <yuya@tcha.org>
parents:
11462
diff
changeset
|
3088 if not os.path.isdir(destdir): |
0c944b7af564
mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara <yuya@tcha.org>
parents:
11462
diff
changeset
|
3089 os.makedirs(destdir) |
2819 | 3090 util.rename(q.join(patch), absdest) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3091 r = q.qrepo() |
12875
b59b5193d4d0
mq: qrename should not touch the dirstate if src is untracked (issue2460)
Patrick Mezard <pmezard@gmail.com>
parents:
12850
diff
changeset
|
3092 if r and patch in r.dirstate: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
3093 wctx = r[None] |
27848
9bda75a0c783
with: use context manager in qrename
Bryan O'Sullivan <bryano@fb.com>
parents:
27847
diff
changeset
|
3094 with r.wlock(): |
6648
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
3095 if r.dirstate[patch] == 'a': |
14434
cc8c09855d19
dirstate: rename forget to drop
Matt Mackall <mpm@selenic.com>
parents:
14424
diff
changeset
|
3096 r.dirstate.drop(patch) |
6648
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
3097 r.dirstate.add(name) |
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
3098 else: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
3099 wctx.copy(patch, name) |
14435
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
3100 wctx.forget([patch]) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3101 |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3102 q.savedirty() |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3103 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3104 @command("qrestore", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3105 [('d', 'delete', None, _('delete save entry')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3106 ('u', 'update', None, _('update queue working directory'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3107 _('hg qrestore [-d] [-u] REV'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3108 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 3109 def restore(ui, repo, rev, **opts): |
10360
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
3110 """restore the queue state saved by a revision (DEPRECATED) |
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
3111 |
12352
5be733b20bd1
mq: fix the deprecation comment for qsave & qrestore.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12344
diff
changeset
|
3112 This command is deprecated, use :hg:`rebase` instead.""" |
1808 | 3113 rev = repo.lookup(rev) |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
3114 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3115 q.restore(repo, rev, delete=opts.get(r'delete'), |
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3116 qupdate=opts.get(r'update')) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3117 q.savedirty() |
1808 | 3118 return 0 |
3119 | |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3120 @command("qsave", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3121 [('c', 'copy', None, _('copy patch directory')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3122 ('n', 'name', '', |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3123 _('copy directory name'), _('NAME')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3124 ('e', 'empty', None, _('clear queue status file')), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32347
diff
changeset
|
3125 ('f', 'force', None, _('force copy'))] + cmdutil.commitopts, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3126 _('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3127 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
1808 | 3128 def save(ui, repo, **opts): |
10360
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
3129 """save current queue state (DEPRECATED) |
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
3130 |
12352
5be733b20bd1
mq: fix the deprecation comment for qsave & qrestore.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12344
diff
changeset
|
3131 This command is deprecated, use :hg:`rebase` instead.""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
3132 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3133 opts = pycompat.byteskwargs(opts) |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
3134 message = cmdutil.logmessage(ui, opts) |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
3135 ret = q.save(repo, msg=message) |
1808 | 3136 if ret: |
3137 return ret | |
15880
02b135558756
mq: make qsave implementation more explicit
Mads Kiilerich <mads@kiilerich.com>
parents:
15879
diff
changeset
|
3138 q.savedirty() # save to .hg/patches before copying |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3139 if opts.get('copy'): |
1808 | 3140 path = q.path |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3141 if opts.get('name'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3142 newpath = os.path.join(q.basepath, opts.get('name')) |
1808 | 3143 if os.path.exists(newpath): |
3144 if not os.path.isdir(newpath): | |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3145 raise error.Abort(_('destination %s exists and is not ' |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
3146 'a directory') % newpath) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3147 if not opts.get('force'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3148 raise error.Abort(_('destination %s exists, ' |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
3149 'use -f to force') % newpath) |
1808 | 3150 else: |
3151 newpath = savename(path) | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
3152 ui.warn(_("copy %s to %s\n") % (path, newpath)) |
1808 | 3153 util.copyfiles(path, newpath) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3154 if opts.get('empty'): |
15880
02b135558756
mq: make qsave implementation more explicit
Mads Kiilerich <mads@kiilerich.com>
parents:
15879
diff
changeset
|
3155 del q.applied[:] |
02b135558756
mq: make qsave implementation more explicit
Mads Kiilerich <mads@kiilerich.com>
parents:
15879
diff
changeset
|
3156 q.applieddirty = True |
02b135558756
mq: make qsave implementation more explicit
Mads Kiilerich <mads@kiilerich.com>
parents:
15879
diff
changeset
|
3157 q.savedirty() |
1808 | 3158 return 0 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3159 |
1808 | 3160 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3161 @command("qselect", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3162 [('n', 'none', None, _('disable all guards')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3163 ('s', 'series', None, _('list all guards in series file')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3164 ('', 'pop', None, _('pop to before first guarded applied patch')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3165 ('', 'reapply', None, _('pop, then reapply patches'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3166 _('hg qselect [OPTION]... [GUARD]...'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3167 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3168 def select(ui, repo, *args, **opts): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3169 '''set or print guarded patches to push |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3170 |
11307
7f72031d4047
mq: use hg reST role some more
Martin Geisler <mg@aragost.com>
parents:
11303
diff
changeset
|
3171 Use the :hg:`qguard` command to set or print guards on patch, then use |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3172 qselect to tell mq which guards to use. A patch will be pushed if |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3173 it has no guards or any positive guards match the currently |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3174 selected guard, but will not be pushed if any negative guards |
9824
87c92b260710
mq: fix literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9733
diff
changeset
|
3175 match the current guard. For example:: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3176 |
13791 | 3177 qguard foo.patch -- -stable (negative guard) |
3178 qguard bar.patch +stable (positive guard) | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3179 qselect stable |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3180 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3181 This activates the "stable" guard. mq will skip foo.patch (because |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3182 it has a negative match) but push bar.patch (because it has a |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3183 positive match). |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3184 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3185 With no arguments, prints the currently active guards. |
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3186 With one argument, sets the active guard. |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
3187 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3188 Use -n/--none to deactivate guards (no other arguments needed). |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3189 When no guards are active, patches with positive guards are |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3190 skipped and patches with negative guards are pushed. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3191 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3192 qselect can change the guards on applied patches. It does not pop |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3193 guarded patches by default. Use --pop to pop back to the last |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3194 applied patch that is not guarded. Use --reapply (which implies |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3195 --pop) to push back to the current patch afterwards, but skip |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3196 guarded patches. |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3197 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3198 Use -s/--series to print a list of all guards in the series file |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3199 (no other arguments needed). Use -v for more information. |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3200 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3201 Returns 0 on success.''' |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3202 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3203 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3204 opts = pycompat.byteskwargs(opts) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3205 guards = q.active() |
22453
fd0f0b0d316d
mq: report correct numbers for changing "number of guarded, applied patches"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
3206 pushable = lambda i: q.pushable(q.applied[i].name)[0] |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3207 if args or opts.get('none'): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3208 old_unapplied = q.unapplied(repo) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
3209 old_guarded = [i for i in pycompat.xrange(len(q.applied)) |
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
3210 if not pushable(i)] |
14578
28a2646f3b81
mq: rename set_active to setactive
Adrian Buehlmann <adrian@cadifra.com>
parents:
14577
diff
changeset
|
3211 q.setactive(args) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3212 q.savedirty() |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3213 if not args: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3214 ui.status(_('guards deactivated\n')) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3215 if not opts.get('pop') and not opts.get('reapply'): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3216 unapplied = q.unapplied(repo) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
3217 guarded = [i for i in pycompat.xrange(len(q.applied)) |
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
3218 if not pushable(i)] |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3219 if len(unapplied) != len(old_unapplied): |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3220 ui.status(_('number of unguarded, unapplied patches has ' |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3221 'changed from %d to %d\n') % |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3222 (len(old_unapplied), len(unapplied))) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3223 if len(guarded) != len(old_guarded): |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3224 ui.status(_('number of guarded, applied patches has changed ' |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3225 'from %d to %d\n') % |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3226 (len(old_guarded), len(guarded))) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3227 elif opts.get('series'): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3228 guards = {} |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3229 noguards = 0 |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
3230 for gs in q.seriesguards: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3231 if not gs: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3232 noguards += 1 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3233 for g in gs: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3234 guards.setdefault(g, 0) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3235 guards[g] += 1 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3236 if ui.verbose: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3237 guards['NONE'] = noguards |
36282
3e1139b7d617
py3: explicitly convert result of dict.items() into list
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36281
diff
changeset
|
3238 guards = list(guards.items()) |
9032
1fa80c5428b8
compat: use 'key' argument instead of 'cmp' when sorting a list
Alejandro Santos <alejolp@alejolp.com>
parents:
9016
diff
changeset
|
3239 guards.sort(key=lambda x: x[0][1:]) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3240 if guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3241 ui.note(_('guards in series file:\n')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3242 for guard, count in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3243 ui.note('%2d ' % count) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3244 ui.write(guard, '\n') |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3245 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3246 ui.note(_('no guards in series file\n')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3247 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3248 if guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3249 ui.note(_('active guards:\n')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3250 for g in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3251 ui.write(g, '\n') |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3252 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3253 ui.write(_('no active guards\n')) |
22454
ac31d87608d6
mq: use "mq.applied[i].name" instead of "mq.appliedname(i)" for safety
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22453
diff
changeset
|
3254 reapply = opts.get('reapply') and q.applied and q.applied[-1].name |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3255 popped = False |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
3256 if opts.get('pop') or opts.get('reapply'): |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
3257 for i in pycompat.xrange(len(q.applied)): |
22456
4bbcee186fc6
mq: examine "pushable" of already applied patch correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22455
diff
changeset
|
3258 if not pushable(i): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3259 ui.status(_('popping guarded patches\n')) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3260 popped = True |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3261 if i == 0: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3262 q.pop(repo, all=True) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3263 else: |
22455
c89379d47e95
mq: pop correct patches when changing pushable-ness of already applied ones
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22454
diff
changeset
|
3264 q.pop(repo, q.applied[i - 1].name) |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3265 break |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3266 if popped: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3267 try: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3268 if reapply: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3269 ui.status(_('reapplying unguarded patches\n')) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3270 q.push(repo, reapply) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3271 finally: |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3272 q.savedirty() |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3273 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3274 @command("qfinish", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3275 [('a', 'applied', None, _('finish all applied changesets'))], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3276 _('hg qfinish [-a] [REV]...'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3277 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3278 def finish(ui, repo, *revrange, **opts): |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3279 """move applied patches into repository history |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3280 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3281 Finishes the specified revisions (corresponding to applied |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3282 patches) by moving them out of mq control into regular repository |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3283 history. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3284 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3285 Accepts a revision range or the -a/--applied option. If --applied |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3286 is specified, all applied mq revisions are removed from mq |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3287 control. Otherwise, the given revisions must be at the base of the |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3288 stack of applied patches. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3289 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3290 This can be especially useful if your changes have been applied to |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3291 an upstream repository, or if you are about to push your changes |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3292 to upstream. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3293 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3294 Returns 0 on success. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3295 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3296 if not opts.get(r'applied') and not revrange: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3297 raise error.Abort(_('no revisions specified')) |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3298 elif opts.get(r'applied'): |
11730
7469ff872122
qfinish: fix range logic for --applied
Matt Mackall <mpm@selenic.com>
parents:
11717
diff
changeset
|
3299 revrange = ('qbase::qtip',) + revrange |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3300 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3301 q = repo.mq |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3302 if not q.applied: |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3303 ui.status(_('no patches applied\n')) |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3304 return 0 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3305 |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14298
diff
changeset
|
3306 revs = scmutil.revrange(repo, revrange) |
15476
7c06e9c35f2f
mq: add a warning about uncommitted changes for qfinish
Matt Mackall <mpm@selenic.com>
parents:
15322
diff
changeset
|
3307 if repo['.'].rev() in revs and repo[None].files(): |
7c06e9c35f2f
mq: add a warning about uncommitted changes for qfinish
Matt Mackall <mpm@selenic.com>
parents:
15322
diff
changeset
|
3308 ui.warn(_('warning: uncommitted changes in the working directory\n')) |
17512 | 3309 # queue.finish may changes phases but leave the responsibility to lock the |
15920
885e0c71db9b
mq: turn changeset draft on qfinish (except if qparent is secret)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15883
diff
changeset
|
3310 # repo to the caller to avoid deadlock with wlock. This command code is |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17191
diff
changeset
|
3311 # responsibility for this locking. |
27847
71853c0ba592
with: use context manager in qfinish
Bryan O'Sullivan <bryano@fb.com>
parents:
27832
diff
changeset
|
3312 with repo.lock(): |
15920
885e0c71db9b
mq: turn changeset draft on qfinish (except if qparent is secret)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15883
diff
changeset
|
3313 q.finish(repo, revs) |
885e0c71db9b
mq: turn changeset draft on qfinish (except if qparent is secret)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15883
diff
changeset
|
3314 q.savedirty() |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3315 return 0 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3316 |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3317 @command("qqueue", |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3318 [('l', 'list', False, _('list all available queues')), |
14987
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
3319 ('', 'active', False, _('print name of active queue')), |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3320 ('c', 'create', False, _('create new queue')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3321 ('', 'rename', False, _('rename active queue')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3322 ('', 'delete', False, _('delete reference to queue')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3323 ('', 'purge', False, _('delete queue, and remove patch dir')), |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
3324 ], |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3325 _('[OPTION] [QUEUE]'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
39895
diff
changeset
|
3326 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3327 def qqueue(ui, repo, name=None, **opts): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3328 '''manage multiple patch queues |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3329 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3330 Supports switching between different patch queues, as well as creating |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3331 new patch queues and deleting existing ones. |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3332 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3333 Omitting a queue name or specifying -l/--list will show you the registered |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3334 queues - by default the "normal" patches queue is registered. The currently |
14987
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
3335 active queue will be marked with "(active)". Specifying --active will print |
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
3336 only the name of the active queue. |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3337 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3338 To create a new queue, use -c/--create. The queue is automatically made |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3339 active, except in the case where there are applied patches from the |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3340 currently active queue in the repository. Then the queue will only be |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3341 created and switching will fail. |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3342 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3343 To delete an existing queue, use --delete. You cannot delete the currently |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3344 active queue. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3345 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3346 Returns 0 on success. |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3347 ''' |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3348 q = repo.mq |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3349 _defaultqueue = 'patches' |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3350 _allqueues = 'patches.queues' |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3351 _activequeue = 'patches.queue' |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3352 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3353 def _getcurrent(): |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3354 cur = os.path.basename(q.path) |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3355 if cur.startswith('patches-'): |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3356 cur = cur[8:] |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3357 return cur |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3358 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3359 def _noqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3360 try: |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23443
diff
changeset
|
3361 fh = repo.vfs(_allqueues, 'r') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3362 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3363 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3364 return True |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3365 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3366 return False |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3367 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3368 def _getqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3369 current = _getcurrent() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3370 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3371 try: |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23443
diff
changeset
|
3372 fh = repo.vfs(_allqueues, 'r') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3373 queues = [queue.strip() for queue in fh if queue.strip()] |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
3374 fh.close() |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3375 if current not in queues: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3376 queues.append(current) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3377 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3378 queues = [_defaultqueue] |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3379 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3380 return sorted(queues) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3381 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3382 def _setactive(name): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3383 if q.applied: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3384 raise error.Abort(_('new queue created, but cannot make active ' |
17708
4f2f0f367ef6
mq: improve qqueue message with patches applied (issue3036)
Bryan O'Sullivan <bryano@fb.com>
parents:
17537
diff
changeset
|
3385 'as patches are applied')) |
11938
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
3386 _setactivenocheck(name) |
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
3387 |
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
3388 def _setactivenocheck(name): |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23443
diff
changeset
|
3389 fh = repo.vfs(_activequeue, 'w') |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3390 if name != 'patches': |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3391 fh.write(name) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3392 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3393 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3394 def _addqueue(name): |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23443
diff
changeset
|
3395 fh = repo.vfs(_allqueues, 'a') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3396 fh.write('%s\n' % (name,)) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3397 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3398 |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3399 def _queuedir(name): |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3400 if name == 'patches': |
31333
f897a088377c
mq: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31312
diff
changeset
|
3401 return repo.vfs.join('patches') |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3402 else: |
31333
f897a088377c
mq: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31312
diff
changeset
|
3403 return repo.vfs.join('patches-' + name) |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3404 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3405 def _validname(name): |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3406 for n in name: |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3407 if n in ':\\/.': |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3408 return False |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3409 return True |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3410 |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3411 def _delete(name): |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3412 if name not in existing: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3413 raise error.Abort(_('cannot delete queue that does not exist')) |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3414 |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3415 current = _getcurrent() |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3416 |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3417 if name == current: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3418 raise error.Abort(_('cannot delete currently active queue')) |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3419 |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23443
diff
changeset
|
3420 fh = repo.vfs('patches.queues.new', 'w') |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3421 for queue in existing: |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3422 if queue == name: |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3423 continue |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3424 fh.write('%s\n' % (queue,)) |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3425 fh.close() |
31312
7eb53603744b
vfs: use repo.vfs.rename
Mads Kiilerich <mads@kiilerich.com>
parents:
31309
diff
changeset
|
3426 repo.vfs.rename('patches.queues.new', _allqueues) |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3427 |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3428 opts = pycompat.byteskwargs(opts) |
14987
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
3429 if not name or opts.get('list') or opts.get('active'): |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3430 current = _getcurrent() |
14987
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
3431 if opts.get('active'): |
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
3432 ui.write('%s\n' % (current,)) |
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
3433 return |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3434 for queue in _getqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3435 ui.write('%s' % (queue,)) |
11767
9b771b4ce2f3
mq/qqueue: --list does not print (active) with --quiet
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11730
diff
changeset
|
3436 if queue == current and not ui.quiet: |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3437 ui.write(_(' (active)\n')) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3438 else: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3439 ui.write('\n') |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3440 return |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3441 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3442 if not _validname(name): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3443 raise error.Abort( |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3444 _('invalid queue name, may not contain the characters ":\\/."')) |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3445 |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3446 with repo.wlock(): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3447 existing = _getqueues() |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3448 |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3449 if opts.get('create'): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3450 if name in existing: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3451 raise error.Abort(_('queue "%s" already exists') % name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3452 if _noqueues(): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3453 _addqueue(_defaultqueue) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3454 _addqueue(name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3455 _setactive(name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3456 elif opts.get('rename'): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3457 current = _getcurrent() |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3458 if name == current: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3459 raise error.Abort(_('can\'t rename "%s" to its current name') |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3460 % name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3461 if name in existing: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3462 raise error.Abort(_('queue "%s" already exists') % name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3463 |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3464 olddir = _queuedir(current) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3465 newdir = _queuedir(name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3466 |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3467 if os.path.exists(newdir): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3468 raise error.Abort(_('non-queue directory "%s" already exists') % |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3469 newdir) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3470 |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3471 fh = repo.vfs('patches.queues.new', 'w') |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3472 for queue in existing: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3473 if queue == current: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3474 fh.write('%s\n' % (name,)) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3475 if os.path.exists(olddir): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3476 util.rename(olddir, newdir) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3477 else: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3478 fh.write('%s\n' % (queue,)) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3479 fh.close() |
31312
7eb53603744b
vfs: use repo.vfs.rename
Mads Kiilerich <mads@kiilerich.com>
parents:
31309
diff
changeset
|
3480 repo.vfs.rename('patches.queues.new', _allqueues) |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3481 _setactivenocheck(name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3482 elif opts.get('delete'): |
11967
6e3875a80533
mq/qqueue: add --purge option to delete a queue and its patch dir
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11966
diff
changeset
|
3483 _delete(name) |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3484 elif opts.get('purge'): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3485 if name in existing: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3486 _delete(name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3487 qdir = _queuedir(name) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3488 if os.path.exists(qdir): |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3489 shutil.rmtree(qdir) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3490 else: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3491 if name not in existing: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3492 raise error.Abort(_('use --create to create a new queue')) |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
3493 _setactive(name) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3494 |
15928
3a51eb88046a
mq: ensure mq changesets are set to secret when no phase data are found
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15927
diff
changeset
|
3495 def mqphasedefaults(repo, roots): |
3a51eb88046a
mq: ensure mq changesets are set to secret when no phase data are found
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15927
diff
changeset
|
3496 """callback used to set mq changeset as secret when no phase data exists""" |
3a51eb88046a
mq: ensure mq changesets are set to secret when no phase data are found
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15927
diff
changeset
|
3497 if repo.mq.applied: |
34184
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
3498 if repo.ui.configbool('mq', 'secret'): |
16028
922c0e9b40be
mq: take mq.secret configuration into account when picking the default phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16027
diff
changeset
|
3499 mqphase = phases.secret |
922c0e9b40be
mq: take mq.secret configuration into account when picking the default phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16027
diff
changeset
|
3500 else: |
922c0e9b40be
mq: take mq.secret configuration into account when picking the default phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16027
diff
changeset
|
3501 mqphase = phases.draft |
15972
341c58282b25
mq: pass qbase node instead of mq statusentry in phasedefaults
Augie Fackler <durin42@gmail.com>
parents:
15952
diff
changeset
|
3502 qbase = repo[repo.mq.applied[0].node] |
16028
922c0e9b40be
mq: take mq.secret configuration into account when picking the default phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16027
diff
changeset
|
3503 roots[mqphase].add(qbase.node()) |
15928
3a51eb88046a
mq: ensure mq changesets are set to secret when no phase data are found
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15927
diff
changeset
|
3504 return roots |
3a51eb88046a
mq: ensure mq changesets are set to secret when no phase data are found
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15927
diff
changeset
|
3505 |
1808 | 3506 def reposetup(ui, repo): |
2818
bdc067ff6cf5
Make mq camelcase consistent with the rest of hg.
Brendan Cully <brendan@kublai.com>
parents:
2816
diff
changeset
|
3507 class mqrepo(repo.__class__): |
19395
19622224559b
mq: use an unfiltered property cache for the queue object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19212
diff
changeset
|
3508 @localrepo.unfilteredpropertycache |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
3509 def mq(self): |
19064
743daa601445
mq: do not inherit settings form base repo in mqrepo (Fixes issue2358)
Simon Heimberg <simohe@besonet.ch>
parents:
18958
diff
changeset
|
3510 return queue(self.ui, self.baseui, self.path) |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
3511 |
20628
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20442
diff
changeset
|
3512 def invalidateall(self): |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20442
diff
changeset
|
3513 super(mqrepo, self).invalidateall() |
40360
dee73a97e132
py3: invalidate repository cache with system-string keys
Yuya Nishihara <yuya@tcha.org>
parents:
40295
diff
changeset
|
3514 if localrepo.hasunfilteredcache(self, r'mq'): |
20629
277dc5f27310
cmdserver: recreate mq object on runcommand in case queue path was changed
Yuya Nishihara <yuya@tcha.org>
parents:
20628
diff
changeset
|
3515 # recreate mq in case queue path was changed |
40360
dee73a97e132
py3: invalidate repository cache with system-string keys
Yuya Nishihara <yuya@tcha.org>
parents:
40295
diff
changeset
|
3516 delattr(self.unfiltered(), r'mq') |
20628
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20442
diff
changeset
|
3517 |
14596
6a0070d00bc8
mq: rename abort_if_wdir_patched to abortifwdirpatched
Adrian Buehlmann <adrian@cadifra.com>
parents:
14595
diff
changeset
|
3518 def abortifwdirpatched(self, errmsg, force=False): |
19856
28b1b7b9b4a9
shelve: allow shelving of a change with an mq patch applied
David Soria Parra <dsp@experimentalworks.net>
parents:
19826
diff
changeset
|
3519 if self.mq.applied and self.mq.checkapplied and not force: |
13520
9510ddf87c43
mq: forbid commit of merge involving mq patches
Martin Geisler <mg@aragost.com>
parents:
13508
diff
changeset
|
3520 parents = self.dirstate.parents() |
9510ddf87c43
mq: forbid commit of merge involving mq patches
Martin Geisler <mg@aragost.com>
parents:
13508
diff
changeset
|
3521 patches = [s.node for s in self.mq.applied] |
9510ddf87c43
mq: forbid commit of merge involving mq patches
Martin Geisler <mg@aragost.com>
parents:
13508
diff
changeset
|
3522 if parents[0] in patches or parents[1] in patches: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3523 raise error.Abort(errmsg) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
3524 |
8711 | 3525 def commit(self, text="", user=None, date=None, match=None, |
31407
b8848750a3c1
mq: don't use mutable default argument value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31394
diff
changeset
|
3526 force=False, editor=False, extra=None): |
b8848750a3c1
mq: don't use mutable default argument value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31394
diff
changeset
|
3527 if extra is None: |
b8848750a3c1
mq: don't use mutable default argument value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31394
diff
changeset
|
3528 extra = {} |
14596
6a0070d00bc8
mq: rename abort_if_wdir_patched to abortifwdirpatched
Adrian Buehlmann <adrian@cadifra.com>
parents:
14595
diff
changeset
|
3529 self.abortifwdirpatched( |
2848
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
3530 _('cannot commit over an applied mq patch'), |
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
3531 force) |
2845
addd03c7fbfa
Disallow commit over an applied mq patch.
Brendan Cully <brendan@kublai.com>
parents:
2844
diff
changeset
|
3532 |
8711 | 3533 return super(mqrepo, self).commit(text, user, date, match, force, |
3534 editor, extra) | |
2845
addd03c7fbfa
Disallow commit over an applied mq patch.
Brendan Cully <brendan@kublai.com>
parents:
2844
diff
changeset
|
3535 |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20827
diff
changeset
|
3536 def checkpush(self, pushop): |
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20827
diff
changeset
|
3537 if self.mq.applied and self.mq.checkapplied and not pushop.force: |
15952
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3538 outapplied = [e.node for e in self.mq.applied] |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20827
diff
changeset
|
3539 if pushop.revs: |
15952
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3540 # Assume applied patches have no non-patch descendants and |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3541 # are not on remote already. Filtering any changeset not |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3542 # pushed. |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20827
diff
changeset
|
3543 heads = set(pushop.revs) |
15952
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3544 for node in reversed(outapplied): |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3545 if node in heads: |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3546 break |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3547 else: |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3548 outapplied.pop() |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3549 # looking for pushed and shared changeset |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3550 for node in outapplied: |
17954
4dc438ddd246
mq: don't refer to a random name-captured repo object
Bryan O'Sullivan <bryano@fb.com>
parents:
17922
diff
changeset
|
3551 if self[node].phase() < phases.secret: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3552 raise error.Abort(_('source has mq patches applied')) |
15952
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
3553 # no non-secret patches pushed |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20827
diff
changeset
|
3554 super(mqrepo, self).checkpush(pushop) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
3555 |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3556 def _findtags(self): |
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3557 '''augment tags from base class with patch tags''' |
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3558 result = super(mqrepo, self)._findtags() |
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
3559 |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
3560 q = self.mq |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
3561 if not q.applied: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3562 return result |
2663
96950d39171d
Mq: modify repo.lookup to resolve applied patches too.
Brendan Cully <brendan@kublai.com>
parents:
2554
diff
changeset
|
3563 |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
3564 mqtags = [(patch.node, patch.name) for patch in q.applied] |
5979
b4858eb4b58f
mqrepo: don't abort if the status file has an unknown node
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5534
diff
changeset
|
3565 |
13508
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
3566 try: |
18011
4908197d7422
clfilter: mq should not warn about filtered mq patches
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18010
diff
changeset
|
3567 # for now ignore filtering business |
4908197d7422
clfilter: mq should not warn about filtered mq patches
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18010
diff
changeset
|
3568 self.unfiltered().changelog.rev(mqtags[-1][0]) |
14600
17c16bcf6926
mq: catch correct exception when calling changelog.rev()
Idan Kamara <idankk86@gmail.com>
parents:
14596
diff
changeset
|
3569 except error.LookupError: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
3570 self.ui.warn(_('mq status file refers to unknown node %s\n') |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
3571 % short(mqtags[-1][0])) |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3572 return result |
5979
b4858eb4b58f
mqrepo: don't abort if the status file has an unknown node
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5534
diff
changeset
|
3573 |
18662
c5f7e83d47cd
mq: comply with filtering when injecting fake tags (issue3812)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18644
diff
changeset
|
3574 # do not add fake tags for filtered revisions |
c5f7e83d47cd
mq: comply with filtering when injecting fake tags (issue3812)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18644
diff
changeset
|
3575 included = self.changelog.hasnode |
c5f7e83d47cd
mq: comply with filtering when injecting fake tags (issue3812)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18644
diff
changeset
|
3576 mqtags = [mqt for mqt in mqtags if included(mqt[0])] |
c5f7e83d47cd
mq: comply with filtering when injecting fake tags (issue3812)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18644
diff
changeset
|
3577 if not mqtags: |
c5f7e83d47cd
mq: comply with filtering when injecting fake tags (issue3812)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18644
diff
changeset
|
3578 return result |
c5f7e83d47cd
mq: comply with filtering when injecting fake tags (issue3812)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18644
diff
changeset
|
3579 |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
3580 mqtags.append((mqtags[-1][0], 'qtip')) |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
3581 mqtags.append((mqtags[0][0], 'qbase')) |
4219
6cb5be6bd70f
mq: add qparent tag (first parent of qbase)
Brendan Cully <brendan@kublai.com>
parents:
4209
diff
changeset
|
3582 mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent')) |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3583 tags = result[0] |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
3584 for patch in mqtags: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3585 if patch[1] in tags: |
16929
4b02d7006169
mq: lowercase warning messages
Martin Geisler <mg@aragost.com>
parents:
16867
diff
changeset
|
3586 self.ui.warn(_('tag %s overrides mq patch of the same ' |
16683 | 3587 'name\n') % patch[1]) |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
3588 else: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3589 tags[patch[1]] = patch[0] |
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
3590 |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
3591 return result |
2664
9b8df8dceeed
Add qtip and qbase to mq qlookup.
Brendan Cully <brendan@kublai.com>
parents:
2663
diff
changeset
|
3592 |
2851
82f50658c72b
mq: only add mq attribute to local repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
3593 if repo.local(): |
82f50658c72b
mq: only add mq attribute to local repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
3594 repo.__class__ = mqrepo |
1808 | 3595 |
15928
3a51eb88046a
mq: ensure mq changesets are set to secret when no phase data are found
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15927
diff
changeset
|
3596 repo._phasedefaults.append(mqphasedefaults) |
3a51eb88046a
mq: ensure mq changesets are set to secret when no phase data are found
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15927
diff
changeset
|
3597 |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3598 def mqimport(orig, ui, repo, *args, **kwargs): |
16416
c3aedd526d53
mq: replace hasattr() with util.safehasattr(), update check-code.py
Patrick Mezard <patrick@mezard.eu>
parents:
16303
diff
changeset
|
3599 if (util.safehasattr(repo, 'abortifwdirpatched') |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3600 and not kwargs.get(r'no_commit', False)): |
14596
6a0070d00bc8
mq: rename abort_if_wdir_patched to abortifwdirpatched
Adrian Buehlmann <adrian@cadifra.com>
parents:
14595
diff
changeset
|
3601 repo.abortifwdirpatched(_('cannot import over an applied patch'), |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3602 kwargs.get(r'force')) |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3603 return orig(ui, repo, *args, **kwargs) |
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3604 |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3605 def mqinit(orig, ui, *args, **kwargs): |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3606 mq = kwargs.pop(r'mq', None) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3607 |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3608 if not mq: |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3609 return orig(ui, *args, **kwargs) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3610 |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3611 if args: |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3612 repopath = args[0] |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3613 if not hg.islocal(repopath): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3614 raise error.Abort(_('only a local queue repository ' |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3615 'may be initialized')) |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3616 else: |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39049
diff
changeset
|
3617 repopath = cmdutil.findrepo(encoding.getcwd()) |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3618 if not repopath: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3619 raise error.Abort(_('there is no Mercurial repository here ' |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3620 '(.hg not found)')) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3621 repo = hg.repository(ui, repopath) |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
3622 return qinit(ui, repo, True) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3623 |
10359
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3624 def mqcommand(orig, ui, repo, *args, **kwargs): |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3625 """Add --mq option to operate on patch repository instead of main""" |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3626 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3627 # some commands do not like getting unknown options |
32193
c6cbd0b66465
py3: convert key to str to make kwargs.pop work in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31556
diff
changeset
|
3628 mq = kwargs.pop(r'mq', None) |
10359
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3629 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3630 if not mq: |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3631 return orig(ui, repo, *args, **kwargs) |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3632 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3633 q = repo.mq |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3634 r = q.qrepo() |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3635 if not r: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
3636 raise error.Abort(_('no queue repository')) |
10407
2e8926e9cc32
mq: incorporate mq repo config when using --mq
Brendan Cully <brendan@kublai.com>
parents:
10402
diff
changeset
|
3637 return orig(r.ui, r, *args, **kwargs) |
10359
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3638 |
19212
d0ba7022c13b
mq: switch to new summary hook mechanism
Bryan O'Sullivan <bryano@fb.com>
parents:
19064
diff
changeset
|
3639 def summaryhook(ui, repo): |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3640 q = repo.mq |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3641 m = [] |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3642 a, u = len(q.applied), len(q.unapplied(repo)) |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3643 if a: |
11121
d061ef1d781c
mq: make use of output labeling for summary
Eric Eisner <ede@mit.edu>
parents:
11120
diff
changeset
|
3644 m.append(ui.label(_("%d applied"), 'qseries.applied') % a) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3645 if u: |
11121
d061ef1d781c
mq: make use of output labeling for summary
Eric Eisner <ede@mit.edu>
parents:
11120
diff
changeset
|
3646 m.append(ui.label(_("%d unapplied"), 'qseries.unapplied') % u) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3647 if m: |
17893
4d1da97aa7e7
i18n: make column positioning message of MQ summary output translatable
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17892
diff
changeset
|
3648 # i18n: column positioning for "hg summary" |
4d1da97aa7e7
i18n: make column positioning message of MQ summary output translatable
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17892
diff
changeset
|
3649 ui.write(_("mq: %s\n") % ', '.join(m)) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3650 else: |
17892
ba0a1701c81a
i18n: add "i18n" comment to column positioning messages of "hg summary"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17888
diff
changeset
|
3651 # i18n: column positioning for "hg summary" |
11119
2e270443a2c6
mq: mark string for translation
Martin Geisler <mg@lazybytes.net>
parents:
11107
diff
changeset
|
3652 ui.note(_("mq: (empty queue)\n")) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3653 |
28394
dcb4209bd30d
revset: replace extpredicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28313
diff
changeset
|
3654 revsetpredicate = registrar.revsetpredicate() |
27586
42910f9fffeb
revset: use delayregistrar to register predicate in extension easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27533
diff
changeset
|
3655 |
42910f9fffeb
revset: use delayregistrar to register predicate in extension easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27533
diff
changeset
|
3656 @revsetpredicate('mq()') |
14210
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
3657 def revsetmq(repo, subset, x): |
27586
42910f9fffeb
revset: use delayregistrar to register predicate in extension easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27533
diff
changeset
|
3658 """Changesets managed by MQ. |
14210
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
3659 """ |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
3660 revsetlang.getargs(x, 0, 0, _("mq takes no arguments")) |
14210
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
3661 applied = set([repo[r.node].rev() for r in repo.mq.applied]) |
31023
aea06029919e
revset: import set classes directly from smartset module
Yuya Nishihara <yuya@tcha.org>
parents:
30879
diff
changeset
|
3662 return smartset.baseset([r for r in subset if r in applied]) |
14210
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
3663 |
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
3664 # tell hggettext to extract docstrings from these functions: |
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
3665 i18nfunctions = [revsetmq] |
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
3666 |
17101
6bc275593d07
mq: defer command wrapping to extsetup (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17059
diff
changeset
|
3667 def extsetup(ui): |
6bc275593d07
mq: defer command wrapping to extsetup (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17059
diff
changeset
|
3668 # Ensure mq wrappers are called first, regardless of extension load order by |
6bc275593d07
mq: defer command wrapping to extsetup (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17059
diff
changeset
|
3669 # NOT wrapping in uisetup() and instead deferring to init stage two here. |
10591
ff2704a8ded3
mq: drop -Q in favor of --mq only
Matt Mackall <mpm@selenic.com>
parents:
10589
diff
changeset
|
3670 mqopt = [('', 'mq', None, _("operate on patch repository"))] |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3671 |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3672 extensions.wrapcommand(commands.table, 'import', mqimport) |
19212
d0ba7022c13b
mq: switch to new summary hook mechanism
Bryan O'Sullivan <bryano@fb.com>
parents:
19064
diff
changeset
|
3673 cmdutil.summaryhooks.add('mq', summaryhook) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3674 |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3675 entry = extensions.wrapcommand(commands.table, 'init', mqinit) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3676 entry[1].extend(mqopt) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3677 |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3678 def dotable(cmdtable): |
28313
aa73d6a5d9ea
dispatch: store norepo/optionalrepo/inferrepo attributes in function (API)
Yuya Nishihara <yuya@tcha.org>
parents:
27919
diff
changeset
|
3679 for cmd, entry in cmdtable.iteritems(): |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3680 cmd = cmdutil.parsealiases(cmd)[0] |
28313
aa73d6a5d9ea
dispatch: store norepo/optionalrepo/inferrepo attributes in function (API)
Yuya Nishihara <yuya@tcha.org>
parents:
27919
diff
changeset
|
3681 func = entry[0] |
30485
acd30a959980
dispatch: stop supporting non-use of @command
Augie Fackler <augie@google.com>
parents:
30369
diff
changeset
|
3682 if func.norepo: |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3683 continue |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3684 entry = extensions.wrapcommand(cmdtable, cmd, mqcommand) |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3685 entry[1].extend(mqopt) |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3686 |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3687 dotable(commands.table) |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3688 |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3689 for extname, extmodule in extensions.extensions(): |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3690 if extmodule.__file__ != __file__: |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3691 dotable(getattr(extmodule, 'cmdtable', {})) |
7142
88f1b8081f1c
Prevent import over an applied patch (closes issue795)
Brendan Cully <brendan@kublai.com>
parents:
7113
diff
changeset
|
3692 |
10826
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3693 colortable = {'qguard.negative': 'red', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3694 'qguard.positive': 'yellow', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3695 'qguard.unguarded': 'green', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3696 'qseries.applied': 'blue bold underline', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3697 'qseries.guarded': 'black bold', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3698 'qseries.missing': 'red bold', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3699 'qseries.unapplied': 'black bold'} |