Mercurial > hg
annotate hgext/mq.py @ 46082:c80f9e3daec3
share: remove unexpected heading from "verbose" container in help test
`test-gendoc-*.t` have been failing for me since 91425656e2b1 (share:
add documentation about share-safe mode in `hg help -e share`,
2020-11-27) with this kind of output:
```
--- /usr/local/google/home/martinvonz/hg/tests/test-gendoc-ru.t
+++ /usr/local/google/home/martinvonz/hg/tests/test-gendoc-ru.t.err
@@ -2,3 +2,9 @@
$ $TESTDIR/check-gendoc ru
checking for parse errors
+ gendoc.txt:12818: (SEVERE/4) Unexpected section title.
+
+ Sharing requirements and configs of source repository with shares
+ -----------------------------------------------------------------
+ Exiting due to level-4 (SEVERE) system message.
+ [1]
```
This patch fixes that.
Differential Revision: https://phab.mercurial-scm.org/D9552
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 09 Dec 2020 09:54:49 -0800 |
parents | 89a2afe31e82 |
children | ffd3e823a7e5 |
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 |
44019
5bbd770d1324
mq: avoid using `__file__` to compare modules
Matt Harbison <matt_harbison@yahoo.com>
parents:
43987
diff
changeset
|
71 import sys |
3891 | 72 from mercurial.i18n import _ |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
73 from mercurial.node import ( |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
74 bin, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
75 hex, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
76 nullid, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
77 nullrev, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
78 short, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
79 ) |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
80 from mercurial.pycompat import ( |
43090
1f339b503a40
py3: manually import pycompat.delattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
81 delattr, |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
82 getattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
83 open, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
84 ) |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
85 from mercurial import ( |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
86 cmdutil, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
87 commands, |
30489
0ae83ede68c5
mq: refer to dirstateguard by its new name
Augie Fackler <augie@google.com>
parents:
30485
diff
changeset
|
88 dirstateguard, |
34022
d5b2beca16c0
python3: wrap all uses of <exception>.strerror with strtolocal
Augie Fackler <raf@durin42.com>
parents:
33489
diff
changeset
|
89 encoding, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
90 error, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
91 extensions, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
92 hg, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
93 localrepo, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
94 lock as lockmod, |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35844
diff
changeset
|
95 logcmdutil, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
96 patch as patchmod, |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
97 phases, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30489
diff
changeset
|
98 pycompat, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
99 registrar, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
100 revsetlang, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
101 scmutil, |
31023
aea06029919e
revset: import set classes directly from smartset module
Yuya Nishihara <yuya@tcha.org>
parents:
30879
diff
changeset
|
102 smartset, |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45375
diff
changeset
|
103 strip, |
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35948
diff
changeset
|
104 subrepoutil, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
105 util, |
31243
816bc3b35bac
vfs: use 'vfs' module directly in 'hgext.mq'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
106 vfs as vfsmod, |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
107 ) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
108 from mercurial.utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
109 dateutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
110 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
111 ) |
29127
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
112 |
fa161ac73b24
py3: make hgext/mq.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28622
diff
changeset
|
113 release = lockmod.release |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
114 seriesopts = [(b's', b'summary', None, _(b'print first line of patch header'))] |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
115 |
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
116 cmdtable = {} |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32193
diff
changeset
|
117 command = registrar.command(cmdtable) |
29841
d5883fd055c6
extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents:
29752
diff
changeset
|
118 # 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
|
119 # 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
|
120 # 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
|
121 # leave the attribute unspecified. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
122 testedwith = b'ships-with-hg-core' |
14298
21719639276d
mq: use cmdutil.command decorator
Martin Geisler <mg@aragost.com>
parents:
14267
diff
changeset
|
123 |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
124 configtable = {} |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
125 configitem = registrar.configitem(configtable) |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
126 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
127 configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
128 b'mq', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
129 b'git', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
130 default=b'auto', |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
131 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
132 configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
133 b'mq', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
134 b'keepchanges', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
135 default=False, |
34182
cac8c4e51951
configitems: register the 'mq.keepchanges' config
Boris Feld <boris.feld@octobus.net>
parents:
34181
diff
changeset
|
136 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
137 configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
138 b'mq', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
139 b'plain', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
140 default=False, |
34183
5c150b70d004
configitems: register the 'mq.plain' config
Boris Feld <boris.feld@octobus.net>
parents:
34182
diff
changeset
|
141 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
142 configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
143 b'mq', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
144 b'secret', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
145 default=False, |
34184
b5bbfe176004
configitems: register the 'mq.secret' config
Boris Feld <boris.feld@octobus.net>
parents:
34183
diff
changeset
|
146 ) |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
147 |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
19916
diff
changeset
|
148 # 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
|
149 try: |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45375
diff
changeset
|
150 extensions.find(b'strip') |
19822
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
151 except KeyError: |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
152 # 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
|
153 # 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
|
154 class dummyui(object): |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19820
diff
changeset
|
155 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
|
156 pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
157 |
40995
19178aeb9b43
mq: implement log() on dummyui
Yuya Nishihara <yuya@tcha.org>
parents:
40360
diff
changeset
|
158 def log(self, event, msgfmt, *msgargs, **opts): |
19178aeb9b43
mq: implement log() on dummyui
Yuya Nishihara <yuya@tcha.org>
parents:
40360
diff
changeset
|
159 pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
160 |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45375
diff
changeset
|
161 extensions.load(dummyui(), b'strip', b'') |
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45375
diff
changeset
|
162 |
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45375
diff
changeset
|
163 strip = strip.strip |
42492
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
164 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
165 |
42492
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
166 def checksubstate(repo, baserev=None): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
167 """return list of subrepos at a different revision than substate. |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
168 Abort if any subrepos have uncommitted changes.""" |
42492
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
169 inclsubs = [] |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
170 wctx = repo[None] |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
171 if baserev: |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
172 bctx = repo[baserev] |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
173 else: |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
174 bctx = wctx.p1() |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
175 for s in sorted(wctx.substate): |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
176 wctx.sub(s).bailifchanged(True) |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
177 if s not in bctx.substate or bctx.sub(s).dirty(): |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
178 inclsubs.append(s) |
4bcabb5ae9b6
strip: move checksubstate() to mq (its only caller)
Martin von Zweigbergk <martinvonz@google.com>
parents:
42489
diff
changeset
|
179 return inclsubs |
19823
6fb14d21fe9d
strip: move checksubstate from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19822
diff
changeset
|
180 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
181 |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
182 # 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
|
183 # 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
|
184 normname = util.normpath |
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
185 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
186 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8761
diff
changeset
|
187 class statusentry(object): |
10682
8ed350051896
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10681
diff
changeset
|
188 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
|
189 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
|
190 |
9bce28609a95
mq: fix up statusentry to be both repr()-able and bytes()-able
Augie Fackler <augie@google.com>
parents:
35145
diff
changeset
|
191 def __bytes__(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
192 return hex(self.node) + b':' + self.name |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
193 |
35842
9bce28609a95
mq: fix up statusentry to be both repr()-able and bytes()-able
Augie Fackler <augie@google.com>
parents:
35145
diff
changeset
|
194 __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
|
195 __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
|
196 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
197 |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
198 # 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
|
199 HGHEADERS = [ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
200 # '# HG changeset patch', |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
201 b'# User ', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
202 b'# Date ', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
203 b'# ', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
204 b'# Branch ', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
205 b'# Node ID ', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
206 b'# Parent ', # can occur twice for merges - but that is not relevant for mq |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
207 ] |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
208 # 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
|
209 PLAINHEADERS = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
210 b'from': 0, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
211 b'date': 1, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
212 b'subject': 2, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
213 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
214 |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
215 |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
216 def inserthgheader(lines, header, value): |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
217 """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
|
218 >>> try: inserthgheader([], b'# Date ', b'z') |
34138
0f9936d80e01
doctest: upgrade old-style "except" clause
Yuya Nishihara <yuya@tcha.org>
parents:
34137
diff
changeset
|
219 ... 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
|
220 oops |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
221 >>> 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
|
222 ['# 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
|
223 >>> 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
|
224 ['# 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
|
225 >>> 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
|
226 ['# 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
|
227 >>> 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
|
228 ... 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
|
229 ['# 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
|
230 >>> 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
|
231 ['# 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
|
232 >>> 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
|
233 ... b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
234 ['# 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
|
235 >>> 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
|
236 ... b'# Date ', b'z') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
237 ['# 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
|
238 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
239 start = lines.index(b'# HG changeset patch') + 1 |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
240 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
|
241 bestpos = len(lines) |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
242 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
|
243 line = lines[i] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
244 if not line.startswith(b'# '): |
23412
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
245 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
|
246 break |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
247 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
|
248 if line.startswith(h): |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
249 if lineindex == newindex: |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
250 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
|
251 return lines |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
252 if lineindex > newindex: |
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
253 bestpos = min(bestpos, i) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
254 break # next line |
23412
94092019e839
mq: fix update of headers that occur in the "wrong" order
Mads Kiilerich <madski@unity3d.com>
parents:
23346
diff
changeset
|
255 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
|
256 return lines |
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22545
diff
changeset
|
257 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
258 |
23345
83cbf556babf
mq: introduce insertplainheader - same naive implementation as before
Mads Kiilerich <madski@unity3d.com>
parents:
23344
diff
changeset
|
259 def insertplainheader(lines, header, value): |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
260 """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
|
261 >>> insertplainheader([], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
262 ['Date: z'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
263 >>> insertplainheader([b''], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
264 ['Date: z', ''] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
265 >>> insertplainheader([b'x'], b'Date', b'z') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
266 ['Date: z', '', 'x'] |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
267 >>> 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
|
268 ['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
|
269 >>> 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
|
270 [' 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
|
271 >>> 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
|
272 ['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
|
273 >>> 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
|
274 ['From: y', 'foo: bar', 'DATE: z', '', 'x'] |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
275 """ |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
276 newprio = PLAINHEADERS[header.lower()] |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
277 bestpos = len(lines) |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
278 for i, line in enumerate(lines): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
279 if b':' in line: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
280 lheader = line.split(b':', 1)[0].strip().lower() |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
281 lprio = PLAINHEADERS.get(lheader, newprio + 1) |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
282 if lprio == newprio: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
283 lines[i] = b'%s: %s' % (header, value) |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
284 return lines |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
285 if lprio > newprio and i < bestpos: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
286 bestpos = i |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
287 else: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
288 if line: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
289 lines.insert(i, b'') |
23442
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
290 if i < bestpos: |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
291 bestpos = i |
a5c94ea3b8af
mq: smarter handling of plain headers
Mads Kiilerich <madski@unity3d.com>
parents:
23412
diff
changeset
|
292 break |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
293 lines.insert(bestpos, b'%s: %s' % (header, value)) |
23345
83cbf556babf
mq: introduce insertplainheader - same naive implementation as before
Mads Kiilerich <madski@unity3d.com>
parents:
23344
diff
changeset
|
294 return lines |
83cbf556babf
mq: introduce insertplainheader - same naive implementation as before
Mads Kiilerich <madski@unity3d.com>
parents:
23344
diff
changeset
|
295 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
296 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
297 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
|
298 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
|
299 def eatdiff(lines): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
300 while lines: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
301 l = lines[-1] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
302 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
303 l.startswith(b"diff -") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
304 or l.startswith(b"Index:") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
305 or l.startswith(b"===========") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
306 ): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
307 del lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
308 else: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
309 break |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
310 |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
311 def eatempty(lines): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
312 while lines: |
10688
d4d3a8a65248
mq: don't use regexp when not necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10687
diff
changeset
|
313 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
|
314 del lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
315 else: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
316 break |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
317 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
318 message = [] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
319 comments = [] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
320 user = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
321 date = None |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
322 parent = None |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
323 format = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
324 subject = None |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
325 branch = None |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
326 nodeid = None |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
327 diffstart = 0 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
328 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
329 for line in open(pf, b'rb'): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
330 line = line.rstrip() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
331 if line.startswith(b'diff --git') or ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
332 diffstart and line.startswith(b'+++ ') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
333 ): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
334 diffstart = 2 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
335 break |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
336 diffstart = 0 # reset |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
337 if line.startswith(b"--- "): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
338 diffstart = 1 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
339 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
340 elif format == b"hgpatch": |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
341 # parse values when importing the result of an hg export |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
342 if line.startswith(b"# User "): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
343 user = line[7:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
344 elif line.startswith(b"# Date "): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
345 date = line[7:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
346 elif line.startswith(b"# Parent "): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
347 parent = line[9:].lstrip() # handle double trailing space |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
348 elif line.startswith(b"# Branch "): |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
349 branch = line[9:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
350 elif line.startswith(b"# Node ID "): |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
351 nodeid = line[10:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
352 elif not line.startswith(b"# ") and line: |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
353 message.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
354 format = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
355 elif line == b'# 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
|
356 message = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
357 format = b"hgpatch" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
358 elif format != b"tagdone" and ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
359 line.startswith(b"Subject: ") or line.startswith(b"subject: ") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
360 ): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
361 subject = line[9:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
362 format = b"tag" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
363 elif format != b"tagdone" and ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
364 line.startswith(b"From: ") or line.startswith(b"from: ") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
365 ): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
366 user = line[6:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
367 format = b"tag" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
368 elif format != b"tagdone" and ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
369 line.startswith(b"Date: ") or line.startswith(b"date: ") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
370 ): |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
371 date = line[6:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
372 format = b"tag" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
373 elif format == b"tag" and line == b"": |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
374 # 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
|
375 # end once you find a blank line in the source |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
376 format = b"tagdone" |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
377 elif message or line: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
378 message.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
379 comments.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
380 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
381 eatdiff(message) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
382 eatdiff(comments) |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
383 # 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
|
384 # 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
|
385 self.diffstartline = len(comments) |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
386 eatempty(message) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
387 eatempty(comments) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
388 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
389 # make sure message isn't empty |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
390 if format and format.startswith(b"tag") and subject: |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
391 message.insert(0, subject) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
392 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
393 self.message = message |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
394 self.comments = comments |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
395 self.user = user |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
396 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
|
397 self.parent = parent |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
398 # 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
|
399 self.nodeid = nodeid |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
400 self.branch = branch |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
401 self.haspatch = diffstart > 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
402 self.plainmode = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
403 plainmode |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
404 or b'# HG changeset patch' not in self.comments |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
405 and any( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
406 c.startswith(b'Date: ') or c.startswith(b'From: ') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
407 for c in self.comments |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
408 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
409 ) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
410 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
411 def setuser(self, user): |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
412 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 inserthgheader(self.comments, b'# User ', user) |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
414 except ValueError: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
415 if self.plainmode: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
416 insertplainheader(self.comments, b'From', user) |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
417 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
418 tmp = [b'# HG changeset patch', b'# User ' + user] |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
419 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
|
420 self.user = user |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
421 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
422 def setdate(self, date): |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
423 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
424 inserthgheader(self.comments, b'# Date ', date) |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
425 except ValueError: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
426 if self.plainmode: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
427 insertplainheader(self.comments, b'Date', date) |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
428 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
429 tmp = [b'# HG changeset patch', b'# Date ' + date] |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
430 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
|
431 self.date = date |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
432 |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
433 def setparent(self, parent): |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
434 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
435 inserthgheader(self.comments, b'# Parent ', parent) |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
436 except ValueError: |
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
437 if not self.plainmode: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
438 tmp = [b'# HG changeset patch', b'# Parent ' + parent] |
23443
3b653c2fd6ba
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich <madski@unity3d.com>
parents:
23442
diff
changeset
|
439 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
|
440 self.parent = parent |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
441 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
442 def setmessage(self, message): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
443 if self.comments: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
444 self._delmsg() |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
445 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
|
446 if message: |
6333412245ec
mq: when setting message in plain mode, separate it from header (issue4453)
Mads Kiilerich <madski@unity3d.com>
parents:
23128
diff
changeset
|
447 if self.plainmode and self.comments and self.comments[-1]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
448 self.comments.append(b'') |
23344
6333412245ec
mq: when setting message in plain mode, separate it from header (issue4453)
Mads Kiilerich <madski@unity3d.com>
parents:
23128
diff
changeset
|
449 self.comments.append(message) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
450 |
35916
d41e41d11574
py3: add __bytes__() for mq.patchheader and make sure __str__ returns str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35888
diff
changeset
|
451 def __bytes__(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
452 s = b'\n'.join(self.comments).rstrip() |
22522
382c2be610dc
mq: simplify patchheader handling of the empty line before the diff
Mads Kiilerich <madski@unity3d.com>
parents:
22521
diff
changeset
|
453 if not s: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
454 return b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
455 return s + b'\n\n' |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
456 |
35916
d41e41d11574
py3: add __bytes__() for mq.patchheader and make sure __str__ returns str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35888
diff
changeset
|
457 __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
|
458 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
459 def _delmsg(self): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
460 """Remove existing message, keeping the rest of the comments fields. |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
461 If comments contains 'subject: ', message will prepend |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
462 the field and a blank line.""" |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
463 if self.message: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
464 subj = b'subject: ' + self.message[0].lower() |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
465 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
|
466 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
|
467 del self.comments[i] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
468 self.message = self.message[2:] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
469 break |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
470 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
|
471 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
|
472 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
|
473 ci += 1 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
474 del self.comments[ci] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
475 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
476 |
16102 | 477 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
|
478 """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
|
479 |
db4b0532dbf2
mq: rename secretcommit to newcommit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16048
diff
changeset
|
480 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
|
481 creating new changeset. |
15926
f94513971767
mq: have mq create secret changeset only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15924
diff
changeset
|
482 """ |
18010
38b51a60a195
clfilter: ensure that mq performs commits on unfiltered repos
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17954
diff
changeset
|
483 repo = repo.unfiltered() |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
484 if phase is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
485 if repo.ui.configbool(b'mq', b'secret'): |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
486 phase = phases.secret |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
487 overrides = {(b'ui', b'allowemptycommit'): True} |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
488 if phase is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
489 overrides[(b'phases', b'new-commit')] = phase |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
490 with repo.ui.configoverride(overrides, b'mq'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
491 repo.ui.setconfig(b'ui', b'allowemptycommit', True) |
15926
f94513971767
mq: have mq create secret changeset only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15924
diff
changeset
|
492 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
|
493 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
494 |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
495 class AbortNoCleanup(error.Abort): |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
496 pass |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
497 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
498 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8761
diff
changeset
|
499 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
|
500 def __init__(self, ui, baseui, path, patchdir=None): |
1808 | 501 self.basepath = path |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
502 try: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
503 with open(os.path.join(path, b'patches.queue'), 'rb') as fh: |
36107
bff95b002e33
py3: open patches.queue in binary mode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36106
diff
changeset
|
504 cur = fh.read().rstrip() |
bff95b002e33
py3: open patches.queue in binary mode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36106
diff
changeset
|
505 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
506 if not cur: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
507 curpath = os.path.join(path, b'patches') |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
508 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
509 curpath = os.path.join(path, b'patches-' + cur) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
510 except IOError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
511 curpath = os.path.join(path, b'patches') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
512 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
|
513 self.opener = vfsmod.vfs(self.path) |
1808 | 514 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
|
515 self.baseui = baseui |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
516 self.applieddirty = False |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
517 self.seriesdirty = False |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
518 self.added = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
519 self.seriespath = b"series" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
520 self.statuspath = b"status" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
521 self.guardspath = b"guards" |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
522 self.activeguards = None |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
523 self.guardsdirty = False |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
524 # Handle mq.git as a bool with extended values |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
525 gitmode = ui.config(b'mq', b'git').lower() |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
526 boolmode = stringutil.parsebool(gitmode) |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
527 if boolmode is not None: |
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
528 if boolmode: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
529 gitmode = b'yes' |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
530 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
531 gitmode = b'no' |
34181
62490b84ebf8
configitems: register the 'mq.git' config
Boris Feld <boris.feld@octobus.net>
parents:
34138
diff
changeset
|
532 self.gitmode = gitmode |
25827
0fdf2c304019
mq: tweak config reading to make check-config happy
Matt Mackall <mpm@selenic.com>
parents:
25660
diff
changeset
|
533 # deprecated config: mq.plain |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
534 self.plainmode = ui.configbool(b'mq', b'plain') |
19856
28b1b7b9b4a9
shelve: allow shelving of a change with an mq patch applied
David Soria Parra <dsp@experimentalworks.net>
parents:
19826
diff
changeset
|
535 self.checkapplied = True |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
536 |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
537 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
538 def applied(self): |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
539 def parselines(lines): |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
540 for l in lines: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
541 entry = l.split(b':', 1) |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
542 if len(entry) > 1: |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
543 n, name = entry |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
544 yield statusentry(bin(n), name) |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
545 elif l.strip(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
546 self.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
547 _(b'malformated mq status line: %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
548 % stringutil.pprint(entry) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
549 ) |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
550 # else we ignore empty lines |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
551 |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
552 try: |
14588
bd3d75a03f80
mq: rename status_path to statuspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14587
diff
changeset
|
553 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
|
554 return list(parselines(lines)) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
555 except IOError as e: |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
556 if e.errno == errno.ENOENT: |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
557 return [] |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
558 raise |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
559 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
560 @util.propertycache |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
561 def fullseries(self): |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
562 try: |
15878 | 563 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
|
564 except IOError as e: |
15258
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
565 if e.errno == errno.ENOENT: |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
566 return [] |
fe9677449331
mq: eliminate explicit checks for file existence
Idan Kamara <idankk86@gmail.com>
parents:
15257
diff
changeset
|
567 raise |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
568 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
569 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
570 def series(self): |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
571 self.parseseries() |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
572 return self.series |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
573 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
574 @util.propertycache |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
575 def seriesguards(self): |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
576 self.parseseries() |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
577 return self.seriesguards |
1808 | 578 |
8525
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
579 def invalidate(self): |
43421
be384a2052aa
py3: don't use bytes with vars() or __dict__
Martin von Zweigbergk <martinvonz@google.com>
parents:
43117
diff
changeset
|
580 for a in 'applied fullseries series seriesguards'.split(): |
8525
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
581 if a in self.__dict__: |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
582 delattr(self, a) |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
583 self.applieddirty = False |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
584 self.seriesdirty = False |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
585 self.guardsdirty = False |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
586 self.activeguards = None |
8525
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
587 |
34090
987a85c42b08
mq: create non-lossy patches, also with custom global diff configuration
Mads Kiilerich <mads@kiilerich.com>
parents:
33489
diff
changeset
|
588 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
|
589 """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
|
590 git format, and possibly plain and without lossy options.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
591 diffopts = patchmod.difffeatureopts( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
592 self.ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
593 opts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
594 git=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
595 whitespace=not plain, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
596 formatchanging=not plain, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
597 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
598 if self.gitmode == b'auto': |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
599 diffopts.upgrade = True |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
600 elif self.gitmode == b'keep': |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
601 pass |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
602 elif self.gitmode in (b'yes', b'no'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
603 diffopts.git = self.gitmode == b'yes' |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
604 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
605 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
606 _(b'mq.git option can be auto/keep/yes/no got %s') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
607 % self.gitmode |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
608 ) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
609 if patchfn: |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
610 diffopts = self.patchopts(diffopts, patchfn) |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
611 return diffopts |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
612 |
10186
296a0b14a686
mq: preserve --git flag when folding patches
Patrick Mezard <pmezard@gmail.com>
parents:
10185
diff
changeset
|
613 def patchopts(self, diffopts, *patches): |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
614 """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
|
615 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
|
616 """ |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
617 diffopts = diffopts.copy() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
618 if not diffopts.git and self.gitmode == b'keep': |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
619 for patchfn in patches: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
620 patchf = self.opener(patchfn, b'r') |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
621 # if the patch was a git patch, refresh it as a git patch |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
622 diffopts.git = any( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
623 line.startswith(b'diff --git') for line in patchf |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
624 ) |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
625 patchf.close() |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
626 return diffopts |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2873
diff
changeset
|
627 |
2819 | 628 def join(self, *p): |
629 return os.path.join(self.path, *p) | |
630 | |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
631 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
|
632 def matchpatch(l): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
633 l = l.split(b'#', 1)[0] |
10685
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
634 return l.strip() == patch |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
635 |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
636 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
|
637 if matchpatch(l): |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
638 return index |
1808 | 639 return None |
640 | |
35145
25c543944bc0
py3: add b'' to regular expressions which are raw strings
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34918
diff
changeset
|
641 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
|
642 |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
643 def parseseries(self): |
1808 | 644 self.series = [] |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
645 self.seriesguards = [] |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
646 for l in self.fullseries: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
647 h = l.find(b'#') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
648 if h == -1: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
649 patch = l |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
650 comment = b'' |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
651 elif h == 0: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
652 continue |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
653 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
654 patch = l[:h] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
655 comment = l[h:] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
656 patch = patch.strip() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
657 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
|
658 if patch in self.series: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
659 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
660 _(b'%s appears more than once in %s') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
661 % (patch, self.join(self.seriespath)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
662 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
663 self.series.append(patch) |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
664 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
|
665 |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
666 def checkguard(self, guard): |
6607
75b506f0e571
mq: make qselect fail properly on an empty guard
Patrick Mezard <pmezard@gmail.com>
parents:
6606
diff
changeset
|
667 if not guard: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
668 return _(b'guard cannot be an empty string') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
669 bad_chars = b'# \t\r\n\f' |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
670 first = guard[0] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
671 if first in b'-+': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
672 return _(b'guard %r starts with invalid character: %r') % ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
673 guard, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
674 first, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
675 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
676 for c in bad_chars: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
677 if c in guard: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
678 return _(b'invalid character in guard %r: %r') % (guard, c) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
679 |
14578
28a2646f3b81
mq: rename set_active to setactive
Adrian Buehlmann <adrian@cadifra.com>
parents:
14577
diff
changeset
|
680 def setactive(self, guards): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
681 for guard in guards: |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
682 bad = self.checkguard(guard) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
683 if bad: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
684 raise error.Abort(bad) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8188
diff
changeset
|
685 guards = sorted(set(guards)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
686 self.ui.debug(b'active guards: %s\n' % b' '.join(guards)) |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
687 self.activeguards = guards |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
688 self.guardsdirty = True |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
689 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
690 def active(self): |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
691 if self.activeguards is None: |
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
692 self.activeguards = [] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
693 try: |
14589
7d59ee9e711b
mq: rename guards_path to guardspath
Adrian Buehlmann <adrian@cadifra.com>
parents:
14588
diff
changeset
|
694 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
|
695 except IOError as err: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
696 if err.errno != errno.ENOENT: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
697 raise |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
698 guards = [] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
699 for i, guard in enumerate(guards): |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
700 bad = self.checkguard(guard) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
701 if bad: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
702 self.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
703 b'%s:%d: %s\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
704 % (self.join(self.guardspath), i + 1, bad) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
705 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
706 else: |
14590
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
707 self.activeguards.append(guard) |
dbb80f03d4ae
mq: rename active_guards to activeguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14589
diff
changeset
|
708 return self.activeguards |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
709 |
14577
76357276662e
mq: rename set_guards to setguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14576
diff
changeset
|
710 def setguards(self, idx, guards): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
711 for g in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
712 if len(g) < 2: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
713 raise error.Abort(_(b'guard %r too short') % g) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
714 if g[0] not in b'-+': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
715 raise error.Abort(_(b'guard %r starts with invalid char') % g) |
14576
668ea374f46e
mq: rename check_guard to checkguard
Adrian Buehlmann <adrian@cadifra.com>
parents:
14575
diff
changeset
|
716 bad = self.checkguard(g[1:]) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
717 if bad: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
718 raise error.Abort(bad) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
719 drop = self.guard_re.sub(b'', self.fullseries[idx]) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
720 self.fullseries[idx] = drop + b''.join([b' #' + g for g in guards]) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
721 self.parseseries() |
14593
599a72895c0d
mq: rename series_dirty to seriesdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14592
diff
changeset
|
722 self.seriesdirty = True |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
723 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
724 def pushable(self, idx): |
36106
c33a99506e13
py3: compare against bytes instead of str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36032
diff
changeset
|
725 if isinstance(idx, bytes): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
726 idx = self.series.index(idx) |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
727 patchguards = self.seriesguards[idx] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
728 if not patchguards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
729 return True, None |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
730 guards = self.active() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
731 exactneg = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
732 g for g in patchguards if g.startswith(b'-') and g[1:] in guards |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
733 ] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
734 if exactneg: |
39049
b53ec524420b
mq: use stringutil.pprint instead of pycompat.byterepr
Augie Fackler <augie@google.com>
parents:
38783
diff
changeset
|
735 return False, stringutil.pprint(exactneg[0]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
736 pos = [g for g in patchguards if g.startswith(b'+')] |
2850
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
737 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
|
738 if pos: |
2850
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
739 if exactpos: |
39049
b53ec524420b
mq: use stringutil.pprint instead of pycompat.byterepr
Augie Fackler <augie@google.com>
parents:
38783
diff
changeset
|
740 return True, stringutil.pprint(exactpos[0]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
741 return False, b' '.join([stringutil.pprint(p) for p in pos]) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
742 return True, b'' |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
743 |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
744 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
|
745 if all_patches: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
746 write = self.ui.write |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
747 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
748 write = self.ui.warn |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
749 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
750 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
|
751 if isinstance(idx, bytes): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
752 idx = self.series.index(idx) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
753 pushable, why = self.pushable(idx) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
754 if all_patches and pushable: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
755 if why is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
756 write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
757 _(b'allowing %s - no guards in effect\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
758 % self.series[idx] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
759 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
760 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
761 if not why: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
762 write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
763 _(b'allowing %s - no matching negative guards\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
764 % self.series[idx] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
765 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
766 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
767 write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
768 _(b'allowing %s - guarded by %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
769 % (self.series[idx], why) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
770 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
771 if not pushable: |
2829
05316bb57d01
mq: make guards more strict, add tests
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2828
diff
changeset
|
772 if why: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
773 write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
774 _(b'skipping %s - guarded by %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
775 % (self.series[idx], why) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
776 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
777 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
778 write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
779 _(b'skipping %s - no matching guards\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
780 % self.series[idx] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
781 ) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
782 |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
783 def savedirty(self): |
14594
3752b5e1f4c4
mq: rename write_list to writelist
Adrian Buehlmann <adrian@cadifra.com>
parents:
14593
diff
changeset
|
784 def writelist(items, path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
785 fp = self.opener(path, b'wb') |
2772
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
786 for i in items: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
787 fp.write(b"%s\n" % i) |
2772
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
788 fp.close() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
789 |
14592
fc94add69d9f
mq: rename applied_dirty to applieddirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14591
diff
changeset
|
790 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
|
791 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
|
792 self.applieddirty = False |
14593
599a72895c0d
mq: rename series_dirty to seriesdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14592
diff
changeset
|
793 if self.seriesdirty: |
14594
3752b5e1f4c4
mq: rename write_list to writelist
Adrian Buehlmann <adrian@cadifra.com>
parents:
14593
diff
changeset
|
794 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
|
795 self.seriesdirty = False |
14591
b49099712d30
mq: rename guards_dirty to guardsdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14590
diff
changeset
|
796 if self.guardsdirty: |
14594
3752b5e1f4c4
mq: rename write_list to writelist
Adrian Buehlmann <adrian@cadifra.com>
parents:
14593
diff
changeset
|
797 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
|
798 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
|
799 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
|
800 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
|
801 if qrepo: |
12658
97d7ee445e98
mq: silence spurious output.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12655
diff
changeset
|
802 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
|
803 self.added = [] |
1808 | 804 |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
805 def removeundo(self, repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
806 undo = repo.sjoin(b'undo') |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
807 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
|
808 return |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
809 try: |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
810 os.unlink(undo) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
811 except OSError as inst: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
812 self.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
813 _(b'error removing undo: %s\n') % stringutil.forcebytestr(inst) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
814 ) |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
815 |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
816 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
|
817 # backup local changes in --force case |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
818 for f in sorted(files): |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
819 absf = repo.wjoin(f) |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
820 if os.path.lexists(absf): |
41599
106b0bec162a
mq: migrate to scmutil.backuppath()
Martin von Zweigbergk <martinvonz@google.com>
parents:
41592
diff
changeset
|
821 absorig = scmutil.backuppath(self.ui, repo, f) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
822 self.ui.note( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
823 _(b'saving current version of %s as %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
824 % (f, os.path.relpath(absorig)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
825 ) |
41592
e67a85e0f19e
mq: always show relative path to .orig backup
Martin von Zweigbergk <martinvonz@google.com>
parents:
41532
diff
changeset
|
826 |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
827 if copy: |
26943
263edb591b72
mq: let the user choose where .orig files are kept
Christian Delahousse <cdelahousse@fb.com>
parents:
26831
diff
changeset
|
828 util.copyfile(absf, absorig) |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
829 else: |
26943
263edb591b72
mq: let the user choose where .orig files are kept
Christian Delahousse <cdelahousse@fb.com>
parents:
26831
diff
changeset
|
830 util.rename(absf, absorig) |
16633
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
831 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
832 def printdiff( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
833 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
834 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
835 diffopts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
836 node1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
837 node2=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
838 files=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
839 fp=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
840 changes=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
841 opts=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
842 ): |
31432
6e1c79578e5c
mq: explicitly tests for None
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31407
diff
changeset
|
843 if opts is None: |
6e1c79578e5c
mq: explicitly tests for None
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31407
diff
changeset
|
844 opts = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
845 stat = opts.get(b'stat') |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14636
diff
changeset
|
846 m = scmutil.match(repo[node1], files, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
847 logcmdutil.diffordiffstat( |
44823
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
848 self.ui, |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
849 repo, |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
850 diffopts, |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
851 repo[node1], |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
852 repo[node2], |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
853 m, |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
854 changes, |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
855 stat, |
3b7aabd02e11
cleanup: avoid extra node/ctx conversions in logcmdutil.diffordiffstat
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
856 fp, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
857 ) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2873
diff
changeset
|
858 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
859 def mergeone(self, repo, mergeq, head, patch, rev, diffopts): |
1808 | 860 # first try just applying the patch |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
861 (err, n) = self.apply( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
862 repo, [patch], update_status=False, strict=True, merge=rev |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
863 ) |
1808 | 864 |
865 if err == 0: | |
866 return (err, n) | |
867 | |
868 if n is None: | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
869 raise error.Abort(_(b"apply failed for patch %s") % patch) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
870 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
871 self.ui.warn(_(b"patch didn't work out, merging %s\n") % patch) |
1808 | 872 |
873 # 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
|
874 hg.clean(repo, head) |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
875 strip(self.ui, repo, [n], update=False, backup=False) |
1808 | 876 |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6668
diff
changeset
|
877 ctx = repo[rev] |
44435
4152183acedd
mq: don't tell user to commit merge that we already committed
Martin von Zweigbergk <martinvonz@google.com>
parents:
44434
diff
changeset
|
878 ret = hg.merge(ctx, remind=False) |
1808 | 879 if ret: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
880 raise error.Abort(_(b"update returned %d") % ret) |
16102 | 881 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
|
882 if n is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
883 raise error.Abort(_(b"repo commit failed")) |
1808 | 884 try: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
885 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
|
886 except Exception: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
887 raise error.Abort(_(b"unable to read %s") % patch) |
1808 | 888 |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
889 diffopts = self.patchopts(diffopts, patch) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
890 patchf = self.opener(patch, b"w") |
36667
bcfc4e3b6548
py3: use bytes() instead of str()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36632
diff
changeset
|
891 comments = bytes(ph) |
1808 | 892 if comments: |
893 patchf.write(comments) | |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
894 self.printdiff(repo, diffopts, head, n, fp=patchf) |
1808 | 895 patchf.close() |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
896 self.removeundo(repo) |
1808 | 897 return (0, n) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
898 |
1808 | 899 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
|
900 """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
|
901 |
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
902 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
|
903 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
|
904 (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
|
905 |
d5ec50e8604b
mq: document repo.mq.qparents
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19815
diff
changeset
|
906 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
|
907 """ |
1808 | 908 if rev is None: |
909 (p1, p2) = repo.dirstate.parents() | |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
910 if p2 == nullid: |
1808 | 911 return p1 |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
912 if not self.applied: |
1808 | 913 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
|
914 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
|
915 p1, p2 = repo.changelog.parents(rev) |
10680
45eb9b5dacf6
mq: simplify qparents calculation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10679
diff
changeset
|
916 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
|
917 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
|
918 return p1 |
1808 | 919 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
920 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
|
921 if not self.applied: |
1808 | 922 # each of the patches merged in will have two parents. This |
923 # can confuse the qrefresh, qdiff, and strip code because it | |
924 # needs to know which parent is actually in the patch queue. | |
925 # so, we insert a merge marker with only one parent. This way | |
926 # the first patch in the queue is never a merge patch | |
927 # | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
928 pname = b".hg.patches.merge.marker" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
929 n = newcommit(repo, None, b'[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
|
930 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
|
931 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
|
932 self.applieddirty = True |
1808 | 933 |
934 head = self.qparents(repo) | |
935 | |
936 for patch in series: | |
2696 | 937 patch = mergeq.lookup(patch, strict=True) |
1808 | 938 if not patch: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
939 self.ui.warn(_(b"patch %s does not exist\n") % patch) |
1808 | 940 return (1, None) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
941 pushable, reason = self.pushable(patch) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
942 if not pushable: |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
943 self.explainpushable(patch, all_patches=True) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
944 continue |
1808 | 945 info = mergeq.isapplied(patch) |
946 if not info: | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
947 self.ui.warn(_(b"patch %s is not applied\n") % patch) |
1808 | 948 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
|
949 rev = info[1] |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
950 err, head = self.mergeone(repo, mergeq, head, patch, rev, diffopts) |
1808 | 951 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
|
952 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
|
953 self.applieddirty = True |
1808 | 954 if err: |
955 return (err, head) | |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
956 self.savedirty() |
1808 | 957 return (0, head) |
958 | |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
959 def patch(self, repo, patchfile): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
960 """Apply patchfile to the working directory. |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
961 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
|
962 files = set() |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
963 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
964 fuzz = patchmod.patch( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
965 self.ui, repo, patchfile, strip=1, files=files, eolmode=None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
966 ) |
14260
00a881581400
patch: make patch()/internalpatch() always update the dirstate
Patrick Mezard <pmezard@gmail.com>
parents:
14259
diff
changeset
|
967 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
|
968 except Exception as inst: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
969 self.ui.note(stringutil.forcebytestr(inst) + b'\n') |
2919
b70740aefa4d
Unify mq and hg patch invocation.
Brendan Cully <brendan@kublai.com>
parents:
2905
diff
changeset
|
970 if not self.ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
971 self.ui.warn(_(b"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
|
972 self.ui.traceback() |
14260
00a881581400
patch: make patch()/internalpatch() always update the dirstate
Patrick Mezard <pmezard@gmail.com>
parents:
14259
diff
changeset
|
973 return (False, list(files), False) |
2796
4c39568007f9
mq: codingstyle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2795
diff
changeset
|
974 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
975 def apply( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
976 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
977 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
978 series, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
979 list=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
980 update_status=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
981 strict=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
982 patchdir=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
983 merge=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
984 all_files=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
985 tobackup=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
986 keepchanges=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
987 ): |
26578
8bd2759f1fa7
dirstate: remove meaningless dirstateguard
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26345
diff
changeset
|
988 wlock = lock = tr = None |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
989 try: |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
990 wlock = repo.wlock() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
991 lock = repo.lock() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
992 tr = repo.transaction(b"qpush") |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
993 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
994 ret = self._apply( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
995 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
996 series, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
997 list, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
998 update_status, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
999 strict, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1000 patchdir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1001 merge, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1002 all_files=all_files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1003 tobackup=tobackup, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1004 keepchanges=keepchanges, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1005 ) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1006 tr.close() |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
1007 self.savedirty() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1008 return ret |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1009 except AbortNoCleanup: |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1010 tr.close() |
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1011 self.savedirty() |
24826
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
1012 raise |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1013 except: # re-raises |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1014 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1015 tr.abort() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1016 finally: |
15881
3862369cf9b9
mq: use .invalidate to cancel dirty mq state when cancelling transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15880
diff
changeset
|
1017 self.invalidate() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1018 raise |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1019 finally: |
26578
8bd2759f1fa7
dirstate: remove meaningless dirstateguard
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26345
diff
changeset
|
1020 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
|
1021 self.removeundo(repo) |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
1022 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1023 def _apply( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1024 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1025 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1026 series, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1027 list=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1028 update_status=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1029 strict=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1030 patchdir=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1031 merge=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1032 all_files=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1033 tobackup=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1034 keepchanges=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1035 ): |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1036 """returns (error, hash) |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1037 |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1038 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
|
1039 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
|
1040 are modified by a patch. |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1041 """ |
1808 | 1042 # TODO unify with commands.py |
1043 if not patchdir: | |
1044 patchdir = self.path | |
1045 err = 0 | |
1046 n = None | |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
1047 for patchname in series: |
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
1048 pushable, reason = self.pushable(patchname) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1049 if not pushable: |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
1050 self.explainpushable(patchname, all_patches=True) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1051 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1052 self.ui.status(_(b"applying %s\n") % patchname) |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
1053 pf = os.path.join(patchdir, patchname) |
1808 | 1054 |
1055 try: | |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
1056 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
|
1057 except IOError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1058 self.ui.warn(_(b"unable to read %s\n") % patchname) |
1808 | 1059 err = 1 |
1060 break | |
1061 | |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1062 message = ph.message |
1808 | 1063 if not message: |
12849
d966eb464888
mq: mark strings that should not be translated
Martin Geisler <mg@lazybytes.net>
parents:
12848
diff
changeset
|
1064 # The commit message should not be translated |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1065 message = b"imported patch %s\n" % patchname |
1808 | 1066 else: |
1067 if list: | |
12849
d966eb464888
mq: mark strings that should not be translated
Martin Geisler <mg@lazybytes.net>
parents:
12848
diff
changeset
|
1068 # The commit message should not be translated |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1069 message.append(b"\nimported patch %s" % patchname) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1070 message = b'\n'.join(message) |
1808 | 1071 |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
1072 if ph.haspatch: |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1073 if tobackup: |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1074 touched = patchmod.changedfiles(self.ui, repo, pf) |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1075 touched = set(touched) & tobackup |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1076 if touched and keepchanges: |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1077 raise AbortNoCleanup( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1078 _(b"conflicting local changes found"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1079 hint=_(b"did you forget to qrefresh?"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1080 ) |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1081 self.backup(repo, touched, copy=True) |
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1082 tobackup = tobackup - touched |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
1083 (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
|
1084 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
|
1085 all_files.update(files) |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
1086 patcherr = not patcherr |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
1087 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1088 self.ui.warn(_(b"patch %s is empty\n") % patchname) |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
1089 patcherr, files, fuzz = 0, [], 0 |
1808 | 1090 |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
1091 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
|
1092 # 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
|
1093 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
|
1094 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
|
1095 for f in files: |
12344
b6173aee4a47
Use lexists() instead of exists() where appropriate
Patrick Mezard <pmezard@gmail.com>
parents:
12067
diff
changeset
|
1096 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
|
1097 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
|
1098 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
|
1099 removed.append(f) |
32347
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1100 with repo.dirstate.parentchange(): |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1101 for f in removed: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1102 repo.dirstate.remove(f) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1103 for f in merged: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1104 repo.dirstate.merge(f) |
41399
5cb8158a61f7
cleanup: use p1() instead of parents() when we only need the first parent
Martin von Zweigbergk <martinvonz@google.com>
parents:
41373
diff
changeset
|
1105 p1 = repo.dirstate.p1() |
32347
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1106 repo.setparents(p1, merge) |
6603
41eb20cc1c02
match: remove files arg from repo.status and friends
Matt Mackall <mpm@selenic.com>
parents:
6602
diff
changeset
|
1107 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1108 if all_files and b'.hgsubstate' in all_files: |
20959
b6e0616d08cb
mq: repo['.'] is not a wctx, repo[None] is
Mads Kiilerich <madski@unity3d.com>
parents:
20924
diff
changeset
|
1109 wctx = repo[None] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1110 pctx = repo[b'.'] |
19638
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
1111 overwrite = False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1112 mergedsubstate = subrepoutil.submerge( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1113 repo, pctx, wctx, wctx, overwrite |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1114 ) |
19638
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
1115 files += mergedsubstate.keys() |
20096384754f
mq: update subrepos when applying / unapplying patches that change .hgsubstate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19636
diff
changeset
|
1116 |
14322
a90131b85fd8
scmutil: drop aliases in cmdutil for match functions
Matt Mackall <mpm@selenic.com>
parents:
14319
diff
changeset
|
1117 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
|
1118 oldtip = repo.changelog.tip() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1119 n = newcommit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1120 repo, None, message, ph.user, ph.date, match=match, force=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1121 ) |
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
|
1122 if repo.changelog.tip() == oldtip: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1123 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1124 _(b"qpush exactly duplicates child changeset") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1125 ) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
1126 if n is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1127 raise error.Abort(_(b"repository commit failed")) |
1808 | 1128 |
1129 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
|
1130 self.applied.append(statusentry(n, patchname)) |
1808 | 1131 |
1132 if patcherr: | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1133 self.ui.warn( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
1134 _(b"patch failed, rejects left in working directory\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1135 ) |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1136 err = 2 |
1808 | 1137 break |
1138 | |
1139 if fuzz and strict: | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1140 self.ui.warn(_(b"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
|
1141 err = 3 |
1808 | 1142 break |
1143 return (err, n) | |
1144 | |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1145 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
|
1146 if not keep: |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1147 r = self.qrepo() |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1148 if r: |
14435
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
1149 r[None].forget(patches) |
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
1150 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
|
1151 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
|
1152 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
|
1153 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
|
1154 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
|
1155 raise |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1156 |
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
|
1157 qfinished = [] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1158 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
|
1159 qfinished = self.applied[:numrevs] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1160 del self.applied[:numrevs] |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1161 self.applieddirty = True |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1162 |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1163 unknown = [] |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1164 |
37525
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1165 sortedseries = [] |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1166 for p in patches: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1167 idx = self.findseries(p) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1168 if idx is None: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1169 sortedseries.append((-1, p)) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1170 else: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1171 sortedseries.append((idx, p)) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1172 |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1173 sortedseries.sort(reverse=True) |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1174 for (i, p) in sortedseries: |
a7de62adcf03
py3: workaround comparing NoneType and integers
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37522
diff
changeset
|
1175 if i != -1: |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1176 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
|
1177 else: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1178 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
|
1179 |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1180 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
|
1181 if numrevs: |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44435
diff
changeset
|
1182 rev = {entry.name: entry.node for entry in qfinished} |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1183 for p in unknown: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1184 msg = _(b'revision %s refers to unknown patches: %s\n') |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
1185 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
|
1186 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1187 msg = _(b'unknown patches: %s\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1188 raise error.Abort(b''.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
|
1189 |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
1190 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1191 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
|
1192 return [entry.node for entry in qfinished] |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1193 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1194 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
|
1195 firstrev = repo[self.applied[0].node].rev() |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1196 patches = [] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1197 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
|
1198 |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1199 if rev < firstrev: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1200 raise error.Abort(_(b'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
|
1201 |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1202 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
|
1203 base = self.applied[i].node |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1204 if ctx.node() != base: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1205 msg = _(b'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
|
1206 raise error.Abort(msg % rev) |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1207 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1208 patch = self.applied[i].name |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1209 for fmt in (b'[mq]: %s', b'imported patch %s'): |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1210 if ctx.description() == fmt % patch: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1211 msg = _(b'patch %s finalized without changeset message\n') |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1212 repo.ui.status(msg % patch) |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1213 break |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
1214 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1215 patches.append(patch) |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1216 return patches |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1217 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1218 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
|
1219 # 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
|
1220 # executed before we remove the patches. |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16656
diff
changeset
|
1221 repo._phasecache |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1222 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
|
1223 qfinished = self._cleanup(patches, len(patches)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1224 if qfinished and repo.ui.configbool(b'mq', b'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
|
1225 # 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
|
1226 oldqbase = repo[qfinished[0]] |
34562
c2d2e18f9700
mq: use the newcommitphase utility
Boris Feld <boris.feld@octobus.net>
parents:
34505
diff
changeset
|
1227 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
|
1228 if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1229 with repo.transaction(b'qfinish') as tr: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22057
diff
changeset
|
1230 phases.advanceboundary(repo, tr, tphase, qfinished) |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
1231 |
3088
dc784839516d
mq: add qdelete --forget option
Brendan Cully <brendan@kublai.com>
parents:
3087
diff
changeset
|
1232 def delete(self, repo, patches, opts): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1233 if not patches and not opts.get(b'rev'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1234 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
1235 _(b'qdelete requires at least one revision or patch name') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1236 ) |
4736
04b2c1e27c26
mq: require patch argument or revision for qdelete
Brendan Cully <brendan@kublai.com>
parents:
4730
diff
changeset
|
1237 |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
1238 realpatches = [] |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1239 for patch in patches: |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1240 patch = self.lookup(patch, strict=True) |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1241 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
|
1242 if info: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1243 raise error.Abort(_(b"cannot delete applied patch %s") % patch) |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1244 if patch not in self.series: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1245 raise error.Abort(_(b"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
|
1246 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
|
1247 realpatches.append(patch) |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1248 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1249 numrevs = 0 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1250 if opts.get(b'rev'): |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1251 if not self.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1252 raise error.Abort(_(b'no patches applied')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1253 revs = scmutil.revrange(repo, opts.get(b'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
|
1254 revs.sort() |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1255 revpatches = self._revpatches(repo, revs) |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
1256 realpatches += revpatches |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
1257 numrevs = len(revpatches) |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1258 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1259 self._cleanup(realpatches, numrevs, opts.get(b'keep')) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1260 |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1261 def checktoppatch(self, repo): |
18343
cfa731b45b75
mq: checktoppatch should only check if p1 is qtip
Mads Kiilerich <mads@kiilerich.com>
parents:
18342
diff
changeset
|
1262 '''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
|
1263 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
|
1264 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
|
1265 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
|
1266 if repo.dirstate.p1() != top: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1267 raise error.Abort(_(b"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
|
1268 return top, patch |
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1269 return None, None |
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1270 |
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
|
1271 def putsubstate2changes(self, substatestate, changes): |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1272 if isinstance(changes, list): |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1273 mar = changes[:3] |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1274 else: |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1275 mar = (changes.modified, changes.added, changes.removed) |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1276 if any((b'.hgsubstate' in files for files in mar)): |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1277 return # already listed up |
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
|
1278 # not yet listed up |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1279 if substatestate in b'a?': |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1280 mar[1].append(b'.hgsubstate') |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1281 elif substatestate in b'r': |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1282 mar[2].append(b'.hgsubstate') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1283 else: # modified |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1284 mar[0].append(b'.hgsubstate') |
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
|
1285 |
19812
5d6cfdc38a3d
mq: simplifies the refresh hint in checklocalchanges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19763
diff
changeset
|
1286 def checklocalchanges(self, repo, force=False, refresh=True): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1287 excsuffix = b'' |
14256
d04ba50e104d
mq: allow to qpop/push with a dirty working copy (issue2780)
Idan Kamara <idankk86@gmail.com>
parents:
14241
diff
changeset
|
1288 if refresh: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1289 excsuffix = b', qrefresh first' |
19812
5d6cfdc38a3d
mq: simplifies the refresh hint in checklocalchanges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19763
diff
changeset
|
1290 # plain versions for i18n tool to detect them |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1291 _(b"local changes found, qrefresh first") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1292 _(b"local changed subrepos found, qrefresh first") |
42489
cf445a212b9c
mq: remove dependency on strip's checklocalchanges()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42057
diff
changeset
|
1293 |
cf445a212b9c
mq: remove dependency on strip's checklocalchanges()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42057
diff
changeset
|
1294 s = repo.status() |
cf445a212b9c
mq: remove dependency on strip's checklocalchanges()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42057
diff
changeset
|
1295 if not force: |
42597
51e52a495214
mq: fix for merge detection methods
Taapas Agrawal <taapas2897@gmail.com>
parents:
42492
diff
changeset
|
1296 cmdutil.checkunfinished(repo) |
42489
cf445a212b9c
mq: remove dependency on strip's checklocalchanges()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42057
diff
changeset
|
1297 if s.modified or s.added or s.removed or s.deleted: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1298 _(b"local changes found") # i18n tool detection |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1299 raise error.Abort(_(b"local changes found" + excsuffix)) |
42489
cf445a212b9c
mq: remove dependency on strip's checklocalchanges()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42057
diff
changeset
|
1300 if checksubstate(repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1301 _(b"local changed subrepos found") # i18n tool detection |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1302 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1303 _(b"local changed subrepos found" + excsuffix) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1304 ) |
42597
51e52a495214
mq: fix for merge detection methods
Taapas Agrawal <taapas2897@gmail.com>
parents:
42492
diff
changeset
|
1305 else: |
51e52a495214
mq: fix for merge detection methods
Taapas Agrawal <taapas2897@gmail.com>
parents:
42492
diff
changeset
|
1306 cmdutil.checkunfinished(repo, skipmerge=True) |
42489
cf445a212b9c
mq: remove dependency on strip's checklocalchanges()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42057
diff
changeset
|
1307 return s |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
1308 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1309 _reserved = (b'series', b'status', b'guards', b'.', b'..') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1310 |
14584
3343a74eea4e
mq: rename check_reserved_name to checkreservedname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14583
diff
changeset
|
1311 def checkreservedname(self, name): |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1312 if name in self._reserved: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1313 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1314 _(b'"%s" cannot be used as the name of a patch') % name |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1315 ) |
31556
448acdee9161
mq: reject new patch name containing leading/trailing whitespace
Yuya Nishihara <yuya@tcha.org>
parents:
31460
diff
changeset
|
1316 if name != name.strip(): |
448acdee9161
mq: reject new patch name containing leading/trailing whitespace
Yuya Nishihara <yuya@tcha.org>
parents:
31460
diff
changeset
|
1317 # whitespace is stripped by parseseries() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1318 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
1319 _(b'patch name cannot begin or end with whitespace') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1320 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1321 for prefix in (b'.hg', b'.mq'): |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1322 if name.startswith(prefix): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1323 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1324 _(b'patch name cannot begin with "%s"') % prefix |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1325 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1326 for c in (b'#', b':', b'\r', b'\n'): |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1327 if c in name: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1328 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1329 _(b'%r cannot be used in the name of a patch') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1330 % pycompat.bytestr(c) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1331 ) |
14054
3c616f512a5b
mq: be more explicit on invalid patch name message
Idan Kamara <idankk86@gmail.com>
parents:
14052
diff
changeset
|
1332 |
14422
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1333 def checkpatchname(self, name, force=False): |
14584
3343a74eea4e
mq: rename check_reserved_name to checkreservedname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14583
diff
changeset
|
1334 self.checkreservedname(name) |
14422
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1335 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
|
1336 if os.path.isdir(self.join(name)): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1337 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1338 _(b'"%s" already exists as a directory') % name |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1339 ) |
14422
2e77525e52d9
mq: wrap patch file name checks in a function
Idan Kamara <idankk86@gmail.com>
parents:
14396
diff
changeset
|
1340 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1341 raise error.Abort(_(b'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
|
1342 |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1343 def makepatchname(self, title, fallbackname): |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1344 """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
|
1345 it unique in the existing list""" |
41532
bd3f03d8cc9f
global: use raw strings for regular expressions with escapes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41399
diff
changeset
|
1346 namebase = re.sub(br'[\s\W_]+', b'_', title.lower()).strip(b'_') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1347 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
|
1348 if namebase: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1349 try: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1350 self.checkreservedname(namebase) |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1351 except error.Abort: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1352 namebase = fallbackname |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1353 else: |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1354 namebase = fallbackname |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1355 name = namebase |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1356 i = 0 |
27919
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1357 while True: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1358 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
|
1359 try: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1360 self.checkpatchname(name) |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1361 break |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1362 except error.Abort: |
db24d6888896
mq: check for reserved patch name with qimport -r (issue5033)
Mads Kiilerich <madski@unity3d.com>
parents:
27918
diff
changeset
|
1363 pass |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1364 i += 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1365 name = b'%s__%d' % (namebase, i) |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1366 return name |
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
1367 |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1368 def checkkeepchanges(self, keepchanges, force): |
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1369 if force and keepchanges: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1370 raise error.Abort(_(b'cannot use both --force and --keep-changes')) |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1371 |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1372 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
|
1373 """options: |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
1374 msg: a string or a no-argument function returning a string |
7157
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
1375 """ |
36387
dbf34d0ef9f6
py3: use pycompat.byteskwargs() to fix keyword arguments handling
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36343
diff
changeset
|
1376 opts = pycompat.byteskwargs(opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1377 msg = opts.get(b'msg') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1378 edit = opts.get(b'edit') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1379 editform = opts.get(b'editform', b'mq.qnew') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1380 user = opts.get(b'user') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1381 date = opts.get(b'date') |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1382 if date: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36389
diff
changeset
|
1383 date = dateutil.parsedate(date) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1384 diffopts = self.diffopts({b'git': opts.get(b'git')}, plain=True) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1385 if opts.get(b'checkname', True): |
14424
4eb88d296f63
record: check patch name is valid before prompting in qrecord
Idan Kamara <idankk86@gmail.com>
parents:
14423
diff
changeset
|
1386 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
|
1387 inclsubs = checksubstate(repo) |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1388 if inclsubs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1389 substatestate = repo.dirstate[b'.hgsubstate'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1390 if opts.get(b'include') or opts.get(b'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
|
1391 # 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
|
1392 def badfn(f, msg): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1393 if f != b'.hgsubstate': # .hgsubstate is auto-created |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1394 raise error.Abort(b'%s: %s' % (f, msg)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1395 |
25469
cc3d94e5994e
mq: use the optional badfn argument when building a matcher
Matt Harbison <matt_harbison@yahoo.com>
parents:
25454
diff
changeset
|
1396 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
|
1397 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
|
1398 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
|
1399 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
|
1400 commitfiles = list(inclsubs) |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1401 commitfiles.extend(changes.modified) |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1402 commitfiles.extend(changes.added) |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1403 commitfiles.extend(changes.removed) |
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
|
1404 match = scmutil.matchfiles(repo, commitfiles) |
10372
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
1405 if len(repo[None].parents()) > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1406 raise error.Abort(_(b'cannot manage merge changesets')) |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1407 self.checktoppatch(repo) |
14585
74bf9c84cfd0
mq: rename full_series_end to fullseriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14584
diff
changeset
|
1408 insert = self.fullseriesend() |
27827
a5b168953013
with: use context manager for wlock in qnew
Bryan O'Sullivan <bryano@fb.com>
parents:
27651
diff
changeset
|
1409 with repo.wlock(): |
12878
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
1410 try: |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
1411 # if patch file write fails, abort early |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1412 p = self.opener(patchfn, b"w") |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
1413 except IOError as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1414 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1415 _(b'cannot write patch "%s": %s') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1416 % (patchfn, encoding.strtolocal(e.strerror)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1417 ) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1418 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1419 defaultmsg = b"[mq]: %s" % patchfn |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
1420 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
|
1421 if edit: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1422 |
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
|
1423 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
|
1424 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
|
1425 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
|
1426 else: |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1427 return defaultmsg |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1428 |
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
|
1429 # i18n: this message is shown in editor with "HG: " prefix |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1430 extramsg = _(b'Leave message empty to use default message.') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1431 editor = cmdutil.getcommiteditor( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1432 finishdesc=finishdesc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1433 extramsg=extramsg, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1434 editform=editform, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1435 ) |
21234
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1436 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
|
1437 else: |
b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20959
diff
changeset
|
1438 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
|
1439 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1440 n = newcommit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1441 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1442 None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1443 commitmsg, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1444 user, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1445 date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1446 match=match, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1447 force=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1448 editor=editor, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1449 ) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
1450 if n is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1451 raise error.Abort(_(b"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
|
1452 try: |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1453 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
|
1454 self.applied.append(statusentry(n, patchfn)) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
1455 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1456 self.seriesdirty = True |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1457 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
|
1458 nctx = repo[n] |
22547
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1459 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
|
1460 if user: |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1461 ph.setuser(user) |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1462 if date: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1463 ph.setdate(b'%d %d' % date) |
22547
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1464 ph.setparent(hex(nctx.p1().node())) |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1465 msg = nctx.description().strip() |
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1466 if msg == defaultmsg.strip(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1467 msg = b'' |
22547
3d616d27a422
mq: write headers of new patches using patchheader
Mads Kiilerich <madski@unity3d.com>
parents:
22546
diff
changeset
|
1468 ph.setmessage(msg) |
35948
f87641bf4d23
py3: use bytes instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35918
diff
changeset
|
1469 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
|
1470 if commitfiles: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1471 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
|
1472 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
|
1473 self.putsubstate2changes(substatestate, changes) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1474 chunks = patchmod.diff( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1475 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1476 node1=parent, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1477 node2=n, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1478 changes=changes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1479 opts=diffopts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1480 ) |
7308
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
1481 for chunk in chunks: |
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
1482 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
|
1483 p.close() |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1484 r = self.qrepo() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1485 if r: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
1486 r[None].add([patchfn]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1487 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
|
1488 repo.rollback() |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1489 raise |
7280
810ca383da9c
remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7271
diff
changeset
|
1490 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
|
1491 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
|
1492 try: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1493 os.unlink(patchpath) |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16687
diff
changeset
|
1494 except OSError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1495 self.ui.warn(_(b'error unlinking %s\n') % patchpath) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
1496 raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1497 self.removeundo(repo) |
1808 | 1498 |
1499 def isapplied(self, patch): | |
1500 """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
|
1501 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
|
1502 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
|
1503 return (i, a.node, a.name) |
1808 | 1504 return None |
1505 | |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
1506 # if the exact patch name does not exist, we try a few |
2696 | 1507 # variations. If strict is passed, we try only #1 |
1508 # | |
15256
8caf7a757afa
mq: fix corner cases for handling of patch 0 in qselect
Mads Kiilerich <mads@kiilerich.com>
parents:
15148
diff
changeset
|
1509 # 1) a number (as string) to indicate an offset in the series file |
2696 | 1510 # 2) a unique substring of the patch name was given |
1511 # 3) patchname[-+]num to indicate an offset in the series file | |
1512 def lookup(self, patch, strict=False): | |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1513 def partialname(s): |
2696 | 1514 if s in self.series: |
1515 return s | |
2765
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1516 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
|
1517 if len(matches) > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1518 self.ui.warn(_(b'patch name "%s" is ambiguous:\n') % s) |
2765
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1519 for m in matches: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1520 self.ui.warn(b' %s\n' % m) |
2765
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1521 return None |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1522 if matches: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1523 return matches[0] |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1524 if self.series and self.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1525 if s == b'qtip': |
18054
b35e3364f94a
check-code: there must also be whitespace between ')' and operator
Mads Kiilerich <madski@unity3d.com>
parents:
18011
diff
changeset
|
1526 return self.series[self.seriesend(True) - 1] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1527 if s == b'qbase': |
2696 | 1528 return self.series[0] |
1529 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
|
1530 |
12df451ce205
mq: don't warn about ambiguous patch name when using patch index (issue1439)
Jason Orendorff <jorendorff@mozilla.com>
parents:
7566
diff
changeset
|
1531 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
|
1532 return patch |
2696 | 1533 |
2819 | 1534 if not os.path.isfile(self.join(patch)): |
1808 | 1535 try: |
1536 sno = int(patch) | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1537 except (ValueError, OverflowError): |
2696 | 1538 pass |
1539 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
|
1540 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
|
1541 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
|
1542 |
2696 | 1543 if not strict: |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1544 res = partialname(patch) |
2696 | 1545 if res: |
1546 return res | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1547 minus = patch.rfind(b'-') |
3082
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1548 if minus >= 0: |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1549 res = partialname(patch[:minus]) |
2696 | 1550 if res: |
1551 i = self.series.index(res) | |
1552 try: | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1553 off = int(patch[minus + 1 :] or 1) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1554 except (ValueError, OverflowError): |
2696 | 1555 pass |
1556 else: | |
1557 if i - off >= 0: | |
1558 return self.series[i - off] | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1559 plus = patch.rfind(b'+') |
3082
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1560 if plus >= 0: |
14595
f2c9d4091e0e
mq: rename partial_name to partialname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14594
diff
changeset
|
1561 res = partialname(patch[:plus]) |
2696 | 1562 if res: |
1563 i = self.series.index(res) | |
1564 try: | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1565 off = int(patch[plus + 1 :] or 1) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1566 except (ValueError, OverflowError): |
2696 | 1567 pass |
1568 else: | |
1569 if i + off < len(self.series): | |
1570 return self.series[i + off] | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1571 raise error.Abort(_(b"patch %s not in series") % patch) |
1808 | 1572 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1573 def push( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1574 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1575 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1576 patch=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1577 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1578 list=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1579 mergeq=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1580 all=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1581 move=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1582 exact=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1583 nobackup=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1584 keepchanges=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1585 ): |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1586 self.checkkeepchanges(keepchanges, force) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1587 diffopts = self.diffopts() |
27828
823069f73ff9
with: use context manager for wlock in qpush
Bryan O'Sullivan <bryano@fb.com>
parents:
27827
diff
changeset
|
1588 with repo.wlock(): |
20119
1648e44edd8d
mq: prefer a loop to a double-for list comprehension
Kevin Bullock <kbullock@ringworld.org>
parents:
20053
diff
changeset
|
1589 heads = [] |
42002
662ffdde5adf
branchcache: rename itervalues() to iterheads()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41780
diff
changeset
|
1590 for hs in repo.branchmap().iterheads(): |
20119
1648e44edd8d
mq: prefer a loop to a double-for list comprehension
Kevin Bullock <kbullock@ringworld.org>
parents:
20053
diff
changeset
|
1591 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
|
1592 if not heads: |
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1593 heads = [nullid] |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13793
diff
changeset
|
1594 if repo.dirstate.p1() not in heads and not exact: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1595 self.ui.status(_(b"(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
|
1596 |
8795
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1597 if not self.series: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1598 self.ui.warn(_(b'no patches in series\n')) |
8795
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1599 return 0 |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1600 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1601 # 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
|
1602 # 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
|
1603 # 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
|
1604 # go backwards with qpush) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1605 if patch: |
15257
a8555f9908d1
mq: cleanup of lookup - handling of None is not relevant
Mads Kiilerich <mads@kiilerich.com>
parents:
15256
diff
changeset
|
1606 patch = self.lookup(patch) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1607 info = self.isapplied(patch) |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1608 if info and info[0] >= len(self.applied) - 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1609 self.ui.warn( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1610 _(b'qpush: %s is already at the top\n') % patch |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1611 ) |
11439
778377be3662
mq: explicit exit code when patch is already on top
Gilles Moris <gilles.moris@free.fr>
parents:
11438
diff
changeset
|
1612 return 0 |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1613 |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1614 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
|
1615 if pushable: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
1616 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
|
1617 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1618 _(b"cannot push to a previous patch: %s") % patch |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1619 ) |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1620 else: |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1621 if reason: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1622 reason = _(b'guarded by %s') % reason |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1623 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1624 reason = _(b'no matching guards') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1625 self.ui.warn( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1626 _(b"cannot push '%s' - %s\n") % (patch, reason) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1627 ) |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1628 return 1 |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1629 elif all: |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1630 patch = self.series[-1] |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1631 if self.isapplied(patch): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1632 self.ui.warn(_(b'all patches are currently applied\n')) |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1633 return 0 |
4100
c30c922f907a
Modify qpush/qpop idempotent operations to return success
Ben Thomas <bthomas@virtualiron.com>
parents:
4099
diff
changeset
|
1634 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1635 # 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
|
1636 # 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
|
1637 # 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
|
1638 # 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
|
1639 # 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
|
1640 start = self.seriesend() |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1641 if start == len(self.series): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1642 self.ui.warn(_(b'patch series already fully applied\n')) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1643 return 1 |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1644 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
|
1645 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
|
1646 |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1647 if exact: |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1648 if keepchanges: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
1649 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1650 _(b"cannot use --exact and --keep-changes together") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1651 ) |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1652 if move: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1653 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
1654 _(b'cannot use --exact and --move together') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1655 ) |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1656 if self.applied: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1657 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
1658 _(b'cannot push --exact with applied patches') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1659 ) |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1660 root = self.series[start] |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1661 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
|
1662 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
|
1663 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1664 _(b"%s does not have a parent recorded") % root |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1665 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1666 if not repo[target] == repo[b'.']: |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1667 hg.update(repo, target) |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1668 |
11064
590b1d6ef50b
mq: qpush --move, reorder patch series and apply only the patch
Mads Kiilerich <mads@kiilerich.com>
parents:
11050
diff
changeset
|
1669 if move: |
11715
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1670 if not patch: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1671 raise error.Abort(_(b"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
|
1672 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
|
1673 # 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
|
1674 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
|
1675 break |
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1676 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
|
1677 # 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
|
1678 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
|
1679 break |
16303
7ee8aa662937
mq: fix qpush --move with comments in series file between applied patches
Mads Kiilerich <mads@kiilerich.com>
parents:
16290
diff
changeset
|
1680 index = fullstart + i |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1681 assert index < len(self.fullseries) |
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1682 fullpatch = self.fullseries[index] |
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
1683 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
|
1684 self.fullseries.insert(fullstart, fullpatch) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
1685 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1686 self.seriesdirty = True |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1687 |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1688 self.applieddirty = True |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1689 if start > 0: |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1690 self.checktoppatch(repo) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1691 if not patch: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1692 patch = self.series[start] |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1693 end = start + 1 |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
1694 else: |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1695 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
|
1696 |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1697 tobackup = set() |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1698 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
|
1699 status = self.checklocalchanges(repo, force=True) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1700 if keepchanges: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1701 tobackup.update( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1702 status.modified |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1703 + status.added |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1704 + status.removed |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1705 + status.deleted |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1706 ) |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
1707 else: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1708 tobackup.update(status.modified + status.added) |
16634
435375cc0ca0
mq: backup local changes in qpush --force
Patrick Mezard <patrick@mezard.eu>
parents:
16633
diff
changeset
|
1709 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1710 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
|
1711 all_files = set() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1712 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1713 if mergeq: |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1714 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
|
1715 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1716 ret = self.apply( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1717 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1718 s, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1719 list, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1720 all_files=all_files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1721 tobackup=tobackup, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1722 keepchanges=keepchanges, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1723 ) |
24826
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
1724 except AbortNoCleanup: |
9b02b678888e
mq: avoid silent failure when single patch doesn't apply (issue4604)
Matt Mackall <mpm@selenic.com>
parents:
24365
diff
changeset
|
1725 raise |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1726 except: # re-raises |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1727 self.ui.warn(_(b'cleaning up working directory...\n')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1728 cmdutil.revert( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
1729 self.ui, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
1730 repo, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
1731 repo[b'.'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
1732 no_backup=True, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1733 ) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1734 # 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
|
1735 # 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
|
1736 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
|
1737 if f not in repo.dirstate: |
31309
8908f985570c
vfs: use repo.wvfs.unlinkpath
Mads Kiilerich <madski@unity3d.com>
parents:
31243
diff
changeset
|
1738 repo.wvfs.unlinkpath(f, ignoremissing=True) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1739 self.ui.warn(_(b'done\n')) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1740 raise |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1741 |
9590
07a62819b309
mq: fix traceback for qpush inexistant-patch with no patch applied
Benoit Allard <benoit@aeteurope.nl>
parents:
9588
diff
changeset
|
1742 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
|
1743 return ret[0] |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1744 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
|
1745 if ret[0] and ret[0] > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1746 msg = _(b"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
|
1747 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
|
1748 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1749 self.ui.write(_(b"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
|
1750 return ret[0] |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1751 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1752 def pop( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1753 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1754 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1755 patch=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1756 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1757 update=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1758 all=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1759 nobackup=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1760 keepchanges=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1761 ): |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1762 self.checkkeepchanges(keepchanges, force) |
27829
bab359a3cf49
with: use context manager for wlock in qpop
Bryan O'Sullivan <bryano@fb.com>
parents:
27828
diff
changeset
|
1763 with repo.wlock(): |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1764 if patch: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1765 # index, rev, patch |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1766 info = self.isapplied(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1767 if not info: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1768 patch = self.lookup(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1769 info = self.isapplied(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1770 if not info: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1771 raise error.Abort(_(b"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
|
1772 |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1773 if not self.applied: |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1774 # 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
|
1775 # but not qpop without an argument |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1776 self.ui.warn(_(b"no patches applied\n")) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1777 return not all |
1808 | 1778 |
7620
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1779 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
|
1780 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
|
1781 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
|
1782 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
|
1783 else: |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1784 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
|
1785 |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1786 if start >= len(self.applied): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1787 self.ui.warn(_(b"qpop: %s is already at the top\n") % patch) |
7620
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1788 return |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1789 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1790 if not update: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1791 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
|
1792 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
|
1793 for p in parents: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1794 if p in rr: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1795 self.ui.warn(_(b"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
|
1796 update = True |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1797 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
|
1798 parents = [p.node() for p in repo[None].parents()] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1799 update = any( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1800 entry.node in parents for entry in self.applied[start:] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1801 ) |
1808 | 1802 |
16633
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
1803 tobackup = set() |
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
1804 if update: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1805 s = self.checklocalchanges(repo, force=force or keepchanges) |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1806 if force: |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1807 if not nobackup: |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22821
diff
changeset
|
1808 tobackup.update(s.modified + s.added) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1809 elif keepchanges: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1810 tobackup.update( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1811 s.modified + s.added + s.removed + s.deleted |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1812 ) |
14732
e9ed3506f066
backout of d04ba50e104d: allow to qpop/push with a dirty working copy
Idan Kamara <idankk86@gmail.com>
parents:
14671
diff
changeset
|
1813 |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
1814 self.applieddirty = True |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1815 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
|
1816 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
|
1817 |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1818 try: |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1819 heads = repo.changelog.heads(rev) |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
1820 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
|
1821 node = short(rev) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1822 raise error.Abort(_(b'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
|
1823 |
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
|
1824 if heads != [self.applied[-1].node]: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1825 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1826 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1827 b"popping would remove a revision not " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1828 b"managed by this patch queue" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1829 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1830 ) |
16048
140b6282ac79
mq: prevent rewriting operation on public changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16043
diff
changeset
|
1831 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
|
1832 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1833 _(b"popping would remove a public revision"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1834 hint=_(b"see 'hg help phases' for details"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1835 ) |
5980
dcda0c90125c
mq: pop/refresh: avoid losing revisions not managed by mq
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5979
diff
changeset
|
1836 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1837 # 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
|
1838 # form of hg.update. |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1839 if update: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1840 qp = self.qparents(repo, rev) |
10663
85e81d9bfb7a
mq: simplify and use context API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10662
diff
changeset
|
1841 ctx = repo[qp] |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1842 st = repo.status(qp, b'.') |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1843 m, a, r, d = st.modified, st.added, st.removed, st.deleted |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1844 if d: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1845 raise error.Abort(_(b"deletions found between repo revs")) |
16633
b2ca2f40c9c1
mq: backup local changes in qpop --force (issue3433)
Patrick Mezard <patrick@mezard.eu>
parents:
16551
diff
changeset
|
1846 |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1847 tobackup = set(a + m + r) & tobackup |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
1848 if keepchanges and tobackup: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1849 raise error.Abort(_(b"local changes found, qrefresh first")) |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
1850 self.backup(repo, tobackup) |
32347
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1851 with repo.dirstate.parentchange(): |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1852 for f in a: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1853 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
|
1854 repo.dirstate.drop(f) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1855 for f in m + r: |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1856 fctx = ctx[f] |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1857 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
|
1858 repo.dirstate.normal(f) |
f4aee989ebec
mq: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
1859 repo.setparents(qp, nullid) |
9110
561ff8d9e4f0
mq: qpop now tells which patches are popped
Mads Kiilerich <mads@kiilerich.com>
parents:
9067
diff
changeset
|
1860 for patch in reversed(self.applied[start:end]): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1861 self.ui.status(_(b"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
|
1862 del self.applied[start:end] |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
1863 strip(self.ui, repo, [rev], update=False, backup=False) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1864 for s, state in repo[b'.'].substate.items(): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1865 repo[b'.'].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
|
1866 if self.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1867 self.ui.write(_(b"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
|
1868 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1869 self.ui.write(_(b"patch queue now empty\n")) |
1808 | 1870 |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
1871 def diff(self, repo, pats, opts): |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1872 top, patch = self.checktoppatch(repo) |
1808 | 1873 if not top: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1874 self.ui.write(_(b"no patches applied\n")) |
1808 | 1875 return |
1876 qp = self.qparents(repo, top) | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1877 if opts.get(b'reverse'): |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1878 node1, node2 = None, qp |
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1879 else: |
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1880 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
|
1881 diffopts = self.diffopts(opts, patch) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1882 self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts) |
1808 | 1883 |
2938
5b7a118f5b6c
allow qrefresh to take a list of files; closes #96.
Brendan Cully <brendan@kublai.com>
parents:
2937
diff
changeset
|
1884 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
|
1885 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
|
1886 if not self.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1887 self.ui.write(_(b"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
|
1888 return 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1889 msg = opts.get(b'msg', b'').rstrip() |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1890 edit = opts.get(b'edit') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1891 editform = opts.get(b'editform', b'mq.qrefresh') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1892 newuser = opts.get(b'user') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1893 newdate = opts.get(b'date') |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1894 if newdate: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1895 newdate = b'%d %d' % dateutil.parsedate(newdate) |
1808 | 1896 wlock = repo.wlock() |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1897 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1898 try: |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
1899 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
|
1900 (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
|
1901 if repo.changelog.heads(top) != [top]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1902 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1903 _(b"cannot qrefresh a revision with children") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1904 ) |
16048
140b6282ac79
mq: prevent rewriting operation on public changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16043
diff
changeset
|
1905 if not repo[top].mutable(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1906 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1907 _(b"cannot qrefresh public revision"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1908 hint=_(b"see 'hg help phases' for details"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1909 ) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1910 |
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
|
1911 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
|
1912 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
|
1913 |
37381
76823340a899
mq: avoid a silly conversion from binary nodeid to hex
Martin von Zweigbergk <martinvonz@google.com>
parents:
37262
diff
changeset
|
1914 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
|
1915 if inclsubs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1916 substatestate = repo.dirstate[b'.hgsubstate'] |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1917 |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
1918 ph = patchheader(self.join(patchfn), self.plainmode) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1919 diffopts = self.diffopts( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1920 {b'git': opts.get(b'git')}, patchfn, plain=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
1921 ) |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
1922 if newuser: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1923 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
|
1924 if newdate: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1925 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
|
1926 ph.setparent(hex(patchparent)) |
5180
5bbbd1f1d586
mq: truncate patch just before rewriting header
Brendan Cully <brendan@kublai.com>
parents:
4930
diff
changeset
|
1927 |
7400
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1928 # only commit new patch when write is complete |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1929 patchf = self.opener(patchfn, b'w', atomictemp=True) |
7400
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1930 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1931 # 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
|
1932 # and then commit. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1933 # |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1934 # this should really read: |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1935 # st = repo.status(top, patchparent) |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17424
diff
changeset
|
1936 # 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
|
1937 # caching against the next repo.status call |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1938 st = repo.status(patchparent, top) |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1939 mm, aa, dd = st.modified, st.added, st.removed |
41779
6ed520c3e932
mq: slightly modernize by using context object
Martin von Zweigbergk <martinvonz@google.com>
parents:
41599
diff
changeset
|
1940 ctx = repo[top] |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1941 aaa = aa[:] |
34083
08346a8fa65f
cleanup: rename "matchfn" to "match" where obviously a matcher
Martin von Zweigbergk <martinvonz@google.com>
parents:
34022
diff
changeset
|
1942 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
|
1943 # 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
|
1944 # patch already plus specified files |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1945 if opts.get(b'short'): |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1946 # 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
|
1947 # 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
|
1948 match = scmutil.matchfiles(repo, mm + aa + dd + match1.files()) |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17191
diff
changeset
|
1949 # 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
|
1950 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
|
1951 else: |
14322
a90131b85fd8
scmutil: drop aliases in cmdutil for match functions
Matt Mackall <mpm@selenic.com>
parents:
14319
diff
changeset
|
1952 match = scmutil.matchall(repo) |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1953 stb = repo.status(match=match) |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1954 m, a, r, d = stb.modified, stb.added, stb.removed, stb.deleted |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1955 mm = set(mm) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1956 aa = set(aa) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1957 dd = set(dd) |
1808 | 1958 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1959 # 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
|
1960 # 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
|
1961 # 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
|
1962 # show up in the added section |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1963 for x in m: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1964 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
|
1965 mm.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1966 # 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
|
1967 # 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
|
1968 # show up in the changed section. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1969 for x in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1970 if x in dd: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1971 dd.remove(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1972 mm.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1973 else: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1974 aa.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1975 # 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
|
1976 # 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
|
1977 forget = [] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1978 for x in d + r: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1979 if x in aa: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1980 aa.remove(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1981 forget.append(x) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1982 continue |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1983 else: |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1984 mm.discard(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1985 dd.add(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1986 |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1987 m = list(mm) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1988 r = list(dd) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1989 a = list(aa) |
17888
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1990 |
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18371
diff
changeset
|
1991 # 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
|
1992 # apply match1 via repo.status to ensure correct case handling. |
43640
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1993 st = repo.status(patchparent, match=match1) |
2d5b991c2192
mq: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
1994 cm, ca, cr, cd = st.modified, st.added, st.removed, st.deleted |
17888
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1995 allmatches = set(cm + ca + cr + cd) |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1996 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
|
1997 |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1998 files = set(inclsubs) |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
1999 for x in refreshchanges: |
20827
ca5dd216cb62
localrepo: omit ".hgsubstate" also from "added" files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20790
diff
changeset
|
2000 files.update(x) |
17888
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
2001 match = scmutil.matchfiles(repo, files) |
39b7052b217b
mq: fix qrefresh case sensitivity (issue3271)
Durham Goode <durham@fb.com>
parents:
17887
diff
changeset
|
2002 |
17730
6c6987761e42
mq: update bookmarks during qrefresh
David Soria Parra <dsp@php.net>
parents:
17708
diff
changeset
|
2003 bmlist = repo[top].bookmarks() |
1808 | 2004 |
24997
12f3c7144a39
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24996
diff
changeset
|
2005 dsguard = None |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2006 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2007 dsguard = dirstateguard.dirstateguard(repo, b'mq.refresh') |
10368 | 2008 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
|
2009 copies = {} |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2010 for dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2011 src = repo.dirstate.copied(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2012 # 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
|
2013 # 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
|
2014 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
|
2015 copies.setdefault(src, []).append(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2016 repo.dirstate.add(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2017 # 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
|
2018 for dst in aaa: |
41780
18f619d3b1bb
mq: get copy source from context object instead of from filelog
Martin von Zweigbergk <martinvonz@google.com>
parents:
41779
diff
changeset
|
2019 src = ctx[dst].copysource() |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2020 if src: |
41780
18f619d3b1bb
mq: get copy source from context object instead of from filelog
Martin von Zweigbergk <martinvonz@google.com>
parents:
41779
diff
changeset
|
2021 copies.setdefault(src, []).extend( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2022 copies.get(dst, []) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2023 ) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2024 if dst in a: |
41780
18f619d3b1bb
mq: get copy source from context object instead of from filelog
Martin von Zweigbergk <martinvonz@google.com>
parents:
41779
diff
changeset
|
2025 copies[src].append(dst) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2026 # 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
|
2027 if dst in copies: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2028 del copies[dst] |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43090
diff
changeset
|
2029 for src, dsts in pycompat.iteritems(copies): |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2030 for dst in dsts: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2031 repo.dirstate.copy(src, dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2032 else: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2033 for dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2034 repo.dirstate.add(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2035 # Drop useless copy information |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2036 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
|
2037 repo.dirstate.copy(None, f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2038 for f in r: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2039 repo.dirstate.remove(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2040 # 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
|
2041 # 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
|
2042 mm = [] |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
2043 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
|
2044 if not match1(m[i]): |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2045 mm.append(m[i]) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2046 del m[i] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2047 for f in m: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2048 repo.dirstate.normal(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2049 for f in mm: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2050 repo.dirstate.normallookup(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2051 for f in forget: |
14434
cc8c09855d19
dirstate: rename forget to drop
Matt Mackall <mpm@selenic.com>
parents:
14424
diff
changeset
|
2052 repo.dirstate.drop(f) |
1808 | 2053 |
41779
6ed520c3e932
mq: slightly modernize by using context object
Martin von Zweigbergk <martinvonz@google.com>
parents:
41599
diff
changeset
|
2054 user = ph.user or ctx.user() |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2055 |
16026
31c02546e6de
qrefresh: keep changeset phase during refresh
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16017
diff
changeset
|
2056 oldphase = repo[top].phase() |
31c02546e6de
qrefresh: keep changeset phase during refresh
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16017
diff
changeset
|
2057 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2058 # 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
|
2059 repo.setparents(*cparents) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2060 self.applied.pop() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
2061 self.applieddirty = True |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
2062 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
|
2063 dsguard.close() |
12f3c7144a39
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24996
diff
changeset
|
2064 finally: |
12f3c7144a39
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24996
diff
changeset
|
2065 release(dsguard) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2066 |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2067 try: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2068 # 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
|
2069 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2070 defaultmsg = b"[mq]: %s" % patchfn |
22003
cbbd957358ff
mq: pass 'editform' argument to 'cmdutil.getcommiteditor'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21965
diff
changeset
|
2071 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
|
2072 if edit: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2073 |
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
|
2074 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
|
2075 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
|
2076 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
|
2077 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
|
2078 return defaultmsg |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2079 |
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
|
2080 # i18n: this message is shown in editor with "HG: " prefix |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2081 extramsg = _(b'Leave message empty to use default message.') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2082 editor = cmdutil.getcommiteditor( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2083 finishdesc=finishdesc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2084 extramsg=extramsg, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2085 editform=editform, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2086 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2087 message = msg or b"\n".join(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
|
2088 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
|
2089 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
|
2090 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
|
2091 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2092 message = b"\n".join(ph.message) |
21235
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
2093 else: |
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
2094 message = msg |
51069bf6366b
qrefresh: relocate message/patch-header handling to delay message determination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21234
diff
changeset
|
2095 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
|
2096 |
16100
24df9338aa01
mq: ensure all mq commits are made with secretcommit()
Patrick Mezard <patrick@mezard.eu>
parents:
16064
diff
changeset
|
2097 # 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
|
2098 # the old one. |
27001
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
2099 lock = tr = None |
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
2100 try: |
c07a2fd31970
mq: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27000
diff
changeset
|
2101 lock = repo.lock() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2102 tr = repo.transaction(b'mq') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2103 n = newcommit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2104 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2105 oldphase, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2106 message, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2107 user, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2108 ph.date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2109 match=match, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2110 force=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2111 editor=editor, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2112 ) |
27000
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2113 # 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
|
2114 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
|
2115 if inclsubs: |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2116 self.putsubstate2changes(substatestate, c) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2117 chunks = patchmod.diff( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2118 repo, patchparent, changes=c, opts=diffopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2119 ) |
35948
f87641bf4d23
py3: use bytes instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35918
diff
changeset
|
2120 comments = bytes(ph) |
27000
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2121 if comments: |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2122 patchf.write(comments) |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2123 for chunk in chunks: |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2124 patchf.write(chunk) |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2125 patchf.close() |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2126 |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2127 marks = repo._bookmarks |
33489
870560c759ed
bookmark: use 'applychanges' in the mq extension
Boris Feld <boris.feld@octobus.net>
parents:
32375
diff
changeset
|
2128 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
|
2129 tr.close() |
27000
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2130 |
05d8db5d2116
mq: indentation change to make the next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
26943
diff
changeset
|
2131 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
|
2132 finally: |
30070
3006d0d26ad3
mq: release lock after transaction in qrefresh
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29968
diff
changeset
|
2133 lockmod.release(tr, lock) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2134 except: # re-raises |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2135 ctx = repo[cparents[0]] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2136 repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2137 self.savedirty() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2138 self.ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2139 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2140 b'qrefresh interrupted while patch was popped! ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2141 b'(revert --all, qpush to recover)\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2142 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2143 ) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
2144 raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
2145 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
2146 wlock.release() |
7401
41e87b4d0c9d
mq: recover more gracefully from interrupted qrefresh (issue1216)
Brendan Cully <brendan@kublai.com>
parents:
7400
diff
changeset
|
2147 self.removeundo(repo) |
1808 | 2148 |
2149 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
|
2150 if not create and os.path.isdir(self.path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2151 raise error.Abort(_(b"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
|
2152 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
|
2153 os.mkdir(self.path) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25469
diff
changeset
|
2154 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
|
2155 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
|
2156 raise |
1808 | 2157 if create: |
2158 return self.qrepo(create=True) | |
2159 | |
2160 def unapplied(self, repo, patch=None): | |
2161 if patch and patch not in self.series: | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2162 raise error.Abort(_(b"patch %s is not in series file") % patch) |
1808 | 2163 if not patch: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2164 start = self.seriesend() |
1808 | 2165 else: |
2166 start = self.series.index(patch) + 1 | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2167 unapplied = [] |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
2168 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
|
2169 pushable, reason = self.pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2170 if pushable: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2171 unapplied.append((i, self.series[i])) |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
2172 self.explainpushable(i) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2173 return unapplied |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2174 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2175 def qseries( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2176 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2177 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2178 missing=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2179 start=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2180 length=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2181 status=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2182 summary=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2183 ): |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
2184 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
|
2185 if pfx: |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
2186 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
|
2187 if summary: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
2188 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
|
2189 if ph.message: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2190 msg = ph.message[0] |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2191 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2192 msg = b'' |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2193 |
11327
6c469f2f9f12
mq: use ui.formatted() instead of ui.plain().
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11321
diff
changeset
|
2194 if self.ui.formatted(): |
12689
c52c629ce19e
termwidth: move to ui.ui from util
Augie Fackler <durin42@gmail.com>
parents:
12682
diff
changeset
|
2195 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
|
2196 if width > 0: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36668
diff
changeset
|
2197 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
|
2198 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2199 msg = b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2200 self.ui.write(patchname, label=b'qseries.' + state) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2201 self.ui.write(b': ') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2202 self.ui.write(msg, label=b'qseries.message.' + state) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2203 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2204 self.ui.write(patchname, label=b'qseries.' + state) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2205 self.ui.write(b'\n') |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2206 |
42057
566daffc607d
cleanup: use set literals where possible
Martin von Zweigbergk <martinvonz@google.com>
parents:
42002
diff
changeset
|
2207 applied = {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
|
2208 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
|
2209 length = len(self.series) - start |
1808 | 2210 if not missing: |
9016
894c5b4be275
mq: align columns in verbose qseries output.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
8948
diff
changeset
|
2211 if self.ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2212 idxwidth = len(b"%d" % (start + length - 1)) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
2213 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
|
2214 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
|
2215 if patch in applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2216 char, state = b'A', b'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
|
2217 elif self.pushable(i)[0]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2218 char, state = b'U', b'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
|
2219 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2220 char, state = b'G', b'guarded' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2221 pfx = b'' |
1808 | 2222 if self.ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2223 pfx = b'%*d %s ' % (idxwidth, i, char) |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
2224 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
|
2225 continue |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
2226 displayname(pfx, patch, state) |
1808 | 2227 else: |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2228 msng_list = [] |
1808 | 2229 for root, dirs, files in os.walk(self.path): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2230 d = root[len(self.path) + 1 :] |
1808 | 2231 for f in files: |
2232 fl = os.path.join(d, f) | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2233 if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2234 fl not in self.series |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2235 and fl |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2236 not in ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2237 self.statuspath, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2238 self.seriespath, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2239 self.guardspath, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2240 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2241 and not fl.startswith(b'.') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2242 ): |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2243 msng_list.append(fl) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8188
diff
changeset
|
2244 for x in sorted(msng_list): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2245 pfx = self.ui.verbose and b'D ' or b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2246 displayname(pfx, x, b'missing') |
1808 | 2247 |
2248 def issaveline(self, l): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2249 if l.name == b'.hg.patches.save.line': |
1808 | 2250 return True |
2251 | |
2252 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
|
2253 ui = self.baseui.copy() |
34918
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
2254 # 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
|
2255 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
|
2256 ui.pageractive = self.ui.pageractive |
274811627808
mq: copy pager attributes back to qrepo.ui
Yuya Nishihara <yuya@tcha.org>
parents:
34562
diff
changeset
|
2257 # internal config: ui.formatted |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2258 ui.setconfig( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2259 b'ui', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2260 b'formatted', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2261 self.ui.config(b'ui', b'formatted'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2262 b'mqpager', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2263 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2264 ui.setconfig( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2265 b'ui', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2266 b'interactive', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2267 self.ui.config(b'ui', b'interactive'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2268 b'mqpager', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2269 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2270 if create or os.path.isdir(self.join(b".hg")): |
11965
77f1f206e135
mq: don't inherit default and default-push paths with --mq (issue2333)
Mads Kiilerich <mads@kiilerich.com>
parents:
11715
diff
changeset
|
2271 return hg.repository(ui, path=self.path, create=create) |
1808 | 2272 |
2273 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
|
2274 desc = repo[rev].description().strip() |
1808 | 2275 lines = desc.splitlines() |
2276 datastart = None | |
2277 series = [] | |
2278 applied = [] | |
2279 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
|
2280 for i, line in enumerate(lines): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2281 if line == b'Patch Data:': |
1808 | 2282 datastart = i + 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2283 elif line.startswith(b'Dirstate:'): |
8632
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
2284 l = line.rstrip() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2285 l = l[10:].split(b' ') |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2286 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
|
2287 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
|
2288 l = line.rstrip() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2289 n, name = l.split(b':', 1) |
10683
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
2290 if n: |
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
2291 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
|
2292 else: |
10682
8ed350051896
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10681
diff
changeset
|
2293 series.append(l) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
2294 if datastart is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2295 self.ui.warn(_(b"no saved patch data found\n")) |
1808 | 2296 return 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2297 self.ui.warn(_(b"restoring status: %s\n") % lines[0]) |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
2298 self.fullseries = series |
1808 | 2299 self.applied = applied |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
2300 self.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
2301 self.seriesdirty = True |
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
2302 self.applieddirty = True |
1808 | 2303 heads = repo.changelog.heads() |
2304 if delete: | |
2305 if rev not in heads: | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2306 self.ui.warn(_(b"save entry has children, leaving it alone\n")) |
1808 | 2307 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2308 self.ui.warn(_(b"removing save entry %s\n") % short(rev)) |
1808 | 2309 pp = repo.dirstate.parents() |
2310 if rev in pp: | |
2311 update = True | |
2312 else: | |
2313 update = False | |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22049
diff
changeset
|
2314 strip(self.ui, repo, [rev], update=update, backup=False) |
1808 | 2315 if qpp: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2316 self.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2317 _(b"saved queue repository parents: %s %s\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2318 % (short(qpp[0]), short(qpp[1])) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2319 ) |
1808 | 2320 if qupdate: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2321 self.ui.status(_(b"updating queue directory\n")) |
1808 | 2322 r = self.qrepo() |
2323 if not r: | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2324 self.ui.warn(_(b"unable to load queue repository\n")) |
1808 | 2325 return 1 |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2804
diff
changeset
|
2326 hg.clean(r, qpp[0]) |
1808 | 2327 |
2328 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
|
2329 if not self.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2330 self.ui.warn(_(b"save: no patches applied, exiting\n")) |
1808 | 2331 return 1 |
2332 if self.issaveline(self.applied[-1]): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2333 self.ui.warn(_(b"status is already saved\n")) |
1808 | 2334 return 1 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2335 |
1808 | 2336 if not msg: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2337 msg = _(b"hg patches saved state") |
1808 | 2338 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2339 msg = b"hg patches: " + msg.rstrip(b'\r\n') |
1808 | 2340 r = self.qrepo() |
2341 if r: | |
2342 pp = r.dirstate.parents() | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2343 msg += b"\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1])) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2344 msg += b"\n\nPatch Data:\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2345 msg += b''.join(b'%s\n' % x for x in self.applied) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2346 msg += b''.join(b':%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
|
2347 n = repo.commit(msg, force=True) |
1808 | 2348 if not n: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2349 self.ui.warn(_(b"repo commit failed\n")) |
1808 | 2350 return 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2351 self.applied.append(statusentry(n, b'.hg.patches.save.line')) |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
2352 self.applieddirty = True |
4209
dbc3846c09a1
Merge with -stable, fix small test failure
Matt Mackall <mpm@selenic.com>
parents:
4207
diff
changeset
|
2353 self.removeundo(repo) |
1808 | 2354 |
14585
74bf9c84cfd0
mq: rename full_series_end to fullseriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14584
diff
changeset
|
2355 def fullseriesend(self): |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
2356 if self.applied: |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
2357 p = self.applied[-1].name |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
2358 end = self.findseries(p) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
2359 if end is None: |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
2360 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
|
2361 return end + 1 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
2362 return 0 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
2363 |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2364 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
|
2365 """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
|
2366 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
|
2367 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
|
2368 """ |
1808 | 2369 end = 0 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2370 |
19500
a96565abbd59
mq: rename next() to nextpatch() to avoid confusing a future check-code patch
Augie Fackler <raf@durin42.com>
parents:
19481
diff
changeset
|
2371 def nextpatch(start): |
10687
583adcf63f80
mq: use xrange/enumerate instead of += 1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10686
diff
changeset
|
2372 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
|
2373 return start |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
2374 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
|
2375 p, reason = self.pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2376 if p: |
16063
c36db39b3fee
mq: fix qnext when all remaining patches are guarded
Patrick Mezard <pmezard@gmail.com>
parents:
16048
diff
changeset
|
2377 return i |
14579
f7b25764d974
mq: rename explain_pushable to explainpushable
Adrian Buehlmann <adrian@cadifra.com>
parents:
14578
diff
changeset
|
2378 self.explainpushable(i) |
16063
c36db39b3fee
mq: fix qnext when all remaining patches are guarded
Patrick Mezard <pmezard@gmail.com>
parents:
16048
diff
changeset
|
2379 return len(self.series) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2380 |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
2381 if self.applied: |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
2382 p = self.applied[-1].name |
1808 | 2383 try: |
2384 end = self.series.index(p) | |
2385 except ValueError: | |
2386 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
|
2387 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
|
2388 return nextpatch(end) |
1808 | 2389 |
2390 def appliedname(self, index): | |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
2391 pname = self.applied[index].name |
1808 | 2392 if not self.ui.verbose: |
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
2393 p = pname |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
2394 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2395 p = (b"%d" % self.series.index(pname)) + b" " + pname |
1808 | 2396 return p |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2397 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2398 def qimport( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2399 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2400 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2401 files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2402 patchname=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2403 rev=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2404 existing=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2405 force=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2406 git=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2407 ): |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2408 def checkseries(patchname): |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2409 if patchname in self.series: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2410 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2411 _(b'patch %s is already in the series file') % patchname |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2412 ) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2413 |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2414 if rev: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2415 if files: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2416 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
2417 _(b'option "-r" not valid when importing files') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2418 ) |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14298
diff
changeset
|
2419 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
|
2420 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
|
2421 elif not files: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2422 raise error.Abort(_(b'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
|
2423 if (len(files) > 1 or len(rev) > 1) and patchname: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2424 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
2425 _(b'option "-n" not valid when importing multiple patches') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2426 ) |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2427 imported = [] |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2428 if rev: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2429 # 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
|
2430 # 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
|
2431 # 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
|
2432 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
|
2433 if len(heads) > 1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2434 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
2435 _(b'revision %d is the root of more than one branch') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2436 % rev.last() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2437 ) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2438 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
|
2439 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
|
2440 if base in [n.node for n in self.applied]: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2441 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2442 _(b'revision %d is already managed') % rev.first() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2443 ) |
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
|
2444 if heads != [self.applied[-1].node]: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2445 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
2446 _(b'revision %d is not the parent of the queue') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2447 % rev.first() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2448 ) |
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
|
2449 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
|
2450 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
|
2451 else: |
22821
5d4c17d11d7e
qimport: use `first` and `last` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22819
diff
changeset
|
2452 if heads != [repo.changelog.node(rev.first())]: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2453 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2454 _(b'revision %d has unmanaged children') % rev.first() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2455 ) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2456 lastparent = None |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2457 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2458 diffopts = self.diffopts({b'git': git}) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2459 with repo.transaction(b'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
|
2460 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
|
2461 if not repo[r].mutable(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2462 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2463 _(b'revision %d is not mutable') % r, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2464 hint=_(b"see 'hg help phases' " b'for details'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2465 ) |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2466 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
|
2467 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
|
2468 if p2 != nullrev: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2469 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2470 _(b'cannot import merge revision %d') % r |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2471 ) |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2472 if lastparent and lastparent != r: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2473 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
2474 _(b'revision %d is not the parent of %d') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2475 % (r, lastparent) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2476 ) |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2477 lastparent = p1 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2478 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2479 if not patchname: |
27918
c7cd551f07d0
mq: refactor makepatchname into class method
Mads Kiilerich <madski@unity3d.com>
parents:
27865
diff
changeset
|
2480 patchname = self.makepatchname( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2481 repo[r].description().split(b'\n', 1)[0], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2482 b'%d.diff' % r, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2483 ) |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2484 checkseries(patchname) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2485 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
|
2486 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
|
2487 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2488 with self.opener(patchname, b"w") as fp: |
37603
678d760c71ff
export: extract function to write patch to file object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37559
diff
changeset
|
2489 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
|
2490 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2491 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
|
2492 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
|
2493 |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2494 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
|
2495 imported.append(patchname) |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2496 patchname = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2497 if rev and repo.ui.configbool(b'mq', b'secret'): |
22049
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2498 # 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
|
2499 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
|
2500 self.parseseries() |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2501 self.applieddirty = True |
86c5318b8e5b
mq: wrap qimport phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22048
diff
changeset
|
2502 self.seriesdirty = True |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2503 |
10687
583adcf63f80
mq: use xrange/enumerate instead of += 1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10686
diff
changeset
|
2504 for i, filename in enumerate(files): |
1808 | 2505 if existing: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2506 if filename == b'-': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2507 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2508 _(b'-e is incompatible with import from -') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2509 ) |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2510 filename = normname(filename) |
14584
3343a74eea4e
mq: rename check_reserved_name to checkreservedname
Adrian Buehlmann <adrian@cadifra.com>
parents:
14583
diff
changeset
|
2511 self.checkreservedname(filename) |
20402 | 2512 if util.url(filename).islocal(): |
20394
a817964e7fdf
qimport: allow importing URLs
Matt Mackall <mpm@selenic.com>
parents:
20119
diff
changeset
|
2513 originpath = self.join(filename) |
a817964e7fdf
qimport: allow importing URLs
Matt Mackall <mpm@selenic.com>
parents:
20119
diff
changeset
|
2514 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
|
2515 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2516 _(b"patch %s does not exist") % filename |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2517 ) |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2518 |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2519 if patchname: |
14423 | 2520 self.checkpatchname(patchname, force) |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2521 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2522 self.ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2523 _(b'renaming %s to %s\n') % (filename, patchname) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2524 ) |
11701
84fb29f5e0d2
mq: fix qimport --name --existing --force on win32
Patrick Mezard <pmezard@gmail.com>
parents:
11700
diff
changeset
|
2525 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
|
2526 else: |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2527 patchname = filename |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
2528 |
1808 | 2529 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2530 if filename == b'-' and not patchname: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2531 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2532 _(b'need --name to import a patch from -') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2533 ) |
14395
dc961471efde
mq: check patch name is valid before reading imported file
Idan Kamara <idankk86@gmail.com>
parents:
14382
diff
changeset
|
2534 elif not patchname: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2535 patchname = normname( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2536 os.path.basename(filename.rstrip(b'/')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2537 ) |
14423 | 2538 self.checkpatchname(patchname, force) |
1808 | 2539 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2540 if filename == b'-': |
14636
b98063487a6f
mq: use ui.fin when importing patch from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14635
diff
changeset
|
2541 text = self.ui.fin.read() |
3547 | 2542 else: |
17887
0e2846b2482c
url: use open and not url.open for local files (issue3624)
Siddharth Agarwal <sid0@fb.com>
parents:
17773
diff
changeset
|
2543 fp = hg.openpath(self.ui, filename) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
2544 text = fp.read() |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
2545 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
|
2546 except (OSError, IOError): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2547 raise error.Abort(_(b"unable to read file %s") % filename) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2548 patchf = self.opener(patchname, b"w") |
1808 | 2549 patchf.write(text) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
2550 patchf.close() |
7160
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
2551 if not force: |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
2552 checkseries(patchname) |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
2553 if patchname not in self.series: |
14585
74bf9c84cfd0
mq: rename full_series_end to fullseriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14584
diff
changeset
|
2554 index = self.fullseriesend() + i |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
2555 self.fullseries[index:index] = [patchname] |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
2556 self.parseseries() |
14593
599a72895c0d
mq: rename series_dirty to seriesdirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14592
diff
changeset
|
2557 self.seriesdirty = True |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2558 self.ui.warn(_(b"adding %s to series file\n") % patchname) |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
2559 self.added.append(patchname) |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2560 imported.append(patchname) |
3133
15fde1970003
qimport: rename patch to patchname to avoid shadowing module
Brendan Cully <brendan@kublai.com>
parents:
3091
diff
changeset
|
2561 patchname = None |
1808 | 2562 |
13409
9e5df8719ad4
mq: remove undo after a qimport
André Sintzoff <andre.sintzoff@gmail.com>
parents:
13400
diff
changeset
|
2563 self.removeundo(repo) |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2564 return imported |
13409
9e5df8719ad4
mq: remove undo after a qimport
André Sintzoff <andre.sintzoff@gmail.com>
parents:
13400
diff
changeset
|
2565 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2566 |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
2567 def fixkeepchangesopts(ui, opts): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2568 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2569 not ui.configbool(b'mq', b'keepchanges') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2570 or opts.get(b'force') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2571 or opts.get(b'exact') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2572 ): |
16656
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2573 return opts |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2574 opts = dict(opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2575 opts[b'keep_changes'] = True |
16656
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2576 return opts |
4ae3ba9e4d7a
mq: introduce mq.check setting
Patrick Mezard <patrick@mezard.eu>
parents:
16655
diff
changeset
|
2577 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2578 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2579 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2580 b"qdelete|qremove|qrm", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2581 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2582 (b'k', b'keep', None, _(b'keep patch file')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2583 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2584 b'r', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2585 b'rev', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2586 [], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2587 _(b'stop managing a revision (DEPRECATED)'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2588 _(b'REV'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2589 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2590 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2591 _(b'hg qdelete [-k] [PATCH]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2592 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2593 ) |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
2594 def delete(ui, repo, *patches, **opts): |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
2595 """remove patches from queue |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
2596 |
15798
e6c44dbe902f
mq: Document that qdel requires exact patch identifiers
Olav Reinert <seroton10@gmail.com>
parents:
15322
diff
changeset
|
2597 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
|
2598 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
|
2599 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
|
2600 |
8be38b624902
mq: no longer mention the deprecated qdelete's --revision option
Cédric Duval <cedricduval@free.fr>
parents:
8894
diff
changeset
|
2601 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
|
2602 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
|
2603 q = repo.mq |
36281
d822f3fb6be8
py3: use pycompat.byteskwargs() to convert opts keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36107
diff
changeset
|
2604 q.delete(repo, patches, pycompat.byteskwargs(opts)) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2605 q.savedirty() |
1808 | 2606 return 0 |
2607 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2608 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2609 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2610 b"qapplied", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2611 [(b'1', b'last', None, _(b'show only the preceding applied patch'))] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2612 + seriesopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2613 _(b'hg qapplied [-1] [-s] [PATCH]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2614 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2615 ) |
1808 | 2616 def applied(ui, repo, patch=None, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2617 """print the patches already applied |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2618 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2619 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
|
2620 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2621 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2622 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
|
2623 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2624 if patch: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2625 if patch not in q.series: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2626 raise error.Abort(_(b"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
|
2627 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
|
2628 else: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2629 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
|
2630 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2631 if opts.get(b'last') and not end: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2632 ui.write(_(b"no patches applied\n")) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2633 return 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2634 elif opts.get(b'last') and end == 1: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2635 ui.write(_(b"only one patch applied\n")) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2636 return 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2637 elif opts.get(b'last'): |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2638 start = end - 2 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2639 end = 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2640 else: |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2641 start = 0 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2642 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2643 q.qseries( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2644 repo, length=end, start=start, status=b'A', summary=opts.get(b'summary') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2645 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2646 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2647 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2648 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2649 b"qunapplied", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2650 [(b'1', b'first', None, _(b'show only the first patch'))] + seriesopts, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2651 _(b'hg qunapplied [-1] [-s] [PATCH]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2652 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2653 ) |
1808 | 2654 def unapplied(ui, repo, patch=None, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2655 """print the patches not yet applied |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2656 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2657 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
|
2658 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2659 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2660 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
|
2661 if patch: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2662 if patch not in q.series: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2663 raise error.Abort(_(b"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
|
2664 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
|
2665 else: |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
2666 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
|
2667 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2668 if start == len(q.series) and opts.get(b'first'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2669 ui.write(_(b"all patches applied\n")) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2670 return 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
2671 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2672 if opts.get(b'first'): |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2673 length = 1 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2674 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2675 length = None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2676 q.qseries( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2677 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2678 start=start, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2679 length=length, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2680 status=b'U', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2681 summary=opts.get(b'summary'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2682 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2683 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2684 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2685 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2686 b"qimport", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2687 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2688 (b'e', b'existing', None, _(b'import file in patch directory')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2689 (b'n', b'name', b'', _(b'name of patch file'), _(b'NAME')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2690 (b'f', b'force', None, _(b'overwrite existing files')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2691 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2692 b'r', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2693 b'rev', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2694 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2695 _(b'place existing revisions under mq control'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2696 _(b'REV'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2697 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2698 (b'g', b'git', None, _(b'use git extended diff format')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2699 (b'P', b'push', None, _(b'qpush after importing')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2700 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2701 _(b'hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2702 helpcategory=command.CATEGORY_IMPORT_EXPORT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2703 ) |
1808 | 2704 def qimport(ui, repo, *filename, **opts): |
16152
816211dfa3a5
mq: expand qimport summary
Matt Mackall <mpm@selenic.com>
parents:
16128
diff
changeset
|
2705 """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
|
2706 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2707 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
|
2708 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
|
2709 to the series. |
d6caebe9c293
mq: qimport: explain insertion point in doc string
Adrian Buehlmann <adrian@cadifra.com>
parents:
6627
diff
changeset
|
2710 |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2711 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
|
2712 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
|
2713 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2714 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
|
2715 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
|
2716 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2717 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
|
2718 overwritten. |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
2719 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2720 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
|
2721 (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
|
2722 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
|
2723 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
|
2724 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
|
2725 and permission changes. Use :hg:`qfinish` to remove changesets |
42fc6c7c4ad5
mq: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
19395
diff
changeset
|
2726 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
|
2727 |
1f0a5a5fff43
Update qimport help explaining how to read a patch from stdin (Issue371)
David Frey <dpfrey@shaw.ca>
parents:
8028
diff
changeset
|
2728 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
|
2729 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
|
2730 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
|
2731 |
11706
5fdf08b6b50c
mq: correct qimport documentation
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11701
diff
changeset
|
2732 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
|
2733 |
52c863295754
mq: document possible combination of -e and -n for qimport
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11699
diff
changeset
|
2734 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
|
2735 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2736 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
|
2737 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2738 opts = pycompat.byteskwargs(opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2739 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
|
2740 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
|
2741 try: |
16119
5de83d9ca79c
mq: make qimport --push push all imported patches (issue3130)
Patrick Mezard <patrick@mezard.eu>
parents:
16101
diff
changeset
|
2742 imported = q.qimport( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2743 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2744 filename, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2745 patchname=opts.get(b'name'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2746 existing=opts.get(b'existing'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2747 force=opts.get(b'force'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2748 rev=opts.get(b'rev'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2749 git=opts.get(b'git'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2750 ) |
16027
29ea059be33c
qimport: when mq.secret=True set qimported revision as secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16026
diff
changeset
|
2751 finally: |
29ea059be33c
qimport: when mq.secret=True set qimported revision as secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16026
diff
changeset
|
2752 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
|
2753 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2754 if imported and opts.get(b'push') and not opts.get(b'rev'): |
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
|
2755 return q.push(repo, imported[-1]) |
1808 | 2756 return 0 |
2757 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2758 |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2759 def qinit(ui, repo, create): |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2760 """initialize a new queue repository |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
2761 |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2762 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
|
2763 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
|
2764 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
|
2765 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2766 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
|
2767 q = repo.mq |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2768 r = q.init(repo, create) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
2769 q.savedirty() |
1808 | 2770 if r: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2771 if not os.path.exists(r.wjoin(b'.hgignore')): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2772 fp = r.wvfs(b'.hgignore', b'w') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2773 fp.write(b'^\\.hg\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2774 fp.write(b'^\\.mq\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2775 fp.write(b'syntax: glob\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2776 fp.write(b'status\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2777 fp.write(b'guards\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
|
2778 fp.close() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2779 if not os.path.exists(r.wjoin(b'series')): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2780 r.wvfs(b'series', b'w').close() |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2781 r[None].add([b'.hgignore', b'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
|
2782 commands.add(ui, r) |
1808 | 2783 return 0 |
2784 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2785 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2786 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2787 b"qinit", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2788 [(b'c', b'create-repo', None, _(b'create queue repository'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2789 _(b'hg qinit [-c]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2790 helpcategory=command.CATEGORY_REPO_CREATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2791 helpbasic=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2792 ) |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2793 def init(ui, repo, **opts): |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2794 """init a new queue repository (DEPRECATED) |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2795 |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2796 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
|
2797 -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
|
2798 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
|
2799 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
|
2800 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
|
2801 |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2802 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
|
2803 commands. With -c, use :hg:`init --mq` instead.""" |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
2804 return qinit(ui, repo, create=opts.get('create_repo')) |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
2805 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2806 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2807 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2808 b"qclone", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2809 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2810 (b'', b'pull', None, _(b'use pull protocol to copy metadata')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2811 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2812 b'U', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2813 b'noupdate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2814 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2815 _(b'do not update the new working directories'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2816 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2817 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2818 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2819 b'uncompressed', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2820 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2821 _(b'use uncompressed transfer (fast over LAN)'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2822 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2823 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2824 b'p', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2825 b'patches', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2826 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2827 _(b'location of source patch repository'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2828 _(b'REPO'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2829 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2830 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2831 + cmdutil.remoteopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2832 _(b'hg qclone [OPTION]... SOURCE [DEST]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2833 helpcategory=command.CATEGORY_REPO_CREATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2834 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2835 ) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2836 def clone(ui, source, dest=None, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
2837 """clone main and patch repository at same time |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2838 |
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
2839 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
|
2840 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
|
2841 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
|
2842 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
|
2843 before that it has no patches applied. |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2844 |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2845 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
|
2846 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
|
2847 |
8760
bf17aeafb869
Spell Mercurial as a proper noun
timeless <timeless@gmail.com>
parents:
8711
diff
changeset
|
2848 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
|
2849 would be created by :hg:`init --mq`. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2850 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2851 Return 0 on success. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
2852 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
2853 opts = pycompat.byteskwargs(opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2854 |
5226
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2855 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
|
2856 """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
|
2857 url = repo.url() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2858 if url.endswith(b'/'): |
5226
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2859 url = url[:-1] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2860 return url + b'/.hg/patches' |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2861 |
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2862 # main repo (destination and sources) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2863 if dest is None: |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2864 dest = hg.defaultdest(source) |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2865 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
|
2866 |
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2867 # patches repo (source only) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2868 if opts.get(b'patches'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2869 patchespath = ui.expandpath(opts.get(b'patches')) |
7729
dd08e1e0cea1
mq: allow qclone's -p option to use path alias
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7639
diff
changeset
|
2870 else: |
dd08e1e0cea1
mq: allow qclone's -p option to use path alias
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7639
diff
changeset
|
2871 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
|
2872 try: |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2873 hg.peer(ui, opts, patchespath) |
7637 | 2874 except error.RepoError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2875 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
2876 _(b'versioned patch repository not found (see init --mq)') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2877 ) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2878 qbase, destrev = None, None |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2879 if sr.local(): |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2880 repo = sr.local() |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2881 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
|
2882 qbase = repo.mq.applied[0].node |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2883 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
|
2884 heads = set(repo.heads()) |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2885 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
|
2886 destrev.append(repo.changelog.parents(qbase)[0]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2887 elif sr.capable(b'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
|
2888 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2889 qbase = sr.lookup(b'qbase') |
7637 | 2890 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
|
2891 pass |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2892 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2893 ui.note(_(b'cloning main repository\n')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2894 sr, dr = hg.clone( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2895 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2896 opts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2897 sr.url(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2898 dest, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2899 pull=opts.get(b'pull'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2900 revs=destrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2901 update=False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2902 stream=opts.get(b'uncompressed'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2903 ) |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2904 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2905 ui.note(_(b'cloning patch repository\n')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2906 hg.clone( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2907 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2908 opts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2909 opts.get(b'patches') or patchdir(sr), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2910 patchdir(dr), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2911 pull=opts.get(b'pull'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2912 update=not opts.get(b'noupdate'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2913 stream=opts.get(b'uncompressed'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2914 ) |
15921
92e455f2866c
qclone: add a few comment and blank line
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15920
diff
changeset
|
2915 |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2916 if dr.local(): |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2917 repo = dr.local() |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2918 if qbase: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2919 ui.note( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2920 _( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2921 b'stripping applied patches from destination ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2922 b'repository\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2923 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2924 ) |
19819
f0fc4d5797e1
mq: extract `mq.queue.strip`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19818
diff
changeset
|
2925 strip(ui, repo, [qbase], update=False, backup=None) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2926 if not opts.get(b'noupdate'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2927 ui.note(_(b'updating destination repository\n')) |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
17153
diff
changeset
|
2928 hg.update(repo, repo.changelog.tip()) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2929 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2930 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2931 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2932 b"qcommit|qci", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2933 commands.table[b"commit|ci"][1], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2934 _(b'hg qcommit [OPTION]... [FILE]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2935 helpcategory=command.CATEGORY_COMMITTING, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2936 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2937 ) |
1808 | 2938 def commit(ui, repo, *pats, **opts): |
10361
49cd2e7fd91c
mq: deprecate qinit and qcommit
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10360
diff
changeset
|
2939 """commit changes in the queue repository (DEPRECATED) |
49cd2e7fd91c
mq: deprecate qinit and qcommit
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10360
diff
changeset
|
2940 |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11121
diff
changeset
|
2941 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
|
2942 q = repo.mq |
1808 | 2943 r = q.qrepo() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2944 if not r: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2945 raise error.Abort(b'no queue repository') |
1808 | 2946 commands.commit(r.ui, r, *pats, **opts) |
2947 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2948 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2949 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2950 b"qseries", |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
2951 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
2952 (b'm', b'missing', None, _(b'print patches not in series')), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
2953 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
2954 + seriesopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2955 _(b'hg qseries [-ms]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2956 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2957 ) |
1808 | 2958 def series(ui, repo, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2959 """print the entire series file |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2960 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2961 Returns 0 on success.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2962 repo.mq.qseries( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
2963 repo, missing=opts.get('missing'), summary=opts.get('summary') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2964 ) |
1808 | 2965 return 0 |
2966 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2967 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2968 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2969 b"qtop", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2970 seriesopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2971 _(b'hg qtop [-s]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2972 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2973 ) |
1808 | 2974 def top(ui, repo, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2975 """print the name of the current patch |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2976 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2977 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
|
2978 q = repo.mq |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2979 if q.applied: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2980 t = q.seriesend(True) |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2981 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2982 t = 0 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
23879
diff
changeset
|
2983 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2984 if t: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2985 q.qseries( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2986 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2987 start=t - 1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2988 length=1, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2989 status=b'A', |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
2990 summary=opts.get('summary'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2991 ) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2992 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2993 ui.write(_(b"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
|
2994 return 1 |
1808 | 2995 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2996 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2997 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2998 b"qnext", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
2999 seriesopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3000 _(b'hg qnext [-s]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3001 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3002 ) |
1808 | 3003 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
|
3004 """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
|
3005 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3006 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
|
3007 q = repo.mq |
14586
af91cb281975
mq: rename series_end to seriesend
Adrian Buehlmann <adrian@cadifra.com>
parents:
14585
diff
changeset
|
3008 end = q.seriesend() |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
3009 if end == len(q.series): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3010 ui.write(_(b"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
|
3011 return 1 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3012 q.qseries(repo, start=end, length=1, summary=opts.get('summary')) |
1808 | 3013 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3014 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3015 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3016 b"qprev", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3017 seriesopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3018 _(b'hg qprev [-s]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3019 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3020 ) |
1808 | 3021 def prev(ui, repo, **opts): |
16188
6b52963ced73
mq: fix qapplied --last and qprev documentation (issue3282)
Patrick Mezard <patrick@mezard.eu>
parents:
16119
diff
changeset
|
3022 """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
|
3023 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3024 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
|
3025 q = repo.mq |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
3026 l = len(q.applied) |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
3027 if l == 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3028 ui.write(_(b"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
|
3029 return 1 |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
3030 if not l: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3031 ui.write(_(b"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
|
3032 return 1 |
16064
7e5a281a082c
mq: make qprev return the previous applied patch (issue3245)
Patrick Mezard <pmezard@gmail.com>
parents:
16063
diff
changeset
|
3033 idx = q.series.index(q.applied[-2].name) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3034 q.qseries( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3035 repo, start=idx, length=1, status=b'A', summary=opts.get('summary') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3036 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3037 |
1808 | 3038 |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
3039 def setupheaderopts(ui, opts): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3040 if not opts.get(b'user') and opts.get(b'currentuser'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3041 opts[b'user'] = ui.username() |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3042 if not opts.get(b'date') and opts.get(b'currentdate'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3043 opts[b'date'] = b"%d %d" % dateutil.makedate() |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
3044 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3045 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3046 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3047 b"qnew", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3048 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3049 (b'e', b'edit', None, _(b'invoke editor on commit messages')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3050 (b'f', b'force', None, _(b'import uncommitted changes (DEPRECATED)')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3051 (b'g', b'git', None, _(b'use git extended diff format')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3052 (b'U', b'currentuser', None, _(b'add "From: <current user>" to patch')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3053 (b'u', b'user', b'', _(b'add "From: <USER>" to patch'), _(b'USER')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3054 (b'D', b'currentdate', None, _(b'add "Date: <current date>" to patch')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3055 (b'd', b'date', b'', _(b'add "Date: <DATE>" to patch'), _(b'DATE')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3056 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3057 + cmdutil.walkopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3058 + cmdutil.commitopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3059 _(b'hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3060 helpcategory=command.CATEGORY_COMMITTING, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3061 helpbasic=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3062 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3063 ) |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
3064 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
|
3065 """create a new patch |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
3066 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3067 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
|
3068 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
|
3069 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
|
3070 -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
|
3071 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
|
3072 as uncommitted modifications. |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
3073 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3074 -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
|
3075 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
|
3076 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
|
3077 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3078 -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
|
3079 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
|
3080 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
|
3081 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3082 Use the -g/--git option to keep the patch in the git extended diff |
7387 | 3083 format. Read the diffs help topic for more information on why this |
3084 is important for preserving permission changes and copy/rename | |
3085 information. | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3086 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3087 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
|
3088 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3089 opts = pycompat.byteskwargs(opts) |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
3090 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
|
3091 q = repo.mq |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3092 opts[b'msg'] = msg |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
3093 setupheaderopts(ui, opts) |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3094 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
|
3095 q.savedirty() |
1808 | 3096 return 0 |
3097 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3098 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3099 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3100 b"qrefresh", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3101 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3102 (b'e', b'edit', None, _(b'invoke editor on commit messages')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3103 (b'g', b'git', None, _(b'use git extended diff format')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3104 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3105 b's', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3106 b'short', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3107 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3108 _(b'refresh only files already in the patch and specified files'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3109 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3110 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3111 b'U', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3112 b'currentuser', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3113 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3114 _(b'add/update author field in patch with current user'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3115 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3116 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3117 b'u', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3118 b'user', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3119 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3120 _(b'add/update author field in patch with given user'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3121 _(b'USER'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3122 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3123 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3124 b'D', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3125 b'currentdate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3126 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3127 _(b'add/update date field in patch with current date'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3128 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3129 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3130 b'd', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3131 b'date', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3132 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3133 _(b'add/update date field in patch with given date'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3134 _(b'DATE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3135 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3136 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3137 + cmdutil.walkopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3138 + cmdutil.commitopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3139 _(b'hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3140 helpcategory=command.CATEGORY_COMMITTING, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3141 helpbasic=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3142 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3143 ) |
2938
5b7a118f5b6c
allow qrefresh to take a list of files; closes #96.
Brendan Cully <brendan@kublai.com>
parents:
2937
diff
changeset
|
3144 def refresh(ui, repo, *pats, **opts): |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3145 """update the current patch |
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3146 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3147 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
|
3148 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
|
3149 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
|
3150 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3151 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
|
3152 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
|
3153 |
11947
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
3154 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
|
3155 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
|
3156 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
|
3157 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3158 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
|
3159 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
|
3160 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
|
3161 git diff format. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3162 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3163 Returns 0 on success. |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3164 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3165 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
|
3166 q = repo.mq |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
3167 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
|
3168 setupheaderopts(ui, opts) |
27830
1c5941542f24
with: use context manager for wlock in qrefresh
Bryan O'Sullivan <bryano@fb.com>
parents:
27829
diff
changeset
|
3169 with repo.wlock(): |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3170 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
|
3171 q.savedirty() |
2b9c32929e62
mq: make qrefresh/qfold keep wlock until saving patch status
Yuya Nishihara <yuya@tcha.org>
parents:
14600
diff
changeset
|
3172 return ret |
1808 | 3173 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3174 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3175 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3176 b"qdiff", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3177 cmdutil.diffopts + cmdutil.diffopts2 + cmdutil.walkopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3178 _(b'hg qdiff [OPTION]... [FILE]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3179 helpcategory=command.CATEGORY_FILE_CONTENTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3180 helpbasic=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3181 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3182 ) |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
3183 def diff(ui, repo, *pats, **opts): |
6606
088ba40585b9
mq: expand help text for qdiff
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6561
diff
changeset
|
3184 """diff of the current patch and subsequent modifications |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
3185 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3186 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
|
3187 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
|
3188 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
|
3189 after a qrefresh). |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
3190 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10962
diff
changeset
|
3191 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
|
3192 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
|
3193 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
|
3194 qrefresh. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3195 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3196 Returns 0 on success. |
6606
088ba40585b9
mq: expand help text for qdiff
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6561
diff
changeset
|
3197 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3198 ui.pager(b'qdiff') |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3199 repo.mq.diff(repo, pats, pycompat.byteskwargs(opts)) |
1808 | 3200 return 0 |
3201 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3202 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3203 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3204 b'qfold', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3205 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3206 (b'e', b'edit', None, _(b'invoke editor on commit messages')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3207 (b'k', b'keep', None, _(b'keep folded patch files')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3208 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3209 + cmdutil.commitopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3210 _(b'hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3211 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3212 ) |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3213 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
|
3214 """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
|
3215 |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
3216 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
|
3217 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
|
3218 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
|
3219 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
|
3220 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
|
3221 removed afterwards. |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
3222 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3223 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
|
3224 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
|
3225 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3226 Returns 0 on success.""" |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3227 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
|
3228 q = repo.mq |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
3229 if not files: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3230 raise error.Abort(_(b'qfold requires at least one patch name')) |
14581
da40ee1adc2b
mq: rename check_toppatch to checktoppatch
Adrian Buehlmann <adrian@cadifra.com>
parents:
14580
diff
changeset
|
3231 if not q.checktoppatch(repo)[0]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3232 raise error.Abort(_(b'no patches applied')) |
14583
28f87e14d923
mq: rename check_localchanges to checklocalchanges
Adrian Buehlmann <adrian@cadifra.com>
parents:
14582
diff
changeset
|
3233 q.checklocalchanges(repo) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
3234 |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
3235 message = cmdutil.logmessage(ui, opts) |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3236 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3237 parent = q.lookup(b'qtip') |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
3238 patches = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
3239 messages = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
3240 for f in files: |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
3241 p = q.lookup(f) |
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
3242 if p in patches or p == parent: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3243 ui.warn(_(b'skipping already folded patch %s\n') % p) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
3244 if q.isapplied(p): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3245 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3246 _(b'qfold cannot fold already applied patch %s') % p |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3247 ) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
3248 patches.append(p) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
3249 |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
3250 for p in patches: |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3251 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
|
3252 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
|
3253 if ph.message: |
1d5ecaa47abb
mq: filter out empty commit messages in qfold
Brendan Cully <brendan@kublai.com>
parents:
7453
diff
changeset
|
3254 messages.append(ph.message) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
3255 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
|
3256 (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
|
3257 if not patchsuccess: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3258 raise error.Abort(_(b'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
|
3259 |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3260 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
|
3261 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
|
3262 message = ph.message |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3263 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
|
3264 if msg: |
2455e96ec73b
mq: don't add '* * *' separators when there is no commit message
Mads Kiilerich <madski@unity3d.com>
parents:
19997
diff
changeset
|
3265 if message: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3266 message.append(b'* * *') |
20053
2455e96ec73b
mq: don't add '* * *' separators when there is no commit message
Mads Kiilerich <madski@unity3d.com>
parents:
19997
diff
changeset
|
3267 message.extend(msg) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3268 message = b'\n'.join(message) |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3269 |
10186
296a0b14a686
mq: preserve --git flag when folding patches
Patrick Mezard <pmezard@gmail.com>
parents:
10185
diff
changeset
|
3270 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
|
3271 with repo.wlock(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3272 q.refresh( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3273 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3274 msg=message, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3275 git=diffopts.git, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3276 edit=opts.get(b'edit'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3277 editform=b'mq.qfold', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3278 ) |
14620
2b9c32929e62
mq: make qrefresh/qfold keep wlock until saving patch status
Yuya Nishihara <yuya@tcha.org>
parents:
14600
diff
changeset
|
3279 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
|
3280 q.savedirty() |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
3281 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3282 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3283 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3284 b"qgoto", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3285 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3286 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3287 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3288 b'keep-changes', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3289 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3290 _(b'tolerate non-conflicting local changes'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3291 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3292 (b'f', b'force', None, _(b'overwrite any local changes')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3293 (b'', b'no-backup', None, _(b'do not save backup copies of files')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3294 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3295 _(b'hg qgoto [OPTION]... PATCH'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3296 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3297 ) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
3298 def goto(ui, repo, patch, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3299 """push or pop patches until named patch is at top of stack |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3300 |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3301 Returns 0 on success.""" |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3302 opts = pycompat.byteskwargs(opts) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3303 opts = fixkeepchangesopts(ui, opts) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
3304 q = repo.mq |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
3305 patch = q.lookup(patch) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3306 nobackup = opts.get(b'no_backup') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3307 keepchanges = opts.get(b'keep_changes') |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
3308 if q.isapplied(patch): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3309 ret = q.pop( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3310 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3311 patch, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3312 force=opts.get(b'force'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3313 nobackup=nobackup, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3314 keepchanges=keepchanges, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3315 ) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
3316 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3317 ret = q.push( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3318 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3319 patch, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3320 force=opts.get(b'force'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3321 nobackup=nobackup, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3322 keepchanges=keepchanges, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3323 ) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3324 q.savedirty() |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
3325 return ret |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
3326 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3327 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3328 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3329 b"qguard", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3330 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3331 (b'l', b'list', None, _(b'list all patches and guards')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3332 (b'n', b'none', None, _(b'drop all guards')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3333 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3334 _(b'hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3335 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3336 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3337 def guard(ui, repo, *args, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3338 """set or print guards for a patch |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3339 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3340 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
|
3341 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
|
3342 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
|
3343 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
|
3344 has activated it. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3345 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3346 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
|
3347 With arguments, set guards for the named patch. |
12389 | 3348 |
3349 .. note:: | |
19997
de16c673455b
documentation: add an extra newline after note directive
Simon Heimberg <simohe@besonet.ch>
parents:
19951
diff
changeset
|
3350 |
12389 | 3351 Specifying negative guards now requires '--'. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3352 |
9824
87c92b260710
mq: fix literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9733
diff
changeset
|
3353 To set guards on another patch:: |
87c92b260710
mq: fix literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9733
diff
changeset
|
3354 |
10476
3113736dbac5
mq: more instructive use of "--" in qguard help (issue2040)
Martin Geisler <mg@lazybytes.net>
parents:
10413
diff
changeset
|
3355 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
|
3356 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3357 Returns 0 on success. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3358 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3359 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3360 def status(idx): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3361 guards = q.seriesguards[idx] or [b'unguarded'] |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
3362 if q.series[idx] in applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3363 state = b'applied' |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
3364 elif q.pushable(idx)[0]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3365 state = b'unapplied' |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
3366 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3367 state = b'guarded' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3368 label = b'qguard.patch qguard.%s qseries.%s' % (state, state) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3369 ui.write(b'%s: ' % ui.label(q.series[idx], label)) |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
3370 |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
3371 for i, guard in enumerate(guards): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3372 if guard.startswith(b'+'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3373 ui.write(guard, label=b'qguard.positive') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3374 elif guard.startswith(b'-'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3375 ui.write(guard, label=b'qguard.negative') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
3376 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3377 ui.write(guard, label=b'qguard.unguarded') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
3378 if i != len(guards) - 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3379 ui.write(b' ') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3380 ui.write(b'\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3381 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3382 q = repo.mq |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44435
diff
changeset
|
3383 applied = {p.name for p in q.applied} |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3384 patch = None |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3385 args = list(args) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3386 if opts.get('list'): |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3387 if args or opts.get('none'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3388 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
3389 _(b'cannot mix -l/--list with options or arguments') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3390 ) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
3391 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
|
3392 status(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3393 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3394 if not args or args[0][0:1] in b'-+': |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3395 if not q.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3396 raise error.Abort(_(b'no patches applied')) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3397 patch = q.applied[-1].name |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3398 if patch is None and args[0][0:1] not in b'-+': |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3399 patch = args.pop(0) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3400 if patch is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3401 raise error.Abort(_(b'no patch to work with')) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3402 if args or opts.get('none'): |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
3403 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
|
3404 if idx is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3405 raise error.Abort(_(b'no patch named %s') % patch) |
14577
76357276662e
mq: rename set_guards to setguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14576
diff
changeset
|
3406 q.setguards(idx, args) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3407 q.savedirty() |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3408 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3409 status(q.series.index(q.lookup(patch))) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3410 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3411 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3412 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3413 b"qheader", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3414 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3415 _(b'hg qheader [PATCH]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3416 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3417 ) |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
3418 def header(ui, repo, patch=None): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3419 """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
|
3420 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3421 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
|
3422 q = repo.mq |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
3423 |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
3424 if patch: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
3425 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
|
3426 else: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
3427 if not q.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3428 ui.write(_(b'no patches applied\n')) |
3008
c203ccd7d838
qheader: exit withh meaningful error code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3006
diff
changeset
|
3429 return 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3430 patch = q.lookup(b'qtip') |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
3431 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
|
3432 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3433 ui.write(b'\n'.join(ph.message) + b'\n') |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
3434 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3435 |
1808 | 3436 def lastsavename(path): |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
3437 (directory, base) = os.path.split(path) |
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
3438 names = os.listdir(directory) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3439 namere = re.compile(b"%s.([0-9]+)" % base) |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
3440 maxindex = None |
1808 | 3441 maxname = None |
3442 for f in names: | |
3443 m = namere.match(f) | |
3444 if m: | |
3445 index = int(m.group(1)) | |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
3446 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
|
3447 maxindex = index |
1808 | 3448 maxname = f |
3449 if maxname: | |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
3450 return (os.path.join(directory, maxname), maxindex) |
1808 | 3451 return (None, None) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3452 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3453 |
1808 | 3454 def savename(path): |
3455 (last, index) = lastsavename(path) | |
3456 if last is None: | |
3457 index = 0 | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3458 newpath = path + b".%d" % (index + 1) |
1808 | 3459 return newpath |
3460 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3461 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3462 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3463 b"qpush", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3464 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3465 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3466 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3467 b'keep-changes', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3468 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3469 _(b'tolerate non-conflicting local changes'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3470 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3471 (b'f', b'force', None, _(b'apply on top of local changes')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3472 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3473 b'e', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3474 b'exact', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3475 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3476 _(b'apply the target patch to its recorded parent'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3477 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3478 (b'l', b'list', None, _(b'list patch name in commit text')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3479 (b'a', b'all', None, _(b'apply all patches')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3480 (b'm', b'merge', None, _(b'merge from another queue (DEPRECATED)')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3481 (b'n', b'name', b'', _(b'merge queue name (DEPRECATED)'), _(b'NAME')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3482 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3483 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3484 b'move', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3485 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3486 _(b'reorder patch series and apply only the patch'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3487 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3488 (b'', b'no-backup', None, _(b'do not save backup copies of files')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3489 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3490 _(b'hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3491 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3492 helpbasic=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3493 ) |
1808 | 3494 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
|
3495 """push the next patch onto the stack |
6553
0bb76d168437
remove trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6552
diff
changeset
|
3496 |
16654
490ed8972f1b
mq: introduce qpush --check
Patrick Mezard <patrick@mezard.eu>
parents:
16653
diff
changeset
|
3497 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
|
3498 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
|
3499 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
|
3500 uncommitted changes. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3501 |
13725
6783f47d90dd
mq: fix typo in docstring
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
13632
diff
changeset
|
3502 Return 0 on success. |
6552
315b36ce6251
mq: add a little documentation on qpush -f
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6382
diff
changeset
|
3503 """ |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
3504 q = repo.mq |
1808 | 3505 mergeq = None |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3506 |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3507 opts = pycompat.byteskwargs(opts) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3508 opts = fixkeepchangesopts(ui, opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3509 if opts.get(b'merge'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3510 if opts.get(b'name'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3511 newpath = repo.vfs.join(opts.get(b'name')) |
1808 | 3512 else: |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3513 newpath, i = lastsavename(q.path) |
1808 | 3514 if not newpath: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3515 ui.warn(_(b"no saved queues found, please use -n\n")) |
1808 | 3516 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
|
3517 mergeq = queue(ui, repo.baseui, repo.path, newpath) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3518 ui.warn(_(b"merging with queue at: %s\n") % mergeq.path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3519 ret = q.push( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3520 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3521 patch, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3522 force=opts.get(b'force'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3523 list=opts.get(b'list'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3524 mergeq=mergeq, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3525 all=opts.get(b'all'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3526 move=opts.get(b'move'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3527 exact=opts.get(b'exact'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3528 nobackup=opts.get(b'no_backup'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3529 keepchanges=opts.get(b'keep_changes'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3530 ) |
1808 | 3531 return ret |
3532 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3533 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3534 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3535 b"qpop", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3536 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3537 (b'a', b'all', None, _(b'pop all patches')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3538 (b'n', b'name', b'', _(b'queue name to pop (DEPRECATED)'), _(b'NAME')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3539 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3540 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3541 b'keep-changes', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3542 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3543 _(b'tolerate non-conflicting local changes'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3544 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3545 (b'f', b'force', None, _(b'forget any local changes to patched files')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3546 (b'', b'no-backup', None, _(b'do not save backup copies of files')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3547 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3548 _(b'hg qpop [-a] [-f] [PATCH | INDEX]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3549 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3550 helpbasic=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3551 ) |
1808 | 3552 def pop(ui, repo, patch=None, **opts): |
6611
f4c612da788d
mq: add correct documentation for qpop
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6610
diff
changeset
|
3553 """pop the current patch off the stack |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
3554 |
16653
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3555 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
|
3556 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
|
3557 the top of the stack. |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3558 |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3559 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
|
3560 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
|
3561 overlap with patched files. With -f/--force, backup and discard |
73b8c2554be8
mq: introduce qpop --check
Patrick Mezard <patrick@mezard.eu>
parents:
16635
diff
changeset
|
3562 changes made to such files. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3563 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3564 Return 0 on success. |
6611
f4c612da788d
mq: add correct documentation for qpop
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6610
diff
changeset
|
3565 """ |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3566 opts = pycompat.byteskwargs(opts) |
16733
4da10c00a20c
mq: rename --check into --keep-changes
Patrick Mezard <patrick@mezard.eu>
parents:
16718
diff
changeset
|
3567 opts = fixkeepchangesopts(ui, opts) |
1808 | 3568 localupdate = True |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3569 if opts.get(b'name'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3570 q = queue(ui, repo.baseui, repo.path, repo.vfs.join(opts.get(b'name'))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3571 ui.warn(_(b'using patch queue: %s\n') % q.path) |
1808 | 3572 localupdate = False |
3573 else: | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
3574 q = repo.mq |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3575 ret = q.pop( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3576 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3577 patch, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3578 force=opts.get(b'force'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3579 update=localupdate, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3580 all=opts.get(b'all'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3581 nobackup=opts.get(b'no_backup'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3582 keepchanges=opts.get(b'keep_changes'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3583 ) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3584 q.savedirty() |
4099
cf5580c16b13
mq: propagate the return error of pop
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4096
diff
changeset
|
3585 return ret |
1808 | 3586 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3587 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3588 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3589 b"qrename|qmv", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3590 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3591 _(b'hg qrename PATCH1 [PATCH2]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3592 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3593 ) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3594 def rename(ui, repo, patch, name=None, **opts): |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3595 """rename a patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3596 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3597 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
|
3598 With two arguments, renames PATCH1 to PATCH2. |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3599 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3600 Returns 0 on success.""" |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3601 q = repo.mq |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3602 if not name: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3603 name = patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3604 patch = None |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3605 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3606 if patch: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3607 patch = q.lookup(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3608 else: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3609 if not q.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3610 ui.write(_(b'no patches applied\n')) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3611 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3612 patch = q.lookup(b'qtip') |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
3613 absdest = q.join(name) |
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
3614 if os.path.isdir(absdest): |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
3615 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
|
3616 absdest = q.join(name) |
14423 | 3617 q.checkpatchname(name) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3618 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3619 ui.note(_(b'renaming %s to %s\n') % (patch, name)) |
14574
12fba7bcb4f1
mq: rename find_series to findseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14573
diff
changeset
|
3620 i = q.findseries(patch) |
14572
8ff2957c1d82
mq: rename full_series to fullseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14564
diff
changeset
|
3621 guards = q.guard_re.findall(q.fullseries[i]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3622 q.fullseries[i] = name + b''.join([b' #' + g for g in guards]) |
14575
845c864200d0
mq: rename parse_series to parseseries
Adrian Buehlmann <adrian@cadifra.com>
parents:
14574
diff
changeset
|
3623 q.parseseries() |
15879
710e6bf15538
mq: consistently use boolean values for dirty flags
Mads Kiilerich <mads@kiilerich.com>
parents:
15878
diff
changeset
|
3624 q.seriesdirty = True |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3625 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3626 info = q.isapplied(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3627 if info: |
2818
bdc067ff6cf5
Make mq camelcase consistent with the rest of hg.
Brendan Cully <brendan@kublai.com>
parents:
2816
diff
changeset
|
3628 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
|
3629 q.applieddirty = True |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3630 |
11513
0c944b7af564
mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara <yuya@tcha.org>
parents:
11462
diff
changeset
|
3631 destdir = os.path.dirname(absdest) |
0c944b7af564
mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara <yuya@tcha.org>
parents:
11462
diff
changeset
|
3632 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
|
3633 os.makedirs(destdir) |
2819 | 3634 util.rename(q.join(patch), absdest) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3635 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
|
3636 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
|
3637 wctx = r[None] |
27848
9bda75a0c783
with: use context manager in qrename
Bryan O'Sullivan <bryano@fb.com>
parents:
27847
diff
changeset
|
3638 with r.wlock(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3639 if r.dirstate[patch] == b'a': |
14434
cc8c09855d19
dirstate: rename forget to drop
Matt Mackall <mpm@selenic.com>
parents:
14424
diff
changeset
|
3640 r.dirstate.drop(patch) |
6648
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
3641 r.dirstate.add(name) |
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
3642 else: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
3643 wctx.copy(patch, name) |
14435
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
3644 wctx.forget([patch]) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3645 |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3646 q.savedirty() |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3647 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3648 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3649 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3650 b"qrestore", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3651 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3652 (b'd', b'delete', None, _(b'delete save entry')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3653 (b'u', b'update', None, _(b'update queue working directory')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3654 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3655 _(b'hg qrestore [-d] [-u] REV'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3656 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3657 ) |
1808 | 3658 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
|
3659 """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
|
3660 |
12352
5be733b20bd1
mq: fix the deprecation comment for qsave & qrestore.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12344
diff
changeset
|
3661 This command is deprecated, use :hg:`rebase` instead.""" |
1808 | 3662 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
|
3663 q = repo.mq |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3664 q.restore(repo, rev, delete=opts.get('delete'), qupdate=opts.get('update')) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3665 q.savedirty() |
1808 | 3666 return 0 |
3667 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3668 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3669 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3670 b"qsave", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3671 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3672 (b'c', b'copy', None, _(b'copy patch directory')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3673 (b'n', b'name', b'', _(b'copy directory name'), _(b'NAME')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3674 (b'e', b'empty', None, _(b'clear queue status file')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3675 (b'f', b'force', None, _(b'force copy')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3676 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3677 + cmdutil.commitopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3678 _(b'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3679 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3680 ) |
1808 | 3681 def save(ui, repo, **opts): |
10360
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
3682 """save current queue state (DEPRECATED) |
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
3683 |
12352
5be733b20bd1
mq: fix the deprecation comment for qsave & qrestore.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12344
diff
changeset
|
3684 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
|
3685 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3686 opts = pycompat.byteskwargs(opts) |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14620
diff
changeset
|
3687 message = cmdutil.logmessage(ui, opts) |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
3688 ret = q.save(repo, msg=message) |
1808 | 3689 if ret: |
3690 return ret | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3691 q.savedirty() # save to .hg/patches before copying |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3692 if opts.get(b'copy'): |
1808 | 3693 path = q.path |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3694 if opts.get(b'name'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3695 newpath = os.path.join(q.basepath, opts.get(b'name')) |
1808 | 3696 if os.path.exists(newpath): |
3697 if not os.path.isdir(newpath): | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3698 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
3699 _(b'destination %s exists and is not a directory') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3700 % newpath |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3701 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3702 if not opts.get(b'force'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3703 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
3704 _(b'destination %s exists, use -f to force') % newpath |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3705 ) |
1808 | 3706 else: |
3707 newpath = savename(path) | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3708 ui.warn(_(b"copy %s to %s\n") % (path, newpath)) |
1808 | 3709 util.copyfiles(path, newpath) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3710 if opts.get(b'empty'): |
15880
02b135558756
mq: make qsave implementation more explicit
Mads Kiilerich <mads@kiilerich.com>
parents:
15879
diff
changeset
|
3711 del q.applied[:] |
02b135558756
mq: make qsave implementation more explicit
Mads Kiilerich <mads@kiilerich.com>
parents:
15879
diff
changeset
|
3712 q.applieddirty = True |
02b135558756
mq: make qsave implementation more explicit
Mads Kiilerich <mads@kiilerich.com>
parents:
15879
diff
changeset
|
3713 q.savedirty() |
1808 | 3714 return 0 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3715 |
1808 | 3716 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3717 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3718 b"qselect", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3719 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3720 (b'n', b'none', None, _(b'disable all guards')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3721 (b's', b'series', None, _(b'list all guards in series file')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3722 (b'', b'pop', None, _(b'pop to before first guarded applied patch')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3723 (b'', b'reapply', None, _(b'pop, then reapply patches')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3724 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3725 _(b'hg qselect [OPTION]... [GUARD]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3726 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3727 ) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3728 def select(ui, repo, *args, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3729 """set or print guarded patches to push |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3730 |
11307
7f72031d4047
mq: use hg reST role some more
Martin Geisler <mg@aragost.com>
parents:
11303
diff
changeset
|
3731 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
|
3732 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
|
3733 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
|
3734 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
|
3735 match the current guard. For example:: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3736 |
13791 | 3737 qguard foo.patch -- -stable (negative guard) |
3738 qguard bar.patch +stable (positive guard) | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3739 qselect stable |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3740 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3741 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
|
3742 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
|
3743 positive match). |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3744 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3745 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
|
3746 With one argument, sets the active guard. |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
3747 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3748 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
|
3749 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
|
3750 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
|
3751 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
3752 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
|
3753 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
|
3754 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
|
3755 --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
|
3756 guarded patches. |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3757 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3758 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
|
3759 (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
|
3760 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3761 Returns 0 on success.""" |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3762 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3763 q = repo.mq |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
3764 opts = pycompat.byteskwargs(opts) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3765 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
|
3766 pushable = lambda i: q.pushable(q.applied[i].name)[0] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3767 if args or opts.get(b'none'): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3768 old_unapplied = q.unapplied(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3769 old_guarded = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3770 i for i in pycompat.xrange(len(q.applied)) if not pushable(i) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3771 ] |
14578
28a2646f3b81
mq: rename set_active to setactive
Adrian Buehlmann <adrian@cadifra.com>
parents:
14577
diff
changeset
|
3772 q.setactive(args) |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3773 q.savedirty() |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3774 if not args: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3775 ui.status(_(b'guards deactivated\n')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3776 if not opts.get(b'pop') and not opts.get(b'reapply'): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3777 unapplied = q.unapplied(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3778 guarded = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3779 i for i in pycompat.xrange(len(q.applied)) if not pushable(i) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3780 ] |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3781 if len(unapplied) != len(old_unapplied): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3782 ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3783 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3784 b'number of unguarded, unapplied patches has ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3785 b'changed from %d to %d\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3786 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3787 % (len(old_unapplied), len(unapplied)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3788 ) |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3789 if len(guarded) != len(old_guarded): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3790 ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3791 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3792 b'number of guarded, applied patches has changed ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3793 b'from %d to %d\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3794 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3795 % (len(old_guarded), len(guarded)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3796 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3797 elif opts.get(b'series'): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3798 guards = {} |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3799 noguards = 0 |
14573
d590ff1f22b2
mq: rename series_guards to seriesguards
Adrian Buehlmann <adrian@cadifra.com>
parents:
14572
diff
changeset
|
3800 for gs in q.seriesguards: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3801 if not gs: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3802 noguards += 1 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3803 for g in gs: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3804 guards.setdefault(g, 0) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3805 guards[g] += 1 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3806 if ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3807 guards[b'NONE'] = noguards |
36282
3e1139b7d617
py3: explicitly convert result of dict.items() into list
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36281
diff
changeset
|
3808 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
|
3809 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
|
3810 if guards: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3811 ui.note(_(b'guards in series file:\n')) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3812 for guard, count in guards: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3813 ui.note(b'%2d ' % count) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3814 ui.write(guard, b'\n') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3815 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3816 ui.note(_(b'no guards in series file\n')) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3817 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3818 if guards: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3819 ui.note(_(b'active guards:\n')) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3820 for g in guards: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3821 ui.write(g, b'\n') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3822 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3823 ui.write(_(b'no active guards\n')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3824 reapply = opts.get(b'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
|
3825 popped = False |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3826 if opts.get(b'pop') or opts.get(b'reapply'): |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38050
diff
changeset
|
3827 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
|
3828 if not pushable(i): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3829 ui.status(_(b'popping guarded patches\n')) |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3830 popped = True |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3831 if i == 0: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3832 q.pop(repo, all=True) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3833 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
|
3834 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
|
3835 break |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3836 if popped: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3837 try: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3838 if reapply: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3839 ui.status(_(b'reapplying unguarded patches\n')) |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3840 q.push(repo, reapply) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
3841 finally: |
14580
92101ea35015
mq: rename save_dirty to savedirty
Adrian Buehlmann <adrian@cadifra.com>
parents:
14579
diff
changeset
|
3842 q.savedirty() |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
3843 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3844 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3845 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3846 b"qfinish", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3847 [(b'a', b'applied', None, _(b'finish all applied changesets'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3848 _(b'hg qfinish [-a] [REV]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3849 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3850 ) |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3851 def finish(ui, repo, *revrange, **opts): |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3852 """move applied patches into repository history |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3853 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3854 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
|
3855 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
|
3856 history. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3857 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
3858 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
|
3859 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
|
3860 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
|
3861 stack of applied patches. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3862 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3863 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
|
3864 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
|
3865 to upstream. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3866 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3867 Returns 0 on success. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3868 """ |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3869 if not opts.get('applied') and not revrange: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3870 raise error.Abort(_(b'no revisions specified')) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
3871 elif opts.get('applied'): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3872 revrange = (b'qbase::qtip',) + revrange |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3873 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3874 q = repo.mq |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3875 if not q.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3876 ui.status(_(b'no patches applied\n')) |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3877 return 0 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3878 |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14298
diff
changeset
|
3879 revs = scmutil.revrange(repo, revrange) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3880 if repo[b'.'].rev() in revs and repo[None].files(): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3881 ui.warn(_(b'warning: uncommitted changes in the working directory\n')) |
17512 | 3882 # 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
|
3883 # 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
|
3884 # responsibility for this locking. |
27847
71853c0ba592
with: use context manager in qfinish
Bryan O'Sullivan <bryano@fb.com>
parents:
27832
diff
changeset
|
3885 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
|
3886 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
|
3887 q.savedirty() |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3888 return 0 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3889 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3890 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3891 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3892 b"qqueue", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3893 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3894 (b'l', b'list', False, _(b'list all available queues')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3895 (b'', b'active', False, _(b'print name of active queue')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3896 (b'c', b'create', False, _(b'create new queue')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3897 (b'', b'rename', False, _(b'rename active queue')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3898 (b'', b'delete', False, _(b'delete reference to queue')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3899 (b'', b'purge', False, _(b'delete queue, and remove patch dir')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3900 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3901 _(b'[OPTION] [QUEUE]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3902 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3903 ) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3904 def qqueue(ui, repo, name=None, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3905 """manage multiple patch queues |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3906 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3907 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
|
3908 new patch queues and deleting existing ones. |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3909 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3910 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
|
3911 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
|
3912 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
|
3913 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
|
3914 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3915 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
|
3916 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
|
3917 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
|
3918 created and switching will fail. |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3919 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3920 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
|
3921 active queue. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3922 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
3923 Returns 0 on success. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
3924 """ |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3925 q = repo.mq |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3926 _defaultqueue = b'patches' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3927 _allqueues = b'patches.queues' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3928 _activequeue = b'patches.queue' |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3929 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3930 def _getcurrent(): |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3931 cur = os.path.basename(q.path) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3932 if cur.startswith(b'patches-'): |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3933 cur = cur[8:] |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3934 return cur |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3935 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3936 def _noqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3937 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3938 fh = repo.vfs(_allqueues, b'r') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3939 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3940 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3941 return True |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3942 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3943 return False |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3944 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3945 def _getqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3946 current = _getcurrent() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3947 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3948 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3949 fh = repo.vfs(_allqueues, b'r') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3950 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
|
3951 fh.close() |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3952 if current not in queues: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3953 queues.append(current) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3954 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3955 queues = [_defaultqueue] |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3956 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3957 return sorted(queues) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3958 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3959 def _setactive(name): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3960 if q.applied: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3961 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3962 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3963 b'new queue created, but cannot make active ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3964 b'as patches are applied' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3965 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
3966 ) |
11938
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
3967 _setactivenocheck(name) |
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
3968 |
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
3969 def _setactivenocheck(name): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3970 fh = repo.vfs(_activequeue, b'w') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3971 if name != b'patches': |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3972 fh.write(name) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3973 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3974 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3975 def _addqueue(name): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3976 fh = repo.vfs(_allqueues, b'a') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3977 fh.write(b'%s\n' % (name,)) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3978 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3979 |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3980 def _queuedir(name): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3981 if name == b'patches': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3982 return repo.vfs.join(b'patches') |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3983 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3984 return repo.vfs.join(b'patches-' + name) |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3985 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3986 def _validname(name): |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3987 for n in name: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3988 if n in b':\\/.': |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3989 return False |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3990 return True |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
3991 |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3992 def _delete(name): |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3993 if name not in existing: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3994 raise error.Abort(_(b'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
|
3995 |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3996 current = _getcurrent() |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3997 |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
3998 if name == current: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3999 raise error.Abort(_(b'cannot delete currently active queue')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4000 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4001 fh = repo.vfs(b'patches.queues.new', b'w') |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
4002 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
|
4003 if queue == name: |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
4004 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4005 fh.write(b'%s\n' % (queue,)) |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
4006 fh.close() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4007 repo.vfs.rename(b'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
|
4008 |
34505
91250ff7d48a
py3: fix keyword arguments handling in mq
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34184
diff
changeset
|
4009 opts = pycompat.byteskwargs(opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4010 if not name or opts.get(b'list') or opts.get(b'active'): |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
4011 current = _getcurrent() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4012 if opts.get(b'active'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4013 ui.write(b'%s\n' % (current,)) |
14987
3709cca378ff
mq/qqueue: print current queue name
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14943
diff
changeset
|
4014 return |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
4015 for queue in _getqueues(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4016 ui.write(b'%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
|
4017 if queue == current and not ui.quiet: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4018 ui.write(_(b' (active)\n')) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
4019 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4020 ui.write(b'\n') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
4021 return |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
4022 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
4023 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
|
4024 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4025 _(b'invalid queue name, may not contain the characters ":\\/."') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4026 ) |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
4027 |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4028 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
|
4029 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
|
4030 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4031 if opts.get(b'create'): |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4032 if name in existing: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4033 raise error.Abort(_(b'queue "%s" already exists') % 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
|
4034 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
|
4035 _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
|
4036 _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
|
4037 _setactive(name) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4038 elif opts.get(b'rename'): |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4039 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
|
4040 if name == current: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4041 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4042 _(b'can\'t rename "%s" to its current name') % name |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4043 ) |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4044 if name in existing: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4045 raise error.Abort(_(b'queue "%s" already exists') % 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
|
4046 |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4047 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
|
4048 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
|
4049 |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4050 if os.path.exists(newdir): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4051 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4052 _(b'non-queue directory "%s" already exists') % newdir |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4053 ) |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4054 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4055 fh = repo.vfs(b'patches.queues.new', b'w') |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4056 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
|
4057 if queue == current: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4058 fh.write(b'%s\n' % (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
|
4059 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
|
4060 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
|
4061 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4062 fh.write(b'%s\n' % (queue,)) |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4063 fh.close() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4064 repo.vfs.rename(b'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
|
4065 _setactivenocheck(name) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4066 elif opts.get(b'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
|
4067 _delete(name) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4068 elif opts.get(b'purge'): |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4069 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
|
4070 _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
|
4071 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
|
4072 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
|
4073 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
|
4074 else: |
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4075 if name not in existing: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4076 raise error.Abort(_(b'use --create to create a new queue')) |
29752
8a8c1c4b8f24
mq: take wlock when 'qqueue' is doing write operations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29127
diff
changeset
|
4077 _setactive(name) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
4078 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4079 |
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
|
4080 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
|
4081 """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
|
4082 if repo.mq.applied: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4083 if repo.ui.configbool(b'mq', b'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
|
4084 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
|
4085 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
|
4086 mqphase = phases.draft |
15972
341c58282b25
mq: pass qbase node instead of mq statusentry in phasedefaults
Augie Fackler <durin42@gmail.com>
parents:
15952
diff
changeset
|
4087 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
|
4088 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
|
4089 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
|
4090 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4091 |
1808 | 4092 def reposetup(ui, repo): |
2818
bdc067ff6cf5
Make mq camelcase consistent with the rest of hg.
Brendan Cully <brendan@kublai.com>
parents:
2816
diff
changeset
|
4093 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
|
4094 @localrepo.unfilteredpropertycache |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
4095 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
|
4096 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
|
4097 |
20628
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20442
diff
changeset
|
4098 def invalidateall(self): |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20442
diff
changeset
|
4099 super(mqrepo, self).invalidateall() |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
4100 if localrepo.hasunfilteredcache(self, 'mq'): |
20629
277dc5f27310
cmdserver: recreate mq object on runcommand in case queue path was changed
Yuya Nishihara <yuya@tcha.org>
parents:
20628
diff
changeset
|
4101 # recreate mq in case queue path was changed |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
4102 delattr(self.unfiltered(), 'mq') |
20628
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20442
diff
changeset
|
4103 |
14596
6a0070d00bc8
mq: rename abort_if_wdir_patched to abortifwdirpatched
Adrian Buehlmann <adrian@cadifra.com>
parents:
14595
diff
changeset
|
4104 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
|
4105 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
|
4106 parents = self.dirstate.parents() |
9510ddf87c43
mq: forbid commit of merge involving mq patches
Martin Geisler <mg@aragost.com>
parents:
13508
diff
changeset
|
4107 patches = [s.node for s in self.mq.applied] |
41373
b5f5dc0fa908
mq: slightly simplify check for patched working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
40995
diff
changeset
|
4108 if any(p in patches for p in parents): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26578
diff
changeset
|
4109 raise error.Abort(errmsg) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
4110 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4111 def commit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4112 self, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4113 text=b"", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4114 user=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4115 date=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4116 match=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4117 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4118 editor=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4119 extra=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4120 ): |
31407
b8848750a3c1
mq: don't use mutable default argument value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31394
diff
changeset
|
4121 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
|
4122 extra = {} |
14596
6a0070d00bc8
mq: rename abort_if_wdir_patched to abortifwdirpatched
Adrian Buehlmann <adrian@cadifra.com>
parents:
14595
diff
changeset
|
4123 self.abortifwdirpatched( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4124 _(b'cannot commit over an applied mq patch'), force |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4125 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4126 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4127 return super(mqrepo, self).commit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4128 text, user, date, match, force, editor, extra |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4129 ) |
2845
addd03c7fbfa
Disallow commit over an applied mq patch.
Brendan Cully <brendan@kublai.com>
parents:
2844
diff
changeset
|
4130 |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20827
diff
changeset
|
4131 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
|
4132 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
|
4133 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
|
4134 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
|
4135 # 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
|
4136 # 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
|
4137 # pushed. |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20827
diff
changeset
|
4138 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
|
4139 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
|
4140 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
|
4141 break |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
4142 else: |
ec8a9e06cf05
mq-safety: don't apply safety on non-outgoing changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15934
diff
changeset
|
4143 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
|
4144 # 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
|
4145 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
|
4146 if self[node].phase() < phases.secret: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4147 raise error.Abort(_(b'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
|
4148 # 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
|
4149 super(mqrepo, self).checkpush(pushop) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
4150 |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4151 def _findtags(self): |
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4152 '''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
|
4153 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
|
4154 |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
4155 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
|
4156 if not q.applied: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4157 return result |
2663
96950d39171d
Mq: modify repo.lookup to resolve applied patches too.
Brendan Cully <brendan@kublai.com>
parents:
2554
diff
changeset
|
4158 |
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
|
4159 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
|
4160 |
13508
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
4161 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
|
4162 # 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
|
4163 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
|
4164 except error.LookupError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4165 self.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4166 _(b'mq status file refers to unknown node %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4167 % short(mqtags[-1][0]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4168 ) |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4169 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
|
4170 |
18662
c5f7e83d47cd
mq: comply with filtering when injecting fake tags (issue3812)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18644
diff
changeset
|
4171 # 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
|
4172 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
|
4173 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
|
4174 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
|
4175 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
|
4176 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4177 mqtags.append((mqtags[-1][0], b'qtip')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4178 mqtags.append((mqtags[0][0], b'qbase')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4179 mqtags.append((self.changelog.parents(mqtags[0][0])[0], b'qparent')) |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4180 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
|
4181 for patch in mqtags: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4182 if patch[1] in tags: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4183 self.ui.warn( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
4184 _(b'tag %s overrides mq patch of the same name\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4185 % patch[1] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4186 ) |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
4187 else: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4188 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
|
4189 |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
4190 return result |
2664
9b8df8dceeed
Add qtip and qbase to mq qlookup.
Brendan Cully <brendan@kublai.com>
parents:
2663
diff
changeset
|
4191 |
2851
82f50658c72b
mq: only add mq attribute to local repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
4192 if repo.local(): |
82f50658c72b
mq: only add mq attribute to local repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
4193 repo.__class__ = mqrepo |
1808 | 4194 |
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
|
4195 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
|
4196 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4197 |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
4198 def mqimport(orig, ui, repo, *args, **kwargs): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4199 if util.safehasattr(repo, b'abortifwdirpatched') and not kwargs.get( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
4200 'no_commit', False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4201 ): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4202 repo.abortifwdirpatched( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
4203 _(b'cannot import over an applied patch'), kwargs.get('force') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4204 ) |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
4205 return orig(ui, repo, *args, **kwargs) |
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
4206 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4207 |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4208 def mqinit(orig, ui, *args, **kwargs): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
4209 mq = kwargs.pop('mq', None) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4210 |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4211 if not mq: |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4212 return orig(ui, *args, **kwargs) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4213 |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
4214 if args: |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
4215 repopath = args[0] |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
4216 if not hg.islocal(repopath): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4217 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
4218 _(b'only a local queue repository may be initialized') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4219 ) |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
4220 else: |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39049
diff
changeset
|
4221 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
|
4222 if not repopath: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4223 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
4224 _(b'there is no Mercurial repository here (.hg not found)') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4225 ) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4226 repo = hg.repository(ui, repopath) |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
4227 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
|
4228 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4229 |
10359
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4230 def mqcommand(orig, ui, repo, *args, **kwargs): |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4231 """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
|
4232 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4233 # some commands do not like getting unknown options |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43421
diff
changeset
|
4234 mq = kwargs.pop('mq', None) |
10359
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4235 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4236 if not mq: |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4237 return orig(ui, repo, *args, **kwargs) |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4238 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4239 q = repo.mq |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4240 r = q.qrepo() |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
4241 if not r: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4242 raise error.Abort(_(b'no queue repository')) |
10407
2e8926e9cc32
mq: incorporate mq repo config when using --mq
Brendan Cully <brendan@kublai.com>
parents:
10402
diff
changeset
|
4243 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
|
4244 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4245 |
19212
d0ba7022c13b
mq: switch to new summary hook mechanism
Bryan O'Sullivan <bryano@fb.com>
parents:
19064
diff
changeset
|
4246 def summaryhook(ui, repo): |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
4247 q = repo.mq |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
4248 m = [] |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
4249 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
|
4250 if a: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4251 m.append(ui.label(_(b"%d applied"), b'qseries.applied') % a) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
4252 if u: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4253 m.append(ui.label(_(b"%d unapplied"), b'qseries.unapplied') % u) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
4254 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
|
4255 # i18n: column positioning for "hg summary" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4256 ui.write(_(b"mq: %s\n") % b', '.join(m)) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
4257 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
|
4258 # i18n: column positioning for "hg summary" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4259 ui.note(_(b"mq: (empty queue)\n")) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
4260 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4261 |
28394
dcb4209bd30d
revset: replace extpredicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28313
diff
changeset
|
4262 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
|
4263 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4264 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4265 @revsetpredicate(b'mq()') |
14210
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
4266 def revsetmq(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
4267 """Changesets managed by MQ.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4268 revsetlang.getargs(x, 0, 0, _(b"mq takes no arguments")) |
42057
566daffc607d
cleanup: use set literals where possible
Martin von Zweigbergk <martinvonz@google.com>
parents:
42002
diff
changeset
|
4269 applied = {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
|
4270 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
|
4271 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4272 |
14210
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
4273 # 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
|
4274 i18nfunctions = [revsetmq] |
68ade2a6b30a
mq: add a 'mq()' revset predicate that returns applied mq csets
Idan Kamara <idankk86@gmail.com>
parents:
14191
diff
changeset
|
4275 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4276 |
17101
6bc275593d07
mq: defer command wrapping to extsetup (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17059
diff
changeset
|
4277 def extsetup(ui): |
6bc275593d07
mq: defer command wrapping to extsetup (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17059
diff
changeset
|
4278 # 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
|
4279 # NOT wrapping in uisetup() and instead deferring to init stage two here. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4280 mqopt = [(b'', b'mq', None, _(b"operate on patch repository"))] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4281 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4282 extensions.wrapcommand(commands.table, b'import', mqimport) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4283 cmdutil.summaryhooks.add(b'mq', summaryhook) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4284 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4285 entry = extensions.wrapcommand(commands.table, b'init', mqinit) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4286 entry[1].extend(mqopt) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
4287 |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
4288 def dotable(cmdtable): |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43090
diff
changeset
|
4289 for cmd, entry in pycompat.iteritems(cmdtable): |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
4290 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
|
4291 func = entry[0] |
30485
acd30a959980
dispatch: stop supporting non-use of @command
Augie Fackler <augie@google.com>
parents:
30369
diff
changeset
|
4292 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
|
4293 continue |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
4294 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
|
4295 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
|
4296 |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
4297 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
|
4298 |
44019
5bbd770d1324
mq: avoid using `__file__` to compare modules
Matt Harbison <matt_harbison@yahoo.com>
parents:
43987
diff
changeset
|
4299 thismodule = sys.modules["hgext.mq"] |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
4300 for extname, extmodule in extensions.extensions(): |
44019
5bbd770d1324
mq: avoid using `__file__` to compare modules
Matt Harbison <matt_harbison@yahoo.com>
parents:
43987
diff
changeset
|
4301 if extmodule != thismodule: |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
4302 dotable(getattr(extmodule, 'cmdtable', {})) |
7142
88f1b8081f1c
Prevent import over an applied patch (closes issue795)
Brendan Cully <brendan@kublai.com>
parents:
7113
diff
changeset
|
4303 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4304 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4305 colortable = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4306 b'qguard.negative': b'red', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4307 b'qguard.positive': b'yellow', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4308 b'qguard.unguarded': b'green', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4309 b'qseries.applied': b'blue bold underline', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4310 b'qseries.guarded': b'black bold', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4311 b'qseries.missing': b'red bold', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4312 b'qseries.unapplied': b'black bold', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42597
diff
changeset
|
4313 } |