author | Vadim Gelfer <vadim.gelfer@gmail.com> |
Thu, 27 Jul 2006 16:41:59 -0700 | |
changeset 2711 | 8e5cd8d11b51 |
parent 2710 | ca97be5babf8 |
child 2712 | 35caf437a201 |
permissions | -rw-r--r-- |
1808 | 1 |
# queue.py - patch queues for mercurial |
2 |
# |
|
3 |
# Copyright 2005 Chris Mason <mason@suse.com> |
|
4 |
# |
|
5 |
# This software may be used and distributed according to the terms |
|
6 |
# of the GNU General Public License, incorporated herein by reference. |
|
7 |
||
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
8 |
'''patch management and development |
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 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
11 |
repository. It manages two stacks of patches - all known patches, and |
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 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
15 |
directory. Applied patches are both patch files and changesets. |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
16 |
|
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
17 |
Common tasks (use "hg help command" for more details): |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
18 |
|
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
19 |
prepare repository to work with patches qinit |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
20 |
create new patch qnew |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
21 |
import existing patch qimport |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
22 |
|
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
23 |
print patch series qseries |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
24 |
print applied patches qapplied |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
25 |
print name of top applied patch qtop |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
26 |
|
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
27 |
add known patch to applied stack qpush |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
28 |
remove patch from applied stack qpop |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
29 |
refresh contents of top applied patch qrefresh |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
30 |
''' |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
31 |
|
1808 | 32 |
from mercurial.demandload import * |
33 |
demandload(globals(), "os sys re struct traceback errno bz2") |
|
34 |
from mercurial.i18n import gettext as _ |
|
35 |
from mercurial import ui, hg, revlog, commands, util |
|
36 |
||
37 |
versionstr = "0.45" |
|
38 |
||
39 |
repomap = {} |
|
40 |
||
2047
ebf1ecb5f4e8
Register qversion as a non repository related command
Edouard Gomez <ed.gomez@free.fr>
parents:
1863
diff
changeset
|
41 |
commands.norepo += " qversion" |
1808 | 42 |
class queue: |
43 |
def __init__(self, ui, path, patchdir=None): |
|
44 |
self.basepath = path |
|
45 |
if patchdir: |
|
46 |
self.path = patchdir |
|
47 |
else: |
|
48 |
self.path = os.path.join(path, "patches") |
|
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
|
49 |
self.opener = util.opener(self.path) |
1808 | 50 |
self.ui = ui |
51 |
self.applied = [] |
|
52 |
self.full_series = [] |
|
53 |
self.applied_dirty = 0 |
|
54 |
self.series_dirty = 0 |
|
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
|
55 |
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
|
56 |
self.status_path = "status" |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
57 |
|
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
|
58 |
if os.path.exists(os.path.join(self.path, self.series_path)): |
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
59 |
self.full_series = self.opener(self.series_path).read().splitlines() |
1808 | 60 |
self.read_series(self.full_series) |
61 |
||
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
|
62 |
if os.path.exists(os.path.join(self.path, self.status_path)): |
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
63 |
self.applied = self.opener(self.status_path).read().splitlines() |
1808 | 64 |
|
65 |
def find_series(self, patch): |
|
66 |
pre = re.compile("(\s*)([^#]+)") |
|
67 |
index = 0 |
|
68 |
for l in self.full_series: |
|
69 |
m = pre.match(l) |
|
70 |
if m: |
|
71 |
s = m.group(2) |
|
72 |
s = s.rstrip() |
|
73 |
if s == patch: |
|
74 |
return index |
|
75 |
index += 1 |
|
76 |
return None |
|
77 |
||
78 |
def read_series(self, list): |
|
79 |
def matcher(list): |
|
80 |
pre = re.compile("(\s*)([^#]+)") |
|
81 |
for l in list: |
|
82 |
m = pre.match(l) |
|
83 |
if m: |
|
84 |
s = m.group(2) |
|
85 |
s = s.rstrip() |
|
86 |
if len(s) > 0: |
|
87 |
yield s |
|
88 |
self.series = [] |
|
89 |
self.series = [ x for x in matcher(list) ] |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
90 |
|
1808 | 91 |
def save_dirty(self): |
92 |
if self.applied_dirty: |
|
93 |
if len(self.applied) > 0: |
|
94 |
nl = "\n" |
|
95 |
else: |
|
96 |
nl = "" |
|
97 |
f = self.opener(self.status_path, "w") |
|
98 |
f.write("\n".join(self.applied) + nl) |
|
99 |
if self.series_dirty: |
|
100 |
if len(self.full_series) > 0: |
|
101 |
nl = "\n" |
|
102 |
else: |
|
103 |
nl = "" |
|
104 |
f = self.opener(self.series_path, "w") |
|
105 |
f.write("\n".join(self.full_series) + nl) |
|
106 |
||
107 |
def readheaders(self, patch): |
|
108 |
def eatdiff(lines): |
|
109 |
while lines: |
|
110 |
l = lines[-1] |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
111 |
if (l.startswith("diff -") or |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
112 |
l.startswith("Index:") or |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
113 |
l.startswith("===========")): |
1808 | 114 |
del lines[-1] |
115 |
else: |
|
116 |
break |
|
117 |
def eatempty(lines): |
|
118 |
while lines: |
|
119 |
l = lines[-1] |
|
120 |
if re.match('\s*$', l): |
|
121 |
del lines[-1] |
|
122 |
else: |
|
123 |
break |
|
124 |
||
125 |
pf = os.path.join(self.path, patch) |
|
126 |
message = [] |
|
127 |
comments = [] |
|
128 |
user = None |
|
2299
dacf718e1d48
Add timestamp field to export format. Make import and mq use it.
Danek Duvall <danek.duvall@sun.com>
parents:
2270
diff
changeset
|
129 |
date = None |
1808 | 130 |
format = None |
131 |
subject = None |
|
132 |
diffstart = 0 |
|
133 |
||
134 |
for line in file(pf): |
|
135 |
line = line.rstrip() |
|
136 |
if diffstart: |
|
137 |
if line.startswith('+++ '): |
|
138 |
diffstart = 2 |
|
139 |
break |
|
140 |
if line.startswith("--- "): |
|
141 |
diffstart = 1 |
|
142 |
continue |
|
143 |
elif format == "hgpatch": |
|
144 |
# parse values when importing the result of an hg export |
|
145 |
if line.startswith("# User "): |
|
146 |
user = line[7:] |
|
2300
52b9b6751b2c
Use "# Date" instead of "# Timestamp" for dated export/import of patches.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2299
diff
changeset
|
147 |
elif line.startswith("# Date "): |
52b9b6751b2c
Use "# Date" instead of "# Timestamp" for dated export/import of patches.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2299
diff
changeset
|
148 |
date = line[7:] |
1808 | 149 |
elif not line.startswith("# ") and line: |
150 |
message.append(line) |
|
151 |
format = None |
|
152 |
elif line == '# HG changeset patch': |
|
153 |
format = "hgpatch" |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
154 |
elif (format != "tagdone" and (line.startswith("Subject: ") or |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
155 |
line.startswith("subject: "))): |
1808 | 156 |
subject = line[9:] |
157 |
format = "tag" |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
158 |
elif (format != "tagdone" and (line.startswith("From: ") or |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
159 |
line.startswith("from: "))): |
1808 | 160 |
user = line[6:] |
161 |
format = "tag" |
|
162 |
elif format == "tag" and line == "": |
|
163 |
# when looking for tags (subject: from: etc) they |
|
164 |
# end once you find a blank line in the source |
|
165 |
format = "tagdone" |
|
2301
7c2623aedeb4
Strip empty lines and trailing spaces around commit messages.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2300
diff
changeset
|
166 |
elif message or line: |
1808 | 167 |
message.append(line) |
168 |
comments.append(line) |
|
169 |
||
170 |
eatdiff(message) |
|
171 |
eatdiff(comments) |
|
172 |
eatempty(message) |
|
173 |
eatempty(comments) |
|
174 |
||
175 |
# make sure message isn't empty |
|
176 |
if format and format.startswith("tag") and subject: |
|
177 |
message.insert(0, "") |
|
178 |
message.insert(0, subject) |
|
2299
dacf718e1d48
Add timestamp field to export format. Make import and mq use it.
Danek Duvall <danek.duvall@sun.com>
parents:
2270
diff
changeset
|
179 |
return (message, comments, user, date, diffstart > 1) |
1808 | 180 |
|
181 |
def mergeone(self, repo, mergeq, head, patch, rev, wlock): |
|
182 |
# first try just applying the patch |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
183 |
(err, n) = self.apply(repo, [ patch ], update_status=False, |
1808 | 184 |
strict=True, merge=rev, wlock=wlock) |
185 |
||
186 |
if err == 0: |
|
187 |
return (err, n) |
|
188 |
||
189 |
if n is None: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
190 |
raise util.Abort(_("apply failed for patch %s") % patch) |
1808 | 191 |
|
192 |
self.ui.warn("patch didn't work out, merging %s\n" % patch) |
|
193 |
||
194 |
# apply failed, strip away that rev and merge. |
|
195 |
repo.update(head, allow=False, force=True, wlock=wlock) |
|
196 |
self.strip(repo, n, update=False, backup='strip', wlock=wlock) |
|
197 |
||
198 |
c = repo.changelog.read(rev) |
|
199 |
ret = repo.update(rev, allow=True, wlock=wlock) |
|
200 |
if ret: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
201 |
raise util.Abort(_("update returned %d") % ret) |
1808 | 202 |
n = repo.commit(None, c[4], c[1], force=1, wlock=wlock) |
203 |
if n == None: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
204 |
raise util.Abort(_("repo commit failed")) |
1808 | 205 |
try: |
2299
dacf718e1d48
Add timestamp field to export format. Make import and mq use it.
Danek Duvall <danek.duvall@sun.com>
parents:
2270
diff
changeset
|
206 |
message, comments, user, date, patchfound = mergeq.readheaders(patch) |
1808 | 207 |
except: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
208 |
raise util.Abort(_("unable to read %s") % patch) |
1808 | 209 |
|
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
|
210 |
patchf = self.opener(patch, "w") |
1808 | 211 |
if comments: |
212 |
comments = "\n".join(comments) + '\n\n' |
|
213 |
patchf.write(comments) |
|
214 |
commands.dodiff(patchf, self.ui, repo, head, n) |
|
215 |
patchf.close() |
|
216 |
return (0, n) |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
217 |
|
1808 | 218 |
def qparents(self, repo, rev=None): |
219 |
if rev is None: |
|
220 |
(p1, p2) = repo.dirstate.parents() |
|
221 |
if p2 == revlog.nullid: |
|
222 |
return p1 |
|
223 |
if len(self.applied) == 0: |
|
224 |
return None |
|
225 |
(top, patch) = self.applied[-1].split(':') |
|
226 |
top = revlog.bin(top) |
|
227 |
return top |
|
228 |
pp = repo.changelog.parents(rev) |
|
229 |
if pp[1] != revlog.nullid: |
|
230 |
arevs = [ x.split(':')[0] for x in self.applied ] |
|
231 |
p0 = revlog.hex(pp[0]) |
|
232 |
p1 = revlog.hex(pp[1]) |
|
233 |
if p0 in arevs: |
|
234 |
return pp[0] |
|
235 |
if p1 in arevs: |
|
236 |
return pp[1] |
|
237 |
return pp[0] |
|
238 |
||
239 |
def mergepatch(self, repo, mergeq, series, wlock): |
|
240 |
if len(self.applied) == 0: |
|
241 |
# each of the patches merged in will have two parents. This |
|
242 |
# can confuse the qrefresh, qdiff, and strip code because it |
|
243 |
# needs to know which parent is actually in the patch queue. |
|
244 |
# so, we insert a merge marker with only one parent. This way |
|
245 |
# the first patch in the queue is never a merge patch |
|
246 |
# |
|
247 |
pname = ".hg.patches.merge.marker" |
|
248 |
n = repo.commit(None, '[mq]: merge marker', user=None, force=1, |
|
249 |
wlock=wlock) |
|
250 |
self.applied.append(revlog.hex(n) + ":" + pname) |
|
251 |
self.applied_dirty = 1 |
|
252 |
||
253 |
head = self.qparents(repo) |
|
254 |
||
255 |
for patch in series: |
|
2696 | 256 |
patch = mergeq.lookup(patch, strict=True) |
1808 | 257 |
if not patch: |
258 |
self.ui.warn("patch %s does not exist\n" % patch) |
|
259 |
return (1, None) |
|
260 |
||
261 |
info = mergeq.isapplied(patch) |
|
262 |
if not info: |
|
263 |
self.ui.warn("patch %s is not applied\n" % patch) |
|
264 |
return (1, None) |
|
265 |
rev = revlog.bin(info[1]) |
|
266 |
(err, head) = self.mergeone(repo, mergeq, head, patch, rev, wlock) |
|
267 |
if head: |
|
268 |
self.applied.append(revlog.hex(head) + ":" + patch) |
|
269 |
self.applied_dirty = 1 |
|
270 |
if err: |
|
271 |
return (err, head) |
|
272 |
return (0, head) |
|
273 |
||
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
274 |
def apply(self, repo, series, list=False, update_status=True, |
1808 | 275 |
strict=False, patchdir=None, merge=None, wlock=None): |
276 |
# TODO unify with commands.py |
|
277 |
if not patchdir: |
|
278 |
patchdir = self.path |
|
279 |
pwd = os.getcwd() |
|
280 |
os.chdir(repo.root) |
|
281 |
err = 0 |
|
282 |
if not wlock: |
|
283 |
wlock = repo.wlock() |
|
284 |
lock = repo.lock() |
|
285 |
tr = repo.transaction() |
|
286 |
n = None |
|
287 |
for patch in series: |
|
288 |
self.ui.warn("applying %s\n" % patch) |
|
289 |
pf = os.path.join(patchdir, patch) |
|
290 |
||
291 |
try: |
|
2299
dacf718e1d48
Add timestamp field to export format. Make import and mq use it.
Danek Duvall <danek.duvall@sun.com>
parents:
2270
diff
changeset
|
292 |
message, comments, user, date, patchfound = self.readheaders(patch) |
1808 | 293 |
except: |
294 |
self.ui.warn("Unable to read %s\n" % pf) |
|
295 |
err = 1 |
|
296 |
break |
|
297 |
||
298 |
if not message: |
|
299 |
message = "imported patch %s\n" % patch |
|
300 |
else: |
|
301 |
if list: |
|
302 |
message.append("\nimported patch %s" % patch) |
|
303 |
message = '\n'.join(message) |
|
304 |
||
305 |
try: |
|
2270
afd7c4ec000f
Fix issue240: mq: qpush fails on Solaris
Danek Duvall <danek.duvall@sun.com>
parents:
2185
diff
changeset
|
306 |
pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') |
afd7c4ec000f
Fix issue240: mq: qpush fails on Solaris
Danek Duvall <danek.duvall@sun.com>
parents:
2185
diff
changeset
|
307 |
f = os.popen("%s -p1 --no-backup-if-mismatch < '%s'" % (pp, pf)) |
1808 | 308 |
except: |
309 |
self.ui.warn("patch failed, unable to continue (try -v)\n") |
|
310 |
err = 1 |
|
311 |
break |
|
312 |
files = [] |
|
313 |
fuzz = False |
|
314 |
for l in f: |
|
315 |
l = l.rstrip('\r\n'); |
|
316 |
if self.ui.verbose: |
|
317 |
self.ui.warn(l + "\n") |
|
318 |
if l[:14] == 'patching file ': |
|
319 |
pf = os.path.normpath(l[14:]) |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
320 |
# when patch finds a space in the file name, it puts |
1808 | 321 |
# single quotes around the filename. strip them off |
322 |
if pf[0] == "'" and pf[-1] == "'": |
|
323 |
pf = pf[1:-1] |
|
324 |
if pf not in files: |
|
325 |
files.append(pf) |
|
326 |
printed_file = False |
|
327 |
file_str = l |
|
328 |
elif l.find('with fuzz') >= 0: |
|
329 |
if not printed_file: |
|
330 |
self.ui.warn(file_str + '\n') |
|
331 |
printed_file = True |
|
332 |
self.ui.warn(l + '\n') |
|
333 |
fuzz = True |
|
334 |
elif l.find('saving rejects to file') >= 0: |
|
335 |
self.ui.warn(l + '\n') |
|
336 |
elif l.find('FAILED') >= 0: |
|
337 |
if not printed_file: |
|
338 |
self.ui.warn(file_str + '\n') |
|
339 |
printed_file = True |
|
340 |
self.ui.warn(l + '\n') |
|
341 |
patcherr = f.close() |
|
342 |
||
343 |
if merge and len(files) > 0: |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
344 |
# Mark as merged and update dirstate parent info |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
345 |
repo.dirstate.update(repo.dirstate.filterfiles(files), 'm') |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
346 |
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
|
347 |
repo.dirstate.setparents(p1, merge) |
1808 | 348 |
if len(files) > 0: |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
349 |
commands.addremove_lock(self.ui, repo, files, |
1808 | 350 |
opts={}, wlock=wlock) |
2299
dacf718e1d48
Add timestamp field to export format. Make import and mq use it.
Danek Duvall <danek.duvall@sun.com>
parents:
2270
diff
changeset
|
351 |
n = repo.commit(files, message, user, date, force=1, lock=lock, |
1808 | 352 |
wlock=wlock) |
353 |
||
354 |
if n == None: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
355 |
raise util.Abort(_("repo commit failed")) |
1808 | 356 |
|
357 |
if update_status: |
|
358 |
self.applied.append(revlog.hex(n) + ":" + patch) |
|
359 |
||
360 |
if patcherr: |
|
361 |
if not patchfound: |
|
362 |
self.ui.warn("patch %s is empty\n" % patch) |
|
363 |
err = 0 |
|
364 |
else: |
|
365 |
self.ui.warn("patch failed, rejects left in working dir\n") |
|
366 |
err = 1 |
|
367 |
break |
|
368 |
||
369 |
if fuzz and strict: |
|
370 |
self.ui.warn("fuzz found when applying patch, stopping\n") |
|
371 |
err = 1 |
|
372 |
break |
|
373 |
tr.close() |
|
374 |
os.chdir(pwd) |
|
375 |
return (err, n) |
|
376 |
||
377 |
def delete(self, repo, patch): |
|
2696 | 378 |
patch = self.lookup(patch, strict=True) |
1808 | 379 |
info = self.isapplied(patch) |
380 |
if info: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
381 |
raise util.Abort(_("cannot delete applied patch %s") % patch) |
1808 | 382 |
if patch not in self.series: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
383 |
raise util.Abort(_("patch %s not in series file") % patch) |
1808 | 384 |
i = self.find_series(patch) |
385 |
del self.full_series[i] |
|
386 |
self.read_series(self.full_series) |
|
387 |
self.series_dirty = 1 |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
388 |
|
1808 | 389 |
def check_toppatch(self, repo): |
390 |
if len(self.applied) > 0: |
|
391 |
(top, patch) = self.applied[-1].split(':') |
|
392 |
top = revlog.bin(top) |
|
393 |
pp = repo.dirstate.parents() |
|
394 |
if top not in pp: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
395 |
raise util.Abort(_("queue top not at same revision as working directory")) |
1808 | 396 |
return top |
397 |
return None |
|
398 |
def check_localchanges(self, repo): |
|
399 |
(c, a, r, d, u) = repo.changes(None, None) |
|
400 |
if c or a or d or r: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
401 |
raise util.Abort(_("local changes found, refresh first")) |
1808 | 402 |
def new(self, repo, patch, msg=None, force=None): |
2710
ca97be5babf8
mq: do not allow to qnew a patch twice
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2699
diff
changeset
|
403 |
if os.path.exists(os.path.join(self.path, patch)): |
ca97be5babf8
mq: do not allow to qnew a patch twice
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2699
diff
changeset
|
404 |
raise util.Abort(_('patch "%s" already exists') % patch) |
2511
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
405 |
commitfiles = [] |
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
406 |
(c, a, r, d, u) = repo.changes(None, None) |
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
407 |
if c or a or d or r: |
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
408 |
if not force: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
409 |
raise util.Abort(_("local changes found, refresh first")) |
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
410 |
commitfiles = c + a + r |
1808 | 411 |
self.check_toppatch(repo) |
412 |
wlock = repo.wlock() |
|
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
413 |
insert = self.full_series_end() |
1808 | 414 |
if msg: |
2511
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
415 |
n = repo.commit(commitfiles, "[mq]: %s" % msg, force=True, |
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
416 |
wlock=wlock) |
1808 | 417 |
else: |
2511
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
418 |
n = repo.commit(commitfiles, |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
419 |
"New patch: %s" % patch, force=True, wlock=wlock) |
1808 | 420 |
if n == None: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
421 |
raise util.Abort(_("repo commit failed")) |
1808 | 422 |
self.full_series[insert:insert] = [patch] |
423 |
self.applied.append(revlog.hex(n) + ":" + patch) |
|
424 |
self.read_series(self.full_series) |
|
425 |
self.series_dirty = 1 |
|
426 |
self.applied_dirty = 1 |
|
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
|
427 |
p = self.opener(patch, "w") |
1808 | 428 |
if msg: |
429 |
msg = msg + "\n" |
|
430 |
p.write(msg) |
|
431 |
p.close() |
|
432 |
wlock = None |
|
433 |
r = self.qrepo() |
|
434 |
if r: r.add([patch]) |
|
2511
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
435 |
if commitfiles: |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
436 |
self.refresh(repo, msg=None, short=True) |
1808 | 437 |
|
438 |
def strip(self, repo, rev, update=True, backup="all", wlock=None): |
|
439 |
def limitheads(chlog, stop): |
|
440 |
"""return the list of all nodes that have no children""" |
|
441 |
p = {} |
|
442 |
h = [] |
|
443 |
stoprev = 0 |
|
444 |
if stop in chlog.nodemap: |
|
445 |
stoprev = chlog.rev(stop) |
|
446 |
||
447 |
for r in range(chlog.count() - 1, -1, -1): |
|
448 |
n = chlog.node(r) |
|
449 |
if n not in p: |
|
450 |
h.append(n) |
|
451 |
if n == stop: |
|
452 |
break |
|
453 |
if r < stoprev: |
|
454 |
break |
|
455 |
for pn in chlog.parents(n): |
|
456 |
p[pn] = 1 |
|
457 |
return h |
|
458 |
||
459 |
def bundle(cg): |
|
460 |
backupdir = repo.join("strip-backup") |
|
461 |
if not os.path.isdir(backupdir): |
|
462 |
os.mkdir(backupdir) |
|
463 |
name = os.path.join(backupdir, "%s" % revlog.short(rev)) |
|
464 |
name = savename(name) |
|
465 |
self.ui.warn("saving bundle to %s\n" % name) |
|
466 |
# TODO, exclusive open |
|
467 |
f = open(name, "wb") |
|
468 |
try: |
|
469 |
f.write("HG10") |
|
470 |
z = bz2.BZ2Compressor(9) |
|
471 |
while 1: |
|
472 |
chunk = cg.read(4096) |
|
473 |
if not chunk: |
|
474 |
break |
|
475 |
f.write(z.compress(chunk)) |
|
476 |
f.write(z.flush()) |
|
477 |
except: |
|
478 |
os.unlink(name) |
|
479 |
raise |
|
480 |
f.close() |
|
481 |
return name |
|
482 |
||
483 |
def stripall(rev, revnum): |
|
484 |
cl = repo.changelog |
|
485 |
c = cl.read(rev) |
|
486 |
mm = repo.manifest.read(c[0]) |
|
487 |
seen = {} |
|
488 |
||
489 |
for x in xrange(revnum, cl.count()): |
|
490 |
c = cl.read(cl.node(x)) |
|
491 |
for f in c[3]: |
|
492 |
if f in seen: |
|
493 |
continue |
|
494 |
seen[f] = 1 |
|
495 |
if f in mm: |
|
496 |
filerev = mm[f] |
|
497 |
else: |
|
498 |
filerev = 0 |
|
499 |
seen[f] = filerev |
|
500 |
# we go in two steps here so the strip loop happens in a |
|
501 |
# sensible order. When stripping many files, this helps keep |
|
502 |
# our disk access patterns under control. |
|
503 |
list = seen.keys() |
|
504 |
list.sort() |
|
505 |
for f in list: |
|
506 |
ff = repo.file(f) |
|
507 |
filerev = seen[f] |
|
508 |
if filerev != 0: |
|
509 |
if filerev in ff.nodemap: |
|
510 |
filerev = ff.rev(filerev) |
|
511 |
else: |
|
512 |
filerev = 0 |
|
513 |
ff.strip(filerev, revnum) |
|
514 |
||
515 |
if not wlock: |
|
516 |
wlock = repo.wlock() |
|
517 |
lock = repo.lock() |
|
518 |
chlog = repo.changelog |
|
519 |
# TODO delete the undo files, and handle undo of merge sets |
|
520 |
pp = chlog.parents(rev) |
|
521 |
revnum = chlog.rev(rev) |
|
522 |
||
523 |
if update: |
|
2699
f8bcaf5696d5
mq: strip should not blow away local changes
Chris Mason <mason@suse.com>
parents:
2698
diff
changeset
|
524 |
(c, a, r, d, u) = repo.changes(None, None) |
f8bcaf5696d5
mq: strip should not blow away local changes
Chris Mason <mason@suse.com>
parents:
2698
diff
changeset
|
525 |
if c or a or d or r: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
526 |
raise util.Abort(_("local changes found")) |
1808 | 527 |
urev = self.qparents(repo, rev) |
528 |
repo.update(urev, allow=False, force=True, wlock=wlock) |
|
529 |
repo.dirstate.write() |
|
530 |
||
531 |
# save is a list of all the branches we are truncating away |
|
532 |
# that we actually want to keep. changegroup will be used |
|
533 |
# to preserve them and add them back after the truncate |
|
534 |
saveheads = [] |
|
535 |
savebases = {} |
|
536 |
||
537 |
tip = chlog.tip() |
|
538 |
heads = limitheads(chlog, rev) |
|
539 |
seen = {} |
|
540 |
||
541 |
# search through all the heads, finding those where the revision |
|
542 |
# we want to strip away is an ancestor. Also look for merges |
|
543 |
# that might be turned into new heads by the strip. |
|
544 |
while heads: |
|
545 |
h = heads.pop() |
|
546 |
n = h |
|
547 |
while True: |
|
548 |
seen[n] = 1 |
|
549 |
pp = chlog.parents(n) |
|
550 |
if pp[1] != revlog.nullid and chlog.rev(pp[1]) > revnum: |
|
551 |
if pp[1] not in seen: |
|
552 |
heads.append(pp[1]) |
|
553 |
if pp[0] == revlog.nullid: |
|
554 |
break |
|
555 |
if chlog.rev(pp[0]) < revnum: |
|
556 |
break |
|
557 |
n = pp[0] |
|
558 |
if n == rev: |
|
559 |
break |
|
560 |
r = chlog.reachable(h, rev) |
|
561 |
if rev not in r: |
|
562 |
saveheads.append(h) |
|
563 |
for x in r: |
|
564 |
if chlog.rev(x) > revnum: |
|
565 |
savebases[x] = 1 |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
566 |
|
1808 | 567 |
# create a changegroup for all the branches we need to keep |
568 |
if backup is "all": |
|
569 |
backupch = repo.changegroupsubset([rev], chlog.heads(), 'strip') |
|
570 |
bundle(backupch) |
|
571 |
if saveheads: |
|
572 |
backupch = repo.changegroupsubset(savebases.keys(), saveheads, 'strip') |
|
573 |
chgrpfile = bundle(backupch) |
|
574 |
||
575 |
stripall(rev, revnum) |
|
576 |
||
577 |
change = chlog.read(rev) |
|
578 |
repo.manifest.strip(repo.manifest.rev(change[0]), revnum) |
|
579 |
chlog.strip(revnum, revnum) |
|
580 |
if saveheads: |
|
581 |
self.ui.status("adding branch\n") |
|
582 |
commands.unbundle(self.ui, repo, chgrpfile, update=False) |
|
583 |
if backup is not "strip": |
|
584 |
os.unlink(chgrpfile) |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
585 |
|
1808 | 586 |
def isapplied(self, patch): |
587 |
"""returns (index, rev, patch)""" |
|
588 |
for i in xrange(len(self.applied)): |
|
589 |
p = self.applied[i] |
|
590 |
a = p.split(':') |
|
591 |
if a[1] == patch: |
|
592 |
return (i, a[0], a[1]) |
|
593 |
return None |
|
594 |
||
2696 | 595 |
# if the exact patch name does not exist, we try a few |
596 |
# variations. If strict is passed, we try only #1 |
|
597 |
# |
|
598 |
# 1) a number to indicate an offset in the series file |
|
599 |
# 2) a unique substring of the patch name was given |
|
600 |
# 3) patchname[-+]num to indicate an offset in the series file |
|
601 |
def lookup(self, patch, strict=False): |
|
602 |
def partial_name(s): |
|
603 |
count = 0 |
|
604 |
if s in self.series: |
|
605 |
return s |
|
606 |
for x in self.series: |
|
607 |
if s in x: |
|
608 |
count += 1 |
|
609 |
last = x |
|
610 |
if count > 1: |
|
611 |
return None |
|
612 |
if count: |
|
613 |
return last |
|
614 |
if len(self.series) > 0 and len(self.applied) > 0: |
|
615 |
if s == 'qtip': |
|
616 |
return self.series[self.series_end()-1] |
|
617 |
if s == 'qbase': |
|
618 |
return self.series[0] |
|
619 |
return None |
|
1808 | 620 |
if patch == None: |
621 |
return None |
|
2696 | 622 |
|
623 |
# we don't want to return a partial match until we make |
|
624 |
# sure the file name passed in does not exist (checked below) |
|
625 |
res = partial_name(patch) |
|
626 |
if res and res == patch: |
|
627 |
return res |
|
628 |
||
1808 | 629 |
if not os.path.isfile(os.path.join(self.path, patch)): |
630 |
try: |
|
631 |
sno = int(patch) |
|
632 |
except(ValueError, OverflowError): |
|
2696 | 633 |
pass |
634 |
else: |
|
635 |
if sno < len(self.series): |
|
636 |
patch = self.series[sno] |
|
637 |
return patch |
|
638 |
if not strict: |
|
639 |
# return any partial match made above |
|
640 |
if res: |
|
641 |
return res |
|
642 |
minus = patch.rsplit('-', 1) |
|
643 |
if len(minus) > 1: |
|
644 |
res = partial_name(minus[0]) |
|
645 |
if res: |
|
646 |
i = self.series.index(res) |
|
647 |
try: |
|
648 |
off = int(minus[1] or 1) |
|
649 |
except(ValueError, OverflowError): |
|
650 |
pass |
|
651 |
else: |
|
652 |
if i - off >= 0: |
|
653 |
return self.series[i - off] |
|
654 |
plus = patch.rsplit('+', 1) |
|
655 |
if len(plus) > 1: |
|
656 |
res = partial_name(plus[0]) |
|
657 |
if res: |
|
658 |
i = self.series.index(res) |
|
659 |
try: |
|
660 |
off = int(plus[1] or 1) |
|
661 |
except(ValueError, OverflowError): |
|
662 |
pass |
|
663 |
else: |
|
664 |
if i + off < len(self.series): |
|
665 |
return self.series[i + off] |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
666 |
raise util.Abort(_("patch %s not in series") % patch) |
1808 | 667 |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
668 |
def push(self, repo, patch=None, force=False, list=False, |
1808 | 669 |
mergeq=None, wlock=None): |
670 |
if not wlock: |
|
671 |
wlock = repo.wlock() |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
672 |
patch = self.lookup(patch) |
1808 | 673 |
if patch and self.isapplied(patch): |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
674 |
self.ui.warn(_("patch %s is already applied\n") % patch) |
1808 | 675 |
sys.exit(1) |
676 |
if self.series_end() == len(self.series): |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
677 |
self.ui.warn(_("patch series fully applied\n")) |
1808 | 678 |
sys.exit(1) |
679 |
if not force: |
|
680 |
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
|
681 |
|
1808 | 682 |
self.applied_dirty = 1; |
683 |
start = self.series_end() |
|
684 |
if start > 0: |
|
685 |
self.check_toppatch(repo) |
|
686 |
if not patch: |
|
687 |
patch = self.series[start] |
|
688 |
end = start + 1 |
|
689 |
else: |
|
690 |
end = self.series.index(patch, start) + 1 |
|
691 |
s = self.series[start:end] |
|
692 |
if mergeq: |
|
693 |
ret = self.mergepatch(repo, mergeq, s, wlock) |
|
694 |
else: |
|
695 |
ret = self.apply(repo, s, list, wlock=wlock) |
|
696 |
top = self.applied[-1].split(':')[1] |
|
697 |
if ret[0]: |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
698 |
self.ui.write("Errors during apply, please fix and refresh %s\n" % |
1808 | 699 |
top) |
700 |
else: |
|
701 |
self.ui.write("Now at: %s\n" % top) |
|
702 |
return ret[0] |
|
703 |
||
2697
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
704 |
def pop(self, repo, patch=None, force=False, update=True, all=False, |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
705 |
wlock=None): |
1808 | 706 |
def getfile(f, rev): |
707 |
t = repo.file(f).read(rev) |
|
708 |
try: |
|
709 |
repo.wfile(f, "w").write(t) |
|
710 |
except IOError: |
|
2086
8742352db413
mq: do not fail if directory to create exists
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2047
diff
changeset
|
711 |
try: |
8742352db413
mq: do not fail if directory to create exists
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2047
diff
changeset
|
712 |
os.makedirs(os.path.dirname(repo.wjoin(f))) |
8742352db413
mq: do not fail if directory to create exists
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2047
diff
changeset
|
713 |
except OSError, err: |
8742352db413
mq: do not fail if directory to create exists
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2047
diff
changeset
|
714 |
if err.errno != errno.EEXIST: raise |
1808 | 715 |
repo.wfile(f, "w").write(t) |
716 |
||
717 |
if not wlock: |
|
718 |
wlock = repo.wlock() |
|
719 |
if patch: |
|
720 |
# index, rev, patch |
|
721 |
info = self.isapplied(patch) |
|
722 |
if not info: |
|
723 |
patch = self.lookup(patch) |
|
724 |
info = self.isapplied(patch) |
|
725 |
if not info: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
726 |
raise util.Abort(_("patch %s is not applied") % patch) |
1808 | 727 |
if len(self.applied) == 0: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
728 |
self.ui.warn(_("no patches applied\n")) |
1808 | 729 |
sys.exit(1) |
730 |
||
731 |
if not update: |
|
732 |
parents = repo.dirstate.parents() |
|
733 |
rr = [ revlog.bin(x.split(':')[0]) for x in self.applied ] |
|
734 |
for p in parents: |
|
735 |
if p in rr: |
|
736 |
self.ui.warn("qpop: forcing dirstate update\n") |
|
737 |
update = True |
|
738 |
||
739 |
if not force and update: |
|
740 |
self.check_localchanges(repo) |
|
741 |
||
742 |
self.applied_dirty = 1; |
|
743 |
end = len(self.applied) |
|
744 |
if not patch: |
|
2697
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
745 |
if all: |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
746 |
popi = 0 |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
747 |
else: |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
748 |
popi = len(self.applied) - 1 |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
749 |
else: |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
750 |
popi = info[0] + 1 |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
751 |
if popi >= end: |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
752 |
self.ui.warn("qpop: %s is already at the top\n" % patch) |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
753 |
return |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
754 |
info = [ popi ] + self.applied[popi].split(':') |
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
755 |
|
1808 | 756 |
start = info[0] |
757 |
rev = revlog.bin(info[1]) |
|
758 |
||
759 |
# we know there are no local changes, so we can make a simplified |
|
760 |
# form of hg.update. |
|
761 |
if update: |
|
762 |
top = self.check_toppatch(repo) |
|
763 |
qp = self.qparents(repo, rev) |
|
764 |
changes = repo.changelog.read(qp) |
|
765 |
mf1 = repo.manifest.readflags(changes[0]) |
|
766 |
mmap = repo.manifest.read(changes[0]) |
|
767 |
(c, a, r, d, u) = repo.changes(qp, top) |
|
768 |
if d: |
|
769 |
raise util.Abort("deletions found between repo revs") |
|
770 |
for f in c: |
|
771 |
getfile(f, mmap[f]) |
|
772 |
for f in r: |
|
773 |
getfile(f, mmap[f]) |
|
774 |
util.set_exec(repo.wjoin(f), mf1[f]) |
|
775 |
repo.dirstate.update(c + r, 'n') |
|
776 |
for f in a: |
|
777 |
try: os.unlink(repo.wjoin(f)) |
|
778 |
except: raise |
|
779 |
try: os.removedirs(os.path.dirname(repo.wjoin(f))) |
|
780 |
except: pass |
|
781 |
if a: |
|
782 |
repo.dirstate.forget(a) |
|
783 |
repo.dirstate.setparents(qp, revlog.nullid) |
|
784 |
self.strip(repo, rev, update=False, backup='strip', wlock=wlock) |
|
785 |
del self.applied[start:end] |
|
786 |
if len(self.applied): |
|
787 |
self.ui.write("Now at: %s\n" % self.applied[-1].split(':')[1]) |
|
788 |
else: |
|
789 |
self.ui.write("Patch queue now empty\n") |
|
790 |
||
791 |
def diff(self, repo, files): |
|
792 |
top = self.check_toppatch(repo) |
|
793 |
if not top: |
|
794 |
self.ui.write("No patches applied\n") |
|
795 |
return |
|
796 |
qp = self.qparents(repo, top) |
|
797 |
commands.dodiff(sys.stdout, self.ui, repo, qp, None, files) |
|
798 |
||
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
799 |
def refresh(self, repo, msg=None, short=False): |
1808 | 800 |
if len(self.applied) == 0: |
801 |
self.ui.write("No patches applied\n") |
|
802 |
return |
|
803 |
wlock = repo.wlock() |
|
804 |
self.check_toppatch(repo) |
|
805 |
qp = self.qparents(repo) |
|
806 |
(top, patch) = self.applied[-1].split(':') |
|
807 |
top = revlog.bin(top) |
|
808 |
cparents = repo.changelog.parents(top) |
|
809 |
patchparent = self.qparents(repo, top) |
|
2299
dacf718e1d48
Add timestamp field to export format. Make import and mq use it.
Danek Duvall <danek.duvall@sun.com>
parents:
2270
diff
changeset
|
810 |
message, comments, user, date, patchfound = self.readheaders(patch) |
1808 | 811 |
|
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
|
812 |
patchf = self.opener(patch, "w") |
1808 | 813 |
if comments: |
814 |
comments = "\n".join(comments) + '\n\n' |
|
815 |
patchf.write(comments) |
|
816 |
||
817 |
tip = repo.changelog.tip() |
|
818 |
if top == tip: |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
819 |
# if the top of our patch queue is also the tip, there is an |
1808 | 820 |
# optimization here. We update the dirstate in place and strip |
821 |
# off the tip commit. Then just commit the current directory |
|
822 |
# tree. We can also send repo.commit the list of files |
|
823 |
# changed to speed up the diff |
|
824 |
# |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
825 |
# in short mode, we only diff the files included in the |
1808 | 826 |
# patch already |
827 |
# |
|
828 |
# this should really read: |
|
829 |
#(cc, dd, aa, aa2, uu) = repo.changes(tip, patchparent) |
|
830 |
# but we do it backwards to take advantage of manifest/chlog |
|
831 |
# caching against the next repo.changes call |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
832 |
# |
1808 | 833 |
(cc, aa, dd, aa2, uu) = repo.changes(patchparent, tip) |
834 |
if short: |
|
835 |
filelist = cc + aa + dd |
|
836 |
else: |
|
837 |
filelist = None |
|
838 |
(c, a, r, d, u) = repo.changes(None, None, filelist) |
|
839 |
||
840 |
# we might end up with files that were added between tip and |
|
841 |
# the dirstate parent, but then changed in the local dirstate. |
|
842 |
# in this case, we want them to only show up in the added section |
|
843 |
for x in c: |
|
844 |
if x not in aa: |
|
845 |
cc.append(x) |
|
846 |
# we might end up with files added by the local dirstate that |
|
847 |
# were deleted by the patch. In this case, they should only |
|
848 |
# show up in the changed section. |
|
849 |
for x in a: |
|
850 |
if x in dd: |
|
851 |
del dd[dd.index(x)] |
|
852 |
cc.append(x) |
|
853 |
else: |
|
854 |
aa.append(x) |
|
855 |
# make sure any files deleted in the local dirstate |
|
856 |
# are not in the add or change column of the patch |
|
857 |
forget = [] |
|
858 |
for x in d + r: |
|
859 |
if x in aa: |
|
860 |
del aa[aa.index(x)] |
|
861 |
forget.append(x) |
|
862 |
continue |
|
863 |
elif x in cc: |
|
864 |
del cc[cc.index(x)] |
|
865 |
dd.append(x) |
|
866 |
||
867 |
c = list(util.unique(cc)) |
|
868 |
r = list(util.unique(dd)) |
|
869 |
a = list(util.unique(aa)) |
|
870 |
filelist = list(util.unique(c + r + a )) |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
871 |
commands.dodiff(patchf, self.ui, repo, patchparent, None, |
1808 | 872 |
filelist, changes=(c, a, r, [], u)) |
873 |
patchf.close() |
|
874 |
||
875 |
changes = repo.changelog.read(tip) |
|
876 |
repo.dirstate.setparents(*cparents) |
|
877 |
repo.dirstate.update(a, 'a') |
|
878 |
repo.dirstate.update(r, 'r') |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
879 |
repo.dirstate.update(c, 'n') |
1808 | 880 |
repo.dirstate.forget(forget) |
881 |
||
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
882 |
if not msg: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
883 |
if not message: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
884 |
message = "patch queue: %s\n" % patch |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
885 |
else: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
886 |
message = "\n".join(message) |
1808 | 887 |
else: |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
888 |
message = msg |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
889 |
|
1808 | 890 |
self.strip(repo, top, update=False, backup='strip', wlock=wlock) |
891 |
n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock) |
|
892 |
self.applied[-1] = revlog.hex(n) + ':' + patch |
|
893 |
self.applied_dirty = 1 |
|
894 |
else: |
|
895 |
commands.dodiff(patchf, self.ui, repo, patchparent, None) |
|
896 |
patchf.close() |
|
897 |
self.pop(repo, force=True, wlock=wlock) |
|
898 |
self.push(repo, force=True, wlock=wlock) |
|
899 |
||
900 |
def init(self, repo, create=False): |
|
901 |
if os.path.isdir(self.path): |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
902 |
raise util.Abort(_("patch queue directory already exists")) |
1808 | 903 |
os.mkdir(self.path) |
904 |
if create: |
|
905 |
return self.qrepo(create=True) |
|
906 |
||
907 |
def unapplied(self, repo, patch=None): |
|
908 |
if patch and patch not in self.series: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
909 |
raise util.Abort(_("patch %s is not in series file") % patch) |
1808 | 910 |
if not patch: |
911 |
start = self.series_end() |
|
912 |
else: |
|
913 |
start = self.series.index(patch) + 1 |
|
914 |
for p in self.series[start:]: |
|
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
915 |
if self.ui.verbose: |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
916 |
self.ui.write("%d " % self.series.index(p)) |
1808 | 917 |
self.ui.write("%s\n" % p) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
918 |
|
1808 | 919 |
def qseries(self, repo, missing=None): |
920 |
start = self.series_end() |
|
921 |
if not missing: |
|
922 |
for p in self.series[:start]: |
|
923 |
if self.ui.verbose: |
|
924 |
self.ui.write("%d A " % self.series.index(p)) |
|
925 |
self.ui.write("%s\n" % p) |
|
926 |
for p in self.series[start:]: |
|
927 |
if self.ui.verbose: |
|
928 |
self.ui.write("%d U " % self.series.index(p)) |
|
929 |
self.ui.write("%s\n" % p) |
|
930 |
else: |
|
931 |
list = [] |
|
932 |
for root, dirs, files in os.walk(self.path): |
|
933 |
d = root[len(self.path) + 1:] |
|
934 |
for f in files: |
|
935 |
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
|
936 |
if (fl not in self.series and |
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
937 |
fl not in (self.status_path, self.series_path) |
fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1839
diff
changeset
|
938 |
and not fl.startswith('.')): |
1808 | 939 |
list.append(fl) |
940 |
list.sort() |
|
941 |
if list: |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
942 |
for x in list: |
1808 | 943 |
if self.ui.verbose: |
944 |
self.ui.write("D ") |
|
945 |
self.ui.write("%s\n" % x) |
|
946 |
||
947 |
def issaveline(self, l): |
|
948 |
name = l.split(':')[1] |
|
949 |
if name == '.hg.patches.save.line': |
|
950 |
return True |
|
951 |
||
952 |
def qrepo(self, create=False): |
|
953 |
if create or os.path.isdir(os.path.join(self.path, ".hg")): |
|
1839
876e4e6ad82b
Create local ui object per repository, so .hg/hgrc don't get mixed.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1810
diff
changeset
|
954 |
return hg.repository(self.ui, path=self.path, create=create) |
1808 | 955 |
|
956 |
def restore(self, repo, rev, delete=None, qupdate=None): |
|
957 |
c = repo.changelog.read(rev) |
|
958 |
desc = c[4].strip() |
|
959 |
lines = desc.splitlines() |
|
960 |
i = 0 |
|
961 |
datastart = None |
|
962 |
series = [] |
|
963 |
applied = [] |
|
964 |
qpp = None |
|
965 |
for i in xrange(0, len(lines)): |
|
966 |
if lines[i] == 'Patch Data:': |
|
967 |
datastart = i + 1 |
|
968 |
elif lines[i].startswith('Dirstate:'): |
|
969 |
l = lines[i].rstrip() |
|
970 |
l = l[10:].split(' ') |
|
971 |
qpp = [ hg.bin(x) for x in l ] |
|
972 |
elif datastart != None: |
|
973 |
l = lines[i].rstrip() |
|
974 |
index = l.index(':') |
|
975 |
id = l[:index] |
|
976 |
file = l[index + 1:] |
|
977 |
if id: |
|
978 |
applied.append(l) |
|
979 |
series.append(file) |
|
980 |
if datastart == None: |
|
981 |
self.ui.warn("No saved patch data found\n") |
|
982 |
return 1 |
|
983 |
self.ui.warn("restoring status: %s\n" % lines[0]) |
|
984 |
self.full_series = series |
|
985 |
self.applied = applied |
|
986 |
self.read_series(self.full_series) |
|
987 |
self.series_dirty = 1 |
|
988 |
self.applied_dirty = 1 |
|
989 |
heads = repo.changelog.heads() |
|
990 |
if delete: |
|
991 |
if rev not in heads: |
|
992 |
self.ui.warn("save entry has children, leaving it alone\n") |
|
993 |
else: |
|
994 |
self.ui.warn("removing save entry %s\n" % hg.short(rev)) |
|
995 |
pp = repo.dirstate.parents() |
|
996 |
if rev in pp: |
|
997 |
update = True |
|
998 |
else: |
|
999 |
update = False |
|
1000 |
self.strip(repo, rev, update=update, backup='strip') |
|
1001 |
if qpp: |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1002 |
self.ui.warn("saved queue repository parents: %s %s\n" % |
1808 | 1003 |
(hg.short(qpp[0]), hg.short(qpp[1]))) |
1004 |
if qupdate: |
|
1005 |
print "queue directory updating" |
|
1006 |
r = self.qrepo() |
|
1007 |
if not r: |
|
1008 |
self.ui.warn("Unable to load queue repository\n") |
|
1009 |
return 1 |
|
1010 |
r.update(qpp[0], allow=False, force=True) |
|
1011 |
||
1012 |
def save(self, repo, msg=None): |
|
1013 |
if len(self.applied) == 0: |
|
1014 |
self.ui.warn("save: no patches applied, exiting\n") |
|
1015 |
return 1 |
|
1016 |
if self.issaveline(self.applied[-1]): |
|
1017 |
self.ui.warn("status is already saved\n") |
|
1018 |
return 1 |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1019 |
|
1808 | 1020 |
ar = [ ':' + x for x in self.full_series ] |
1021 |
if not msg: |
|
1022 |
msg = "hg patches saved state" |
|
1023 |
else: |
|
1024 |
msg = "hg patches: " + msg.rstrip('\r\n') |
|
1025 |
r = self.qrepo() |
|
1026 |
if r: |
|
1027 |
pp = r.dirstate.parents() |
|
1028 |
msg += "\nDirstate: %s %s" % (hg.hex(pp[0]), hg.hex(pp[1])) |
|
1029 |
msg += "\n\nPatch Data:\n" |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1030 |
text = msg + "\n".join(self.applied) + '\n' + (ar and "\n".join(ar) |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1031 |
+ '\n' or "") |
1808 | 1032 |
n = repo.commit(None, text, user=None, force=1) |
1033 |
if not n: |
|
1034 |
self.ui.warn("repo commit failed\n") |
|
1035 |
return 1 |
|
1036 |
self.applied.append(revlog.hex(n) + ":" + '.hg.patches.save.line') |
|
1037 |
self.applied_dirty = 1 |
|
1038 |
||
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1039 |
def full_series_end(self): |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1040 |
if len(self.applied) > 0: |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1041 |
(top, p) = self.applied[-1].split(':') |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1042 |
end = self.find_series(p) |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1043 |
if end == None: |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1044 |
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
|
1045 |
return end + 1 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1046 |
return 0 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1047 |
|
1808 | 1048 |
def series_end(self): |
1049 |
end = 0 |
|
1050 |
if len(self.applied) > 0: |
|
1051 |
(top, p) = self.applied[-1].split(':') |
|
1052 |
try: |
|
1053 |
end = self.series.index(p) |
|
1054 |
except ValueError: |
|
1055 |
return 0 |
|
1056 |
return end + 1 |
|
1057 |
return end |
|
1058 |
||
1059 |
def qapplied(self, repo, patch=None): |
|
1060 |
if patch and patch not in self.series: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1061 |
raise util.Abort(_("patch %s is not in series file") % patch) |
1808 | 1062 |
if not patch: |
1063 |
end = len(self.applied) |
|
1064 |
else: |
|
1065 |
end = self.series.index(patch) + 1 |
|
1066 |
for x in xrange(end): |
|
1067 |
p = self.appliedname(x) |
|
1068 |
self.ui.write("%s\n" % p) |
|
1069 |
||
1070 |
def appliedname(self, index): |
|
1071 |
p = self.applied[index] |
|
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1072 |
pname = p.split(':')[1] |
1808 | 1073 |
if not self.ui.verbose: |
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1074 |
p = pname |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1075 |
else: |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1076 |
p = str(self.series.index(pname)) + " " + p |
1808 | 1077 |
return p |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1078 |
|
1808 | 1079 |
def top(self, repo): |
1080 |
if len(self.applied): |
|
1081 |
p = self.appliedname(-1) |
|
1082 |
self.ui.write(p + '\n') |
|
1083 |
else: |
|
1084 |
self.ui.write("No patches applied\n") |
|
1085 |
||
1086 |
def next(self, repo): |
|
1087 |
end = self.series_end() |
|
1088 |
if end == len(self.series): |
|
1089 |
self.ui.write("All patches applied\n") |
|
1090 |
else: |
|
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1091 |
p = self.series[end] |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1092 |
if self.ui.verbose: |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1093 |
self.ui.write("%d " % self.series.index(p)) |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1094 |
self.ui.write(p + '\n') |
1808 | 1095 |
|
1096 |
def prev(self, repo): |
|
1097 |
if len(self.applied) > 1: |
|
1098 |
p = self.appliedname(-2) |
|
1099 |
self.ui.write(p + '\n') |
|
1100 |
elif len(self.applied) == 1: |
|
1101 |
self.ui.write("Only one patch applied\n") |
|
1102 |
else: |
|
1103 |
self.ui.write("No patches applied\n") |
|
1104 |
||
1105 |
def qimport(self, repo, files, patch=None, existing=None, force=None): |
|
1106 |
if len(files) > 1 and patch: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1107 |
raise util.Abort(_('option "-n" not valid when importing multiple ' |
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1108 |
'files')) |
1808 | 1109 |
i = 0 |
2488
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1110 |
added = [] |
1808 | 1111 |
for filename in files: |
1112 |
if existing: |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1113 |
if not patch: |
1808 | 1114 |
patch = filename |
1115 |
if not os.path.isfile(os.path.join(self.path, patch)): |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1116 |
raise util.Abort(_("patch %s does not exist") % patch) |
1808 | 1117 |
else: |
1118 |
try: |
|
1119 |
text = file(filename).read() |
|
1120 |
except IOError: |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1121 |
raise util.Abort(_("unable to read %s") % patch) |
1808 | 1122 |
if not patch: |
1123 |
patch = os.path.split(filename)[1] |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1124 |
if not force and os.path.exists(os.path.join(self.path, patch)): |
2710
ca97be5babf8
mq: do not allow to qnew a patch twice
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2699
diff
changeset
|
1125 |
raise util.Abort(_('patch "%s" already exists') % 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
|
1126 |
patchf = self.opener(patch, "w") |
1808 | 1127 |
patchf.write(text) |
1128 |
if patch in self.series: |
|
2710
ca97be5babf8
mq: do not allow to qnew a patch twice
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2699
diff
changeset
|
1129 |
raise util.Abort(_('patch %s is already in the series file') |
ca97be5babf8
mq: do not allow to qnew a patch twice
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2699
diff
changeset
|
1130 |
% patch) |
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1131 |
index = self.full_series_end() + i |
1808 | 1132 |
self.full_series[index:index] = [patch] |
1133 |
self.read_series(self.full_series) |
|
1134 |
self.ui.warn("adding %s to series file\n" % patch) |
|
1135 |
i += 1 |
|
2488
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1136 |
added.append(patch) |
1808 | 1137 |
patch = None |
1138 |
self.series_dirty = 1 |
|
2488
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1139 |
qrepo = self.qrepo() |
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1140 |
if qrepo: |
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1141 |
qrepo.add(added) |
1808 | 1142 |
|
1143 |
def delete(ui, repo, patch, **opts): |
|
1144 |
"""remove a patch from the series file""" |
|
1145 |
q = repomap[repo] |
|
1146 |
q.delete(repo, patch) |
|
1147 |
q.save_dirty() |
|
1148 |
return 0 |
|
1149 |
||
1150 |
def applied(ui, repo, patch=None, **opts): |
|
1151 |
"""print the patches already applied""" |
|
1152 |
repomap[repo].qapplied(repo, patch) |
|
1153 |
return 0 |
|
1154 |
||
1155 |
def unapplied(ui, repo, patch=None, **opts): |
|
1156 |
"""print the patches not yet applied""" |
|
1157 |
repomap[repo].unapplied(repo, patch) |
|
1158 |
return 0 |
|
1159 |
||
1160 |
def qimport(ui, repo, *filename, **opts): |
|
1161 |
"""import a patch""" |
|
1162 |
q = repomap[repo] |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1163 |
q.qimport(repo, filename, patch=opts['name'], |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1164 |
existing=opts['existing'], force=opts['force']) |
1808 | 1165 |
q.save_dirty() |
1166 |
return 0 |
|
1167 |
||
1168 |
def init(ui, repo, **opts): |
|
1169 |
"""init a new queue repository""" |
|
1170 |
q = repomap[repo] |
|
1171 |
r = q.init(repo, create=opts['create_repo']) |
|
1172 |
q.save_dirty() |
|
1173 |
if r: |
|
1174 |
fp = r.wopener('.hgignore', 'w') |
|
1175 |
print >> fp, 'syntax: glob' |
|
1176 |
print >> fp, 'status' |
|
1177 |
fp.close() |
|
1178 |
r.wopener('series', 'w').close() |
|
1179 |
r.add(['.hgignore', 'series']) |
|
1180 |
return 0 |
|
1181 |
||
1182 |
def commit(ui, repo, *pats, **opts): |
|
2526
37785f986260
mq: Added help for qcommit, consistently talk about queue repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2488
diff
changeset
|
1183 |
"""commit changes in the queue repository""" |
1808 | 1184 |
q = repomap[repo] |
1185 |
r = q.qrepo() |
|
1186 |
if not r: raise util.Abort('no queue repository') |
|
1187 |
commands.commit(r.ui, r, *pats, **opts) |
|
1188 |
||
1189 |
def series(ui, repo, **opts): |
|
1190 |
"""print the entire series file""" |
|
1191 |
repomap[repo].qseries(repo, missing=opts['missing']) |
|
1192 |
return 0 |
|
1193 |
||
1194 |
def top(ui, repo, **opts): |
|
1195 |
"""print the name of the current patch""" |
|
1196 |
repomap[repo].top(repo) |
|
1197 |
return 0 |
|
1198 |
||
1199 |
def next(ui, repo, **opts): |
|
1200 |
"""print the name of the next patch""" |
|
1201 |
repomap[repo].next(repo) |
|
1202 |
return 0 |
|
1203 |
||
1204 |
def prev(ui, repo, **opts): |
|
1205 |
"""print the name of the previous patch""" |
|
1206 |
repomap[repo].prev(repo) |
|
1207 |
return 0 |
|
1208 |
||
1209 |
def new(ui, repo, patch, **opts): |
|
1210 |
"""create a new patch""" |
|
1211 |
q = repomap[repo] |
|
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1212 |
message=commands.logmessage(**opts) |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1213 |
q.new(repo, patch, msg=message, force=opts['force']) |
1808 | 1214 |
q.save_dirty() |
1215 |
return 0 |
|
1216 |
||
1217 |
def refresh(ui, repo, **opts): |
|
1218 |
"""update the current patch""" |
|
1219 |
q = repomap[repo] |
|
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1220 |
message=commands.logmessage(**opts) |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1221 |
q.refresh(repo, msg=message, short=opts['short']) |
1808 | 1222 |
q.save_dirty() |
1223 |
return 0 |
|
1224 |
||
1225 |
def diff(ui, repo, *files, **opts): |
|
1226 |
"""diff of the current patch""" |
|
2097
4d2c2597876f
Fix hg qdiff <file>
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2086
diff
changeset
|
1227 |
# deep in the dirstate code, the walkhelper method wants a list, not a tuple |
4d2c2597876f
Fix hg qdiff <file>
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2086
diff
changeset
|
1228 |
repomap[repo].diff(repo, list(files)) |
1808 | 1229 |
return 0 |
1230 |
||
1231 |
def lastsavename(path): |
|
1232 |
(dir, base) = os.path.split(path) |
|
1233 |
names = os.listdir(dir) |
|
1234 |
namere = re.compile("%s.([0-9]+)" % base) |
|
1235 |
max = None |
|
1236 |
maxname = None |
|
1237 |
for f in names: |
|
1238 |
m = namere.match(f) |
|
1239 |
if m: |
|
1240 |
index = int(m.group(1)) |
|
1241 |
if max == None or index > max: |
|
1242 |
max = index |
|
1243 |
maxname = f |
|
1244 |
if maxname: |
|
1245 |
return (os.path.join(dir, maxname), max) |
|
1246 |
return (None, None) |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1247 |
|
1808 | 1248 |
def savename(path): |
1249 |
(last, index) = lastsavename(path) |
|
1250 |
if last is None: |
|
1251 |
index = 0 |
|
1252 |
newpath = path + ".%d" % (index + 1) |
|
1253 |
return newpath |
|
1254 |
||
1255 |
def push(ui, repo, patch=None, **opts): |
|
1256 |
"""push the next patch onto the stack""" |
|
1257 |
q = repomap[repo] |
|
1258 |
mergeq = None |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1259 |
|
1808 | 1260 |
if opts['all']: |
1261 |
patch = q.series[-1] |
|
1262 |
if opts['merge']: |
|
1263 |
if opts['name']: |
|
1264 |
newpath = opts['name'] |
|
1265 |
else: |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1266 |
newpath, i = lastsavename(q.path) |
1808 | 1267 |
if not newpath: |
1268 |
ui.warn("no saved queues found, please use -n\n") |
|
1269 |
return 1 |
|
1270 |
mergeq = queue(ui, repo.join(""), newpath) |
|
1271 |
ui.warn("merging with queue at: %s\n" % mergeq.path) |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1272 |
ret = q.push(repo, patch, force=opts['force'], list=opts['list'], |
1808 | 1273 |
mergeq=mergeq) |
1274 |
q.save_dirty() |
|
1275 |
return ret |
|
1276 |
||
1277 |
def pop(ui, repo, patch=None, **opts): |
|
1278 |
"""pop the current patch off the stack""" |
|
1279 |
localupdate = True |
|
1280 |
if opts['name']: |
|
1281 |
q = queue(ui, repo.join(""), repo.join(opts['name'])) |
|
1282 |
ui.warn('using patch queue: %s\n' % q.path) |
|
1283 |
localupdate = False |
|
1284 |
else: |
|
1285 |
q = repomap[repo] |
|
2697
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
1286 |
q.pop(repo, patch, force=opts['force'], update=localupdate, all=opts['all']) |
1808 | 1287 |
q.save_dirty() |
1288 |
return 0 |
|
1289 |
||
1290 |
def restore(ui, repo, rev, **opts): |
|
1291 |
"""restore the queue state saved by a rev""" |
|
1292 |
rev = repo.lookup(rev) |
|
1293 |
q = repomap[repo] |
|
1294 |
q.restore(repo, rev, delete=opts['delete'], |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1295 |
qupdate=opts['update']) |
1808 | 1296 |
q.save_dirty() |
1297 |
return 0 |
|
1298 |
||
1299 |
def save(ui, repo, **opts): |
|
1300 |
"""save current queue state""" |
|
1301 |
q = repomap[repo] |
|
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1302 |
message=commands.logmessage(**opts) |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1303 |
ret = q.save(repo, msg=message) |
1808 | 1304 |
if ret: |
1305 |
return ret |
|
1306 |
q.save_dirty() |
|
1307 |
if opts['copy']: |
|
1308 |
path = q.path |
|
1309 |
if opts['name']: |
|
1310 |
newpath = os.path.join(q.basepath, opts['name']) |
|
1311 |
if os.path.exists(newpath): |
|
1312 |
if not os.path.isdir(newpath): |
|
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1313 |
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:
2710
diff
changeset
|
1314 |
'a directory') % newpath) |
1808 | 1315 |
if not opts['force']: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1316 |
raise util.Abort(_('destination %s exists, ' |
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1317 |
'use -f to force') % newpath) |
1808 | 1318 |
else: |
1319 |
newpath = savename(path) |
|
1320 |
ui.warn("copy %s to %s\n" % (path, newpath)) |
|
1321 |
util.copyfiles(path, newpath) |
|
1322 |
if opts['empty']: |
|
1323 |
try: |
|
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
|
1324 |
os.unlink(os.path.join(q.path, q.status_path)) |
1808 | 1325 |
except: |
1326 |
pass |
|
1327 |
return 0 |
|
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1328 |
|
1808 | 1329 |
def strip(ui, repo, rev, **opts): |
1330 |
"""strip a revision and all later revs on the same branch""" |
|
1331 |
rev = repo.lookup(rev) |
|
1332 |
backup = 'all' |
|
1333 |
if opts['backup']: |
|
1334 |
backup = 'strip' |
|
1335 |
elif opts['nobackup']: |
|
1336 |
backup = 'none' |
|
1337 |
repomap[repo].strip(repo, rev, backup=backup) |
|
1338 |
return 0 |
|
1339 |
||
1340 |
def version(ui, q=None): |
|
1341 |
"""print the version number""" |
|
1342 |
ui.write("mq version %s\n" % versionstr) |
|
1343 |
return 0 |
|
1344 |
||
1345 |
def reposetup(ui, repo): |
|
1346 |
repomap[repo] = queue(ui, repo.join("")) |
|
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1347 |
oldtags = repo.tags |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1348 |
|
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1349 |
def qtags(): |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1350 |
if repo.tagscache: |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1351 |
return repo.tagscache |
2663
96950d39171d
Mq: modify repo.lookup to resolve applied patches too.
Brendan Cully <brendan@kublai.com>
parents:
2554
diff
changeset
|
1352 |
|
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1353 |
tagscache = oldtags() |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1354 |
|
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1355 |
q = repomap[repo] |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1356 |
if len(q.applied) == 0: |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1357 |
return tagscache |
2664
9b8df8dceeed
Add qtip and qbase to mq qlookup.
Brendan Cully <brendan@kublai.com>
parents:
2663
diff
changeset
|
1358 |
|
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1359 |
mqtags = [patch.split(':') for patch in q.applied] |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1360 |
mqtags.append((mqtags[-1][0], 'qtip')) |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1361 |
mqtags.append((mqtags[0][0], 'qbase')) |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1362 |
for patch in mqtags: |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1363 |
if patch[1] in tagscache: |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1364 |
repo.ui.warn('Tag %s overrides mq patch of the same name\n' % patch[1]) |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1365 |
else: |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1366 |
tagscache[patch[1]] = revlog.bin(patch[0]) |
2664
9b8df8dceeed
Add qtip and qbase to mq qlookup.
Brendan Cully <brendan@kublai.com>
parents:
2663
diff
changeset
|
1367 |
|
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1368 |
return tagscache |
2663
96950d39171d
Mq: modify repo.lookup to resolve applied patches too.
Brendan Cully <brendan@kublai.com>
parents:
2554
diff
changeset
|
1369 |
|
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1370 |
repo.tags = qtags |
1808 | 1371 |
|
1372 |
cmdtable = { |
|
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1373 |
"qapplied": (applied, [], 'hg qapplied [PATCH]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1374 |
"qcommit|qci": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1375 |
(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
|
1376 |
commands.table["^commit|ci"][1], |
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1377 |
'hg qcommit [OPTION]... [FILE]...'), |
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1378 |
"^qdiff": (diff, [], 'hg qdiff [FILE]...'), |
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1379 |
"qdelete": (delete, [], 'hg qdelete PATCH'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1380 |
"^qimport": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1381 |
(qimport, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1382 |
[('e', 'existing', None, 'import file in patch dir'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1383 |
('n', 'name', '', 'patch file name'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1384 |
('f', 'force', None, 'overwrite existing files')], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1385 |
'hg qimport [-e] [-n NAME] [-f] FILE...'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1386 |
"^qinit": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1387 |
(init, |
2526
37785f986260
mq: Added help for qcommit, consistently talk about queue repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2488
diff
changeset
|
1388 |
[('c', 'create-repo', None, 'create queue repository')], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1389 |
'hg qinit [-c]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1390 |
"qnew": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1391 |
(new, |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1392 |
[('m', 'message', '', _('use <text> as commit message')), |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1393 |
('l', 'logfile', '', _('read the commit message from <file>')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1394 |
('f', 'force', None, 'force')], |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1395 |
'hg qnew [-m TEXT] [-l FILE] [-f] PATCH'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1396 |
"qnext": (next, [], 'hg qnext'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1397 |
"qprev": (prev, [], 'hg qprev'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1398 |
"^qpop": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1399 |
(pop, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1400 |
[('a', 'all', None, 'pop all patches'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1401 |
('n', 'name', '', 'queue name to pop'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1402 |
('f', 'force', None, 'forget any local changes')], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1403 |
'hg qpop [-a] [-n NAME] [-f] [PATCH | INDEX]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1404 |
"^qpush": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1405 |
(push, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1406 |
[('f', 'force', None, 'apply if the patch has rejects'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1407 |
('l', 'list', None, 'list patch name in commit text'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1408 |
('a', 'all', None, 'apply all patches'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1409 |
('m', 'merge', None, 'merge from another queue'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1410 |
('n', 'name', '', 'merge queue name')], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1411 |
'hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1412 |
"^qrefresh": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1413 |
(refresh, |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1414 |
[('m', 'message', '', _('change commit message with <text>')), |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1415 |
('l', 'logfile', '', _('change commit message with <file> content')), |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1416 |
('s', 'short', None, 'short refresh')], |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1417 |
'hg qrefresh [-m TEXT] [-l FILE] [-s]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1418 |
"qrestore": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1419 |
(restore, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1420 |
[('d', 'delete', None, 'delete save entry'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1421 |
('u', 'update', None, 'update queue working dir')], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1422 |
'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
|
1423 |
"qsave": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1424 |
(save, |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1425 |
[('m', 'message', '', _('use <text> as commit message')), |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1426 |
('l', 'logfile', '', _('read the commit message from <file>')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1427 |
('c', 'copy', None, 'copy patch directory'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1428 |
('n', 'name', '', 'copy directory name'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1429 |
('e', 'empty', None, 'clear queue status file'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1430 |
('f', 'force', None, 'force copy')], |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1431 |
'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1432 |
"qseries": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1433 |
(series, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1434 |
[('m', 'missing', None, 'print patches not in series')], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1435 |
'hg qseries [-m]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1436 |
"^strip": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1437 |
(strip, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1438 |
[('f', 'force', None, 'force multi-head removal'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1439 |
('b', 'backup', None, 'bundle unrelated changesets'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1440 |
('n', 'nobackup', None, 'no backups')], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1441 |
'hg strip [-f] [-b] [-n] REV'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1442 |
"qtop": (top, [], 'hg qtop'), |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1443 |
"qunapplied": (unapplied, [], 'hg qunapplied [PATCH]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1444 |
"qversion": (version, [], 'hg qversion') |
1808 | 1445 |
} |
1446 |