Mercurial > hg
annotate hgext/mq.py @ 14016:bd738875943a
merge with stable
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Tue, 26 Apr 2011 13:13:35 +0200 |
parents | d7b4d421b56c |
children | 4f19242dac6c |
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 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10962
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 |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
31 files creations or deletions. This behaviour can be configured with:: |
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 |
1ebe048902d9
mq: mention qqueue in module docstring
Martin Geisler <mg@lazybytes.net>
parents:
11230
diff
changeset
|
41 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
|
42 create other, independent patch queues with the :hg:`qqueue` command. |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
43 ''' |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
44 |
3891 | 45 from mercurial.i18n import _ |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
46 from mercurial.node import bin, hex, short, nullid, nullrev |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
47 from mercurial.lock import release |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
13878
diff
changeset
|
48 from mercurial import commands, cmdutil, hg, patch, scmutil, util |
7637 | 49 from mercurial import repair, extensions, url, error |
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
|
50 import os, sys, re, errno, shutil |
1808 | 51 |
5645
1f044b04fa0a
mq: drop obsolete reference to 'qversion'
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5534
diff
changeset
|
52 commands.norepo += " qclone" |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
53 |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
54 # 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
|
55 # 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
|
56 normname = util.normpath |
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
57 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8761
diff
changeset
|
58 class statusentry(object): |
10682
8ed350051896
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10681
diff
changeset
|
59 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
|
60 self.node, self.name = node, name |
11375
0f33abfccaa1
mq: __str__ falls back to __repr__
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11365
diff
changeset
|
61 def __repr__(self): |
10678
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
62 return hex(self.node) + ':' + self.name |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
63 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
64 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
|
65 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
|
66 def eatdiff(lines): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
67 while lines: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
68 l = lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
69 if (l.startswith("diff -") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
70 l.startswith("Index:") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
71 l.startswith("===========")): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
72 del lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
73 else: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
74 break |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
75 def eatempty(lines): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
76 while lines: |
10688
d4d3a8a65248
mq: don't use regexp when not necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10687
diff
changeset
|
77 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
|
78 del lines[-1] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
79 else: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
80 break |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
81 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
82 message = [] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
83 comments = [] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
84 user = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
85 date = None |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
86 parent = None |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
87 format = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
88 subject = None |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
89 branch = None |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
90 nodeid = None |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
91 diffstart = 0 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
92 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
93 for line in file(pf): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
94 line = line.rstrip() |
10730
4d6bd7b8b6d8
mq: allow lines starting with '--- ' in patch messages
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10691
diff
changeset
|
95 if (line.startswith('diff --git') |
4d6bd7b8b6d8
mq: allow lines starting with '--- ' in patch messages
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10691
diff
changeset
|
96 or (diffstart and line.startswith('+++ '))): |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
97 diffstart = 2 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
98 break |
10730
4d6bd7b8b6d8
mq: allow lines starting with '--- ' in patch messages
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10691
diff
changeset
|
99 diffstart = 0 # reset |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
100 if line.startswith("--- "): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
101 diffstart = 1 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
102 continue |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
103 elif format == "hgpatch": |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
104 # parse values when importing the result of an hg export |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
105 if line.startswith("# User "): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
106 user = line[7:] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
107 elif line.startswith("# Date "): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
108 date = line[7:] |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
109 elif line.startswith("# Parent "): |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
110 parent = line[9:] |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
111 elif line.startswith("# Branch "): |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
112 branch = line[9:] |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
113 elif line.startswith("# Node ID "): |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
114 nodeid = line[10:] |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
115 elif not line.startswith("# ") and line: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
116 message.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
117 format = None |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
118 elif line == '# HG changeset patch': |
9287
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8948
diff
changeset
|
119 message = [] |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
120 format = "hgpatch" |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
121 elif (format != "tagdone" and (line.startswith("Subject: ") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
122 line.startswith("subject: "))): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
123 subject = line[9:] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
124 format = "tag" |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
125 elif (format != "tagdone" and (line.startswith("From: ") or |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
126 line.startswith("from: "))): |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
127 user = line[6:] |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
128 format = "tag" |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
129 elif (format != "tagdone" and (line.startswith("Date: ") or |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
130 line.startswith("date: "))): |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
131 date = line[6:] |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
132 format = "tag" |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
133 elif format == "tag" and line == "": |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
134 # 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
|
135 # end once you find a blank line in the source |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
136 format = "tagdone" |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
137 elif message or line: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
138 message.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
139 comments.append(line) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
140 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
141 eatdiff(message) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
142 eatdiff(comments) |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
143 # 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
|
144 # 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
|
145 self.diffstartline = len(comments) |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
146 eatempty(message) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
147 eatempty(comments) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
148 |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
149 # make sure message isn't empty |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
150 if format and format.startswith("tag") and subject: |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
151 message.insert(0, "") |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
152 message.insert(0, subject) |
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
153 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
154 self.message = message |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
155 self.comments = comments |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
156 self.user = user |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
157 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
|
158 self.parent = parent |
13229
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
159 # 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
|
160 self.nodeid = nodeid |
f3058dd05281
mq: record more data in patchheader class (no behavior changes)
Steve Borho <steve@borho.org>
parents:
13228
diff
changeset
|
161 self.branch = branch |
8653
aa011d123f71
mq: initializing patchheader class directly from patch content
Cédric Duval <cedricduval@free.fr>
parents:
8632
diff
changeset
|
162 self.haspatch = diffstart > 1 |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
163 self.plainmode = plainmode |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
164 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
165 def setuser(self, user): |
8654
f6cc3638f468
mq: rename setheader to updateheader and fix comment
Cédric Duval <cedricduval@free.fr>
parents:
8653
diff
changeset
|
166 if not self.updateheader(['From: ', '# User '], user): |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
167 try: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
168 patchheaderat = self.comments.index('# HG changeset patch') |
9334
08f59f7916f9
mq: fix coding style in qrefresh
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9327
diff
changeset
|
169 self.comments.insert(patchheaderat + 1, '# User ' + user) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
170 except ValueError: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
171 if self.plainmode or self._hasheader(['Date: ']): |
9336
dd6f605b15c0
mq: upgrade the patch to HG format when adding the author name with qrefresh
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9335
diff
changeset
|
172 self.comments = ['From: ' + user] + self.comments |
dd6f605b15c0
mq: upgrade the patch to HG format when adding the author name with qrefresh
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9335
diff
changeset
|
173 else: |
dd6f605b15c0
mq: upgrade the patch to HG format when adding the author name with qrefresh
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9335
diff
changeset
|
174 tmp = ['# HG changeset patch', '# User ' + user, ''] |
dd6f605b15c0
mq: upgrade the patch to HG format when adding the author name with qrefresh
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9335
diff
changeset
|
175 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
|
176 self.user = user |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
177 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
178 def setdate(self, date): |
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
|
179 if not self.updateheader(['Date: ', '# Date '], date): |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
180 try: |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
181 patchheaderat = self.comments.index('# HG changeset patch') |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
182 self.comments.insert(patchheaderat + 1, '# Date ' + date) |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
183 except ValueError: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
184 if self.plainmode or self._hasheader(['From: ']): |
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
|
185 self.comments = ['Date: ' + date] + self.comments |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
186 else: |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
187 tmp = ['# HG changeset patch', '# Date ' + date, ''] |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
188 self.comments = tmp + self.comments |
2b1260436f83
mq: add the date with qrefresh, even if missing (issue1768)
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9336
diff
changeset
|
189 self.date = date |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
190 |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
191 def setparent(self, parent): |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
192 if not self.updateheader(['# Parent '], parent): |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
193 try: |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
194 patchheaderat = self.comments.index('# HG changeset patch') |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
195 self.comments.insert(patchheaderat + 1, '# Parent ' + parent) |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
196 except ValueError: |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
197 pass |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
198 self.parent = parent |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
199 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
200 def setmessage(self, message): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
201 if self.comments: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
202 self._delmsg() |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
203 self.message = [message] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
204 self.comments += self.message |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
205 |
8654
f6cc3638f468
mq: rename setheader to updateheader and fix comment
Cédric Duval <cedricduval@free.fr>
parents:
8653
diff
changeset
|
206 def updateheader(self, prefixes, new): |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
207 '''Update all references to a field in the patch header. |
8654
f6cc3638f468
mq: rename setheader to updateheader and fix comment
Cédric Duval <cedricduval@free.fr>
parents:
8653
diff
changeset
|
208 Return whether the field is present.''' |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
209 res = False |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
210 for prefix in prefixes: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
211 for i in xrange(len(self.comments)): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
212 if self.comments[i].startswith(prefix): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
213 self.comments[i] = prefix + new |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
214 res = True |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
215 break |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
216 return res |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
217 |
9335
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
218 def _hasheader(self, prefixes): |
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
219 '''Check if a header starts with any of the given prefixes.''' |
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
220 for prefix in prefixes: |
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
221 for comment in self.comments: |
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
222 if comment.startswith(prefix): |
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
223 return True |
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
224 return False |
6eaadd777bc4
mq: add function to check if a header exists in a patch
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
parents:
9334
diff
changeset
|
225 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
226 def __str__(self): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
227 if not self.comments: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
228 return '' |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
229 return '\n'.join(self.comments) + '\n\n' |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
230 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
231 def _delmsg(self): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
232 '''Remove existing message, keeping the rest of the comments fields. |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
233 If comments contains 'subject: ', message will prepend |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
234 the field and a blank line.''' |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
235 if self.message: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
236 subj = 'subject: ' + self.message[0].lower() |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
237 for i in xrange(len(self.comments)): |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
238 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
|
239 del self.comments[i] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
240 self.message = self.message[2:] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
241 break |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
242 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
|
243 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
|
244 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
|
245 ci += 1 |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
246 del self.comments[ci] |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
247 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8761
diff
changeset
|
248 class queue(object): |
1808 | 249 def __init__(self, ui, path, patchdir=None): |
250 self.basepath = path | |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
251 try: |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
252 fh = open(os.path.join(path, 'patches.queue')) |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
253 cur = fh.read().rstrip() |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
254 fh.close() |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
255 if not cur: |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
256 curpath = os.path.join(path, 'patches') |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
257 else: |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
258 curpath = os.path.join(path, 'patches-' + cur) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
259 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
260 curpath = os.path.join(path, 'patches') |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
261 self.path = patchdir or curpath |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
13878
diff
changeset
|
262 self.opener = scmutil.opener(self.path) |
1808 | 263 self.ui = ui |
264 self.applied_dirty = 0 | |
265 self.series_dirty = 0 | |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
266 self.added = [] |
1852
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
267 self.series_path = "series" |
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
268 self.status_path = "status" |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
269 self.guards_path = "guards" |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
270 self.active_guards = None |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
271 self.guards_dirty = False |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
272 # Handle mq.git as a bool with extended values |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
273 try: |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
274 gitmode = ui.configbool('mq', 'git', None) |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
275 if gitmode is None: |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
276 raise error.ConfigError() |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
277 self.gitmode = gitmode and 'yes' or 'no' |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
278 except error.ConfigError: |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
279 self.gitmode = ui.config('mq', 'git', 'auto').lower() |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
280 self.plainmode = ui.configbool('mq', 'plain', False) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
281 |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
282 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
283 def applied(self): |
2819 | 284 if os.path.exists(self.join(self.status_path)): |
13507
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
285 def parselines(lines): |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
286 for l in lines: |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
287 entry = l.split(':', 1) |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
288 if len(entry) > 1: |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
289 n, name = entry |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
290 yield statusentry(bin(n), name) |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
291 elif l.strip(): |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
292 self.ui.warn(_('malformated mq status line: %s\n') % entry) |
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
293 # else we ignore empty lines |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
294 lines = self.opener(self.status_path).read().splitlines() |
13507
375ba42f3cda
mq: gracefully handle malformated status file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13409
diff
changeset
|
295 return list(parselines(lines)) |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
296 return [] |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
297 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
298 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
299 def full_series(self): |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
300 if os.path.exists(self.join(self.series_path)): |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
301 return self.opener(self.series_path).read().splitlines() |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
302 return [] |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
303 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
304 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
305 def series(self): |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
306 self.parse_series() |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
307 return self.series |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
308 |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
309 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
310 def series_guards(self): |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
311 self.parse_series() |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
312 return self.series_guards |
1808 | 313 |
8525
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
314 def invalidate(self): |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
315 for a in 'applied full_series series series_guards'.split(): |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
316 if a in self.__dict__: |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
317 delattr(self, a) |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
318 self.applied_dirty = 0 |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
319 self.series_dirty = 0 |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
320 self.guards_dirty = False |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
321 self.active_guards = None |
b169ba60eebe
mq: new method invalidate
Simon Heimberg <simohe@besonet.ch>
parents:
8524
diff
changeset
|
322 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
323 def diffopts(self, opts={}, patchfn=None): |
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
324 diffopts = patch.diffopts(self.ui, opts) |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
325 if self.gitmode == 'auto': |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
326 diffopts.upgrade = True |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
327 elif self.gitmode == 'keep': |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
328 pass |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
329 elif self.gitmode in ('yes', 'no'): |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
330 diffopts.git = self.gitmode == 'yes' |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
331 else: |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
332 raise util.Abort(_('mq.git option can be auto/keep/yes/no' |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
333 ' got %s') % self.gitmode) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
334 if patchfn: |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
335 diffopts = self.patchopts(diffopts, patchfn) |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
336 return diffopts |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
337 |
10186
296a0b14a686
mq: preserve --git flag when folding patches
Patrick Mezard <pmezard@gmail.com>
parents:
10185
diff
changeset
|
338 def patchopts(self, diffopts, *patches): |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
339 """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
|
340 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
|
341 """ |
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
342 diffopts = diffopts.copy() |
10190
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
343 if not diffopts.git and self.gitmode == 'keep': |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
344 for patchfn in patches: |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
345 patchf = self.opener(patchfn, 'r') |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
346 # if the patch was a git patch, refresh it as a git patch |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
347 for line in patchf: |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
348 if line.startswith('diff --git'): |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
349 diffopts.git = True |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
350 break |
9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
Patrick Mezard <pmezard@gmail.com>
parents:
10188
diff
changeset
|
351 patchf.close() |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
352 return diffopts |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2873
diff
changeset
|
353 |
2819 | 354 def join(self, *p): |
355 return os.path.join(self.path, *p) | |
356 | |
1808 | 357 def find_series(self, patch): |
10685
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
358 def matchpatch(l): |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
359 l = l.split('#', 1)[0] |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
360 return l.strip() == patch |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
361 for index, l in enumerate(self.full_series): |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
362 if matchpatch(l): |
10248fc845db
mq: find_series() simplify and don't use regexps
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10684
diff
changeset
|
363 return index |
1808 | 364 return None |
365 | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
366 guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)') |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
367 |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
368 def parse_series(self): |
1808 | 369 self.series = [] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
370 self.series_guards = [] |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
371 for l in self.full_series: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
372 h = l.find('#') |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
373 if h == -1: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
374 patch = l |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
375 comment = '' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
376 elif h == 0: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
377 continue |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
378 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
379 patch = l[:h] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
380 comment = l[h:] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
381 patch = patch.strip() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
382 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
|
383 if patch in self.series: |
87b7ae306d54
mq: bail out if a patch appears more than once in the series file.
Brendan Cully <brendan@kublai.com>
parents:
3183
diff
changeset
|
384 raise util.Abort(_('%s appears more than once in %s') % |
87b7ae306d54
mq: bail out if a patch appears more than once in the series file.
Brendan Cully <brendan@kublai.com>
parents:
3183
diff
changeset
|
385 (patch, self.join(self.series_path))) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
386 self.series.append(patch) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
387 self.series_guards.append(self.guard_re.findall(comment)) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
388 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
389 def check_guard(self, guard): |
6607
75b506f0e571
mq: make qselect fail properly on an empty guard
Patrick Mezard <pmezard@gmail.com>
parents:
6606
diff
changeset
|
390 if not guard: |
75b506f0e571
mq: make qselect fail properly on an empty guard
Patrick Mezard <pmezard@gmail.com>
parents:
6606
diff
changeset
|
391 return _('guard cannot be an empty string') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
392 bad_chars = '# \t\r\n\f' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
393 first = guard[0] |
8288
9de088320e9a
mq: simpler check of first character of guard name
Simon Heimberg <simohe@besonet.ch>
parents:
8225
diff
changeset
|
394 if first in '-+': |
9de088320e9a
mq: simpler check of first character of guard name
Simon Heimberg <simohe@besonet.ch>
parents:
8225
diff
changeset
|
395 return (_('guard %r starts with invalid character: %r') % |
9de088320e9a
mq: simpler check of first character of guard name
Simon Heimberg <simohe@besonet.ch>
parents:
8225
diff
changeset
|
396 (guard, first)) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
397 for c in bad_chars: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
398 if c in guard: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
399 return _('invalid character in guard %r: %r') % (guard, c) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
400 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
401 def set_active(self, guards): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
402 for guard in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
403 bad = self.check_guard(guard) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
404 if bad: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
405 raise util.Abort(bad) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8188
diff
changeset
|
406 guards = sorted(set(guards)) |
9467
4c041f1ee1b4
do not attempt to translate ui.debug output
Martin Geisler <mg@lazybytes.net>
parents:
9440
diff
changeset
|
407 self.ui.debug('active guards: %s\n' % ' '.join(guards)) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
408 self.active_guards = guards |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
409 self.guards_dirty = True |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
410 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
411 def active(self): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
412 if self.active_guards is None: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
413 self.active_guards = [] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
414 try: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
415 guards = self.opener(self.guards_path).read().split() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
416 except IOError, err: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
417 if err.errno != errno.ENOENT: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
418 raise |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
419 guards = [] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
420 for i, guard in enumerate(guards): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
421 bad = self.check_guard(guard) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
422 if bad: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
423 self.ui.warn('%s:%d: %s\n' % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
424 (self.join(self.guards_path), i + 1, bad)) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
425 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
426 self.active_guards.append(guard) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
427 return self.active_guards |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
428 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
429 def set_guards(self, idx, guards): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
430 for g in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
431 if len(g) < 2: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
432 raise util.Abort(_('guard %r too short') % g) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
433 if g[0] not in '-+': |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
434 raise util.Abort(_('guard %r starts with invalid char') % g) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
435 bad = self.check_guard(g[1:]) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
436 if bad: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
437 raise util.Abort(bad) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
438 drop = self.guard_re.sub('', self.full_series[idx]) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
439 self.full_series[idx] = drop + ''.join([' #' + g for g in guards]) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
440 self.parse_series() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
441 self.series_dirty = True |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
442 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
443 def pushable(self, idx): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
444 if isinstance(idx, str): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
445 idx = self.series.index(idx) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
446 patchguards = self.series_guards[idx] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
447 if not patchguards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
448 return True, None |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
449 guards = self.active() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
450 exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
451 if exactneg: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
452 return False, exactneg[0] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
453 pos = [g for g in patchguards if g[0] == '+'] |
2850
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
454 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
|
455 if pos: |
2850
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
456 if exactpos: |
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
457 return True, exactpos[0] |
851b07ec450c
mq: apply patch is any posative guard matches
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2848
diff
changeset
|
458 return False, pos |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
459 return True, '' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
460 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
461 def explain_pushable(self, idx, all_patches=False): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
462 write = all_patches and self.ui.write or self.ui.warn |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
463 if all_patches or self.ui.verbose: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
464 if isinstance(idx, str): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
465 idx = self.series.index(idx) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
466 pushable, why = self.pushable(idx) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
467 if all_patches and pushable: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
468 if why is None: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
469 write(_('allowing %s - no guards in effect\n') % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
470 self.series[idx]) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
471 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
472 if not why: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
473 write(_('allowing %s - no matching negative guards\n') % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
474 self.series[idx]) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
475 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
476 write(_('allowing %s - guarded by %r\n') % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
477 (self.series[idx], why)) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
478 if not pushable: |
2829
05316bb57d01
mq: make guards more strict, add tests
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2828
diff
changeset
|
479 if why: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
480 write(_('skipping %s - guarded by %r\n') % |
3870
22d18051f9e5
mq: fix explain_pushable for negative guards
Brendan Cully <brendan@kublai.com>
parents:
3857
diff
changeset
|
481 (self.series[idx], why)) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
482 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
483 write(_('skipping %s - no matching guards\n') % |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
484 self.series[idx]) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
485 |
1808 | 486 def save_dirty(self): |
2772
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
487 def write_list(items, path): |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
488 fp = self.opener(path, 'w') |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
489 for i in items: |
5878
d39af2eabb8c
transform a bunch of print statements to appropriate ui calls
Matt Mackall <mpm@selenic.com>
parents:
5788
diff
changeset
|
490 fp.write("%s\n" % i) |
2772
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
491 fp.close() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
492 if self.applied_dirty: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
493 write_list(map(str, self.applied), self.status_path) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
494 if self.series_dirty: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
495 write_list(self.full_series, self.series_path) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
496 if self.guards_dirty: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
497 write_list(self.active_guards, self.guards_path) |
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
|
498 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
|
499 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
|
500 if qrepo: |
12658
97d7ee445e98
mq: silence spurious output.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12655
diff
changeset
|
501 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
|
502 self.added = [] |
1808 | 503 |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
504 def removeundo(self, repo): |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
505 undo = repo.sjoin('undo') |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
506 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
|
507 return |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
508 try: |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
509 os.unlink(undo) |
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
510 except OSError, inst: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
511 self.ui.warn(_('error removing undo: %s\n') % str(inst)) |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
512 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
513 def printdiff(self, repo, diffopts, node1, node2=None, files=None, |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
514 fp=None, changes=None, opts={}): |
9640
9e76232fbfbe
diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
9599
diff
changeset
|
515 stat = opts.get('stat') |
6582
5acbdd3941c4
walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents:
6562
diff
changeset
|
516 m = cmdutil.match(repo, files, opts) |
11050
5d35f7d93514
commands: refactor diff --stat and qdiff --stat
Yuya Nishihara <yuya@tcha.org>
parents:
11049
diff
changeset
|
517 cmdutil.diffordiffstat(self.ui, repo, diffopts, node1, node2, m, |
5d35f7d93514
commands: refactor diff --stat and qdiff --stat
Yuya Nishihara <yuya@tcha.org>
parents:
11049
diff
changeset
|
518 changes, stat, fp) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2873
diff
changeset
|
519 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
520 def mergeone(self, repo, mergeq, head, patch, rev, diffopts): |
1808 | 521 # first try just applying the patch |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
522 (err, n) = self.apply(repo, [patch], update_status=False, |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
523 strict=True, merge=rev) |
1808 | 524 |
525 if err == 0: | |
526 return (err, n) | |
527 | |
528 if n is None: | |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
529 raise util.Abort(_("apply failed for patch %s") % patch) |
1808 | 530 |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
531 self.ui.warn(_("patch didn't work out, merging %s\n") % patch) |
1808 | 532 |
533 # 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
|
534 hg.clean(repo, head) |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
535 self.strip(repo, [n], update=False, backup='strip') |
1808 | 536 |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6668
diff
changeset
|
537 ctx = repo[rev] |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
538 ret = hg.merge(repo, rev) |
1808 | 539 if ret: |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
540 raise util.Abort(_("update returned %d") % ret) |
8706
25e9c71b89de
commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents:
8700
diff
changeset
|
541 n = repo.commit(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
|
542 if n is None: |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
543 raise util.Abort(_("repo commit failed")) |
1808 | 544 try: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
545 ph = patchheader(mergeq.join(patch), self.plainmode) |
1808 | 546 except: |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
547 raise util.Abort(_("unable to read %s") % patch) |
1808 | 548 |
10185
7637fe4f525d
mq: preserve --git flag when merging patches
Patrick Mezard <pmezard@gmail.com>
parents:
10184
diff
changeset
|
549 diffopts = self.patchopts(diffopts, patch) |
1852
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
550 patchf = self.opener(patch, "w") |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
551 comments = str(ph) |
1808 | 552 if comments: |
553 patchf.write(comments) | |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
554 self.printdiff(repo, diffopts, head, n, fp=patchf) |
1808 | 555 patchf.close() |
4207
b7e66db28571
Remove undo log after mq operations that rollback would break
Brendan Cully <brendan@kublai.com>
parents:
4206
diff
changeset
|
556 self.removeundo(repo) |
1808 | 557 return (0, n) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
558 |
1808 | 559 def qparents(self, repo, rev=None): |
560 if rev is None: | |
561 (p1, p2) = repo.dirstate.parents() | |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
562 if p2 == nullid: |
1808 | 563 return p1 |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
564 if not self.applied: |
1808 | 565 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
|
566 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
|
567 p1, p2 = repo.changelog.parents(rev) |
10680
45eb9b5dacf6
mq: simplify qparents calculation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10679
diff
changeset
|
568 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
|
569 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
|
570 return p1 |
1808 | 571 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
572 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
|
573 if not self.applied: |
1808 | 574 # each of the patches merged in will have two parents. This |
575 # can confuse the qrefresh, qdiff, and strip code because it | |
576 # needs to know which parent is actually in the patch queue. | |
577 # so, we insert a merge marker with only one parent. This way | |
578 # the first patch in the queue is never a merge patch | |
579 # | |
580 pname = ".hg.patches.merge.marker" | |
8706
25e9c71b89de
commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents:
8700
diff
changeset
|
581 n = repo.commit('[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
|
582 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
|
583 self.applied.append(statusentry(n, pname)) |
1808 | 584 self.applied_dirty = 1 |
585 | |
586 head = self.qparents(repo) | |
587 | |
588 for patch in series: | |
2696 | 589 patch = mergeq.lookup(patch, strict=True) |
1808 | 590 if not patch: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
591 self.ui.warn(_("patch %s does not exist\n") % patch) |
1808 | 592 return (1, None) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
593 pushable, reason = self.pushable(patch) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
594 if not pushable: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
595 self.explain_pushable(patch, all_patches=True) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
596 continue |
1808 | 597 info = mergeq.isapplied(patch) |
598 if not info: | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
599 self.ui.warn(_("patch %s is not applied\n") % patch) |
1808 | 600 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
|
601 rev = info[1] |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
602 err, head = self.mergeone(repo, mergeq, head, patch, rev, diffopts) |
1808 | 603 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
|
604 self.applied.append(statusentry(head, patch)) |
1808 | 605 self.applied_dirty = 1 |
606 if err: | |
607 return (err, head) | |
4437
a210b40d0860
Make mergepatch save queue now that qpush isn't.
Brendan Cully <brendan@kublai.com>
parents:
4432
diff
changeset
|
608 self.save_dirty() |
1808 | 609 return (0, head) |
610 | |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
611 def patch(self, repo, patchfile): |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
612 '''Apply patchfile to the working directory. |
8761
0289f384e1e5
Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents:
8760
diff
changeset
|
613 patchfile: name of patch file''' |
3465
2d35a8d2b32d
patch: return list of modified files even when an exception is raised
Brendan Cully <brendan@kublai.com>
parents:
3375
diff
changeset
|
614 files = {} |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
615 try: |
3465
2d35a8d2b32d
patch: return list of modified files even when an exception is raised
Brendan Cully <brendan@kublai.com>
parents:
3375
diff
changeset
|
616 fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root, |
8811
8b35b08724eb
Make mq, record and transplant honor patch.eol
Patrick Mezard <pmezard@gmail.com>
parents:
8795
diff
changeset
|
617 files=files, eolmode=None) |
2919
b70740aefa4d
Unify mq and hg patch invocation.
Brendan Cully <brendan@kublai.com>
parents:
2905
diff
changeset
|
618 except Exception, inst: |
b70740aefa4d
Unify mq and hg patch invocation.
Brendan Cully <brendan@kublai.com>
parents:
2905
diff
changeset
|
619 self.ui.note(str(inst) + '\n') |
b70740aefa4d
Unify mq and hg patch invocation.
Brendan Cully <brendan@kublai.com>
parents:
2905
diff
changeset
|
620 if not self.ui.verbose: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
621 self.ui.warn(_("patch failed, unable to continue (try -v)\n")) |
3465
2d35a8d2b32d
patch: return list of modified files even when an exception is raised
Brendan Cully <brendan@kublai.com>
parents:
3375
diff
changeset
|
622 return (False, files, False) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
623 |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
624 return (True, files, fuzz) |
2796
4c39568007f9
mq: codingstyle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2795
diff
changeset
|
625 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
626 def apply(self, repo, series, list=False, update_status=True, |
10661
c4859aad1980
mq: all_files can be a set, remove dangerous default values
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10611
diff
changeset
|
627 strict=False, patchdir=None, merge=None, all_files=None): |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
628 wlock = lock = tr = None |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
629 try: |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
630 wlock = repo.wlock() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
631 lock = repo.lock() |
10881
a685011ed38e
localrepo: add desc parameter to transaction
Steve Borho <steve@borho.org>
parents:
10873
diff
changeset
|
632 tr = repo.transaction("qpush") |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
633 try: |
4970
30d4d8985dd8
transactions: avoid late tear-down (issue641)
Matt Mackall <mpm@selenic.com>
parents:
4917
diff
changeset
|
634 ret = self._apply(repo, series, list, update_status, |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
635 strict, patchdir, merge, all_files=all_files) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
636 tr.close() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
637 self.save_dirty() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
638 return ret |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
639 except: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
640 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
641 tr.abort() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
642 finally: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
643 repo.invalidate() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
644 repo.dirstate.invalidate() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
645 raise |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
646 finally: |
11230
5116a077c3da
make transactions work on non-refcounted python implementations
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
11229
diff
changeset
|
647 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
|
648 self.removeundo(repo) |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
649 |
4970
30d4d8985dd8
transactions: avoid late tear-down (issue641)
Matt Mackall <mpm@selenic.com>
parents:
4917
diff
changeset
|
650 def _apply(self, repo, series, list=False, update_status=True, |
10661
c4859aad1980
mq: all_files can be a set, remove dangerous default values
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10611
diff
changeset
|
651 strict=False, patchdir=None, merge=None, all_files=None): |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
652 '''returns (error, hash) |
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
653 error = 1 for unable to read, 2 for patch failed, 3 for patch fuzz''' |
1808 | 654 # TODO unify with commands.py |
655 if not patchdir: | |
656 patchdir = self.path | |
657 err = 0 | |
658 n = None | |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
659 for patchname in series: |
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
660 pushable, reason = self.pushable(patchname) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
661 if not pushable: |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
662 self.explain_pushable(patchname, all_patches=True) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
663 continue |
9111
ac3f1e6696eb
mq: use ui.status when pushing and popping patches
Martin Geisler <mg@lazybytes.net>
parents:
9110
diff
changeset
|
664 self.ui.status(_("applying %s\n") % patchname) |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
665 pf = os.path.join(patchdir, patchname) |
1808 | 666 |
667 try: | |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
668 ph = patchheader(self.join(patchname), self.plainmode) |
1808 | 669 except: |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
670 self.ui.warn(_("unable to read %s\n") % patchname) |
1808 | 671 err = 1 |
672 break | |
673 | |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
674 message = ph.message |
1808 | 675 if not message: |
12849
d966eb464888
mq: mark strings that should not be translated
Martin Geisler <mg@lazybytes.net>
parents:
12848
diff
changeset
|
676 # The commit message should not be translated |
10274
04207f5e7344
mq: Do not translate import message that are appended to commits.
David Soria Parra <dsp@php.net>
parents:
10263
diff
changeset
|
677 message = "imported patch %s\n" % patchname |
1808 | 678 else: |
679 if list: | |
12849
d966eb464888
mq: mark strings that should not be translated
Martin Geisler <mg@lazybytes.net>
parents:
12848
diff
changeset
|
680 # The commit message should not be translated |
10274
04207f5e7344
mq: Do not translate import message that are appended to commits.
David Soria Parra <dsp@php.net>
parents:
10263
diff
changeset
|
681 message.append("\nimported patch %s" % patchname) |
1808 | 682 message = '\n'.join(message) |
683 | |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
684 if ph.haspatch: |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
685 (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
|
686 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
|
687 all_files.update(files) |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
688 patcherr = not patcherr |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
689 else: |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
690 self.ui.warn(_("patch %s is empty\n") % patchname) |
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
691 patcherr, files, fuzz = 0, [], 0 |
1808 | 692 |
2934
2f190e998eb3
Teach mq about git patches
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
693 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
|
694 # 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
|
695 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
|
696 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
|
697 for f in files: |
12344
b6173aee4a47
Use lexists() instead of exists() where appropriate
Patrick Mezard <pmezard@gmail.com>
parents:
12067
diff
changeset
|
698 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
|
699 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
|
700 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
|
701 removed.append(f) |
4904
6fd953d5faea
dirstate: break update into separate functions
Matt Mackall <mpm@selenic.com>
parents:
4890
diff
changeset
|
702 for f in removed: |
6fd953d5faea
dirstate: break update into separate functions
Matt Mackall <mpm@selenic.com>
parents:
4890
diff
changeset
|
703 repo.dirstate.remove(f) |
6fd953d5faea
dirstate: break update into separate functions
Matt Mackall <mpm@selenic.com>
parents:
4890
diff
changeset
|
704 for f in merged: |
6fd953d5faea
dirstate: break update into separate functions
Matt Mackall <mpm@selenic.com>
parents:
4890
diff
changeset
|
705 repo.dirstate.merge(f) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
706 p1, p2 = repo.dirstate.parents() |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
707 repo.dirstate.setparents(p1, merge) |
6603
41eb20cc1c02
match: remove files arg from repo.status and friends
Matt Mackall <mpm@selenic.com>
parents:
6602
diff
changeset
|
708 |
12266
00658492e2aa
patch: break import cycle with cmdutil
Martin Geisler <mg@lazybytes.net>
parents:
12208
diff
changeset
|
709 files = cmdutil.updatedir(self.ui, repo, files) |
6603
41eb20cc1c02
match: remove files arg from repo.status and friends
Matt Mackall <mpm@selenic.com>
parents:
6602
diff
changeset
|
710 match = cmdutil.matchfiles(repo, files or []) |
8706
25e9c71b89de
commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents:
8700
diff
changeset
|
711 n = repo.commit(message, ph.user, ph.date, match=match, force=True) |
1808 | 712 |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
713 if n is None: |
12850
62b334b0dfdf
mq: expand 'repo' -> 'repository' in error message
Martin Geisler <mg@lazybytes.net>
parents:
12849
diff
changeset
|
714 raise util.Abort(_("repository commit failed")) |
1808 | 715 |
716 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
|
717 self.applied.append(statusentry(n, patchname)) |
1808 | 718 |
719 if patcherr: | |
7782
140429276b63
mq: handle empty patches more gracefully (issue1501)
Matt Mackall <mpm@selenic.com>
parents:
7772
diff
changeset
|
720 self.ui.warn(_("patch failed, rejects left in working dir\n")) |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
721 err = 2 |
1808 | 722 break |
723 | |
724 if fuzz and strict: | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
725 self.ui.warn(_("fuzz found when applying patch, stopping\n")) |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
726 err = 3 |
1808 | 727 break |
728 return (err, n) | |
729 | |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
730 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
|
731 if not keep: |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
732 r = self.qrepo() |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
733 if r: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
734 r[None].remove(patches, True) |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
735 else: |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
736 for p in patches: |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
737 os.unlink(self.join(p)) |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
738 |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
739 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
|
740 qfinished = self.applied[:numrevs] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
741 del self.applied[:numrevs] |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
742 self.applied_dirty = 1 |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
743 |
14010
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
744 unknown = [] |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
745 |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
746 for (i, p) in sorted([(self.find_series(p), p) for p in patches], |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
747 reverse=True): |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
748 if i is not None: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
749 del self.full_series[i] |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
750 else: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
751 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
|
752 |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
753 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
|
754 if numrevs: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
755 rev = dict((entry.name, entry.node) for entry in qfinished) |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
756 for p in unknown: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
757 msg = _('revision %s refers to unknown patches: %s\n') |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
758 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
|
759 else: |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
760 msg = _('unknown patches: %s\n') |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
761 raise util.Abort(''.join(msg % p for p in unknown)) |
d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13970
diff
changeset
|
762 |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
763 self.parse_series() |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
764 self.series_dirty = 1 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
765 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
766 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
|
767 firstrev = repo[self.applied[0].node].rev() |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
768 patches = [] |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
769 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
|
770 |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
771 if rev < firstrev: |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
772 raise util.Abort(_('revision %d is not managed') % rev) |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
773 |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
774 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
|
775 base = self.applied[i].node |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
776 if ctx.node() != base: |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
777 msg = _('cannot delete revision %d above applied patches') |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
778 raise util.Abort(msg % rev) |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
779 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
780 patch = self.applied[i].name |
8832
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
781 for fmt in ('[mq]: %s', 'imported patch %s'): |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
782 if ctx.description() == fmt % patch: |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
783 msg = _('patch %s finalized without changeset message\n') |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
784 repo.ui.status(msg % patch) |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
785 break |
6e6f5b80e056
mq: warn about finalizing patches without cset message
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8811
diff
changeset
|
786 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
787 patches.append(patch) |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
788 return patches |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
789 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
790 def finish(self, repo, revs): |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
791 patches = self._revpatches(repo, sorted(revs)) |
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
792 self._cleanup(patches, len(patches)) |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
793 |
3088
dc784839516d
mq: add qdelete --forget option
Brendan Cully <brendan@kublai.com>
parents:
3087
diff
changeset
|
794 def delete(self, repo, patches, opts): |
4736
04b2c1e27c26
mq: require patch argument or revision for qdelete
Brendan Cully <brendan@kublai.com>
parents:
4730
diff
changeset
|
795 if not patches and not opts.get('rev'): |
4737
2ececafa5859
mq: more qdelete help text tweaks
Brendan Cully <brendan@kublai.com>
parents:
4736
diff
changeset
|
796 raise util.Abort(_('qdelete requires at least one revision or ' |
2ececafa5859
mq: more qdelete help text tweaks
Brendan Cully <brendan@kublai.com>
parents:
4736
diff
changeset
|
797 'patch name')) |
4736
04b2c1e27c26
mq: require patch argument or revision for qdelete
Brendan Cully <brendan@kublai.com>
parents:
4730
diff
changeset
|
798 |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
799 realpatches = [] |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
800 for patch in patches: |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
801 patch = self.lookup(patch, strict=True) |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
802 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
|
803 if info: |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
804 raise util.Abort(_("cannot delete applied patch %s") % patch) |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
805 if patch not in self.series: |
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
806 raise util.Abort(_("patch %s not in series file") % patch) |
12655
5192b24f309c
mq: handle deleting the same patch twice in one command (issue2427)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12590
diff
changeset
|
807 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
|
808 realpatches.append(patch) |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
809 |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
810 numrevs = 0 |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
811 if opts.get('rev'): |
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
812 if not self.applied: |
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
813 raise util.Abort(_('no patches applied')) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
814 revs = cmdutil.revrange(repo, opts.get('rev')) |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
815 if len(revs) > 1 and revs[0] > revs[1]: |
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
816 revs.reverse() |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
817 revpatches = self._revpatches(repo, revs) |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
818 realpatches += revpatches |
8833
14639c050251
mq: unify code for qdel -r and qfin
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8832
diff
changeset
|
819 numrevs = len(revpatches) |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
820 |
11365
c3d7daa0928e
mq: make 'qdelete <patchidx>' work again.
Greg Ward <greg-hg@gerg.ca>
parents:
11327
diff
changeset
|
821 self._cleanup(realpatches, numrevs, opts.get('keep')) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
822 |
1808 | 823 def check_toppatch(self, repo): |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
824 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
|
825 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
|
826 patch = self.applied[-1].name |
1808 | 827 pp = repo.dirstate.parents() |
828 if top not in pp: | |
5432
bfbd9b954315
mq: clarify queue top message
Matt Mackall <mpm@selenic.com>
parents:
5336
diff
changeset
|
829 raise util.Abort(_("working directory revision is not qtip")) |
10191
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
830 return top, patch |
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
831 return None, None |
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
832 |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
833 def check_substate(self, repo): |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
834 '''return list of subrepos at a different revision than substate. |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
835 Abort if any subrepos have uncommitted changes.''' |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
836 inclsubs = [] |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
837 wctx = repo[None] |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
838 for s in wctx.substate: |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
839 if wctx.sub(s).dirty(True): |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
840 raise util.Abort( |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
841 _("uncommitted changes in subrepository %s") % s) |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
842 elif wctx.sub(s).dirty(): |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
843 inclsubs.append(s) |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
844 return inclsubs |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
845 |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
846 def check_localchanges(self, repo, force=False, refresh=True): |
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
847 m, a, r, d = repo.status()[:4] |
10372
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
848 if (m or a or r or d) and not force: |
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
849 if refresh: |
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
850 raise util.Abort(_("local changes found, refresh first")) |
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
851 else: |
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
852 raise util.Abort(_("local changes found")) |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
853 return m, a, r, d |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
854 |
5981
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
855 _reserved = ('series', 'status', 'guards') |
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
856 def check_reserved_name(self, name): |
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
857 if (name in self._reserved or name.startswith('.hg') |
10589
92b8c79b34c2
mq: disallow : in patch names (issue2065)
Sune Foldager <cryo@cyanite.org>
parents:
10588
diff
changeset
|
858 or name.startswith('.mq') or '#' in name or ':' in name): |
5981
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
859 raise util.Abort(_('"%s" cannot be used as the name of a patch') |
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
860 % name) |
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
861 |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
862 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
|
863 """options: |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
864 msg: a string or a no-argument function returning a string |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
865 """ |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
866 msg = opts.get('msg') |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
867 user = opts.get('user') |
5788
4107e823dc2c
mq: add --currentdate and --date options to qnew and qrefresh
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5673
diff
changeset
|
868 date = opts.get('date') |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
869 if date: |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
870 date = util.parsedate(date) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
871 diffopts = self.diffopts({'git': opts.get('git')}) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
872 self.check_reserved_name(patchfn) |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
873 if os.path.exists(self.join(patchfn)): |
12879
da4a9ed369c8
qnew: distinguish between existing file and directory (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12878
diff
changeset
|
874 if os.path.isdir(self.join(patchfn)): |
da4a9ed369c8
qnew: distinguish between existing file and directory (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12878
diff
changeset
|
875 raise util.Abort(_('"%s" already exists as a directory') |
da4a9ed369c8
qnew: distinguish between existing file and directory (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12878
diff
changeset
|
876 % patchfn) |
da4a9ed369c8
qnew: distinguish between existing file and directory (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12878
diff
changeset
|
877 else: |
da4a9ed369c8
qnew: distinguish between existing file and directory (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12878
diff
changeset
|
878 raise util.Abort(_('patch "%s" already exists') % patchfn) |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
879 |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
880 inclsubs = self.check_substate(repo) |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
881 if inclsubs: |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
882 inclsubs.append('.hgsubstate') |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
883 if opts.get('include') or opts.get('exclude') or pats: |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
884 if inclsubs: |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
885 pats = list(pats or []) + inclsubs |
6582
5acbdd3941c4
walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents:
6562
diff
changeset
|
886 match = cmdutil.match(repo, pats, opts) |
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
|
887 # 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
|
888 def badfn(f, msg): |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
889 if f != '.hgsubstate': # .hgsubstate is auto-created |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
890 raise util.Abort('%s: %s' % (f, msg)) |
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
|
891 match.bad = badfn |
6603
41eb20cc1c02
match: remove files arg from repo.status and friends
Matt Mackall <mpm@selenic.com>
parents:
6602
diff
changeset
|
892 m, a, r, d = repo.status(match=match)[:4] |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
893 else: |
10372
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
894 m, a, r, d = self.check_localchanges(repo, force=True) |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
895 match = cmdutil.matchfiles(repo, m + a + r + inclsubs) |
10372
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
896 if len(repo[None].parents()) > 1: |
27d542bc0f5b
qnew: ignore force option
Augie Fackler <durin42@gmail.com>
parents:
10370
diff
changeset
|
897 raise util.Abort(_('cannot manage merge changesets')) |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
898 commitfiles = m + a + r |
1808 | 899 self.check_toppatch(repo) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
900 insert = self.full_series_end() |
1808 | 901 wlock = repo.wlock() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
902 try: |
12878
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
903 try: |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
904 # if patch file write fails, abort early |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
905 p = self.opener(patchfn, "w") |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
906 except IOError, e: |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
907 raise util.Abort(_('cannot write patch "%s": %s') |
1634287b6ab1
qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
Martin Geisler <mg@aragost.com>
parents:
12875
diff
changeset
|
908 % (patchfn, e.strerror)) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
909 try: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
910 if self.plainmode: |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
911 if user: |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
912 p.write("From: " + user + "\n") |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
913 if not date: |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
914 p.write("\n") |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
915 if date: |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
916 p.write("Date: %d %d\n\n" % date) |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
917 else: |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
918 p.write("# HG changeset patch\n") |
10413
e433002acb05
fix up a bunch of check-code warnings
Matt Mackall <mpm@selenic.com>
parents:
10410
diff
changeset
|
919 p.write("# Parent " |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13793
diff
changeset
|
920 + hex(repo[None].p1().node()) + "\n") |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
921 if user: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
922 p.write("# User " + user + "\n") |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
923 if date: |
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
924 p.write("# Date %s %s\n\n" % date) |
8366
0bf0045000b5
some modernization cleanups, forward compatibility
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8362
diff
changeset
|
925 if hasattr(msg, '__call__'): |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
926 msg = msg() |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
927 commitmsg = msg and msg or ("[mq]: %s" % patchfn) |
8706
25e9c71b89de
commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents:
8700
diff
changeset
|
928 n = repo.commit(commitmsg, user, date, match=match, force=True) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
929 if n is None: |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
930 raise util.Abort(_("repo commit failed")) |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
931 try: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
932 self.full_series[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
|
933 self.applied.append(statusentry(n, patchfn)) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
934 self.parse_series() |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
935 self.series_dirty = 1 |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
936 self.applied_dirty = 1 |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
937 if msg: |
7614
f9fcb189c8e2
mq: make qnew patch format consistent with qrefresh (issue1457)
Bernhard Leiner <bleiner@gmail.com>
parents:
7568
diff
changeset
|
938 msg = msg + "\n\n" |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
939 p.write(msg) |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
940 if commitfiles: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
941 parent = self.qparents(repo, n) |
7308
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
942 chunks = patch.diff(repo, node1=parent, node2=n, |
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
943 match=match, opts=diffopts) |
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
944 for chunk in chunks: |
b6f5490effbf
patch: turn patch.diff() into a generator
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7307
diff
changeset
|
945 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
|
946 p.close() |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
947 wlock.release() |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
948 wlock = None |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
949 r = self.qrepo() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
950 if r: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
951 r[None].add([patchfn]) |
7162
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
952 except: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
953 repo.rollback() |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
954 raise |
7280
810ca383da9c
remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7271
diff
changeset
|
955 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
|
956 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
|
957 try: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
958 os.unlink(patchpath) |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
959 except: |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
960 self.ui.warn(_('error unlinking %s\n') % patchpath) |
ce10a2f22258
mq: heavy rearrangement of qnew to make it recover reliably from errors.
Brendan Cully <brendan@kublai.com>
parents:
7161
diff
changeset
|
961 raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
962 self.removeundo(repo) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
963 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
964 release(wlock) |
1808 | 965 |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
966 def strip(self, repo, revs, update=True, backup="all", force=None): |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
967 wlock = lock = None |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
968 try: |
1808 | 969 wlock = repo.wlock() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
970 lock = repo.lock() |
1808 | 971 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
972 if update: |
6472
8c4cd80afd3e
mq: add --force option to strip
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6382
diff
changeset
|
973 self.check_localchanges(repo, force=force, refresh=False) |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
974 urev = self.qparents(repo, revs[0]) |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
975 hg.clean(repo, urev) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
976 repo.dirstate.write() |
1808 | 977 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
978 self.removeundo(repo) |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
979 for rev in revs: |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
980 repair.strip(self.ui, repo, rev, backup) |
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
|
981 # strip may have unbundled a set of backed up revisions after |
0b3f910dfd17
mq: really remove undo after a qpush (and after a strip)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5432
diff
changeset
|
982 # the actual strip |
0b3f910dfd17
mq: really remove undo after a qpush (and after a strip)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5432
diff
changeset
|
983 self.removeundo(repo) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
984 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
985 release(lock, wlock) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
986 |
1808 | 987 def isapplied(self, patch): |
988 """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
|
989 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
|
990 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
|
991 return (i, a.node, a.name) |
1808 | 992 return None |
993 | |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
994 # if the exact patch name does not exist, we try a few |
2696 | 995 # variations. If strict is passed, we try only #1 |
996 # | |
997 # 1) a number to indicate an offset in the series file | |
998 # 2) a unique substring of the patch name was given | |
999 # 3) patchname[-+]num to indicate an offset in the series file | |
1000 def lookup(self, patch, strict=False): | |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
1001 patch = patch and str(patch) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
1002 |
2696 | 1003 def partial_name(s): |
1004 if s in self.series: | |
1005 return s | |
2765
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1006 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
|
1007 if len(matches) > 1: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1008 self.ui.warn(_('patch name "%s" is ambiguous:\n') % s) |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1009 for m in matches: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1010 self.ui.warn(' %s\n' % m) |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1011 return None |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1012 if matches: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
1013 return matches[0] |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1014 if self.series and self.applied: |
2696 | 1015 if s == 'qtip': |
3874
e88d03c2a3d9
mq: fix qheader without args when guards are applied after qtop
Brendan Cully <brendan@kublai.com>
parents:
3871
diff
changeset
|
1016 return self.series[self.series_end(True)-1] |
2696 | 1017 if s == 'qbase': |
1018 return self.series[0] | |
1019 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
|
1020 |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
1021 if patch is None: |
1808 | 1022 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
|
1023 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
|
1024 return patch |
2696 | 1025 |
2819 | 1026 if not os.path.isfile(self.join(patch)): |
1808 | 1027 try: |
1028 sno = int(patch) | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1029 except (ValueError, OverflowError): |
2696 | 1030 pass |
1031 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
|
1032 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
|
1033 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
|
1034 |
2696 | 1035 if not strict: |
7568
12df451ce205
mq: don't warn about ambiguous patch name when using patch index (issue1439)
Jason Orendorff <jorendorff@mozilla.com>
parents:
7566
diff
changeset
|
1036 res = partial_name(patch) |
2696 | 1037 if res: |
1038 return res | |
3082
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1039 minus = patch.rfind('-') |
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1040 if minus >= 0: |
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1041 res = partial_name(patch[:minus]) |
2696 | 1042 if res: |
1043 i = self.series.index(res) | |
1044 try: | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1045 off = int(patch[minus + 1:] or 1) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1046 except (ValueError, OverflowError): |
2696 | 1047 pass |
1048 else: | |
1049 if i - off >= 0: | |
1050 return self.series[i - off] | |
3082
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1051 plus = patch.rfind('+') |
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1052 if plus >= 0: |
bed7cb835d8d
Fixed python2.3 incompatibility (rsplit) in qpush/qpop with index.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3076
diff
changeset
|
1053 res = partial_name(patch[:plus]) |
2696 | 1054 if res: |
1055 i = self.series.index(res) | |
1056 try: | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1057 off = int(patch[plus + 1:] or 1) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1058 except (ValueError, OverflowError): |
2696 | 1059 pass |
1060 else: | |
1061 if i + off < len(self.series): | |
1062 return self.series[i + off] | |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
1063 raise util.Abort(_("patch %s not in series") % patch) |
1808 | 1064 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1065 def push(self, repo, patch=None, force=False, list=False, |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1066 mergeq=None, all=False, move=False, exact=False): |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1067 diffopts = self.diffopts() |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
1068 wlock = repo.wlock() |
8795
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1069 try: |
10362
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1070 heads = [] |
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1071 for b, ls in repo.branchmap().iteritems(): |
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1072 heads += ls |
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1073 if not heads: |
2e3ec7ef5349
mq: don't warn on qpush against a branch head
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10361
diff
changeset
|
1074 heads = [nullid] |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13793
diff
changeset
|
1075 if repo.dirstate.p1() not in heads and not exact: |
8795
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1076 self.ui.status(_("(working directory not at a head)\n")) |
6340
949e607ac544
mq: warn when applying a patch to somewhere other than tip
Matt Mackall <mpm@selenic.com>
parents:
6217
diff
changeset
|
1077 |
8795
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1078 if not self.series: |
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1079 self.ui.warn(_('no patches in series\n')) |
51c29aec0b75
mq: eliminate warning on qpush with empty series
Adrian Buehlmann <adrian@cadifra.com>
parents:
8778
diff
changeset
|
1080 return 0 |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1081 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1082 patch = self.lookup(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1083 # 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
|
1084 # 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
|
1085 # 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
|
1086 # go backwards with qpush) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1087 if patch: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1088 info = self.isapplied(patch) |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1089 if info and info[0] >= len(self.applied) - 1: |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1090 self.ui.warn( |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1091 _('qpush: %s is already at the top\n') % patch) |
11439
778377be3662
mq: explicit exit code when patch is already on top
Gilles Moris <gilles.moris@free.fr>
parents:
11438
diff
changeset
|
1092 return 0 |
13369
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1093 |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1094 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
|
1095 if pushable: |
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1096 if self.series.index(patch) < self.series_end(): |
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1097 raise util.Abort( |
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1098 _("cannot push to a previous patch: %s") % patch) |
69238d0ca60f
mq: catch attempt to qpush to an earlier patch (issue2587)
Afuna <afunamatata@gmail.com>
parents:
13224
diff
changeset
|
1099 else: |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1100 if reason: |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1101 reason = _('guarded by %r') % reason |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1102 else: |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1103 reason = _('no matching guards') |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1104 self.ui.warn(_("cannot push '%s' - %s\n") % (patch, reason)) |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1105 return 1 |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1106 elif all: |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1107 patch = self.series[-1] |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1108 if self.isapplied(patch): |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1109 self.ui.warn(_('all patches are currently applied\n')) |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1110 return 0 |
4100
c30c922f907a
Modify qpush/qpop idempotent operations to return success
Ben Thomas <bthomas@virtualiron.com>
parents:
4099
diff
changeset
|
1111 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1112 # 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
|
1113 # 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
|
1114 # 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
|
1115 # 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
|
1116 # work as it detects an error when done |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1117 start = self.series_end() |
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1118 if start == len(self.series): |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1119 self.ui.warn(_('patch series already fully applied\n')) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1120 return 1 |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1121 if not force: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1122 self.check_localchanges(repo) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1123 |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1124 if exact: |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1125 if move: |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1126 raise util.Abort(_("cannot use --exact and --move together")) |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1127 if self.applied: |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1128 raise util.Abort(_("cannot push --exact with applied patches")) |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1129 root = self.series[start] |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1130 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
|
1131 if not target: |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1132 raise util.Abort(_("%s does not have a parent recorded" % root)) |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1133 if not repo[target] == repo['.']: |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1134 hg.update(repo, target) |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
1135 |
11064
590b1d6ef50b
mq: qpush --move, reorder patch series and apply only the patch
Mads Kiilerich <mads@kiilerich.com>
parents:
11050
diff
changeset
|
1136 if move: |
11715
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1137 if not patch: |
13075
d73c3034deee
coding style: fix gratuitous whitespace after Python keywords
Thomas Arendsen Hein <thomas@jtah.de>
parents:
13036
diff
changeset
|
1138 raise util.Abort(_("please specify the patch to move")) |
11715
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1139 for i, rpn in enumerate(self.full_series[start:]): |
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1140 # 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
|
1141 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
|
1142 break |
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1143 index = start + i |
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1144 assert index < len(self.full_series) |
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1145 fullpatch = self.full_series[index] |
4f9dfb54c8b5
qpush --move: move the right patch even with comment lines
Gilles Moris <gilles.moris@free.fr>
parents:
11709
diff
changeset
|
1146 del self.full_series[index] |
11438
88fc876a4833
mq: fix qpush --move for selected guarded patches
Gilles Moris <gilles.moris@free.fr>
parents:
11375
diff
changeset
|
1147 self.full_series.insert(start, fullpatch) |
11064
590b1d6ef50b
mq: qpush --move, reorder patch series and apply only the patch
Mads Kiilerich <mads@kiilerich.com>
parents:
11050
diff
changeset
|
1148 self.parse_series() |
590b1d6ef50b
mq: qpush --move, reorder patch series and apply only the patch
Mads Kiilerich <mads@kiilerich.com>
parents:
11050
diff
changeset
|
1149 self.series_dirty = 1 |
590b1d6ef50b
mq: qpush --move, reorder patch series and apply only the patch
Mads Kiilerich <mads@kiilerich.com>
parents:
11050
diff
changeset
|
1150 |
7398
2cd1308cb588
mq: gracefully abort qpush/qgoto to guarded patch (issue1186)
Brendan Cully <brendan@kublai.com>
parents:
7308
diff
changeset
|
1151 self.applied_dirty = 1 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1152 if start > 0: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1153 self.check_toppatch(repo) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1154 if not patch: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1155 patch = self.series[start] |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1156 end = start + 1 |
4418
0532491f7476
MQ: tidy up if a qpush is interrupted.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4406
diff
changeset
|
1157 else: |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1158 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
|
1159 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1160 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
|
1161 all_files = set() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1162 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1163 if mergeq: |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1164 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
|
1165 else: |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
1166 ret = self.apply(repo, s, list, all_files=all_files) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1167 except: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1168 self.ui.warn(_('cleaning up working directory...')) |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13793
diff
changeset
|
1169 node = repo.dirstate.p1() |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
1170 hg.revert(repo, node, None) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1171 # 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
|
1172 # 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
|
1173 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
|
1174 if f not in repo.dirstate: |
10693
2c2b2d384a47
mq: do not try to delete non-existent files (regression from e8e56d8377ab)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10692
diff
changeset
|
1175 try: |
13235
6bf39d88c857
rename util.unlink to unlinkpath
Adrian Buehlmann <adrian@cadifra.com>
parents:
13229
diff
changeset
|
1176 util.unlinkpath(repo.wjoin(f)) |
10693
2c2b2d384a47
mq: do not try to delete non-existent files (regression from e8e56d8377ab)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10692
diff
changeset
|
1177 except OSError, inst: |
2c2b2d384a47
mq: do not try to delete non-existent files (regression from e8e56d8377ab)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10692
diff
changeset
|
1178 if inst.errno != errno.ENOENT: |
2c2b2d384a47
mq: do not try to delete non-existent files (regression from e8e56d8377ab)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10692
diff
changeset
|
1179 raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1180 self.ui.warn(_('done\n')) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1181 raise |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1182 |
9590
07a62819b309
mq: fix traceback for qpush inexistant-patch with no patch applied
Benoit Allard <benoit@aeteurope.nl>
parents:
9588
diff
changeset
|
1183 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
|
1184 return ret[0] |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1185 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
|
1186 if ret[0] and ret[0] > 1: |
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1187 msg = _("errors during apply, please fix and refresh %s\n") |
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1188 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
|
1189 else: |
7627 | 1190 self.ui.write(_("now at: %s\n") % top) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1191 return ret[0] |
8875
801cacf46e62
mq: fix error message for qpush inexistent-patch (issue1702)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8833
diff
changeset
|
1192 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1193 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
1194 wlock.release() |
1808 | 1195 |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
1196 def pop(self, repo, patch=None, force=False, update=True, all=False): |
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
1197 wlock = repo.wlock() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1198 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1199 if patch: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1200 # index, rev, patch |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1201 info = self.isapplied(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1202 if not info: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1203 patch = self.lookup(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1204 info = self.isapplied(patch) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1205 if not info: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1206 raise util.Abort(_("patch %s is not applied") % patch) |
4100
c30c922f907a
Modify qpush/qpop idempotent operations to return success
Ben Thomas <bthomas@virtualiron.com>
parents:
4099
diff
changeset
|
1207 |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1208 if not self.applied: |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1209 # 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
|
1210 # but not qpop without an argument |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1211 self.ui.warn(_("no patches applied\n")) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1212 return not all |
1808 | 1213 |
7620
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1214 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
|
1215 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
|
1216 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
|
1217 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
|
1218 else: |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1219 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
|
1220 |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1221 if start >= len(self.applied): |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1222 self.ui.warn(_("qpop: %s is already at the top\n") % patch) |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1223 return |
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1224 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1225 if not update: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1226 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
|
1227 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
|
1228 for p in parents: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1229 if p in rr: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1230 self.ui.warn(_("qpop: forcing dirstate update\n")) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1231 update = True |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1232 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
|
1233 parents = [p.node() for p in repo[None].parents()] |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1234 needupdate = False |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1235 for entry in self.applied[start:]: |
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
|
1236 if entry.node in parents: |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1237 needupdate = True |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1238 break |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1239 update = needupdate |
1808 | 1240 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1241 if not force and update: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1242 self.check_localchanges(repo) |
1808 | 1243 |
7620
fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7619
diff
changeset
|
1244 self.applied_dirty = 1 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1245 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
|
1246 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
|
1247 if update: |
10191
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1248 top = self.check_toppatch(repo)[0] |
5980
dcda0c90125c
mq: pop/refresh: avoid losing revisions not managed by mq
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5979
diff
changeset
|
1249 |
7621
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1250 try: |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1251 heads = repo.changelog.heads(rev) |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
1252 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
|
1253 node = short(rev) |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1254 raise util.Abort(_('trying to pop unknown node %s') % node) |
6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7620
diff
changeset
|
1255 |
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
|
1256 if heads != [self.applied[-1].node]: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1257 raise util.Abort(_("popping would remove a revision not " |
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1258 "managed by this patch queue")) |
5980
dcda0c90125c
mq: pop/refresh: avoid losing revisions not managed by mq
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5979
diff
changeset
|
1259 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1260 # 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
|
1261 # form of hg.update. |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1262 if update: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1263 qp = self.qparents(repo, rev) |
10663
85e81d9bfb7a
mq: simplify and use context API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10662
diff
changeset
|
1264 ctx = repo[qp] |
6760
4faaa0535ea7
status: clean up all users for unknown files
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
1265 m, a, r, d = repo.status(qp, top)[:4] |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1266 if d: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1267 raise util.Abort(_("deletions found between repo revs")) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1268 for f in a: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1269 try: |
13235
6bf39d88c857
rename util.unlink to unlinkpath
Adrian Buehlmann <adrian@cadifra.com>
parents:
13229
diff
changeset
|
1270 util.unlinkpath(repo.wjoin(f)) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1271 except OSError, e: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1272 if e.errno != errno.ENOENT: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1273 raise |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1274 repo.dirstate.forget(f) |
10048
46de82e50790
mq: qpop: remove added files before re-adding removed files
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9874
diff
changeset
|
1275 for f in m + r: |
10663
85e81d9bfb7a
mq: simplify and use context API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10662
diff
changeset
|
1276 fctx = ctx[f] |
85e81d9bfb7a
mq: simplify and use context API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10662
diff
changeset
|
1277 repo.wwrite(f, fctx.data(), fctx.flags()) |
10048
46de82e50790
mq: qpop: remove added files before re-adding removed files
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9874
diff
changeset
|
1278 repo.dirstate.normal(f) |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
1279 repo.dirstate.setparents(qp, nullid) |
9110
561ff8d9e4f0
mq: qpop now tells which patches are popped
Mads Kiilerich <mads@kiilerich.com>
parents:
9067
diff
changeset
|
1280 for patch in reversed(self.applied[start:end]): |
9111
ac3f1e6696eb
mq: use ui.status when pushing and popping patches
Martin Geisler <mg@lazybytes.net>
parents:
9110
diff
changeset
|
1281 self.ui.status(_("popping %s\n") % patch.name) |
5987
f2201aee3dc8
qpop/qrefresh: update self.applied before calling strip
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5981
diff
changeset
|
1282 del self.applied[start:end] |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
1283 self.strip(repo, [rev], update=False, backup='strip') |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1284 if self.applied: |
7627 | 1285 self.ui.write(_("now at: %s\n") % self.applied[-1].name) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1286 else: |
7627 | 1287 self.ui.write(_("patch queue now empty\n")) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1288 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
1289 wlock.release() |
1808 | 1290 |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
1291 def diff(self, repo, pats, opts): |
10191
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
1292 top, patch = self.check_toppatch(repo) |
1808 | 1293 if not top: |
7627 | 1294 self.ui.write(_("no patches applied\n")) |
1808 | 1295 return |
1296 qp = self.qparents(repo, top) | |
9857
24bc6e414610
diff: change --inverse to --reverse
Martin Geisler <mg@lazybytes.net>
parents:
9824
diff
changeset
|
1297 if opts.get('reverse'): |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1298 node1, node2 = None, qp |
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1299 else: |
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9642
diff
changeset
|
1300 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
|
1301 diffopts = self.diffopts(opts, patch) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1302 self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts) |
1808 | 1303 |
2938
5b7a118f5b6c
allow qrefresh to take a list of files; closes #96.
Brendan Cully <brendan@kublai.com>
parents:
2937
diff
changeset
|
1304 def refresh(self, repo, pats=None, **opts): |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1305 if not self.applied: |
7627 | 1306 self.ui.write(_("no patches applied\n")) |
3004
ac74046f8f58
qrefresh: exit with status 1 if no patches applied.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2984
diff
changeset
|
1307 return 1 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1308 msg = opts.get('msg', '').rstrip() |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1309 newuser = opts.get('user') |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1310 newdate = opts.get('date') |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1311 if newdate: |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6120
diff
changeset
|
1312 newdate = '%d %d' % util.parsedate(newdate) |
1808 | 1313 wlock = repo.wlock() |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1314 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1315 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1316 self.check_toppatch(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
|
1317 (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
|
1318 if repo.changelog.heads(top) != [top]: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1319 raise util.Abort(_("cannot refresh a revision with children")) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1320 |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1321 inclsubs = self.check_substate(repo) |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1322 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1323 cparents = repo.changelog.parents(top) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1324 patchparent = self.qparents(repo, top) |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
1325 ph = patchheader(self.join(patchfn), self.plainmode) |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1326 diffopts = self.diffopts({'git': opts.get('git')}, patchfn) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1327 if msg: |
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1328 ph.setmessage(msg) |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
1329 if newuser: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1330 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
|
1331 if newdate: |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1332 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
|
1333 ph.setparent(hex(patchparent)) |
5180
5bbbd1f1d586
mq: truncate patch just before rewriting header
Brendan Cully <brendan@kublai.com>
parents:
4930
diff
changeset
|
1334 |
7400
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1335 # only commit new patch when write is complete |
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1336 patchf = self.opener(patchfn, 'w', atomictemp=True) |
409a9b442308
mq: use atomictempfiles during patch refresh
Brendan Cully <brendan@kublai.com>
parents:
7399
diff
changeset
|
1337 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
1338 comments = str(ph) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1339 if comments: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1340 patchf.write(comments) |
1808 | 1341 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1342 # 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
|
1343 # and then commit. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1344 # |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1345 # this should really read: |
13005
cffa35529706
mq: fix comment to reflect change in efbee27415ab
Martin Geisler <mg@aragost.com>
parents:
13004
diff
changeset
|
1346 # mm, dd, aa = repo.status(top, patchparent)[:3] |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1347 # but we do it backwards to take advantage of manifest/chlog |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1348 # caching against the next repo.status call |
13004
efbee27415ab
mq: clean up unused variable in qrefresh
Kevin Bullock <kbullock@ringworld.org>
parents:
12948
diff
changeset
|
1349 mm, aa, dd = repo.status(patchparent, top)[:3] |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1350 changes = repo.changelog.read(top) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1351 man = repo.manifest.read(changes[0]) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1352 aaa = aa[:] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1353 matchfn = cmdutil.match(repo, pats, opts) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1354 # 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
|
1355 # patch already plus specified files |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1356 if opts.get('short'): |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1357 # 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
|
1358 # files plus specified files - unfiltered |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1359 match = cmdutil.matchfiles(repo, mm + aa + dd + matchfn.files()) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1360 # filter with inc/exl options |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1361 matchfn = cmdutil.match(repo, opts=opts) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1362 else: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1363 match = cmdutil.matchall(repo) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1364 m, a, r, d = repo.status(match=match)[:4] |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1365 mm = set(mm) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1366 aa = set(aa) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1367 dd = set(dd) |
1808 | 1368 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1369 # 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
|
1370 # 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
|
1371 # 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
|
1372 # show up in the added section |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1373 for x in m: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1374 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
|
1375 mm.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1376 # 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
|
1377 # 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
|
1378 # show up in the changed section. |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1379 for x in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1380 if x in dd: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1381 dd.remove(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1382 mm.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1383 else: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1384 aa.add(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1385 # 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
|
1386 # 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
|
1387 forget = [] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1388 for x in d + r: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1389 if x in aa: |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1390 aa.remove(x) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1391 forget.append(x) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1392 continue |
12948
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1393 else: |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1394 mm.discard(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1395 dd.add(x) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1396 |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1397 m = list(mm) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1398 r = list(dd) |
de6a28ff5ffc
mq: use sets instead of lists for speed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12879
diff
changeset
|
1399 a = list(aa) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1400 c = [filter(matchfn, l) for l in (m, a, r)] |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13173
diff
changeset
|
1401 match = cmdutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs)) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1402 chunks = patch.diff(repo, patchparent, match=match, |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1403 changes=c, opts=diffopts) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1404 for chunk in chunks: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1405 patchf.write(chunk) |
1808 | 1406 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1407 try: |
10368 | 1408 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
|
1409 copies = {} |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1410 for dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1411 src = repo.dirstate.copied(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1412 # 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
|
1413 # 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
|
1414 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
|
1415 copies.setdefault(src, []).append(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1416 repo.dirstate.add(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1417 # 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
|
1418 for dst in aaa: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1419 f = repo.file(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1420 src = f.renamed(man[dst]) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1421 if src: |
10368 | 1422 copies.setdefault(src[0], []).extend( |
1423 copies.get(dst, [])) | |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1424 if dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1425 copies[src[0]].append(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1426 # 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
|
1427 if dst in copies: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1428 del copies[dst] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1429 for src, dsts in copies.iteritems(): |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1430 for dst in dsts: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1431 repo.dirstate.copy(src, dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1432 else: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1433 for dst in a: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1434 repo.dirstate.add(dst) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1435 # Drop useless copy information |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1436 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
|
1437 repo.dirstate.copy(None, f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1438 for f in r: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1439 repo.dirstate.remove(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1440 # 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
|
1441 # 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
|
1442 mm = [] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1443 for i in xrange(len(m)-1, -1, -1): |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1444 if not matchfn(m[i]): |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1445 mm.append(m[i]) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1446 del m[i] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1447 for f in m: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1448 repo.dirstate.normal(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1449 for f in mm: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1450 repo.dirstate.normallookup(f) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1451 for f in forget: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1452 repo.dirstate.forget(f) |
1808 | 1453 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1454 if not msg: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1455 if not ph.message: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1456 message = "[mq]: %s\n" % patchfn |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1457 else: |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1458 message = "\n".join(ph.message) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1459 else: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1460 message = msg |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1461 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1462 user = ph.user or changes[1] |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
1463 |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1464 # assumes strip can roll itself back if interrupted |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1465 repo.dirstate.setparents(*cparents) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1466 self.applied.pop() |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1467 self.applied_dirty = 1 |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
1468 self.strip(repo, [top], update=False, |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1469 backup='strip') |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1470 except: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1471 repo.dirstate.invalidate() |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1472 raise |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1473 |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1474 try: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1475 # might be nice to attempt to roll back strip after this |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1476 n = repo.commit(message, user, ph.date, match=match, |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1477 force=True) |
13632
33a33f19aad2
mq: do not let qrefresh write bad patch
Martin Geisler <mg@lazybytes.net>
parents:
13520
diff
changeset
|
1478 # only write patch after a successful commit |
33a33f19aad2
mq: do not let qrefresh write bad patch
Martin Geisler <mg@lazybytes.net>
parents:
13520
diff
changeset
|
1479 patchf.rename() |
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
|
1480 self.applied.append(statusentry(n, patchfn)) |
10366
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1481 except: |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1482 ctx = repo[cparents[0]] |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1483 repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1484 self.save_dirty() |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1485 self.ui.warn(_('refresh interrupted while patch was popped! ' |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1486 '(revert --all, qpush to recover)\n')) |
d355cebde5e6
mq: remove qrefresh slow path (issue2025)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10274
diff
changeset
|
1487 raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
1488 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
1489 wlock.release() |
7401
41e87b4d0c9d
mq: recover more gracefully from interrupted qrefresh (issue1216)
Brendan Cully <brendan@kublai.com>
parents:
7400
diff
changeset
|
1490 self.removeundo(repo) |
1808 | 1491 |
1492 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
|
1493 if not create and os.path.isdir(self.path): |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
1494 raise util.Abort(_("patch queue directory already exists")) |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1495 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
|
1496 os.mkdir(self.path) |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1497 except OSError, inst: |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1498 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
|
1499 raise |
1808 | 1500 if create: |
1501 return self.qrepo(create=True) | |
1502 | |
1503 def unapplied(self, repo, patch=None): | |
1504 if patch and patch not in self.series: | |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
1505 raise util.Abort(_("patch %s is not in series file") % patch) |
1808 | 1506 if not patch: |
1507 start = self.series_end() | |
1508 else: | |
1509 start = self.series.index(patch) + 1 | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1510 unapplied = [] |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1511 for i in xrange(start, len(self.series)): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1512 pushable, reason = self.pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1513 if pushable: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1514 unapplied.append((i, self.series[i])) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1515 self.explain_pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1516 return unapplied |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1517 |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1518 def qseries(self, repo, missing=None, start=0, length=None, status=None, |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1519 summary=False): |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1520 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
|
1521 if pfx: |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1522 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
|
1523 if summary: |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
1524 ph = patchheader(self.join(patchname), self.plainmode) |
9874
c51494c53841
qseries: don't truncate the patch name (issue1912)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9867
diff
changeset
|
1525 msg = ph.message and ph.message[0] or '' |
11327
6c469f2f9f12
mq: use ui.formatted() instead of ui.plain().
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11321
diff
changeset
|
1526 if self.ui.formatted(): |
12689
c52c629ce19e
termwidth: move to ui.ui from util
Augie Fackler <durin42@gmail.com>
parents:
12682
diff
changeset
|
1527 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
|
1528 if width > 0: |
c51494c53841
qseries: don't truncate the patch name (issue1912)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9867
diff
changeset
|
1529 msg = util.ellipsis(msg, width) |
c51494c53841
qseries: don't truncate the patch name (issue1912)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9867
diff
changeset
|
1530 else: |
c51494c53841
qseries: don't truncate the patch name (issue1912)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9867
diff
changeset
|
1531 msg = '' |
10932
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1532 self.ui.write(patchname, label='qseries.' + state) |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1533 self.ui.write(': ') |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1534 self.ui.write(msg, label='qseries.message.' + state) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1535 else: |
10932
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1536 self.ui.write(patchname, label='qseries.' + state) |
29c39fe2491b
mq: only highlight/label patch name for qseries.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
10890
diff
changeset
|
1537 self.ui.write('\n') |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1538 |
8152
08e1baf924ca
replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
1539 applied = set([p.name for p in self.applied]) |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1540 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
|
1541 length = len(self.series) - start |
1808 | 1542 if not missing: |
9016
894c5b4be275
mq: align columns in verbose qseries output.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
8948
diff
changeset
|
1543 if self.ui.verbose: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1544 idxwidth = len(str(start + length - 1)) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1545 for i in 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
|
1546 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
|
1547 if patch in applied: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1548 char, state = 'A', 'applied' |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1549 elif self.pushable(i)[0]: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1550 char, state = 'U', 'unapplied' |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1551 else: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1552 char, state = 'G', 'guarded' |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1553 pfx = '' |
1808 | 1554 if self.ui.verbose: |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1555 pfx = '%*d %s ' % (idxwidth, i, char) |
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1556 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
|
1557 continue |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1558 displayname(pfx, patch, state) |
1808 | 1559 else: |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
1560 msng_list = [] |
1808 | 1561 for root, dirs, files in os.walk(self.path): |
1562 d = root[len(self.path) + 1:] | |
1563 for f in files: | |
1564 fl = os.path.join(d, f) | |
1852
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
1565 if (fl not in self.series and |
4241
7c59ade0f0d6
hg qseries -m: guards file was not ignored
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4239
diff
changeset
|
1566 fl not in (self.status_path, self.series_path, |
7c59ade0f0d6
hg qseries -m: guards file was not ignored
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4239
diff
changeset
|
1567 self.guards_path) |
1852
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
1568 and not fl.startswith('.')): |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
1569 msng_list.append(fl) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8188
diff
changeset
|
1570 for x in sorted(msng_list): |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1571 pfx = self.ui.verbose and ('D ') or '' |
10824
18def0d5692d
qseries: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10823
diff
changeset
|
1572 displayname(pfx, x, 'missing') |
1808 | 1573 |
1574 def issaveline(self, l): | |
2816
52516e48e3f3
Update qsave to use StatusEntry; don't throw exception on bad status lines.
Brendan Cully <brendan@kublai.com>
parents:
2804
diff
changeset
|
1575 if l.name == '.hg.patches.save.line': |
1808 | 1576 return True |
1577 | |
1578 def qrepo(self, create=False): | |
11965
77f1f206e135
mq: don't inherit default and default-push paths with --mq (issue2333)
Mads Kiilerich <mads@kiilerich.com>
parents:
11715
diff
changeset
|
1579 ui = self.ui.copy() |
77f1f206e135
mq: don't inherit default and default-push paths with --mq (issue2333)
Mads Kiilerich <mads@kiilerich.com>
parents:
11715
diff
changeset
|
1580 ui.setconfig('paths', 'default', '', overlay=False) |
77f1f206e135
mq: don't inherit default and default-push paths with --mq (issue2333)
Mads Kiilerich <mads@kiilerich.com>
parents:
11715
diff
changeset
|
1581 ui.setconfig('paths', 'default-push', '', overlay=False) |
2819 | 1582 if create or os.path.isdir(self.join(".hg")): |
11965
77f1f206e135
mq: don't inherit default and default-push paths with --mq (issue2333)
Mads Kiilerich <mads@kiilerich.com>
parents:
11715
diff
changeset
|
1583 return hg.repository(ui, path=self.path, create=create) |
1808 | 1584 |
1585 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
|
1586 desc = repo[rev].description().strip() |
1808 | 1587 lines = desc.splitlines() |
1588 i = 0 | |
1589 datastart = None | |
1590 series = [] | |
1591 applied = [] | |
1592 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
|
1593 for i, line in enumerate(lines): |
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
1594 if line == 'Patch Data:': |
1808 | 1595 datastart = i + 1 |
8632
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
1596 elif line.startswith('Dirstate:'): |
9e055cfdd620
replace "i in range(len(xs))" with "i, x in enumerate(xs)"
Martin Geisler <mg@lazybytes.net>
parents:
8624
diff
changeset
|
1597 l = line.rstrip() |
1808 | 1598 l = l[10:].split(' ') |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1599 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
|
1600 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
|
1601 l = line.rstrip() |
10683
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
1602 n, name = l.split(':', 1) |
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
1603 if n: |
cfbf064f0069
mq: qsave creates entries with the left part empty (':patchname')
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10682
diff
changeset
|
1604 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
|
1605 else: |
10682
8ed350051896
mq: simplify statusentry(), fix restore broken by ee48e5ef8753
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10681
diff
changeset
|
1606 series.append(l) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
1607 if datastart is None: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1608 self.ui.warn(_("No saved patch data found\n")) |
1808 | 1609 return 1 |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1610 self.ui.warn(_("restoring status: %s\n") % lines[0]) |
1808 | 1611 self.full_series = series |
1612 self.applied = applied | |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
1613 self.parse_series() |
1808 | 1614 self.series_dirty = 1 |
1615 self.applied_dirty = 1 | |
1616 heads = repo.changelog.heads() | |
1617 if delete: | |
1618 if rev not in heads: | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1619 self.ui.warn(_("save entry has children, leaving it alone\n")) |
1808 | 1620 else: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1621 self.ui.warn(_("removing save entry %s\n") % short(rev)) |
1808 | 1622 pp = repo.dirstate.parents() |
1623 if rev in pp: | |
1624 update = True | |
1625 else: | |
1626 update = False | |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
1627 self.strip(repo, [rev], update=update, backup='strip') |
1808 | 1628 if qpp: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1629 self.ui.warn(_("saved queue repository parents: %s %s\n") % |
6217
fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents:
6195
diff
changeset
|
1630 (short(qpp[0]), short(qpp[1]))) |
1808 | 1631 if qupdate: |
12848
f7f1a146f407
qrestore: trying to improve the English
timeless <timeless@gmail.com>
parents:
12775
diff
changeset
|
1632 self.ui.status(_("updating queue directory\n")) |
1808 | 1633 r = self.qrepo() |
1634 if not r: | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1635 self.ui.warn(_("Unable to load queue repository\n")) |
1808 | 1636 return 1 |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2804
diff
changeset
|
1637 hg.clean(r, qpp[0]) |
1808 | 1638 |
1639 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
|
1640 if not self.applied: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1641 self.ui.warn(_("save: no patches applied, exiting\n")) |
1808 | 1642 return 1 |
1643 if self.issaveline(self.applied[-1]): | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1644 self.ui.warn(_("status is already saved\n")) |
1808 | 1645 return 1 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1646 |
1808 | 1647 if not msg: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1648 msg = _("hg patches saved state") |
1808 | 1649 else: |
1650 msg = "hg patches: " + msg.rstrip('\r\n') | |
1651 r = self.qrepo() | |
1652 if r: | |
1653 pp = r.dirstate.parents() | |
6217
fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents:
6195
diff
changeset
|
1654 msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1])) |
1808 | 1655 msg += "\n\nPatch Data:\n" |
10679
35abaea778dc
mq: simplify commit message generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10678
diff
changeset
|
1656 msg += ''.join('%s\n' % x for x in self.applied) |
35abaea778dc
mq: simplify commit message generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10678
diff
changeset
|
1657 msg += ''.join(':%s\n' % x for x in self.full_series) |
35abaea778dc
mq: simplify commit message generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10678
diff
changeset
|
1658 n = repo.commit(msg, force=True) |
1808 | 1659 if not n: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
1660 self.ui.warn(_("repo commit failed\n")) |
1808 | 1661 return 1 |
10684
485c1d7f8a77
mq: fix coding style (missing space)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10683
diff
changeset
|
1662 self.applied.append(statusentry(n, '.hg.patches.save.line')) |
1808 | 1663 self.applied_dirty = 1 |
4209
dbc3846c09a1
Merge with -stable, fix small test failure
Matt Mackall <mpm@selenic.com>
parents:
4207
diff
changeset
|
1664 self.removeundo(repo) |
1808 | 1665 |
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1666 def full_series_end(self): |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1667 if self.applied: |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
1668 p = self.applied[-1].name |
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1669 end = self.find_series(p) |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
1670 if end is None: |
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1671 return len(self.full_series) |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1672 return end + 1 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1673 return 0 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1674 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1675 def series_end(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
|
1676 """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
|
1677 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
|
1678 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
|
1679 """ |
1808 | 1680 end = 0 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1681 def next(start): |
10687
583adcf63f80
mq: use xrange/enumerate instead of += 1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10686
diff
changeset
|
1682 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
|
1683 return start |
10687
583adcf63f80
mq: use xrange/enumerate instead of += 1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10686
diff
changeset
|
1684 for i in xrange(start, len(self.series)): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1685 p, reason = self.pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1686 if p: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1687 break |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1688 self.explain_pushable(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1689 return i |
10686
0c68c2c36ed8
mq: don't use len(list) unless necessary
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10685
diff
changeset
|
1690 if self.applied: |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
1691 p = self.applied[-1].name |
1808 | 1692 try: |
1693 end = self.series.index(p) | |
1694 except ValueError: | |
1695 return 0 | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1696 return next(end + 1) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
1697 return next(end) |
1808 | 1698 |
1699 def appliedname(self, index): | |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
1700 pname = self.applied[index].name |
1808 | 1701 if not self.ui.verbose: |
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1702 p = pname |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1703 else: |
2941 | 1704 p = str(self.series.index(pname)) + " " + pname |
1808 | 1705 return p |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1706 |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1707 def qimport(self, repo, files, patchname=None, rev=None, existing=None, |
3691
79151c94c3b4
mq: add --git option to qimport -r
Brendan Cully <brendan@kublai.com>
parents:
3685
diff
changeset
|
1708 force=None, git=False): |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1709 def checkseries(patchname): |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1710 if patchname in self.series: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1711 raise util.Abort(_('patch %s is already in the series file') |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1712 % patchname) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1713 def checkfile(patchname): |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1714 if not force and os.path.exists(self.join(patchname)): |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1715 raise util.Abort(_('patch "%s" already exists') |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1716 % patchname) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1717 |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1718 if rev: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1719 if files: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1720 raise util.Abort(_('option "-r" not valid when importing ' |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1721 'files')) |
3707
67f44b825784
Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3700
diff
changeset
|
1722 rev = cmdutil.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
|
1723 rev.sort(reverse=True) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1724 if (len(files) > 1 or len(rev) > 1) and patchname: |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
1725 raise util.Abort(_('option "-n" not valid when importing multiple ' |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1726 'patches')) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1727 if rev: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1728 # 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
|
1729 # 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
|
1730 # Otherwise, they should form a linear path to a head. |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1731 heads = repo.changelog.heads(repo.changelog.node(rev[-1])) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1732 if len(heads) > 1: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1733 raise util.Abort(_('revision %d is the root of more than one ' |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1734 'branch') % rev[-1]) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1735 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
|
1736 base = repo.changelog.node(rev[0]) |
da2a0c9c895d
mq: avoid many hex/bin conversions, keep the binary node when possible
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10663
diff
changeset
|
1737 if base in [n.node for n in self.applied]: |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1738 raise util.Abort(_('revision %d is already managed') |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1739 % rev[0]) |
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
|
1740 if heads != [self.applied[-1].node]: |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1741 raise util.Abort(_('revision %d is not the parent of ' |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1742 'the queue') % rev[0]) |
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
|
1743 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
|
1744 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
|
1745 else: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1746 if heads != [repo.changelog.node(rev[0])]: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1747 raise util.Abort(_('revision %d has unmanaged children') |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1748 % rev[0]) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1749 lastparent = None |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1750 |
10184
8a47347d298b
mq: stop caching and sharing diff options
Patrick Mezard <pmezard@gmail.com>
parents:
10114
diff
changeset
|
1751 diffopts = self.diffopts({'git': git}) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1752 for r in rev: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1753 p1, p2 = repo.changelog.parentrevs(r) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1754 n = repo.changelog.node(r) |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
1755 if p2 != nullrev: |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1756 raise util.Abort(_('cannot import merge revision %d') % r) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1757 if lastparent and lastparent != r: |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1758 raise util.Abort(_('revision %d is not the parent of %d') |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1759 % (r, lastparent)) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1760 lastparent = p1 |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1761 |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1762 if not patchname: |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
1763 patchname = normname('%d.diff' % r) |
5981
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
1764 self.check_reserved_name(patchname) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1765 checkseries(patchname) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1766 checkfile(patchname) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1767 self.full_series.insert(0, patchname) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1768 |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1769 patchf = self.opener(patchname, "w") |
10611
e764f24a45ee
patch/diff: move patch.export() to cmdutil.export()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10591
diff
changeset
|
1770 cmdutil.export(repo, [n], fp=patchf, opts=diffopts) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1771 patchf.close() |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1772 |
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
|
1773 se = statusentry(n, patchname) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1774 self.applied.insert(0, se) |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1775 |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
1776 self.added.append(patchname) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1777 patchname = None |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1778 self.parse_series() |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1779 self.applied_dirty = 1 |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
1780 self.series_dirty = True |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1781 |
10687
583adcf63f80
mq: use xrange/enumerate instead of += 1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10686
diff
changeset
|
1782 for i, filename in enumerate(files): |
1808 | 1783 if existing: |
3547 | 1784 if filename == '-': |
1785 raise util.Abort(_('-e is incompatible with import from -')) | |
11699
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1786 filename = normname(filename) |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1787 self.check_reserved_name(filename) |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1788 originpath = self.join(filename) |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1789 if not os.path.isfile(originpath): |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1790 raise util.Abort(_("patch %s does not exist") % filename) |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1791 |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1792 if patchname: |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1793 self.check_reserved_name(patchname) |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1794 checkfile(patchname) |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1795 |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1796 self.ui.write(_('renaming %s to %s\n') |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1797 % (filename, patchname)) |
11701
84fb29f5e0d2
mq: fix qimport --name --existing --force on win32
Patrick Mezard <pmezard@gmail.com>
parents:
11700
diff
changeset
|
1798 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
|
1799 else: |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1800 patchname = filename |
da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11644
diff
changeset
|
1801 |
1808 | 1802 else: |
1803 try: | |
3547 | 1804 if filename == '-': |
1805 if not patchname: | |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1806 raise util.Abort( |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
1807 _('need --name to import a patch from -')) |
3547 | 1808 text = sys.stdin.read() |
1809 else: | |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
1810 fp = url.open(self.ui, filename) |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
1811 text = fp.read() |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
1812 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
|
1813 except (OSError, IOError): |
11709
3e561b6af810
mq: clarify the fact that qimport is trying to read a file
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11637
diff
changeset
|
1814 raise util.Abort(_("unable to read file %s") % filename) |
3133
15fde1970003
qimport: rename patch to patchname to avoid shadowing module
Brendan Cully <brendan@kublai.com>
parents:
3091
diff
changeset
|
1815 if not patchname: |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
1816 patchname = normname(os.path.basename(filename)) |
5981
ca2af0c81c9a
mq: don't allow patches with some reserved names
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5980
diff
changeset
|
1817 self.check_reserved_name(patchname) |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1818 checkfile(patchname) |
3133
15fde1970003
qimport: rename patch to patchname to avoid shadowing module
Brendan Cully <brendan@kublai.com>
parents:
3091
diff
changeset
|
1819 patchf = self.opener(patchname, "w") |
1808 | 1820 patchf.write(text) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13373
diff
changeset
|
1821 patchf.close() |
7160
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
1822 if not force: |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
1823 checkseries(patchname) |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
1824 if patchname not in self.series: |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
1825 index = self.full_series_end() + i |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
1826 self.full_series[index:index] = [patchname] |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
1827 self.parse_series() |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
1828 self.series_dirty = True |
7597
81f68565281c
mq, i18n: mark strings for translation
Martin Geisler <mg@daimi.au.dk>
parents:
7454
diff
changeset
|
1829 self.ui.warn(_("adding %s to series file\n") % patchname) |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
1830 self.added.append(patchname) |
3133
15fde1970003
qimport: rename patch to patchname to avoid shadowing module
Brendan Cully <brendan@kublai.com>
parents:
3091
diff
changeset
|
1831 patchname = None |
1808 | 1832 |
13409
9e5df8719ad4
mq: remove undo after a qimport
André Sintzoff <andre.sintzoff@gmail.com>
parents:
13400
diff
changeset
|
1833 self.removeundo(repo) |
9e5df8719ad4
mq: remove undo after a qimport
André Sintzoff <andre.sintzoff@gmail.com>
parents:
13400
diff
changeset
|
1834 |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1835 def delete(ui, repo, *patches, **opts): |
2905
790fd342b6c7
Allow qdel to delete multiple patches.
Brendan Cully <brendan@kublai.com>
parents:
2904
diff
changeset
|
1836 """remove patches from queue |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1837 |
8929
cb05e2a00291
mq: compact & rewrap documentation for qdelete command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8904
diff
changeset
|
1838 The patches must not be applied, and at least one patch is required. With |
cb05e2a00291
mq: compact & rewrap documentation for qdelete command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8904
diff
changeset
|
1839 -k/--keep, the patch files are 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
|
1840 |
8be38b624902
mq: no longer mention the deprecated qdelete's --revision option
Cédric Duval <cedricduval@free.fr>
parents:
8894
diff
changeset
|
1841 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
|
1842 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
|
1843 q = repo.mq |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
1844 q.delete(repo, patches, opts) |
1808 | 1845 q.save_dirty() |
1846 return 0 | |
1847 | |
1848 def applied(ui, repo, patch=None, **opts): | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1849 """print the patches already applied |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1850 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1851 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
|
1852 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1853 q = repo.mq |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1854 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1855 if patch: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1856 if patch not in q.series: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1857 raise util.Abort(_("patch %s is not in series file") % patch) |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1858 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
|
1859 else: |
4239
417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4238
diff
changeset
|
1860 end = q.series_end(True) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1861 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1862 if opts.get('last') and not end: |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1863 ui.write(_("no patches applied\n")) |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1864 return 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1865 elif opts.get('last') and end == 1: |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1866 ui.write(_("only one patch applied\n")) |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1867 return 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1868 elif opts.get('last'): |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1869 start = end - 2 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1870 end = 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1871 else: |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1872 start = 0 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1873 |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
1874 q.qseries(repo, length=end, start=start, status='A', |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
1875 summary=opts.get('summary')) |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
1876 |
1808 | 1877 |
1878 def unapplied(ui, repo, patch=None, **opts): | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1879 """print the patches not yet applied |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1880 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1881 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
|
1882 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1883 q = repo.mq |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1884 if patch: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1885 if patch not in q.series: |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1886 raise util.Abort(_("patch %s is not in series file") % patch) |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
1887 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
|
1888 else: |
4238
ce6c364ebb2a
Fix issue443: inconsistent output of "hg qunapplied -v"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4173
diff
changeset
|
1889 start = q.series_end(True) |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1890 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1891 if start == len(q.series) and opts.get('first'): |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1892 ui.write(_("all patches applied\n")) |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1893 return 1 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1894 |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
1895 length = opts.get('first') and 1 or None |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
1896 q.qseries(repo, start=start, length=length, status='U', |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
1897 summary=opts.get('summary')) |
1808 | 1898 |
1899 def qimport(ui, repo, *filename, **opts): | |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1900 """import a patch |
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1901 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
1902 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
|
1903 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
|
1904 to the series. |
d6caebe9c293
mq: qimport: explain insertion point in doc string
Adrian Buehlmann <adrian@cadifra.com>
parents:
6627
diff
changeset
|
1905 |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1906 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
|
1907 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
|
1908 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
1909 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
|
1910 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
|
1911 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
1912 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
|
1913 overwritten. |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1914 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
1915 An existing changeset may be placed under mq control with -r/--rev |
3141
e21337e06952
mq: Add --rev argument to qimport, to adopt existing changesets.
Brendan Cully <brendan@kublai.com>
parents:
3133
diff
changeset
|
1916 (e.g. qimport --rev tip -n patch will place tip under mq control). |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
1917 With -g/--git, patches imported with --rev will use the git diff |
7387 | 1918 format. See the diffs help topic for information on why this is |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
1919 important for preserving rename/copy information and permission |
13528
73bf872a91d8
mq: mention qfinish in qimport help
Patrick Mezard <pmezard@gmail.com>
parents:
13520
diff
changeset
|
1920 changes. Use :hg:`qfinish` to remove changesets 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
|
1921 |
1f0a5a5fff43
Update qimport help explaining how to read a patch from stdin (Issue371)
David Frey <dpfrey@shaw.ca>
parents:
8028
diff
changeset
|
1922 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
|
1923 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
|
1924 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
|
1925 |
11706
5fdf08b6b50c
mq: correct qimport documentation
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11701
diff
changeset
|
1926 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
|
1927 |
52c863295754
mq: document possible combination of -e and -n for qimport
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11699
diff
changeset
|
1928 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
|
1929 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1930 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
|
1931 """ |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1932 q = repo.mq |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
1933 try: |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
1934 q.qimport(repo, filename, patchname=opts.get('name'), |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
1935 existing=opts.get('existing'), force=opts.get('force'), |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
1936 rev=opts.get('rev'), git=opts.get('git')) |
11462
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
1937 finally: |
1b82a26635d7
mq: qimport cleanup on fail (issue2214)
Vishakh H <vsh426@gmail.com>
parents:
11439
diff
changeset
|
1938 q.save_dirty() |
8362
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8288
diff
changeset
|
1939 |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8288
diff
changeset
|
1940 if opts.get('push') and not opts.get('rev'): |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8288
diff
changeset
|
1941 return q.push(repo, None) |
1808 | 1942 return 0 |
1943 | |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1944 def qinit(ui, repo, create): |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1945 """initialize a new queue repository |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1946 |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1947 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
|
1948 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
|
1949 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
|
1950 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1951 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
|
1952 q = repo.mq |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1953 r = q.init(repo, create) |
1808 | 1954 q.save_dirty() |
1955 if r: | |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1956 if not os.path.exists(r.wjoin('.hgignore')): |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1957 fp = r.wopener('.hgignore', 'w') |
6034
83633602e2c5
qinit -c: add ^\.hg and ^\.mq to .hgignore
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6027
diff
changeset
|
1958 fp.write('^\\.hg\n') |
83633602e2c5
qinit -c: add ^\.hg and ^\.mq to .hgignore
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6027
diff
changeset
|
1959 fp.write('^\\.mq\n') |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1960 fp.write('syntax: glob\n') |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1961 fp.write('status\n') |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1962 fp.write('guards\n') |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1963 fp.close() |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1964 if not os.path.exists(r.wjoin('series')): |
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1965 r.wopener('series', 'w').close() |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
1966 r[None].add(['.hgignore', 'series']) |
4071
165abe554c80
mq: qinit -c creates a repo even after a regular qinit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4068
diff
changeset
|
1967 commands.add(ui, r) |
1808 | 1968 return 0 |
1969 | |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1970 def init(ui, repo, **opts): |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1971 """init a new queue repository (DEPRECATED) |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1972 |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1973 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
|
1974 -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
|
1975 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
|
1976 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
|
1977 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
|
1978 |
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
1979 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
|
1980 commands. With -c, use :hg:`init --mq` instead.""" |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
1981 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
|
1982 |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
1983 def clone(ui, source, dest=None, **opts): |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
1984 '''clone main and patch repository at same time |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
1985 |
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
1986 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
|
1987 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
|
1988 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
|
1989 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
|
1990 before that it has no patches applied. |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
1991 |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
1992 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
|
1993 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
|
1994 |
8760
bf17aeafb869
Spell Mercurial as a proper noun
timeless <timeless@gmail.com>
parents:
8711
diff
changeset
|
1995 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
|
1996 would be created by :hg:`init --mq`. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1997 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
1998 Return 0 on success. |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
1999 ''' |
5226
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2000 def patchdir(repo): |
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2001 url = repo.url() |
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2002 if url.endswith('/'): |
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2003 url = url[:-1] |
438ff951df70
avoid double slash problem mentioned in issue695
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5180
diff
changeset
|
2004 return url + '/.hg/patches' |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2005 if dest is None: |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2006 dest = hg.defaultdest(source) |
11273
d1908cb95a82
remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents:
11271
diff
changeset
|
2007 sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source)) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2008 if opts.get('patches'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2009 patchespath = ui.expandpath(opts.get('patches')) |
7729
dd08e1e0cea1
mq: allow qclone's -p option to use path alias
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7639
diff
changeset
|
2010 else: |
dd08e1e0cea1
mq: allow qclone's -p option to use path alias
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7639
diff
changeset
|
2011 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
|
2012 try: |
7874
d812029cda85
cleanup: drop variables for unused return values
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7782
diff
changeset
|
2013 hg.repository(ui, patchespath) |
7637 | 2014 except error.RepoError: |
4862
cba10652a901
mq: improve qclone error handling when patch directory is not a repository.
Brendan Cully <brendan@kublai.com>
parents:
4737
diff
changeset
|
2015 raise util.Abort(_('versioned patch repository not found' |
10690
ea85c01c7835
mq: no longer refer to deprecated qinit -c command
Cédric Duval <cedricduval@free.fr>
parents:
10689
diff
changeset
|
2016 ' (see init --mq)')) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2017 qbase, destrev = None, None |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2018 if sr.local(): |
2725
9ffee4f07323
mq: update to handle repomap not longer used
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2724
diff
changeset
|
2019 if sr.mq.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
|
2020 qbase = sr.mq.applied[0].node |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2021 if not hg.islocal(dest): |
8152
08e1baf924ca
replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
2022 heads = set(sr.heads()) |
08e1baf924ca
replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
2023 destrev = list(heads.difference(sr.heads(qbase))) |
4171
1df1baf2002e
fix qclone to a remote repo
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4133
diff
changeset
|
2024 destrev.append(sr.changelog.parents(qbase)[0]) |
6164
0c2b443fb3c3
mq: make qclone ask remote source repo for qbase using lookup protocol
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6139
diff
changeset
|
2025 elif sr.capable('lookup'): |
6380
a632a9a57821
qclone: do not abort if remote hasn't enabled mq (issue1040)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6340
diff
changeset
|
2026 try: |
a632a9a57821
qclone: do not abort if remote hasn't enabled mq (issue1040)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6340
diff
changeset
|
2027 qbase = sr.lookup('qbase') |
7637 | 2028 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
|
2029 pass |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2030 ui.note(_('cloning main repository\n')) |
4476 | 2031 sr, dr = hg.clone(ui, sr.url(), dest, |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2032 pull=opts.get('pull'), |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2033 rev=destrev, |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2034 update=False, |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2035 stream=opts.get('uncompressed')) |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2036 ui.note(_('cloning patch repository\n')) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2037 hg.clone(ui, opts.get('patches') or patchdir(sr), patchdir(dr), |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2038 pull=opts.get('pull'), update=not opts.get('noupdate'), |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2039 stream=opts.get('uncompressed')) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2040 if dr.local(): |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2041 if qbase: |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2042 ui.note(_('stripping applied patches from destination ' |
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2043 'repository\n')) |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2044 dr.mq.strip(dr, [qbase], update=False, backup=None) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2045 if not opts.get('noupdate'): |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
2046 ui.note(_('updating destination repository\n')) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
2772
diff
changeset
|
2047 hg.update(dr, dr.changelog.tip()) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2713
diff
changeset
|
2048 |
1808 | 2049 def commit(ui, repo, *pats, **opts): |
10361
49cd2e7fd91c
mq: deprecate qinit and qcommit
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10360
diff
changeset
|
2050 """commit changes in the queue repository (DEPRECATED) |
49cd2e7fd91c
mq: deprecate qinit and qcommit
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10360
diff
changeset
|
2051 |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11121
diff
changeset
|
2052 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
|
2053 q = repo.mq |
1808 | 2054 r = q.qrepo() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2055 if not r: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2056 raise util.Abort('no queue repository') |
1808 | 2057 commands.commit(r.ui, r, *pats, **opts) |
2058 | |
2059 def series(ui, repo, **opts): | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2060 """print the entire series file |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2061 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2062 Returns 0 on success.""" |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2063 repo.mq.qseries(repo, missing=opts.get('missing'), summary=opts.get('summary')) |
1808 | 2064 return 0 |
2065 | |
2066 def top(ui, repo, **opts): | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2067 """print the name of the current patch |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2068 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2069 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
|
2070 q = repo.mq |
4406
f700ea2b0689
mq: fix qtop failure when the series ends with guarded patches.
Patrick Mezard <pmezard@gmail.com>
parents:
4341
diff
changeset
|
2071 t = q.applied and q.series_end(True) or 0 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2072 if t: |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2073 q.qseries(repo, start=t - 1, length=1, status='A', |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2074 summary=opts.get('summary')) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2075 else: |
7627 | 2076 ui.write(_("no patches applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2077 return 1 |
1808 | 2078 |
2079 def next(ui, repo, **opts): | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2080 """print the name of the next patch |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2081 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2082 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
|
2083 q = repo.mq |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2084 end = q.series_end() |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2085 if end == len(q.series): |
7627 | 2086 ui.write(_("all patches applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2087 return 1 |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2088 q.qseries(repo, start=end, length=1, summary=opts.get('summary')) |
1808 | 2089 |
2090 def prev(ui, repo, **opts): | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2091 """print the name of the previous patch |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2092 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2093 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
|
2094 q = repo.mq |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2095 l = len(q.applied) |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2096 if l == 1: |
7627 | 2097 ui.write(_("only one patch applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2098 return 1 |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2099 if not l: |
7627 | 2100 ui.write(_("no patches applied\n")) |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
2101 return 1 |
12539
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2102 q.qseries(repo, start=l - 2, length=1, status='A', |
dece1f46f7a2
mq: removed return from callers to patchheader.qseries
Erik Zielke <ez@aragost.com>
parents:
12538
diff
changeset
|
2103 summary=opts.get('summary')) |
1808 | 2104 |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2105 def setupheaderopts(ui, opts): |
9733
f16ec85f125c
mq: do not call ui.username unless it is necessary
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
2106 if not opts.get('user') and opts.get('currentuser'): |
f16ec85f125c
mq: do not call ui.username unless it is necessary
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
2107 opts['user'] = ui.username() |
f16ec85f125c
mq: do not call ui.username unless it is necessary
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
2108 if not opts.get('date') and opts.get('currentdate'): |
f16ec85f125c
mq: do not call ui.username unless it is necessary
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
2109 opts['date'] = "%d %d" % util.makedate() |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2110 |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
2111 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
|
2112 """create a new patch |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
2113 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2114 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
|
2115 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
|
2116 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
|
2117 -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
|
2118 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
|
2119 as uncommitted modifications. |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
2120 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2121 -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
|
2122 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
|
2123 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
|
2124 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2125 -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
|
2126 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
|
2127 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
|
2128 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2129 Use the -g/--git option to keep the patch in the git extended diff |
7387 | 2130 format. Read the diffs help topic for more information on why this |
2131 is important for preserving permission changes and copy/rename | |
2132 information. | |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2133 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2134 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
|
2135 """ |
7157
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
2136 msg = cmdutil.logmessage(opts) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2137 def getmsg(): |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2138 return ui.edit(msg, opts.get('user') or ui.username()) |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2139 q = repo.mq |
7157
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
2140 opts['msg'] = msg |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
2141 if opts.get('edit'): |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
2142 opts['msg'] = getmsg |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
2143 else: |
fd3cba5e73ae
mq: do not invoke editor until just before patch creation. Closes issue1346.
Brendan Cully <brendan@kublai.com>
parents:
7142
diff
changeset
|
2144 opts['msg'] = msg |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2145 setupheaderopts(ui, opts) |
4713
c29ee52e0b68
mq: support qnew -I/-X and file name lists
Brendan Cully <brendan@kublai.com>
parents:
4712
diff
changeset
|
2146 q.new(repo, patch, *args, **opts) |
1808 | 2147 q.save_dirty() |
2148 return 0 | |
2149 | |
2938
5b7a118f5b6c
allow qrefresh to take a list of files; closes #96.
Brendan Cully <brendan@kublai.com>
parents:
2937
diff
changeset
|
2150 def refresh(ui, repo, *pats, **opts): |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2151 """update the current patch |
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2152 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2153 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
|
2154 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
|
2155 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
|
2156 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2157 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
|
2158 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
|
2159 |
11947
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2160 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
|
2161 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
|
2162 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
|
2163 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2164 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
|
2165 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
|
2166 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
|
2167 git diff format. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2168 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2169 Returns 0 on success. |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2170 """ |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2171 q = repo.mq |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4476
diff
changeset
|
2172 message = cmdutil.logmessage(opts) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2173 if opts.get('edit'): |
5334
448eb46d4d84
mq: fix qrefresh -e with no patches applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5226
diff
changeset
|
2174 if not q.applied: |
7627 | 2175 ui.write(_("no patches applied\n")) |
5334
448eb46d4d84
mq: fix qrefresh -e with no patches applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5226
diff
changeset
|
2176 return 1 |
2746
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
2177 if message: |
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
2178 raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
2780
ee48e5ef8753
Use StatusEntry class instead of repeated status line parsing.
Brendan Cully <brendan@kublai.com>
parents:
2765
diff
changeset
|
2179 patch = q.applied[-1].name |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
2180 ph = patchheader(q.join(patch), q.plainmode) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
2181 message = ui.edit('\n'.join(ph.message), ph.user or ui.username()) |
11947
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2182 # We don't want to lose the patch message if qrefresh fails (issue2062) |
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2183 msgfile = repo.opener('last-message.txt', 'wb') |
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2184 msgfile.write(message) |
59ec12093261
mq: save qrefresh message for easy recovery in case it fails (issue2062)
Renato Cunha <renatoc@gmail.com>
parents:
11939
diff
changeset
|
2185 msgfile.close() |
5673
dd3ce7515f4d
mq: add --currentuser and --user options to qnew and qrefresh
peter.arrenbrecht@gmail.com
parents:
5645
diff
changeset
|
2186 setupheaderopts(ui, opts) |
3004
ac74046f8f58
qrefresh: exit with status 1 if no patches applied.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2984
diff
changeset
|
2187 ret = q.refresh(repo, pats, msg=message, **opts) |
1808 | 2188 q.save_dirty() |
3004
ac74046f8f58
qrefresh: exit with status 1 if no patches applied.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2984
diff
changeset
|
2189 return ret |
1808 | 2190 |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
2191 def diff(ui, repo, *pats, **opts): |
6606
088ba40585b9
mq: expand help text for qdiff
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6561
diff
changeset
|
2192 """diff of the current patch and subsequent modifications |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
2193 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2194 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
|
2195 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
|
2196 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
|
2197 after a qrefresh). |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
2198 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10962
diff
changeset
|
2199 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
|
2200 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
|
2201 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
|
2202 qrefresh. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2203 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2204 Returns 0 on success. |
6606
088ba40585b9
mq: expand help text for qdiff
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6561
diff
changeset
|
2205 """ |
2937
9dc568f5e03d
Fix test-mq-qdiff; add -I and -X options to qdiff
Brendan Cully <brendan@kublai.com>
parents:
2936
diff
changeset
|
2206 repo.mq.diff(repo, pats, opts) |
1808 | 2207 return 0 |
2208 | |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2209 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
|
2210 """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
|
2211 |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
2212 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
|
2213 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
|
2214 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
|
2215 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
|
2216 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
|
2217 removed afterwards. |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
2218 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2219 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
|
2220 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
|
2221 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2222 Returns 0 on success.""" |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2223 |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2224 q = repo.mq |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2225 |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2226 if not files: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2227 raise util.Abort(_('qfold requires at least one patch name')) |
10191
99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Patrick Mezard <pmezard@gmail.com>
parents:
10190
diff
changeset
|
2228 if not q.check_toppatch(repo)[0]: |
12067
a4fbbe0fbc38
Lowercase error messages
Martin Geisler <mg@lazybytes.net>
parents:
11965
diff
changeset
|
2229 raise util.Abort(_('no patches applied')) |
8425
73d80d5bf478
mq: abort qfold upon local changes (issue1662)
David Frey <dpfrey@shaw.ca>
parents:
7782
diff
changeset
|
2230 q.check_localchanges(repo) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2231 |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4476
diff
changeset
|
2232 message = cmdutil.logmessage(opts) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2233 if opts.get('edit'): |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2234 if message: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2235 raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2236 |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2237 parent = q.lookup('qtip') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2238 patches = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2239 messages = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2240 for f in files: |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2241 p = q.lookup(f) |
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2242 if p in patches or p == parent: |
12208
482443557cad
mq: add newline after qfold warning
Patrick Mezard <pmezard@gmail.com>
parents:
12070
diff
changeset
|
2243 ui.warn(_('Skipping already folded patch %s\n') % p) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2244 if q.isapplied(p): |
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2245 raise util.Abort(_('qfold cannot fold already applied patch %s') % p) |
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2246 patches.append(p) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2247 |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2248 for p in patches: |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2249 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
|
2250 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
|
2251 if ph.message: |
1d5ecaa47abb
mq: filter out empty commit messages in qfold
Brendan Cully <brendan@kublai.com>
parents:
7453
diff
changeset
|
2252 messages.append(ph.message) |
2936
21bf8929efc8
Fix qfold after recent changes
Brendan Cully <brendan@kublai.com>
parents:
2934
diff
changeset
|
2253 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
|
2254 (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
|
2255 if not patchsuccess: |
12067
a4fbbe0fbc38
Lowercase error messages
Martin Geisler <mg@lazybytes.net>
parents:
11965
diff
changeset
|
2256 raise util.Abort(_('error folding patch %s') % p) |
12266
00658492e2aa
patch: break import cycle with cmdutil
Martin Geisler <mg@lazybytes.net>
parents:
12208
diff
changeset
|
2257 cmdutil.updatedir(ui, repo, files) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2258 |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2259 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
|
2260 ph = patchheader(q.join(parent), q.plainmode) |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
2261 message, user = ph.message, ph.user |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2262 for msg in messages: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2263 message.append('* * *') |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2264 message.extend(msg) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2265 message = '\n'.join(message) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2266 |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2267 if opts.get('edit'): |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2268 message = ui.edit(message, user or ui.username()) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2269 |
10186
296a0b14a686
mq: preserve --git flag when folding patches
Patrick Mezard <pmezard@gmail.com>
parents:
10185
diff
changeset
|
2270 diffopts = q.patchopts(q.diffopts(), *patches) |
296a0b14a686
mq: preserve --git flag when folding patches
Patrick Mezard <pmezard@gmail.com>
parents:
10185
diff
changeset
|
2271 q.refresh(repo, msg=message, git=diffopts.git) |
3243
1d3aceae87c1
mq: update qfold to call delete correctly
Brendan Cully <brendan@kublai.com>
parents:
3223
diff
changeset
|
2272 q.delete(repo, patches, opts) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2273 q.save_dirty() |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
2274 |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2275 def goto(ui, repo, patch, **opts): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2276 '''push or pop patches until named patch is at top of stack |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2277 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2278 Returns 0 on success.''' |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2279 q = repo.mq |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2280 patch = q.lookup(patch) |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2281 if q.isapplied(patch): |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2282 ret = q.pop(repo, patch, force=opts.get('force')) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2283 else: |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2284 ret = q.push(repo, patch, force=opts.get('force')) |
4432
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2285 q.save_dirty() |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2286 return ret |
905397be7688
mq: add qgoto command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4430
diff
changeset
|
2287 |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2288 def guard(ui, repo, *args, **opts): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2289 '''set or print guards for a patch |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2290 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2291 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
|
2292 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
|
2293 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
|
2294 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
|
2295 has activated it. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2296 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2297 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
|
2298 With arguments, set guards for the named patch. |
12389 | 2299 |
2300 .. note:: | |
2301 Specifying negative guards now requires '--'. | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2302 |
9824
87c92b260710
mq: fix literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9733
diff
changeset
|
2303 To set guards on another patch:: |
87c92b260710
mq: fix literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9733
diff
changeset
|
2304 |
10476
3113736dbac5
mq: more instructive use of "--" in qguard help (issue2040)
Martin Geisler <mg@lazybytes.net>
parents:
10413
diff
changeset
|
2305 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
|
2306 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2307 Returns 0 on success. |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2308 ''' |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2309 def status(idx): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2310 guards = q.series_guards[idx] or ['unguarded'] |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2311 if q.series[idx] in applied: |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2312 state = 'applied' |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2313 elif q.pushable(idx)[0]: |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2314 state = 'unapplied' |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2315 else: |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2316 state = 'guarded' |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2317 label = 'qguard.patch qguard.%s qseries.%s' % (state, state) |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2318 ui.write('%s: ' % ui.label(q.series[idx], label)) |
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2319 |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2320 for i, guard in enumerate(guards): |
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2321 if guard.startswith('+'): |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2322 ui.write(guard, label='qguard.positive') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2323 elif guard.startswith('-'): |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2324 ui.write(guard, label='qguard.negative') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2325 else: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2326 ui.write(guard, label='qguard.unguarded') |
10822
4c63f8e787b8
qguard: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10814
diff
changeset
|
2327 if i != len(guards) - 1: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2328 ui.write(' ') |
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
2329 ui.write('\n') |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2330 q = repo.mq |
11819
1c00577b0298
qguard: label patch names by status when listing guards
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11789
diff
changeset
|
2331 applied = set(p.name for p in q.applied) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2332 patch = None |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2333 args = list(args) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2334 if opts.get('list'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2335 if args or opts.get('none'): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2336 raise util.Abort(_('cannot mix -l/--list with options or arguments')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2337 for i in xrange(len(q.series)): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2338 status(i) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2339 return |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2340 if not args or args[0][0:1] in '-+': |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2341 if not q.applied: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2342 raise util.Abort(_('no patches applied')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2343 patch = q.applied[-1].name |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2344 if patch is None and args[0][0:1] not in '-+': |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2345 patch = args.pop(0) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2346 if patch is None: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2347 raise util.Abort(_('no patch to work with')) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2348 if args or opts.get('none'): |
4133
a9ee6c53af8d
mq: abort cleanly when invalid patch name is given to qguard
Christian Ebert <blacktrash@gmx.net>
parents:
4090
diff
changeset
|
2349 idx = q.find_series(patch) |
a9ee6c53af8d
mq: abort cleanly when invalid patch name is given to qguard
Christian Ebert <blacktrash@gmx.net>
parents:
4090
diff
changeset
|
2350 if idx is None: |
a9ee6c53af8d
mq: abort cleanly when invalid patch name is given to qguard
Christian Ebert <blacktrash@gmx.net>
parents:
4090
diff
changeset
|
2351 raise util.Abort(_('no patch named %s') % patch) |
a9ee6c53af8d
mq: abort cleanly when invalid patch name is given to qguard
Christian Ebert <blacktrash@gmx.net>
parents:
4090
diff
changeset
|
2352 q.set_guards(idx, args) |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2353 q.save_dirty() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2354 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2355 status(q.series.index(q.lookup(patch))) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2356 |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2357 def header(ui, repo, patch=None): |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2358 """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
|
2359 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2360 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
|
2361 q = repo.mq |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2362 |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2363 if patch: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2364 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
|
2365 else: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2366 if not q.applied: |
10510
f77f3383c666
i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10498
diff
changeset
|
2367 ui.write(_('no patches applied\n')) |
3008
c203ccd7d838
qheader: exit withh meaningful error code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3006
diff
changeset
|
2368 return 1 |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2369 patch = q.lookup('qtip') |
10397
8cb81d75730c
mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh <steve@stevelosh.com>
parents:
10382
diff
changeset
|
2370 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
|
2371 |
7399
e71bda2d2087
mq: create patch header class to abstract header manipulation
Brendan Cully <brendan@kublai.com>
parents:
7398
diff
changeset
|
2372 ui.write('\n'.join(ph.message) + '\n') |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
2373 |
1808 | 2374 def lastsavename(path): |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2375 (directory, base) = os.path.split(path) |
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2376 names = os.listdir(directory) |
1808 | 2377 namere = re.compile("%s.([0-9]+)" % base) |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2378 maxindex = None |
1808 | 2379 maxname = None |
2380 for f in names: | |
2381 m = namere.match(f) | |
2382 if m: | |
2383 index = int(m.group(1)) | |
8527
f9a80054dd3c
use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents:
8525
diff
changeset
|
2384 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
|
2385 maxindex = index |
1808 | 2386 maxname = f |
2387 if maxname: | |
2794
86c54b7cd331
mq: fix variables shadowing builtin
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2792
diff
changeset
|
2388 return (os.path.join(directory, maxname), maxindex) |
1808 | 2389 return (None, None) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2390 |
1808 | 2391 def savename(path): |
2392 (last, index) = lastsavename(path) | |
2393 if last is None: | |
2394 index = 0 | |
2395 newpath = path + ".%d" % (index + 1) | |
2396 return newpath | |
2397 | |
2398 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
|
2399 """push the next patch onto the stack |
6553
0bb76d168437
remove trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6552
diff
changeset
|
2400 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2401 When -f/--force is applied, all local changes in patched files |
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2402 will be lost. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2403 |
13725
6783f47d90dd
mq: fix typo in docstring
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
13632
diff
changeset
|
2404 Return 0 on success. |
6552
315b36ce6251
mq: add a little documentation on qpush -f
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6382
diff
changeset
|
2405 """ |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2406 q = repo.mq |
1808 | 2407 mergeq = None |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2408 |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2409 if opts.get('merge'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2410 if opts.get('name'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2411 newpath = repo.join(opts.get('name')) |
1808 | 2412 else: |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2413 newpath, i = lastsavename(q.path) |
1808 | 2414 if not newpath: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2415 ui.warn(_("no saved queues found, please use -n\n")) |
1808 | 2416 return 1 |
2417 mergeq = queue(ui, repo.join(""), newpath) | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2418 ui.warn(_("merging with queue at: %s\n") % mergeq.path) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2419 ret = q.push(repo, patch, force=opts.get('force'), list=opts.get('list'), |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
2420 mergeq=mergeq, all=opts.get('all'), move=opts.get('move'), |
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
2421 exact=opts.get('exact')) |
1808 | 2422 return ret |
2423 | |
2424 def pop(ui, repo, patch=None, **opts): | |
6611
f4c612da788d
mq: add correct documentation for qpop
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6610
diff
changeset
|
2425 """pop the current patch off the stack |
6621
d5cbbe2c49ce
mq: lose the trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6611
diff
changeset
|
2426 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2427 By default, pops off the top of the patch stack. If given a patch |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2428 name, keeps popping off patches until the named patch is at the |
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2429 top of the stack. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2430 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2431 Return 0 on success. |
6611
f4c612da788d
mq: add correct documentation for qpop
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6610
diff
changeset
|
2432 """ |
1808 | 2433 localupdate = True |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2434 if opts.get('name'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2435 q = queue(ui, repo.join(""), repo.join(opts.get('name'))) |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2436 ui.warn(_('using patch queue: %s\n') % q.path) |
1808 | 2437 localupdate = False |
2438 else: | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2439 q = repo.mq |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2440 ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate, |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2441 all=opts.get('all')) |
1808 | 2442 q.save_dirty() |
4099
cf5580c16b13
mq: propagate the return error of pop
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4096
diff
changeset
|
2443 return ret |
1808 | 2444 |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2445 def rename(ui, repo, patch, name=None, **opts): |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2446 """rename a patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2447 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2448 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
|
2449 With two arguments, renames PATCH1 to PATCH2. |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2450 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2451 Returns 0 on success.""" |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2452 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2453 q = repo.mq |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2454 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2455 if not name: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2456 name = patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2457 patch = None |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2458 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2459 if patch: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2460 patch = q.lookup(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2461 else: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2462 if not q.applied: |
7627 | 2463 ui.write(_('no patches applied\n')) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2464 return |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2465 patch = q.lookup('qtip') |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
2466 absdest = q.join(name) |
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
2467 if os.path.isdir(absdest): |
4037
bbdba01cce28
Enforce unixish style for all generated patch names.
Patrick Mezard <pmezard@gmail.com>
parents:
4016
diff
changeset
|
2468 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
|
2469 absdest = q.join(name) |
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
2470 if os.path.exists(absdest): |
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
2471 raise util.Abort(_('%s already exists') % absdest) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
2472 |
3083
82c9d1aac308
Make qrename handle directory targets; closes #333.
Brendan Cully <brendan@kublai.com>
parents:
3082
diff
changeset
|
2473 if name in q.series: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2474 raise util.Abort( |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2475 _('A patch named %s already exists in the series file') % name) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2476 |
10510
f77f3383c666
i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10498
diff
changeset
|
2477 ui.note(_('renaming %s to %s\n') % (patch, name)) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2478 i = q.find_series(patch) |
3685
193e9c6d1a6d
Issue424: mq patch loses guard when qrenamed
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents:
3681
diff
changeset
|
2479 guards = q.guard_re.findall(q.full_series[i]) |
193e9c6d1a6d
Issue424: mq patch loses guard when qrenamed
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents:
3681
diff
changeset
|
2480 q.full_series[i] = name + ''.join([' #' + g for g in guards]) |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
2481 q.parse_series() |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2482 q.series_dirty = 1 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2483 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2484 info = q.isapplied(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2485 if info: |
2818
bdc067ff6cf5
Make mq camelcase consistent with the rest of hg.
Brendan Cully <brendan@kublai.com>
parents:
2816
diff
changeset
|
2486 q.applied[info[0]] = statusentry(info[1], name) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2487 q.applied_dirty = 1 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2488 |
11513
0c944b7af564
mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara <yuya@tcha.org>
parents:
11462
diff
changeset
|
2489 destdir = os.path.dirname(absdest) |
0c944b7af564
mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara <yuya@tcha.org>
parents:
11462
diff
changeset
|
2490 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
|
2491 os.makedirs(destdir) |
2819 | 2492 util.rename(q.join(patch), absdest) |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2493 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
|
2494 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
|
2495 wctx = r[None] |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2496 wlock = r.wlock() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
2497 try: |
6648
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
2498 if r.dirstate[patch] == 'a': |
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
2499 r.dirstate.forget(patch) |
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
2500 r.dirstate.add(name) |
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
2501 else: |
2519976a998b
mq: handle added patch renaming correctly
Weijun Wang <weijun.wang@sun.com>
parents:
6635
diff
changeset
|
2502 if r.dirstate[name] == 'r': |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
2503 wctx.undelete([name]) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
2504 wctx.copy(patch, name) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11302
diff
changeset
|
2505 wctx.remove([patch], False) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
2506 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8076
diff
changeset
|
2507 wlock.release() |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2508 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2509 q.save_dirty() |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
2510 |
1808 | 2511 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
|
2512 """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
|
2513 |
12352
5be733b20bd1
mq: fix the deprecation comment for qsave & qrestore.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12344
diff
changeset
|
2514 This command is deprecated, use :hg:`rebase` instead.""" |
1808 | 2515 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
|
2516 q = repo.mq |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2517 q.restore(repo, rev, delete=opts.get('delete'), |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2518 qupdate=opts.get('update')) |
1808 | 2519 q.save_dirty() |
2520 return 0 | |
2521 | |
2522 def save(ui, repo, **opts): | |
10360
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
2523 """save current queue state (DEPRECATED) |
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
2524 |
12352
5be733b20bd1
mq: fix the deprecation comment for qsave & qrestore.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12344
diff
changeset
|
2525 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
|
2526 q = repo.mq |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4476
diff
changeset
|
2527 message = cmdutil.logmessage(opts) |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
2528 ret = q.save(repo, msg=message) |
1808 | 2529 if ret: |
2530 return ret | |
2531 q.save_dirty() | |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2532 if opts.get('copy'): |
1808 | 2533 path = q.path |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2534 if opts.get('name'): |
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2535 newpath = os.path.join(q.basepath, opts.get('name')) |
1808 | 2536 if os.path.exists(newpath): |
2537 if not os.path.isdir(newpath): | |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
2538 raise util.Abort(_('destination %s exists and is not ' |
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
2539 'a directory') % newpath) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2540 if not opts.get('force'): |
2712
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
2541 raise util.Abort(_('destination %s exists, ' |
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2711
diff
changeset
|
2542 'use -f to force') % newpath) |
1808 | 2543 else: |
2544 newpath = savename(path) | |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2545 ui.warn(_("copy %s to %s\n") % (path, newpath)) |
1808 | 2546 util.copyfiles(path, newpath) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2547 if opts.get('empty'): |
1808 | 2548 try: |
2819 | 2549 os.unlink(q.join(q.status_path)) |
1808 | 2550 except: |
2551 pass | |
2552 return 0 | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
2553 |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2554 def strip(ui, repo, *revs, **opts): |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2555 """strip changesets and all their descendants from the repository |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2556 |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2557 The strip command removes the specified changesets and all their |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2558 descendants. If the working directory has uncommitted changes, |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2559 the operation is aborted unless the --force flag is supplied. |
6635
d90d83ebea9e
mq: don't update the working copy on strip if parents aren't stripped
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6634
diff
changeset
|
2560 |
11073
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2561 If a parent of the working directory is stripped, then the working |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2562 directory will automatically be updated to the most recent |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2563 available ancestor of the stripped parent after the operation |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2564 completes. |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2565 |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2566 Any stripped changesets are stored in ``.hg/strip-backup`` as a |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11121
diff
changeset
|
2567 bundle (see :hg:`help bundle` and :hg:`help unbundle`). They can |
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11121
diff
changeset
|
2568 be restored by running :hg:`unbundle .hg/strip-backup/BUNDLE`, |
11073
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2569 where BUNDLE is the bundle file created by the strip. Note that |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2570 the local revision numbers will in general be different after the |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2571 restore. |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2572 |
12282
9e457c3f47d9
mq: rename strip --nobackup option to --no-backup (issue2377)
Christian Ebert <blacktrash@gmx.net>
parents:
12281
diff
changeset
|
2573 Use the --no-backup option to discard the backup bundle once the |
11073
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
2574 operation completes. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2575 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2576 Return 0 on success. |
6635
d90d83ebea9e
mq: don't update the working copy on strip if parents aren't stripped
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6634
diff
changeset
|
2577 """ |
1808 | 2578 backup = 'all' |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2579 if opts.get('backup'): |
1808 | 2580 backup = 'strip' |
13224
0a1eefaf98f2
strip: typo bugfix related to '--nobackup -> --no-backup' rename (issue2377)
Jacek Sowiński <mruwek.gentoo@vcf.pl>
parents:
13035
diff
changeset
|
2581 elif opts.get('no_backup') or opts.get('nobackup'): |
1808 | 2582 backup = 'none' |
6635
d90d83ebea9e
mq: don't update the working copy on strip if parents aren't stripped
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6634
diff
changeset
|
2583 |
d90d83ebea9e
mq: don't update the working copy on strip if parents aren't stripped
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6634
diff
changeset
|
2584 cl = repo.changelog |
12767
c3316b6a3219
strip: support revision sets
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
12755
diff
changeset
|
2585 revs = set(cmdutil.revrange(repo, revs)) |
c3316b6a3219
strip: support revision sets
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
12755
diff
changeset
|
2586 if not revs: |
12775
cbbcabde2414
mq: mark string for i18n
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
12767
diff
changeset
|
2587 raise util.Abort(_('empty revision set')) |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2588 |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2589 descendants = set(cl.descendants(*revs)) |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2590 strippedrevs = revs.union(descendants) |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2591 roots = revs.difference(descendants) |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2592 |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2593 update = False |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2594 # if one of the wdir parent is stripped we'll need |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2595 # to update away to an earlier revision |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2596 for p in repo.dirstate.parents(): |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2597 if p != nullid and cl.rev(p) in strippedrevs: |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2598 update = True |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2599 break |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2600 |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2601 rootnodes = set(cl.node(r) for r in roots) |
6635
d90d83ebea9e
mq: don't update the working copy on strip if parents aren't stripped
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6634
diff
changeset
|
2602 |
11637
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2603 q = repo.mq |
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2604 if q.applied: |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2605 # refresh queue state if we're about to strip |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2606 # applied patches |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2607 if cl.rev(repo.lookup('qtip')) in strippedrevs: |
11637
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2608 q.applied_dirty = True |
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2609 start = 0 |
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2610 end = len(q.applied) |
11789
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2611 for i, statusentry in enumerate(q.applied): |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2612 if statusentry.node in rootnodes: |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2613 # if one of the stripped roots is an applied |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2614 # patch, only part of the queue is stripped |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2615 start = i |
e2bce1c717fa
strip: support multiple revisions
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11767
diff
changeset
|
2616 break |
11637
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2617 del q.applied[start:end] |
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2618 q.save_dirty() |
64f284da1278
mq: cleanup status if applied mq is stripped (issue1881)
Vishakh H <vsh426@gmail.com>
parents:
11546
diff
changeset
|
2619 |
12682
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2620 revs = list(rootnodes) |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2621 if update and opts.get('keep'): |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2622 wlock = repo.wlock() |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2623 try: |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2624 urev = repo.mq.qparents(repo, revs[0]) |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2625 repo.dirstate.rebuild(urev, repo[urev].manifest()) |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2626 repo.dirstate.write() |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2627 update = False |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2628 finally: |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2629 wlock.release() |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2630 |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
2631 repo.mq.strip(repo, revs, backup=backup, update=update, |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2632 force=opts.get('force')) |
1808 | 2633 return 0 |
2634 | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2635 def select(ui, repo, *args, **opts): |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2636 '''set or print guarded patches to push |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2637 |
11307
7f72031d4047
mq: use hg reST role some more
Martin Geisler <mg@aragost.com>
parents:
11303
diff
changeset
|
2638 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
|
2639 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
|
2640 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
|
2641 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
|
2642 match the current guard. For example:: |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2643 |
13791 | 2644 qguard foo.patch -- -stable (negative guard) |
2645 qguard bar.patch +stable (positive guard) | |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2646 qselect stable |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2647 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2648 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
|
2649 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
|
2650 positive match). |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2651 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2652 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
|
2653 With one argument, sets the active guard. |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
2654 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2655 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
|
2656 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
|
2657 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
|
2658 |
2940
b1e6d701a03a
mq help text updates and speling fixes
Brendan Cully <brendan@kublai.com>
parents:
2939
diff
changeset
|
2659 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
|
2660 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
|
2661 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
|
2662 --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
|
2663 guarded patches. |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2664 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2665 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
|
2666 (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
|
2667 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2668 Returns 0 on success.''' |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2669 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2670 q = repo.mq |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2671 guards = q.active() |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2672 if args or opts.get('none'): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2673 old_unapplied = q.unapplied(repo) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2674 old_guarded = [i for i in xrange(len(q.applied)) if |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2675 not q.pushable(i)[0]] |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2676 q.set_active(args) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2677 q.save_dirty() |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2678 if not args: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2679 ui.status(_('guards deactivated\n')) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2680 if not opts.get('pop') and not opts.get('reapply'): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2681 unapplied = q.unapplied(repo) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2682 guarded = [i for i in xrange(len(q.applied)) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2683 if not q.pushable(i)[0]] |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2684 if len(unapplied) != len(old_unapplied): |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2685 ui.status(_('number of unguarded, unapplied patches has ' |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2686 'changed from %d to %d\n') % |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2687 (len(old_unapplied), len(unapplied))) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2688 if len(guarded) != len(old_guarded): |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2689 ui.status(_('number of guarded, applied patches has changed ' |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2690 'from %d to %d\n') % |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2691 (len(old_guarded), len(guarded))) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2692 elif opts.get('series'): |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2693 guards = {} |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2694 noguards = 0 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2695 for gs in q.series_guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2696 if not gs: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2697 noguards += 1 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2698 for g in gs: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2699 guards.setdefault(g, 0) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2700 guards[g] += 1 |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2701 if ui.verbose: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2702 guards['NONE'] = noguards |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2703 guards = guards.items() |
9032
1fa80c5428b8
compat: use 'key' argument instead of 'cmp' when sorting a list
Alejandro Santos <alejolp@alejolp.com>
parents:
9016
diff
changeset
|
2704 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
|
2705 if guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2706 ui.note(_('guards in series file:\n')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2707 for guard, count in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2708 ui.note('%2d ' % count) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2709 ui.write(guard, '\n') |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2710 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2711 ui.note(_('no guards in series file\n')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2712 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2713 if guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2714 ui.note(_('active guards:\n')) |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2715 for g in guards: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2716 ui.write(g, '\n') |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2717 else: |
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2718 ui.write(_('no active guards\n')) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2719 reapply = opts.get('reapply') and q.applied and q.appliedname(-1) |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2720 popped = False |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2721 if opts.get('pop') or opts.get('reapply'): |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2722 for i in xrange(len(q.applied)): |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2723 pushable, reason = q.pushable(i) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2724 if not pushable: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2725 ui.status(_('popping guarded patches\n')) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2726 popped = True |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2727 if i == 0: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2728 q.pop(repo, all=True) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2729 else: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
2730 q.pop(repo, i - 1) |
2844
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2731 break |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2732 if popped: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2733 try: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2734 if reapply: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2735 ui.status(_('reapplying unguarded patches\n')) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2736 q.push(repo, reapply) |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2737 finally: |
582cbc4392cb
qselect: add --pop, --reapply options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2830
diff
changeset
|
2738 q.save_dirty() |
2821
2e4ace008c94
mq: new commands qselect, qguard
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2819
diff
changeset
|
2739 |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2740 def finish(ui, repo, *revrange, **opts): |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2741 """move applied patches into repository history |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2742 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2743 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
|
2744 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
|
2745 history. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2746 |
8076
5ec526c1a32f
help texts: write command line switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
2747 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
|
2748 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
|
2749 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
|
2750 stack of applied patches. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2751 |
7994
3c22fdc741d8
mq: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2752 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
|
2753 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
|
2754 to upstream. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2755 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2756 Returns 0 on success. |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2757 """ |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2758 if not opts.get('applied') and not revrange: |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2759 raise util.Abort(_('no revisions specified')) |
12281
d9cf0d1d0d0f
mq: consistently use opts.get() to prevent potential KeyError
Christian Ebert <blacktrash@gmx.net>
parents:
12266
diff
changeset
|
2760 elif opts.get('applied'): |
11730
7469ff872122
qfinish: fix range logic for --applied
Matt Mackall <mpm@selenic.com>
parents:
11717
diff
changeset
|
2761 revrange = ('qbase::qtip',) + revrange |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2762 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2763 q = repo.mq |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2764 if not q.applied: |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2765 ui.status(_('no patches applied\n')) |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2766 return 0 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2767 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2768 revs = cmdutil.revrange(repo, revrange) |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2769 q.finish(repo, revs) |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2770 q.save_dirty() |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2771 return 0 |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
2772 |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2773 def qqueue(ui, repo, name=None, **opts): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2774 '''manage multiple patch queues |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2775 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2776 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
|
2777 new patch queues and deleting existing ones. |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2778 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2779 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
|
2780 queues - by default the "normal" patches queue is registered. The currently |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2781 active queue will be marked with "(active)". |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2782 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2783 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
|
2784 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
|
2785 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
|
2786 created and switching will fail. |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2787 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2788 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
|
2789 active queue. |
12538
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2790 |
c87216e5e43e
mq: added return 0 on success
Erik Zielke <ez@aragost.com>
parents:
12508
diff
changeset
|
2791 Returns 0 on success. |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2792 ''' |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2793 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2794 q = repo.mq |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2795 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2796 _defaultqueue = 'patches' |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2797 _allqueues = 'patches.queues' |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2798 _activequeue = 'patches.queue' |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2799 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2800 def _getcurrent(): |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2801 cur = os.path.basename(q.path) |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2802 if cur.startswith('patches-'): |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2803 cur = cur[8:] |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2804 return cur |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2805 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2806 def _noqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2807 try: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2808 fh = repo.opener(_allqueues, 'r') |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2809 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2810 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2811 return True |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2812 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2813 return False |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2814 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2815 def _getqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2816 current = _getcurrent() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2817 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2818 try: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2819 fh = repo.opener(_allqueues, 'r') |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2820 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
|
2821 fh.close() |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2822 if current not in queues: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2823 queues.append(current) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2824 except IOError: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2825 queues = [_defaultqueue] |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2826 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2827 return sorted(queues) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2828 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2829 def _setactive(name): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2830 if q.applied: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2831 raise util.Abort(_('patches applied - cannot set new queue active')) |
11938
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
2832 _setactivenocheck(name) |
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
2833 |
b8b1e6e78486
mq/qqueue: split _setactive
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11819
diff
changeset
|
2834 def _setactivenocheck(name): |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2835 fh = repo.opener(_activequeue, 'w') |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2836 if name != 'patches': |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2837 fh.write(name) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2838 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2839 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2840 def _addqueue(name): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2841 fh = repo.opener(_allqueues, 'a') |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2842 fh.write('%s\n' % (name,)) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2843 fh.close() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2844 |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2845 def _queuedir(name): |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2846 if name == 'patches': |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2847 return repo.join('patches') |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2848 else: |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2849 return repo.join('patches-' + name) |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2850 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2851 def _validname(name): |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2852 for n in name: |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2853 if n in ':\\/.': |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2854 return False |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2855 return True |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2856 |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2857 def _delete(name): |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2858 if name not in existing: |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2859 raise util.Abort(_('cannot delete queue that does not exist')) |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2860 |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2861 current = _getcurrent() |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2862 |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2863 if name == current: |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2864 raise util.Abort(_('cannot delete currently active queue')) |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2865 |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2866 fh = repo.opener('patches.queues.new', 'w') |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2867 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
|
2868 if queue == name: |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2869 continue |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2870 fh.write('%s\n' % (queue,)) |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2871 fh.close() |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2872 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues)) |
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2873 |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2874 if not name or opts.get('list'): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2875 current = _getcurrent() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2876 for queue in _getqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2877 ui.write('%s' % (queue,)) |
11767
9b771b4ce2f3
mq/qqueue: --list does not print (active) with --quiet
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11730
diff
changeset
|
2878 if queue == current and not ui.quiet: |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2879 ui.write(_(' (active)\n')) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2880 else: |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2881 ui.write('\n') |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2882 return |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2883 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2884 if not _validname(name): |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2885 raise util.Abort( |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2886 _('invalid queue name, may not contain the characters ":\\/."')) |
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2887 |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2888 existing = _getqueues() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2889 |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2890 if opts.get('create'): |
11271
d1aca0863a9d
mq: prevent the creation of a queue whose name is already taken
Cédric Duval <cedricduval@free.fr>
parents:
11270
diff
changeset
|
2891 if name in existing: |
d1aca0863a9d
mq: prevent the creation of a queue whose name is already taken
Cédric Duval <cedricduval@free.fr>
parents:
11270
diff
changeset
|
2892 raise util.Abort(_('queue "%s" already exists') % name) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2893 if _noqueues(): |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2894 _addqueue(_defaultqueue) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2895 _addqueue(name) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2896 _setactive(name) |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2897 elif opts.get('rename'): |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2898 current = _getcurrent() |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2899 if name == current: |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2900 raise util.Abort(_('can\'t rename "%s" to its current name') % name) |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2901 if name in existing: |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2902 raise util.Abort(_('queue "%s" already exists') % name) |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2903 |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2904 olddir = _queuedir(current) |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2905 newdir = _queuedir(name) |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2906 |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2907 if os.path.exists(newdir): |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2908 raise util.Abort(_('non-queue directory "%s" already exists') % |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2909 newdir) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2910 |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2911 fh = repo.opener('patches.queues.new', 'w') |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2912 for queue in existing: |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2913 if queue == current: |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2914 fh.write('%s\n' % (name,)) |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2915 if os.path.exists(olddir): |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2916 util.rename(olddir, newdir) |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2917 else: |
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2918 fh.write('%s\n' % (queue,)) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2919 fh.close() |
11270
457813cb3024
mq: fix naming issues for qqueue directories
Henrik Stuart <hg@hstuart.dk>
parents:
11234
diff
changeset
|
2920 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues)) |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
2921 _setactivenocheck(name) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2922 elif opts.get('delete'): |
11966
22f1994fb669
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11947
diff
changeset
|
2923 _delete(name) |
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
|
2924 elif opts.get('purge'): |
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
|
2925 if name in existing: |
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
|
2926 _delete(name) |
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
|
2927 qdir = _queuedir(name) |
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
|
2928 if os.path.exists(qdir): |
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
|
2929 shutil.rmtree(qdir) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2930 else: |
11271
d1aca0863a9d
mq: prevent the creation of a queue whose name is already taken
Cédric Duval <cedricduval@free.fr>
parents:
11270
diff
changeset
|
2931 if name not in existing: |
d1aca0863a9d
mq: prevent the creation of a queue whose name is already taken
Cédric Duval <cedricduval@free.fr>
parents:
11270
diff
changeset
|
2932 raise util.Abort(_('use --create to create a new queue')) |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2933 _setactive(name) |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
2934 |
1808 | 2935 def reposetup(ui, repo): |
2818
bdc067ff6cf5
Make mq camelcase consistent with the rest of hg.
Brendan Cully <brendan@kublai.com>
parents:
2816
diff
changeset
|
2936 class mqrepo(repo.__class__): |
8524
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
2937 @util.propertycache |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
2938 def mq(self): |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
2939 return queue(self.ui, self.join("")) |
21c87b299a04
mq: only read files when needed
Simon Heimberg <simohe@besonet.ch>
parents:
8484
diff
changeset
|
2940 |
2848
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
2941 def abort_if_wdir_patched(self, errmsg, force=False): |
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
2942 if self.mq.applied and not force: |
13520
9510ddf87c43
mq: forbid commit of merge involving mq patches
Martin Geisler <mg@aragost.com>
parents:
13508
diff
changeset
|
2943 parents = self.dirstate.parents() |
9510ddf87c43
mq: forbid commit of merge involving mq patches
Martin Geisler <mg@aragost.com>
parents:
13508
diff
changeset
|
2944 patches = [s.node for s in self.mq.applied] |
9510ddf87c43
mq: forbid commit of merge involving mq patches
Martin Geisler <mg@aragost.com>
parents:
13508
diff
changeset
|
2945 if parents[0] in patches or parents[1] in patches: |
2848
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
2946 raise util.Abort(errmsg) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
2947 |
8711 | 2948 def commit(self, text="", user=None, date=None, match=None, |
2949 force=False, editor=False, extra={}): | |
2848
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
2950 self.abort_if_wdir_patched( |
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
2951 _('cannot commit over an applied mq patch'), |
307439d6fede
mq: do not allow to push from repo with patches applied
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2845
diff
changeset
|
2952 force) |
2845
addd03c7fbfa
Disallow commit over an applied mq patch.
Brendan Cully <brendan@kublai.com>
parents:
2844
diff
changeset
|
2953 |
8711 | 2954 return super(mqrepo, self).commit(text, user, date, match, force, |
2955 editor, extra) | |
2845
addd03c7fbfa
Disallow commit over an applied mq patch.
Brendan Cully <brendan@kublai.com>
parents:
2844
diff
changeset
|
2956 |
13327
dc11e30b48a3
mq: factor out push conditions checks
Patrick Mezard <pmezard@gmail.com>
parents:
13256
diff
changeset
|
2957 def checkpush(self, force, revs): |
12378
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2958 if self.mq.applied and not force: |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2959 haspatches = True |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2960 if revs: |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2961 # Assume applied patches have no non-patch descendants |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2962 # and are not on remote already. If they appear in the |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2963 # set of resolved 'revs', bail out. |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2964 applied = set(e.node for e in self.mq.applied) |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2965 haspatches = bool([n for n in revs if n in applied]) |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2966 if haspatches: |
ab237534d800
mq: always require --force when pushing patches (issue2363)
Patrick Mezard <pmezard@gmail.com>
parents:
12352
diff
changeset
|
2967 raise util.Abort(_('source has mq patches applied')) |
13327
dc11e30b48a3
mq: factor out push conditions checks
Patrick Mezard <pmezard@gmail.com>
parents:
13256
diff
changeset
|
2968 super(mqrepo, self).checkpush(force, revs) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3186
diff
changeset
|
2969 |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2970 def _findtags(self): |
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2971 '''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
|
2972 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
|
2973 |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
2974 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
|
2975 if not q.applied: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2976 return result |
2663
96950d39171d
Mq: modify repo.lookup to resolve applied patches too.
Brendan Cully <brendan@kublai.com>
parents:
2554
diff
changeset
|
2977 |
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
|
2978 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
|
2979 |
13508
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
2980 try: |
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
2981 r = self.changelog.rev(mqtags[-1][0]) |
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
2982 except error.RepoLookupError: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2983 self.ui.warn(_('mq status file refers to unknown node %s\n') |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
2984 % short(mqtags[-1][0])) |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2985 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
|
2986 |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
2987 mqtags.append((mqtags[-1][0], 'qtip')) |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
2988 mqtags.append((mqtags[0][0], 'qbase')) |
4219
6cb5be6bd70f
mq: add qparent tag (first parent of qbase)
Brendan Cully <brendan@kublai.com>
parents:
4209
diff
changeset
|
2989 mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent')) |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2990 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
|
2991 for patch in mqtags: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2992 if patch[1] in tags: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2993 self.ui.warn(_('Tag %s overrides mq patch of the same name\n') |
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
2994 % patch[1]) |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
2995 else: |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2996 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
|
2997 |
9145
6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9111
diff
changeset
|
2998 return result |
2664
9b8df8dceeed
Add qtip and qbase to mq qlookup.
Brendan Cully <brendan@kublai.com>
parents:
2663
diff
changeset
|
2999 |
6120
f89878df40fe
move the reading of branch.cache from _branchtags to branchtags
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6048
diff
changeset
|
3000 def _branchtags(self, partial, lrev): |
3492
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3001 q = self.mq |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3002 if not q.applied: |
6120
f89878df40fe
move the reading of branch.cache from _branchtags to branchtags
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6048
diff
changeset
|
3003 return super(mqrepo, self)._branchtags(partial, lrev) |
3492
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3004 |
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
|
3005 cl = self.changelog |
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
|
3006 qbasenode = q.applied[0].node |
13508
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
3007 try: |
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
3008 qbase = cl.rev(qbasenode) |
0396ca8015be
mq: fix qpush recursion in _findtags when status file is wrong (issue2664)
Matt Mackall <mpm@selenic.com>
parents:
13507
diff
changeset
|
3009 except error.LookupError: |
6960
46da38eef1b0
i18n: mark strings for translation in mq extension
Martin Geisler <mg@daimi.au.dk>
parents:
6940
diff
changeset
|
3010 self.ui.warn(_('mq status file refers to unknown node %s\n') |
7639
ae7a614a6a57
mq: remove import of revlog
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
3011 % short(qbasenode)) |
6120
f89878df40fe
move the reading of branch.cache from _branchtags to branchtags
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6048
diff
changeset
|
3012 return super(mqrepo, self)._branchtags(partial, lrev) |
3492
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3013 |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3014 start = lrev + 1 |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3015 if start < qbase: |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3016 # update the cache (excluding the patches) and save it |
10770
fe39f0160c74
localrepo: change _updatebranchcache to use a context generator
Sune Foldager <cryo@cyanite.org>
parents:
10755
diff
changeset
|
3017 ctxgen = (self[r] for r in xrange(lrev + 1, qbase)) |
fe39f0160c74
localrepo: change _updatebranchcache to use a context generator
Sune Foldager <cryo@cyanite.org>
parents:
10755
diff
changeset
|
3018 self._updatebranchcache(partial, ctxgen) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3019 self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1) |
3492
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3020 start = qbase |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3021 # if start = qbase, the cache is as updated as it should be. |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3022 # if start > qbase, the cache includes (part of) the patches. |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3023 # we might as well use it, but we won't save it. |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3024 |
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3025 # update the cache up to the tip |
10770
fe39f0160c74
localrepo: change _updatebranchcache to use a context generator
Sune Foldager <cryo@cyanite.org>
parents:
10755
diff
changeset
|
3026 ctxgen = (self[r] for r in xrange(start, len(cl))) |
fe39f0160c74
localrepo: change _updatebranchcache to use a context generator
Sune Foldager <cryo@cyanite.org>
parents:
10755
diff
changeset
|
3027 self._updatebranchcache(partial, ctxgen) |
3492
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3028 |
3826
b3b868113d24
fix encoding conversion of branch names when mq is loaded
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3763
diff
changeset
|
3029 return partial |
3492
fbf8320f25c8
make mq play nicely with the branch cache
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3473
diff
changeset
|
3030 |
2851
82f50658c72b
mq: only add mq attribute to local repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
3031 if repo.local(): |
82f50658c72b
mq: only add mq attribute to local repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
3032 repo.__class__ = mqrepo |
1808 | 3033 |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3034 def mqimport(orig, ui, repo, *args, **kwargs): |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3035 if (hasattr(repo, 'abort_if_wdir_patched') |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3036 and not kwargs.get('no_commit', False)): |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3037 repo.abort_if_wdir_patched(_('cannot import over an applied patch'), |
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3038 kwargs.get('force')) |
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3039 return orig(ui, repo, *args, **kwargs) |
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3040 |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3041 def mqinit(orig, ui, *args, **kwargs): |
10558
6505773080e4
mq: simplify --mq handling / keep compatibility with other extensions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
3042 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
|
3043 |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3044 if not mq: |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3045 return orig(ui, *args, **kwargs) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3046 |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3047 if args: |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3048 repopath = args[0] |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3049 if not hg.islocal(repopath): |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3050 raise util.Abort(_('only a local queue repository ' |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3051 'may be initialized')) |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3052 else: |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3053 repopath = cmdutil.findrepo(os.getcwd()) |
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3054 if not repopath: |
12067
a4fbbe0fbc38
Lowercase error messages
Martin Geisler <mg@lazybytes.net>
parents:
11965
diff
changeset
|
3055 raise util.Abort(_('there is no Mercurial repository here ' |
10691
a778a367c20b
mq: fix init with nonexistent or non-local repository
Cédric Duval <cedricduval@free.fr>
parents:
10690
diff
changeset
|
3056 '(.hg not found)')) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3057 repo = hg.repository(ui, repopath) |
10480
3076b39d7f3e
mq: unify implementation of qinit and init -Q
Brendan Cully <brendan@kublai.com>
parents:
10476
diff
changeset
|
3058 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
|
3059 |
10359
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3060 def mqcommand(orig, ui, repo, *args, **kwargs): |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3061 """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
|
3062 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3063 # some commands do not like getting unknown options |
10558
6505773080e4
mq: simplify --mq handling / keep compatibility with other extensions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
3064 mq = kwargs.pop('mq', None) |
10359
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3065 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3066 if not mq: |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3067 return orig(ui, repo, *args, **kwargs) |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3068 |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3069 q = repo.mq |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3070 r = q.qrepo() |
ec02cf8d1628
mq: add --mq option to some commands
Brendan Cully <brendan@kublai.com>
parents:
10282
diff
changeset
|
3071 if not r: |
11120
0bedcbcb3ae2
mq: mark error message for translation
Martin Geisler <mg@lazybytes.net>
parents:
11119
diff
changeset
|
3072 raise util.Abort(_('no queue repository')) |
10407
2e8926e9cc32
mq: incorporate mq repo config when using --mq
Brendan Cully <brendan@kublai.com>
parents:
10402
diff
changeset
|
3073 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
|
3074 |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3075 def summary(orig, ui, repo, *args, **kwargs): |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3076 r = orig(ui, repo, *args, **kwargs) |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3077 q = repo.mq |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3078 m = [] |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3079 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
|
3080 if a: |
11121
d061ef1d781c
mq: make use of output labeling for summary
Eric Eisner <ede@mit.edu>
parents:
11120
diff
changeset
|
3081 m.append(ui.label(_("%d applied"), 'qseries.applied') % a) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3082 if u: |
11121
d061ef1d781c
mq: make use of output labeling for summary
Eric Eisner <ede@mit.edu>
parents:
11120
diff
changeset
|
3083 m.append(ui.label(_("%d unapplied"), 'qseries.unapplied') % u) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3084 if m: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
3085 ui.write("mq: %s\n" % ', '.join(m)) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3086 else: |
11119
2e270443a2c6
mq: mark string for translation
Martin Geisler <mg@lazybytes.net>
parents:
11107
diff
changeset
|
3087 ui.note(_("mq: (empty queue)\n")) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3088 return r |
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3089 |
7142
88f1b8081f1c
Prevent import over an applied patch (closes issue795)
Brendan Cully <brendan@kublai.com>
parents:
7113
diff
changeset
|
3090 def uisetup(ui): |
10591
ff2704a8ded3
mq: drop -Q in favor of --mq only
Matt Mackall <mpm@selenic.com>
parents:
10589
diff
changeset
|
3091 mqopt = [('', 'mq', None, _("operate on patch repository"))] |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3092 |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7213
diff
changeset
|
3093 extensions.wrapcommand(commands.table, 'import', mqimport) |
11107
9c72c5c094aa
mq: add a line to hg summary
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
3094 extensions.wrapcommand(commands.table, 'summary', summary) |
10402
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3095 |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3096 entry = extensions.wrapcommand(commands.table, 'init', mqinit) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3097 entry[1].extend(mqopt) |
d216fa04e48a
mq: make init -Q do what qinit -c did
Brendan Cully <brendan@kublai.com>
parents:
10401
diff
changeset
|
3098 |
12036
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3099 nowrap = set(commands.norepo.split(" ") + ['qrecord']) |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3100 |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3101 def dotable(cmdtable): |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3102 for cmd in cmdtable.keys(): |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3103 cmd = cmdutil.parsealiases(cmd)[0] |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3104 if cmd in nowrap: |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3105 continue |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3106 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
|
3107 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
|
3108 |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3109 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
|
3110 |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3111 for extname, extmodule in extensions.extensions(): |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3112 if extmodule.__file__ != __file__: |
31f02288bbc4
mq: extend support for the --mq argument to extension commands
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
11970
diff
changeset
|
3113 dotable(getattr(extmodule, 'cmdtable', {})) |
7142
88f1b8081f1c
Prevent import over an applied patch (closes issue795)
Brendan Cully <brendan@kublai.com>
parents:
7113
diff
changeset
|
3114 |
3183
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
3115 seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
0e6b58c7beea
mq: add --summary to qapplied, qunapplied, qtop, qnext and qprev
Brendan Cully <brendan@kublai.com>
parents:
3141
diff
changeset
|
3116 |
1808 | 3117 cmdtable = { |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
3118 "qapplied": |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
3119 (applied, |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
3120 [('1', 'last', None, _('show only the last patch'))] + seriesopts, |
9438
b2f3b9c82ac0
Add new flag [-1] to synopsis of qapplied/qunapplied
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9375
diff
changeset
|
3121 _('hg qapplied [-1] [-s] [PATCH]')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3122 "qclone": |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3123 (clone, |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3124 [('', 'pull', None, _('use pull protocol to copy metadata')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3125 ('U', 'noupdate', None, _('do not update the new working directories')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3126 ('', 'uncompressed', None, |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3127 _('use uncompressed transfer (fast over LAN)')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3128 ('p', 'patches', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3129 _('location of source patch repository'), _('REPO')), |
5147
c80af96943aa
refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5053
diff
changeset
|
3130 ] + commands.remoteopts, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3131 _('hg qclone [OPTION]... SOURCE [DEST]')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3132 "qcommit|qci": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3133 (commit, |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
3134 commands.table["^commit|ci"][1], |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3135 _('hg qcommit [OPTION]... [FILE]...')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3136 "^qdiff": |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3137 (diff, |
6668
034f444902d9
mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents:
6650
diff
changeset
|
3138 commands.diffopts + commands.diffopts2 + commands.walkopts, |
034f444902d9
mq: qdiff: support all diffopts
Jason Orendorff <jorendorff@mozilla.com>
parents:
6650
diff
changeset
|
3139 _('hg qdiff [OPTION]... [FILE]...')), |
2904
57b88b86a845
Replace qdel/qfold -f option with -k/--keep.
Brendan Cully <brendan@kublai.com>
parents:
2883
diff
changeset
|
3140 "qdelete|qremove|qrm": |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
3141 (delete, |
3373
9851f46d6ecc
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully <brendan@kublai.com>
parents:
3243
diff
changeset
|
3142 [('k', 'keep', None, _('keep patch file')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3143 ('r', 'rev', [], |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3144 _('stop managing a revision (DEPRECATED)'), _('REV'))], |
12590
663d96f33367
mq: Removed extra ... in short help for qdelete
Erik Zielke <ez@aragost.com>
parents:
12589
diff
changeset
|
3145 _('hg qdelete [-k] [PATCH]...')), |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3146 'qfold': |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3147 (fold, |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
3148 [('e', 'edit', None, _('edit patch header')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3149 ('k', 'keep', None, _('keep folded patch files')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3150 ] + commands.commitopts, |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3151 _('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3152 'qgoto': |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3153 (goto, |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3154 [('f', 'force', None, _('overwrite any local changes'))], |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3155 _('hg qgoto [OPTION]... PATCH')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3156 'qguard': |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3157 (guard, |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3158 [('l', 'list', None, _('list all patches and guards')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3159 ('n', 'none', None, _('drop all guards'))], |
10476
3113736dbac5
mq: more instructive use of "--" in qguard help (issue2040)
Martin Geisler <mg@lazybytes.net>
parents:
10413
diff
changeset
|
3160 _('hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3161 'qheader': (header, [], _('hg qheader [PATCH]')), |
10890
301633755dec
mq: promote qnew, demote qinit in short help
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
3162 "qimport": |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3163 (qimport, |
8026
683d8ebcf434
expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
7994
diff
changeset
|
3164 [('e', 'existing', None, _('import file in patch directory')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3165 ('n', 'name', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3166 _('name of patch file'), _('NAME')), |
7002
07c8396fa001
i18n, mq: mark command line options for translation
Martin Geisler <mg@daimi.au.dk>
parents:
6960
diff
changeset
|
3167 ('f', 'force', None, _('overwrite existing files')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3168 ('r', 'rev', [], |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3169 _('place existing revisions under mq control'), _('REV')), |
8362
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8288
diff
changeset
|
3170 ('g', 'git', None, _('use git extended diff format')), |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8288
diff
changeset
|
3171 ('P', 'push', None, _('qpush after importing'))], |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8288
diff
changeset
|
3172 _('hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... FILE...')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3173 "^qinit": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3174 (init, |
7002
07c8396fa001
i18n, mq: mark command line options for translation
Martin Geisler <mg@daimi.au.dk>
parents:
6960
diff
changeset
|
3175 [('c', 'create-repo', None, _('create queue repository'))], |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3176 _('hg qinit [-c]')), |
10890
301633755dec
mq: promote qnew, demote qinit in short help
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
3177 "^qnew": |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3178 (new, |
2939 | 3179 [('e', 'edit', None, _('edit commit message')), |
10382
e54e3f6e6789
mq: fix deprecation mention, line length
Augie Fackler <durin42@gmail.com>
parents:
10372
diff
changeset
|
3180 ('f', 'force', None, _('import uncommitted changes (DEPRECATED)')), |
5025
7041869a1bf6
mq: add qnew --git option
Patrick Mezard <pmezard@gmail.com>
parents:
4970
diff
changeset
|
3181 ('g', 'git', None, _('use git extended diff format')), |
6915
ef14c773b3d6
mq: fix docs for qrefresh -D (issue1234)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6801
diff
changeset
|
3182 ('U', 'currentuser', None, _('add "From: <current user>" to patch')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3183 ('u', 'user', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3184 _('add "From: <USER>" to patch'), _('USER')), |
6915
ef14c773b3d6
mq: fix docs for qrefresh -D (issue1234)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6801
diff
changeset
|
3185 ('D', 'currentdate', None, _('add "Date: <current date>" to patch')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3186 ('d', 'date', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3187 _('add "Date: <DATE>" to patch'), _('DATE')) |
6915
ef14c773b3d6
mq: fix docs for qrefresh -D (issue1234)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6801
diff
changeset
|
3188 ] + commands.walkopts + commands.commitopts, |
10947
ede19417c3c4
mq: Remove -f from qnew command syntax.
Isaac Jurado <diptongo@gmail.com>
parents:
10946
diff
changeset
|
3189 _('hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3190 "qnext": (next, [] + seriesopts, _('hg qnext [-s]')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3191 "qprev": (prev, [] + seriesopts, _('hg qprev [-s]')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3192 "^qpop": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3193 (pop, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3194 [('a', 'all', None, _('pop all patches')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3195 ('n', 'name', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3196 _('queue name to pop (DEPRECATED)'), _('NAME')), |
9588
a9d1e7c8160e
mq: changed help for qpop -f to reflect actual behaviour
Stephen Rasku <mercurial@srasku.net>
parents:
9287
diff
changeset
|
3197 ('f', 'force', None, _('forget any local changes to patched files'))], |
12589
57ad5c4e4213
mq: removed short option in help for deprecated options
Erik Zielke <ez@aragost.com>
parents:
12583
diff
changeset
|
3198 _('hg qpop [-a] [-f] [PATCH | INDEX]')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3199 "^qpush": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3200 (push, |
12583
903828be7397
mq: explain qpush -f better
Mads Kiilerich <mads@kiilerich.com>
parents:
12539
diff
changeset
|
3201 [('f', 'force', None, _('apply on top of local changes')), |
13033
026053f691a4
mq: add an '-e/--exact' option to qpush
Steve Losh <steve@stevelosh.com>
parents:
13031
diff
changeset
|
3202 ('e', 'exact', None, _('apply the target patch to its recorded parent')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3203 ('l', 'list', None, _('list patch name in commit text')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3204 ('a', 'all', None, _('apply all patches')), |
10360
bcf90e712dc3
mq: deprecate qsave, qrestore and related options
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10359
diff
changeset
|
3205 ('m', 'merge', None, _('merge from another queue (DEPRECATED)')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3206 ('n', 'name', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3207 _('merge queue name (DEPRECATED)'), _('NAME')), |
11064
590b1d6ef50b
mq: qpush --move, reorder patch series and apply only the patch
Mads Kiilerich <mads@kiilerich.com>
parents:
11050
diff
changeset
|
3208 ('', 'move', None, _('reorder patch series and apply only the patch'))], |
12589
57ad5c4e4213
mq: removed short option in help for deprecated options
Erik Zielke <ez@aragost.com>
parents:
12583
diff
changeset
|
3209 _('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3210 "^qrefresh": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3211 (refresh, |
2746
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
3212 [('e', 'edit', None, _('edit commit message')), |
3086
17747e80ea6c
mq: Add --git option to qrefresh
Brendan Cully <brendan@kublai.com>
parents:
3085
diff
changeset
|
3213 ('g', 'git', None, _('use git extended diff format')), |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3214 ('s', 'short', None, |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3215 _('refresh only files already in the patch and specified files')), |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3216 ('U', 'currentuser', None, |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3217 _('add/update author field in patch with current user')), |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3218 ('u', 'user', '', |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3219 _('add/update author field in patch with given user'), _('USER')), |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3220 ('D', 'currentdate', None, |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3221 _('add/update date field in patch with current date')), |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10276
diff
changeset
|
3222 ('d', 'date', '', |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3223 _('add/update date field in patch with given date'), _('DATE')) |
6915
ef14c773b3d6
mq: fix docs for qrefresh -D (issue1234)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6801
diff
changeset
|
3224 ] + commands.walkopts + commands.commitopts, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3225 _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')), |
2751
7d1de4545728
mq: add qmv as alias for qrename
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2750
diff
changeset
|
3226 'qrename|qmv': |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3227 (rename, [], _('hg qrename PATCH1 [PATCH2]')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3228 "qrestore": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3229 (restore, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3230 [('d', 'delete', None, _('delete save entry')), |
8026
683d8ebcf434
expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
7994
diff
changeset
|
3231 ('u', 'update', None, _('update queue working directory'))], |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3232 _('hg qrestore [-d] [-u] REV')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3233 "qsave": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3234 (save, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3235 [('c', 'copy', None, _('copy patch directory')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3236 ('n', 'name', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11311
diff
changeset
|
3237 _('copy directory name'), _('NAME')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3238 ('e', 'empty', None, _('clear queue status file')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3239 ('f', 'force', None, _('force copy'))] + commands.commitopts, |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3240 _('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3241 "qselect": |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3242 (select, |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3243 [('n', 'none', None, _('disable all guards')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3244 ('s', 'series', None, _('list all guards in series file')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3245 ('', 'pop', None, _('pop to before first guarded applied patch')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3246 ('', 'reapply', None, _('pop, then reapply patches'))], |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3247 _('hg qselect [OPTION]... [GUARD]...')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3248 "qseries": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
3249 (series, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3250 [('m', 'missing', None, _('print patches not in series')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4722
diff
changeset
|
3251 ] + seriesopts, |
11073
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3252 _('hg qseries [-ms]')), |
11078 | 3253 "strip": |
11073
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3254 (strip, |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3255 [('f', 'force', None, _('force removal of changesets even if the ' |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3256 'working directory has uncommitted changes')), |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3257 ('b', 'backup', None, _('bundle only changesets with local revision' |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3258 ' number greater than REV which are not' |
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3259 ' descendants of REV (DEPRECATED)')), |
12682
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
3260 ('n', 'no-backup', None, _('no backups')), |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
3261 ('', 'nobackup', None, _('no backups (DEPRECATED)')), |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
3262 ('k', 'keep', None, _("do not modify working copy during strip"))], |
58a3e2608ae4
strip: add --keep flag to avoid modifying wc during strip
Augie Fackler <durin42@gmail.com>
parents:
12658
diff
changeset
|
3263 _('hg strip [-k] [-f] [-n] REV...')), |
11073
ee5b112aa529
mq: rewrite strip docstrings
Faheem Mitha <faheem@email.unc.edu>
parents:
10947
diff
changeset
|
3264 "qtop": (top, [] + seriesopts, _('hg qtop [-s]')), |
9364
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
3265 "qunapplied": |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
3266 (unapplied, |
c7c2dd7524dd
mq: add options to qapplied/qunapplied to act like qprev/qnext
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9338
diff
changeset
|
3267 [('1', 'first', None, _('show only the first patch'))] + seriesopts, |
9438
b2f3b9c82ac0
Add new flag [-1] to synopsis of qapplied/qunapplied
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9375
diff
changeset
|
3268 _('hg qunapplied [-1] [-s] [PATCH]')), |
6645
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3269 "qfinish": |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3270 (finish, |
37eedb1a1848
mq: introduce the qfinish command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6644
diff
changeset
|
3271 [('a', 'applied', None, _('finish all applied changesets'))], |
8948
aa0fe57d4abe
mq: standardize qfinish cmdline help string
Martin Geisler <mg@lazybytes.net>
parents:
8932
diff
changeset
|
3272 _('hg qfinish [-a] [REV]...')), |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3273 'qqueue': |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3274 (qqueue, |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3275 [ |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3276 ('l', 'list', False, _('list all available queues')), |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3277 ('c', 'create', False, _('create new queue')), |
11939
7d2ea5ce4aac
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11938
diff
changeset
|
3278 ('', 'rename', False, _('rename active queue')), |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3279 ('', 'delete', False, _('delete reference to queue')), |
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
|
3280 ('', 'purge', False, _('delete queue, and remove patch dir')), |
11229
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3281 ], |
1e701ffd9df4
mq: support multiple patch queues using qqueue
Henrik Stuart <hg@hstuart.dk>
parents:
11216
diff
changeset
|
3282 _('[OPTION] [QUEUE]')), |
1808 | 3283 } |
10826
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3284 |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3285 colortable = {'qguard.negative': 'red', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3286 'qguard.positive': 'yellow', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3287 'qguard.unguarded': 'green', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3288 'qseries.applied': 'blue bold underline', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3289 'qseries.guarded': 'black bold', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3290 'qseries.missing': 'red bold', |
717c35d55fb3
color: colorize based on output labels instead of parsing output
Brodie Rao <brodie@bitheap.org>
parents:
10824
diff
changeset
|
3291 'qseries.unapplied': 'black bold'} |