Mercurial > hg > mercurial-crew-with-dirclash
annotate hgext/mq.py @ 2772:4720e79486d3
mq: simplify save_dirty
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Wed, 02 Aug 2006 20:33:57 -0700 |
parents | 519bf0cd28d2 |
children | 663094f5595b b550cd82f92a |
rev | line source |
---|---|
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1 |
1808 | 2 # queue.py - patch queues for mercurial |
3 # | |
4 # Copyright 2005 Chris Mason <mason@suse.com> | |
5 # | |
6 # This software may be used and distributed according to the terms | |
7 # of the GNU General Public License, incorporated herein by reference. | |
8 | |
2554
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
9 '''patch management and development |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
10 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
11 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
|
12 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
|
13 applied patches (subset of known patches). |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
14 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
15 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
|
16 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
|
17 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
18 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
|
19 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
20 prepare repository to work with patches qinit |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
21 create new patch qnew |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
22 import existing patch qimport |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
23 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
24 print patch series qseries |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
25 print applied patches qapplied |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
26 print name of top applied patch qtop |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
27 |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
28 add known patch to applied stack qpush |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
29 remove patch from applied stack qpop |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
30 refresh contents of top applied patch qrefresh |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
31 ''' |
8264c2034970
help: add help to mq extension
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2531
diff
changeset
|
32 |
1808 | 33 from mercurial.demandload import * |
34 demandload(globals(), "os sys re struct traceback errno bz2") | |
35 from mercurial.i18n import gettext as _ | |
36 from mercurial import ui, hg, revlog, commands, util | |
37 | |
38 versionstr = "0.45" | |
39 | |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
40 commands.norepo += " qclone qversion" |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
41 |
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() |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
60 self.parse_series() |
1808 | 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 | |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
78 def parse_series(self): |
1808 | 79 self.series = [] |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
80 for l in self.full_series: |
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
81 s = l.split('#', 1)[0].strip() |
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
82 if s: |
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
83 self.series.append(s) |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
84 |
1808 | 85 def save_dirty(self): |
2772
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
86 def write_list(items, path): |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
87 fp = self.opener(path, 'w') |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
88 for i in items: |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
89 print >> fp, i |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
90 fp.close() |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
91 if self.applied_dirty: write_list(self.applied, self.status_path) |
4720e79486d3
mq: simplify save_dirty
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2771
diff
changeset
|
92 if self.series_dirty: write_list(self.full_series, self.series_path) |
1808 | 93 |
94 def readheaders(self, patch): | |
95 def eatdiff(lines): | |
96 while lines: | |
97 l = lines[-1] | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
98 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
|
99 l.startswith("Index:") or |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
100 l.startswith("===========")): |
1808 | 101 del lines[-1] |
102 else: | |
103 break | |
104 def eatempty(lines): | |
105 while lines: | |
106 l = lines[-1] | |
107 if re.match('\s*$', l): | |
108 del lines[-1] | |
109 else: | |
110 break | |
111 | |
112 pf = os.path.join(self.path, patch) | |
113 message = [] | |
114 comments = [] | |
115 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
|
116 date = None |
1808 | 117 format = None |
118 subject = None | |
119 diffstart = 0 | |
120 | |
121 for line in file(pf): | |
122 line = line.rstrip() | |
123 if diffstart: | |
124 if line.startswith('+++ '): | |
125 diffstart = 2 | |
126 break | |
127 if line.startswith("--- "): | |
128 diffstart = 1 | |
129 continue | |
130 elif format == "hgpatch": | |
131 # parse values when importing the result of an hg export | |
132 if line.startswith("# User "): | |
133 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
|
134 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
|
135 date = line[7:] |
1808 | 136 elif not line.startswith("# ") and line: |
137 message.append(line) | |
138 format = None | |
139 elif line == '# HG changeset patch': | |
140 format = "hgpatch" | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
141 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
|
142 line.startswith("subject: "))): |
1808 | 143 subject = line[9:] |
144 format = "tag" | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
145 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
|
146 line.startswith("from: "))): |
1808 | 147 user = line[6:] |
148 format = "tag" | |
149 elif format == "tag" and line == "": | |
150 # when looking for tags (subject: from: etc) they | |
151 # end once you find a blank line in the source | |
152 format = "tagdone" | |
2301
7c2623aedeb4
Strip empty lines and trailing spaces around commit messages.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2300
diff
changeset
|
153 elif message or line: |
1808 | 154 message.append(line) |
155 comments.append(line) | |
156 | |
157 eatdiff(message) | |
158 eatdiff(comments) | |
159 eatempty(message) | |
160 eatempty(comments) | |
161 | |
162 # make sure message isn't empty | |
163 if format and format.startswith("tag") and subject: | |
164 message.insert(0, "") | |
165 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
|
166 return (message, comments, user, date, diffstart > 1) |
1808 | 167 |
168 def mergeone(self, repo, mergeq, head, patch, rev, wlock): | |
169 # 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
|
170 (err, n) = self.apply(repo, [ patch ], update_status=False, |
1808 | 171 strict=True, merge=rev, wlock=wlock) |
172 | |
173 if err == 0: | |
174 return (err, n) | |
175 | |
176 if n is None: | |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
177 raise util.Abort(_("apply failed for patch %s") % patch) |
1808 | 178 |
179 self.ui.warn("patch didn't work out, merging %s\n" % patch) | |
180 | |
181 # apply failed, strip away that rev and merge. | |
182 repo.update(head, allow=False, force=True, wlock=wlock) | |
183 self.strip(repo, n, update=False, backup='strip', wlock=wlock) | |
184 | |
185 c = repo.changelog.read(rev) | |
186 ret = repo.update(rev, allow=True, wlock=wlock) | |
187 if ret: | |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
188 raise util.Abort(_("update returned %d") % ret) |
1808 | 189 n = repo.commit(None, c[4], c[1], force=1, wlock=wlock) |
190 if n == None: | |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
191 raise util.Abort(_("repo commit failed")) |
1808 | 192 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
|
193 message, comments, user, date, patchfound = mergeq.readheaders(patch) |
1808 | 194 except: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
195 raise util.Abort(_("unable to read %s") % patch) |
1808 | 196 |
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
|
197 patchf = self.opener(patch, "w") |
1808 | 198 if comments: |
199 comments = "\n".join(comments) + '\n\n' | |
200 patchf.write(comments) | |
201 commands.dodiff(patchf, self.ui, repo, head, n) | |
202 patchf.close() | |
203 return (0, n) | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
204 |
1808 | 205 def qparents(self, repo, rev=None): |
206 if rev is None: | |
207 (p1, p2) = repo.dirstate.parents() | |
208 if p2 == revlog.nullid: | |
209 return p1 | |
210 if len(self.applied) == 0: | |
211 return None | |
212 (top, patch) = self.applied[-1].split(':') | |
213 top = revlog.bin(top) | |
214 return top | |
215 pp = repo.changelog.parents(rev) | |
216 if pp[1] != revlog.nullid: | |
217 arevs = [ x.split(':')[0] for x in self.applied ] | |
218 p0 = revlog.hex(pp[0]) | |
219 p1 = revlog.hex(pp[1]) | |
220 if p0 in arevs: | |
221 return pp[0] | |
222 if p1 in arevs: | |
223 return pp[1] | |
224 return pp[0] | |
225 | |
226 def mergepatch(self, repo, mergeq, series, wlock): | |
227 if len(self.applied) == 0: | |
228 # each of the patches merged in will have two parents. This | |
229 # can confuse the qrefresh, qdiff, and strip code because it | |
230 # needs to know which parent is actually in the patch queue. | |
231 # so, we insert a merge marker with only one parent. This way | |
232 # the first patch in the queue is never a merge patch | |
233 # | |
234 pname = ".hg.patches.merge.marker" | |
235 n = repo.commit(None, '[mq]: merge marker', user=None, force=1, | |
236 wlock=wlock) | |
237 self.applied.append(revlog.hex(n) + ":" + pname) | |
238 self.applied_dirty = 1 | |
239 | |
240 head = self.qparents(repo) | |
241 | |
242 for patch in series: | |
2696 | 243 patch = mergeq.lookup(patch, strict=True) |
1808 | 244 if not patch: |
245 self.ui.warn("patch %s does not exist\n" % patch) | |
246 return (1, None) | |
247 | |
248 info = mergeq.isapplied(patch) | |
249 if not info: | |
250 self.ui.warn("patch %s is not applied\n" % patch) | |
251 return (1, None) | |
252 rev = revlog.bin(info[1]) | |
253 (err, head) = self.mergeone(repo, mergeq, head, patch, rev, wlock) | |
254 if head: | |
255 self.applied.append(revlog.hex(head) + ":" + patch) | |
256 self.applied_dirty = 1 | |
257 if err: | |
258 return (err, head) | |
259 return (0, head) | |
260 | |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
261 def patch(self, repo, patchfile): |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
262 '''Apply patchfile to the working directory. |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
263 patchfile: file name of patch''' |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
264 try: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
265 pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
266 f = os.popen("%s -d '%s' -p1 --no-backup-if-mismatch < '%s'" % |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
267 (pp, repo.root, patchfile)) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
268 except: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
269 self.ui.warn("patch failed, unable to continue (try -v)\n") |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
270 return (None, [], False) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
271 files = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
272 fuzz = False |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
273 for l in f: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
274 l = l.rstrip('\r\n'); |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
275 if self.ui.verbose: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
276 self.ui.warn(l + "\n") |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
277 if l[:14] == 'patching file ': |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
278 pf = os.path.normpath(l[14:]) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
279 # when patch finds a space in the file name, it puts |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
280 # single quotes around the filename. strip them off |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
281 if pf[0] == "'" and pf[-1] == "'": |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
282 pf = pf[1:-1] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
283 if pf not in files: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
284 files.append(pf) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
285 printed_file = False |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
286 file_str = l |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
287 elif l.find('with fuzz') >= 0: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
288 if not printed_file: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
289 self.ui.warn(file_str + '\n') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
290 printed_file = True |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
291 self.ui.warn(l + '\n') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
292 fuzz = True |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
293 elif l.find('saving rejects to file') >= 0: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
294 self.ui.warn(l + '\n') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
295 elif l.find('FAILED') >= 0: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
296 if not printed_file: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
297 self.ui.warn(file_str + '\n') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
298 printed_file = True |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
299 self.ui.warn(l + '\n') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
300 |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
301 return (not f.close(), files, fuzz) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
302 |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
303 def apply(self, repo, series, list=False, update_status=True, |
1808 | 304 strict=False, patchdir=None, merge=None, wlock=None): |
305 # TODO unify with commands.py | |
306 if not patchdir: | |
307 patchdir = self.path | |
308 err = 0 | |
309 if not wlock: | |
310 wlock = repo.wlock() | |
311 lock = repo.lock() | |
312 tr = repo.transaction() | |
313 n = None | |
314 for patch in series: | |
315 self.ui.warn("applying %s\n" % patch) | |
316 pf = os.path.join(patchdir, patch) | |
317 | |
318 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
|
319 message, comments, user, date, patchfound = self.readheaders(patch) |
1808 | 320 except: |
321 self.ui.warn("Unable to read %s\n" % pf) | |
322 err = 1 | |
323 break | |
324 | |
325 if not message: | |
326 message = "imported patch %s\n" % patch | |
327 else: | |
328 if list: | |
329 message.append("\nimported patch %s" % patch) | |
330 message = '\n'.join(message) | |
331 | |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
332 (patcherr, files, fuzz) = self.patch(repo, pf) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
333 patcherr = not patcherr |
1808 | 334 |
335 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
|
336 # 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
|
337 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
|
338 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
|
339 repo.dirstate.setparents(p1, merge) |
1808 | 340 if len(files) > 0: |
2728
5d134f04060f
mq: allow to apply patches in subdir of repo again
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2725
diff
changeset
|
341 cwd = repo.getcwd() |
5d134f04060f
mq: allow to apply patches in subdir of repo again
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2725
diff
changeset
|
342 cfiles = files |
5d134f04060f
mq: allow to apply patches in subdir of repo again
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2725
diff
changeset
|
343 if cwd: |
5d134f04060f
mq: allow to apply patches in subdir of repo again
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2725
diff
changeset
|
344 cfiles = [util.pathto(cwd, f) for f in files] |
5d134f04060f
mq: allow to apply patches in subdir of repo again
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2725
diff
changeset
|
345 commands.addremove_lock(self.ui, repo, cfiles, |
1808 | 346 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
|
347 n = repo.commit(files, message, user, date, force=1, lock=lock, |
1808 | 348 wlock=wlock) |
349 | |
350 if n == None: | |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
351 raise util.Abort(_("repo commit failed")) |
1808 | 352 |
353 if update_status: | |
354 self.applied.append(revlog.hex(n) + ":" + patch) | |
355 | |
356 if patcherr: | |
357 if not patchfound: | |
358 self.ui.warn("patch %s is empty\n" % patch) | |
359 err = 0 | |
360 else: | |
361 self.ui.warn("patch failed, rejects left in working dir\n") | |
362 err = 1 | |
363 break | |
364 | |
365 if fuzz and strict: | |
366 self.ui.warn("fuzz found when applying patch, stopping\n") | |
367 err = 1 | |
368 break | |
369 tr.close() | |
370 return (err, n) | |
371 | |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
372 def delete(self, repo, patch, force=False): |
2696 | 373 patch = self.lookup(patch, strict=True) |
1808 | 374 info = self.isapplied(patch) |
375 if info: | |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
376 raise util.Abort(_("cannot delete applied patch %s") % patch) |
1808 | 377 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
|
378 raise util.Abort(_("patch %s not in series file") % patch) |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
379 if force: |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
380 r = self.qrepo() |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
381 if r: |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
382 r.remove([patch], True) |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
383 else: |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
384 os.unlink(os.path.join(self.path, patch)) |
1808 | 385 i = self.find_series(patch) |
386 del self.full_series[i] | |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
387 self.parse_series() |
1808 | 388 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
|
389 |
1808 | 390 def check_toppatch(self, repo): |
391 if len(self.applied) > 0: | |
392 (top, patch) = self.applied[-1].split(':') | |
393 top = revlog.bin(top) | |
394 pp = repo.dirstate.parents() | |
395 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
|
396 raise util.Abort(_("queue top not at same revision as working directory")) |
1808 | 397 return top |
398 return None | |
399 def check_localchanges(self, repo): | |
400 (c, a, r, d, u) = repo.changes(None, None) | |
401 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
|
402 raise util.Abort(_("local changes found, refresh first")) |
1808 | 403 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
|
404 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
|
405 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
|
406 commitfiles = [] |
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
407 (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
|
408 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
|
409 if not force: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
410 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
|
411 commitfiles = c + a + r |
1808 | 412 self.check_toppatch(repo) |
413 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
|
414 insert = self.full_series_end() |
1808 | 415 if msg: |
2511
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
416 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
|
417 wlock=wlock) |
1808 | 418 else: |
2511
041d8f0a8437
mq: hg qnew -f should refresh the new patch
Chris Mason <mason@suse.com>
parents:
2488
diff
changeset
|
419 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
|
420 "New patch: %s" % patch, force=True, wlock=wlock) |
1808 | 421 if n == None: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
422 raise util.Abort(_("repo commit failed")) |
1808 | 423 self.full_series[insert:insert] = [patch] |
424 self.applied.append(revlog.hex(n) + ":" + patch) | |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
425 self.parse_series() |
1808 | 426 self.series_dirty = 1 |
427 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
|
428 p = self.opener(patch, "w") |
1808 | 429 if msg: |
430 msg = msg + "\n" | |
431 p.write(msg) | |
432 p.close() | |
433 wlock = None | |
434 r = self.qrepo() | |
435 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
|
436 if commitfiles: |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
437 self.refresh(repo, msg=None, short=True) |
1808 | 438 |
439 def strip(self, repo, rev, update=True, backup="all", wlock=None): | |
440 def limitheads(chlog, stop): | |
441 """return the list of all nodes that have no children""" | |
442 p = {} | |
443 h = [] | |
444 stoprev = 0 | |
445 if stop in chlog.nodemap: | |
446 stoprev = chlog.rev(stop) | |
447 | |
448 for r in range(chlog.count() - 1, -1, -1): | |
449 n = chlog.node(r) | |
450 if n not in p: | |
451 h.append(n) | |
452 if n == stop: | |
453 break | |
454 if r < stoprev: | |
455 break | |
456 for pn in chlog.parents(n): | |
457 p[pn] = 1 | |
458 return h | |
459 | |
460 def bundle(cg): | |
461 backupdir = repo.join("strip-backup") | |
462 if not os.path.isdir(backupdir): | |
463 os.mkdir(backupdir) | |
464 name = os.path.join(backupdir, "%s" % revlog.short(rev)) | |
465 name = savename(name) | |
466 self.ui.warn("saving bundle to %s\n" % name) | |
467 # TODO, exclusive open | |
468 f = open(name, "wb") | |
469 try: | |
470 f.write("HG10") | |
471 z = bz2.BZ2Compressor(9) | |
472 while 1: | |
473 chunk = cg.read(4096) | |
474 if not chunk: | |
475 break | |
476 f.write(z.compress(chunk)) | |
477 f.write(z.flush()) | |
478 except: | |
479 os.unlink(name) | |
480 raise | |
481 f.close() | |
482 return name | |
483 | |
484 def stripall(rev, revnum): | |
485 cl = repo.changelog | |
486 c = cl.read(rev) | |
487 mm = repo.manifest.read(c[0]) | |
488 seen = {} | |
489 | |
490 for x in xrange(revnum, cl.count()): | |
491 c = cl.read(cl.node(x)) | |
492 for f in c[3]: | |
493 if f in seen: | |
494 continue | |
495 seen[f] = 1 | |
496 if f in mm: | |
497 filerev = mm[f] | |
498 else: | |
499 filerev = 0 | |
500 seen[f] = filerev | |
501 # we go in two steps here so the strip loop happens in a | |
502 # sensible order. When stripping many files, this helps keep | |
503 # our disk access patterns under control. | |
504 list = seen.keys() | |
505 list.sort() | |
506 for f in list: | |
507 ff = repo.file(f) | |
508 filerev = seen[f] | |
509 if filerev != 0: | |
510 if filerev in ff.nodemap: | |
511 filerev = ff.rev(filerev) | |
512 else: | |
513 filerev = 0 | |
514 ff.strip(filerev, revnum) | |
515 | |
516 if not wlock: | |
517 wlock = repo.wlock() | |
518 lock = repo.lock() | |
519 chlog = repo.changelog | |
520 # TODO delete the undo files, and handle undo of merge sets | |
521 pp = chlog.parents(rev) | |
522 revnum = chlog.rev(rev) | |
523 | |
524 if update: | |
2699
f8bcaf5696d5
mq: strip should not blow away local changes
Chris Mason <mason@suse.com>
parents:
2698
diff
changeset
|
525 (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
|
526 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
|
527 raise util.Abort(_("local changes found")) |
1808 | 528 urev = self.qparents(repo, rev) |
529 repo.update(urev, allow=False, force=True, wlock=wlock) | |
530 repo.dirstate.write() | |
531 | |
532 # save is a list of all the branches we are truncating away | |
533 # that we actually want to keep. changegroup will be used | |
534 # to preserve them and add them back after the truncate | |
535 saveheads = [] | |
536 savebases = {} | |
537 | |
538 tip = chlog.tip() | |
539 heads = limitheads(chlog, rev) | |
540 seen = {} | |
541 | |
542 # search through all the heads, finding those where the revision | |
543 # we want to strip away is an ancestor. Also look for merges | |
544 # that might be turned into new heads by the strip. | |
545 while heads: | |
546 h = heads.pop() | |
547 n = h | |
548 while True: | |
549 seen[n] = 1 | |
550 pp = chlog.parents(n) | |
551 if pp[1] != revlog.nullid and chlog.rev(pp[1]) > revnum: | |
552 if pp[1] not in seen: | |
553 heads.append(pp[1]) | |
554 if pp[0] == revlog.nullid: | |
555 break | |
556 if chlog.rev(pp[0]) < revnum: | |
557 break | |
558 n = pp[0] | |
559 if n == rev: | |
560 break | |
561 r = chlog.reachable(h, rev) | |
562 if rev not in r: | |
563 saveheads.append(h) | |
564 for x in r: | |
565 if chlog.rev(x) > revnum: | |
566 savebases[x] = 1 | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
567 |
1808 | 568 # create a changegroup for all the branches we need to keep |
569 if backup is "all": | |
570 backupch = repo.changegroupsubset([rev], chlog.heads(), 'strip') | |
571 bundle(backupch) | |
572 if saveheads: | |
573 backupch = repo.changegroupsubset(savebases.keys(), saveheads, 'strip') | |
574 chgrpfile = bundle(backupch) | |
575 | |
576 stripall(rev, revnum) | |
577 | |
578 change = chlog.read(rev) | |
579 repo.manifest.strip(repo.manifest.rev(change[0]), revnum) | |
580 chlog.strip(revnum, revnum) | |
581 if saveheads: | |
582 self.ui.status("adding branch\n") | |
583 commands.unbundle(self.ui, repo, chgrpfile, update=False) | |
584 if backup is not "strip": | |
585 os.unlink(chgrpfile) | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
586 |
1808 | 587 def isapplied(self, patch): |
588 """returns (index, rev, patch)""" | |
589 for i in xrange(len(self.applied)): | |
590 p = self.applied[i] | |
591 a = p.split(':') | |
592 if a[1] == patch: | |
593 return (i, a[0], a[1]) | |
594 return None | |
595 | |
2696 | 596 # if the exact patch name does not exist, we try a few |
597 # variations. If strict is passed, we try only #1 | |
598 # | |
599 # 1) a number to indicate an offset in the series file | |
600 # 2) a unique substring of the patch name was given | |
601 # 3) patchname[-+]num to indicate an offset in the series file | |
602 def lookup(self, patch, strict=False): | |
603 def partial_name(s): | |
604 if s in self.series: | |
605 return s | |
2765
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
606 matches = [x for x in self.series if s in x] |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
607 if len(matches) > 1: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
608 self.ui.warn(_('patch name "%s" is ambiguous:\n') % s) |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
609 for m in matches: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
610 self.ui.warn(' %s\n' % m) |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
611 return None |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
612 if matches: |
0327bd1c831c
mq: print matches if patch name not unique
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2757
diff
changeset
|
613 return matches[0] |
2696 | 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") |
2745
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
813 msg = msg.rstrip() |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
814 if msg: |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
815 if comments: |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
816 # Remove existing message. |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
817 ci = 0 |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
818 for mi in range(len(message)): |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
819 while message[mi] != comments[ci]: |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
820 ci += 1 |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
821 del comments[ci] |
1bac2bfe081a
Change patch header as well as commit message with qrefresh -m or -l.
Brendan Cully <brendan@kublai.com>
parents:
2742
diff
changeset
|
822 comments.append(msg) |
1808 | 823 if comments: |
824 comments = "\n".join(comments) + '\n\n' | |
825 patchf.write(comments) | |
826 | |
827 tip = repo.changelog.tip() | |
828 if top == tip: | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
829 # if the top of our patch queue is also the tip, there is an |
1808 | 830 # optimization here. We update the dirstate in place and strip |
831 # off the tip commit. Then just commit the current directory | |
832 # tree. We can also send repo.commit the list of files | |
833 # changed to speed up the diff | |
834 # | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
835 # in short mode, we only diff the files included in the |
1808 | 836 # patch already |
837 # | |
838 # this should really read: | |
839 #(cc, dd, aa, aa2, uu) = repo.changes(tip, patchparent) | |
840 # but we do it backwards to take advantage of manifest/chlog | |
841 # 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
|
842 # |
1808 | 843 (cc, aa, dd, aa2, uu) = repo.changes(patchparent, tip) |
844 if short: | |
845 filelist = cc + aa + dd | |
846 else: | |
847 filelist = None | |
848 (c, a, r, d, u) = repo.changes(None, None, filelist) | |
849 | |
850 # we might end up with files that were added between tip and | |
851 # the dirstate parent, but then changed in the local dirstate. | |
852 # in this case, we want them to only show up in the added section | |
853 for x in c: | |
854 if x not in aa: | |
855 cc.append(x) | |
856 # we might end up with files added by the local dirstate that | |
857 # were deleted by the patch. In this case, they should only | |
858 # show up in the changed section. | |
859 for x in a: | |
860 if x in dd: | |
861 del dd[dd.index(x)] | |
862 cc.append(x) | |
863 else: | |
864 aa.append(x) | |
865 # make sure any files deleted in the local dirstate | |
866 # are not in the add or change column of the patch | |
867 forget = [] | |
868 for x in d + r: | |
869 if x in aa: | |
870 del aa[aa.index(x)] | |
871 forget.append(x) | |
872 continue | |
873 elif x in cc: | |
874 del cc[cc.index(x)] | |
875 dd.append(x) | |
876 | |
877 c = list(util.unique(cc)) | |
878 r = list(util.unique(dd)) | |
879 a = list(util.unique(aa)) | |
880 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
|
881 commands.dodiff(patchf, self.ui, repo, patchparent, None, |
1808 | 882 filelist, changes=(c, a, r, [], u)) |
883 patchf.close() | |
884 | |
885 changes = repo.changelog.read(tip) | |
886 repo.dirstate.setparents(*cparents) | |
887 repo.dirstate.update(a, 'a') | |
888 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
|
889 repo.dirstate.update(c, 'n') |
1808 | 890 repo.dirstate.forget(forget) |
891 | |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
892 if not msg: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
893 if not message: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
894 message = "patch queue: %s\n" % patch |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
895 else: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
896 message = "\n".join(message) |
1808 | 897 else: |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
898 message = msg |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
899 |
1808 | 900 self.strip(repo, top, update=False, backup='strip', wlock=wlock) |
901 n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock) | |
902 self.applied[-1] = revlog.hex(n) + ':' + patch | |
903 self.applied_dirty = 1 | |
904 else: | |
905 commands.dodiff(patchf, self.ui, repo, patchparent, None) | |
906 patchf.close() | |
907 self.pop(repo, force=True, wlock=wlock) | |
908 self.push(repo, force=True, wlock=wlock) | |
909 | |
910 def init(self, repo, create=False): | |
911 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
|
912 raise util.Abort(_("patch queue directory already exists")) |
1808 | 913 os.mkdir(self.path) |
914 if create: | |
915 return self.qrepo(create=True) | |
916 | |
917 def unapplied(self, repo, patch=None): | |
918 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
|
919 raise util.Abort(_("patch %s is not in series file") % patch) |
1808 | 920 if not patch: |
921 start = self.series_end() | |
922 else: | |
923 start = self.series.index(patch) + 1 | |
924 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
|
925 if self.ui.verbose: |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
926 self.ui.write("%d " % self.series.index(p)) |
1808 | 927 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
|
928 |
2756
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
929 def qseries(self, repo, missing=None, summary=False): |
1808 | 930 start = self.series_end() |
931 if not missing: | |
2756
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
932 for i in range(len(self.series)): |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
933 patch = self.series[i] |
1808 | 934 if self.ui.verbose: |
2756
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
935 if i < start: |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
936 status = 'A' |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
937 else: |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
938 status = 'U' |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
939 self.ui.write('%d %s ' % (i, status)) |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
940 if summary: |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
941 msg = self.readheaders(patch)[0] |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
942 msg = msg and ': ' + msg[0] or ': ' |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
943 else: |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
944 msg = '' |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
945 self.ui.write('%s%s\n' % (patch, msg)) |
1808 | 946 else: |
947 list = [] | |
948 for root, dirs, files in os.walk(self.path): | |
949 d = root[len(self.path) + 1:] | |
950 for f in files: | |
951 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
|
952 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
|
953 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
|
954 and not fl.startswith('.')): |
1808 | 955 list.append(fl) |
956 list.sort() | |
957 if list: | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
958 for x in list: |
1808 | 959 if self.ui.verbose: |
960 self.ui.write("D ") | |
961 self.ui.write("%s\n" % x) | |
962 | |
963 def issaveline(self, l): | |
964 name = l.split(':')[1] | |
965 if name == '.hg.patches.save.line': | |
966 return True | |
967 | |
968 def qrepo(self, create=False): | |
969 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
|
970 return hg.repository(self.ui, path=self.path, create=create) |
1808 | 971 |
972 def restore(self, repo, rev, delete=None, qupdate=None): | |
973 c = repo.changelog.read(rev) | |
974 desc = c[4].strip() | |
975 lines = desc.splitlines() | |
976 i = 0 | |
977 datastart = None | |
978 series = [] | |
979 applied = [] | |
980 qpp = None | |
981 for i in xrange(0, len(lines)): | |
982 if lines[i] == 'Patch Data:': | |
983 datastart = i + 1 | |
984 elif lines[i].startswith('Dirstate:'): | |
985 l = lines[i].rstrip() | |
986 l = l[10:].split(' ') | |
987 qpp = [ hg.bin(x) for x in l ] | |
988 elif datastart != None: | |
989 l = lines[i].rstrip() | |
990 index = l.index(':') | |
991 id = l[:index] | |
992 file = l[index + 1:] | |
993 if id: | |
994 applied.append(l) | |
995 series.append(file) | |
996 if datastart == None: | |
997 self.ui.warn("No saved patch data found\n") | |
998 return 1 | |
999 self.ui.warn("restoring status: %s\n" % lines[0]) | |
1000 self.full_series = series | |
1001 self.applied = applied | |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
1002 self.parse_series() |
1808 | 1003 self.series_dirty = 1 |
1004 self.applied_dirty = 1 | |
1005 heads = repo.changelog.heads() | |
1006 if delete: | |
1007 if rev not in heads: | |
1008 self.ui.warn("save entry has children, leaving it alone\n") | |
1009 else: | |
1010 self.ui.warn("removing save entry %s\n" % hg.short(rev)) | |
1011 pp = repo.dirstate.parents() | |
1012 if rev in pp: | |
1013 update = True | |
1014 else: | |
1015 update = False | |
1016 self.strip(repo, rev, update=update, backup='strip') | |
1017 if qpp: | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1018 self.ui.warn("saved queue repository parents: %s %s\n" % |
1808 | 1019 (hg.short(qpp[0]), hg.short(qpp[1]))) |
1020 if qupdate: | |
1021 print "queue directory updating" | |
1022 r = self.qrepo() | |
1023 if not r: | |
1024 self.ui.warn("Unable to load queue repository\n") | |
1025 return 1 | |
1026 r.update(qpp[0], allow=False, force=True) | |
1027 | |
1028 def save(self, repo, msg=None): | |
1029 if len(self.applied) == 0: | |
1030 self.ui.warn("save: no patches applied, exiting\n") | |
1031 return 1 | |
1032 if self.issaveline(self.applied[-1]): | |
1033 self.ui.warn("status is already saved\n") | |
1034 return 1 | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1035 |
1808 | 1036 ar = [ ':' + x for x in self.full_series ] |
1037 if not msg: | |
1038 msg = "hg patches saved state" | |
1039 else: | |
1040 msg = "hg patches: " + msg.rstrip('\r\n') | |
1041 r = self.qrepo() | |
1042 if r: | |
1043 pp = r.dirstate.parents() | |
1044 msg += "\nDirstate: %s %s" % (hg.hex(pp[0]), hg.hex(pp[1])) | |
1045 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
|
1046 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
|
1047 + '\n' or "") |
1808 | 1048 n = repo.commit(None, text, user=None, force=1) |
1049 if not n: | |
1050 self.ui.warn("repo commit failed\n") | |
1051 return 1 | |
1052 self.applied.append(revlog.hex(n) + ":" + '.hg.patches.save.line') | |
1053 self.applied_dirty = 1 | |
1054 | |
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1055 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
|
1056 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
|
1057 (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
|
1058 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
|
1059 if end == None: |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1060 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
|
1061 return end + 1 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1062 return 0 |
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1063 |
1808 | 1064 def series_end(self): |
1065 end = 0 | |
1066 if len(self.applied) > 0: | |
1067 (top, p) = self.applied[-1].split(':') | |
1068 try: | |
1069 end = self.series.index(p) | |
1070 except ValueError: | |
1071 return 0 | |
1072 return end + 1 | |
1073 return end | |
1074 | |
1075 def qapplied(self, repo, patch=None): | |
1076 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
|
1077 raise util.Abort(_("patch %s is not in series file") % patch) |
1808 | 1078 if not patch: |
1079 end = len(self.applied) | |
1080 else: | |
1081 end = self.series.index(patch) + 1 | |
1082 for x in xrange(end): | |
1083 p = self.appliedname(x) | |
1084 self.ui.write("%s\n" % p) | |
1085 | |
1086 def appliedname(self, index): | |
1087 p = self.applied[index] | |
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1088 pname = p.split(':')[1] |
1808 | 1089 if not self.ui.verbose: |
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1090 p = pname |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1091 else: |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1092 p = str(self.series.index(pname)) + " " + p |
1808 | 1093 return p |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1094 |
1808 | 1095 def top(self, repo): |
1096 if len(self.applied): | |
1097 p = self.appliedname(-1) | |
1098 self.ui.write(p + '\n') | |
1099 else: | |
1100 self.ui.write("No patches applied\n") | |
1101 | |
1102 def next(self, repo): | |
1103 end = self.series_end() | |
1104 if end == len(self.series): | |
1105 self.ui.write("All patches applied\n") | |
1106 else: | |
2677
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1107 p = self.series[end] |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1108 if self.ui.verbose: |
ec05ce9cbf47
mq: uniform verbose display of patche[s].
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2664
diff
changeset
|
1109 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
|
1110 self.ui.write(p + '\n') |
1808 | 1111 |
1112 def prev(self, repo): | |
1113 if len(self.applied) > 1: | |
1114 p = self.appliedname(-2) | |
1115 self.ui.write(p + '\n') | |
1116 elif len(self.applied) == 1: | |
1117 self.ui.write("Only one patch applied\n") | |
1118 else: | |
1119 self.ui.write("No patches applied\n") | |
1120 | |
1121 def qimport(self, repo, files, patch=None, existing=None, force=None): | |
1122 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
|
1123 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
|
1124 'files')) |
1808 | 1125 i = 0 |
2488
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1126 added = [] |
1808 | 1127 for filename in files: |
1128 if existing: | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1129 if not patch: |
1808 | 1130 patch = filename |
1131 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
|
1132 raise util.Abort(_("patch %s does not exist") % patch) |
1808 | 1133 else: |
1134 try: | |
1135 text = file(filename).read() | |
1136 except IOError: | |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1137 raise util.Abort(_("unable to read %s") % patch) |
1808 | 1138 if not patch: |
1139 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
|
1140 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
|
1141 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
|
1142 patchf = self.opener(patch, "w") |
1808 | 1143 patchf.write(text) |
1144 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
|
1145 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
|
1146 % patch) |
2698
c1123e83c8e2
mq: fix qnew and qimport to deal with series file comments
Chris Mason <mason@suse.com>
parents:
2697
diff
changeset
|
1147 index = self.full_series_end() + i |
1808 | 1148 self.full_series[index:index] = [patch] |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
1149 self.parse_series() |
1808 | 1150 self.ui.warn("adding %s to series file\n" % patch) |
1151 i += 1 | |
2488
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1152 added.append(patch) |
1808 | 1153 patch = None |
1154 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
|
1155 qrepo = self.qrepo() |
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1156 if qrepo: |
2785aeb51be4
mq: add qimported patches if patch dir is a repo
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
1157 qrepo.add(added) |
1808 | 1158 |
1159 def delete(ui, repo, patch, **opts): | |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1160 """remove a patch from the series file |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1161 |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1162 The patch must not be applied. |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1163 With -f, deletes the patch file as well as the series entry.""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1164 q = repo.mq |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1165 q.delete(repo, patch, force=opts.get('force')) |
1808 | 1166 q.save_dirty() |
1167 return 0 | |
1168 | |
1169 def applied(ui, repo, patch=None, **opts): | |
1170 """print the patches already applied""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1171 repo.mq.qapplied(repo, patch) |
1808 | 1172 return 0 |
1173 | |
1174 def unapplied(ui, repo, patch=None, **opts): | |
1175 """print the patches not yet applied""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1176 repo.mq.unapplied(repo, patch) |
1808 | 1177 return 0 |
1178 | |
1179 def qimport(ui, repo, *filename, **opts): | |
1180 """import a patch""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1181 q = repo.mq |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1182 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
|
1183 existing=opts['existing'], force=opts['force']) |
1808 | 1184 q.save_dirty() |
1185 return 0 | |
1186 | |
1187 def init(ui, repo, **opts): | |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1188 """init a new queue repository |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1189 |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1190 The queue repository is unversioned by default. If -c is |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1191 specified, qinit will create a separate nested repository |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1192 for patches. Use qcommit to commit changes to this queue |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1193 repository.""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1194 q = repo.mq |
1808 | 1195 r = q.init(repo, create=opts['create_repo']) |
1196 q.save_dirty() | |
1197 if r: | |
1198 fp = r.wopener('.hgignore', 'w') | |
1199 print >> fp, 'syntax: glob' | |
1200 print >> fp, 'status' | |
1201 fp.close() | |
1202 r.wopener('series', 'w').close() | |
1203 r.add(['.hgignore', 'series']) | |
1204 return 0 | |
1205 | |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1206 def clone(ui, source, dest=None, **opts): |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1207 '''clone main and patch repository at same time |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1208 |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1209 If source is local, destination will have no patches applied. If |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1210 source is remote, this command can not check if patches are |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1211 applied in source, so cannot guarantee that patches are not |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1212 applied in destination. If you clone remote repository, be sure |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1213 before that it has no patches applied. |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1214 |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1215 Source patch repository is looked for in <src>/.hg/patches by |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1216 default. Use -p <url> to change. |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1217 ''' |
2766
c5ac397f7671
fix call to commands.setremoteconfig
Bryan O'Sullivan <bos@serpentine.com>
parents:
2765
diff
changeset
|
1218 commands.setremoteconfig(ui, opts) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1219 if dest is None: |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1220 dest = hg.defaultdest(source) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1221 sr = hg.repository(ui, ui.expandpath(source)) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1222 qbase, destrev = None, None |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1223 if sr.local(): |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1224 reposetup(ui, sr) |
2725
9ffee4f07323
mq: update to handle repomap not longer used
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2724
diff
changeset
|
1225 if sr.mq.applied: |
9ffee4f07323
mq: update to handle repomap not longer used
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2724
diff
changeset
|
1226 qbase = revlog.bin(sr.mq.applied[0].split(':')[0]) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1227 if not hg.islocal(dest): |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1228 destrev = sr.parents(qbase)[0] |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1229 ui.note(_('cloning main repo\n')) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1230 sr, dr = hg.clone(ui, sr, dest, |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1231 pull=opts['pull'], |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1232 rev=destrev, |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1233 update=False, |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1234 stream=opts['uncompressed']) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1235 ui.note(_('cloning patch repo\n')) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1236 spr, dpr = hg.clone(ui, opts['patches'] or (sr.url() + '/.hg/patches'), |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1237 dr.url() + '/.hg/patches', |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1238 pull=opts['pull'], |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1239 update=not opts['noupdate'], |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1240 stream=opts['uncompressed']) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1241 if dr.local(): |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1242 if qbase: |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1243 ui.note(_('stripping applied patches from destination repo\n')) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1244 reposetup(ui, dr) |
2725
9ffee4f07323
mq: update to handle repomap not longer used
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2724
diff
changeset
|
1245 dr.mq.strip(dr, qbase, update=False, backup=None) |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1246 if not opts['noupdate']: |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1247 ui.note(_('updating destination repo\n')) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1248 dr.update(dr.changelog.tip()) |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1249 |
1808 | 1250 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
|
1251 """commit changes in the queue repository""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1252 q = repo.mq |
1808 | 1253 r = q.qrepo() |
1254 if not r: raise util.Abort('no queue repository') | |
1255 commands.commit(r.ui, r, *pats, **opts) | |
1256 | |
1257 def series(ui, repo, **opts): | |
1258 """print the entire series file""" | |
2756
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
1259 repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary']) |
1808 | 1260 return 0 |
1261 | |
1262 def top(ui, repo, **opts): | |
1263 """print the name of the current patch""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1264 repo.mq.top(repo) |
1808 | 1265 return 0 |
1266 | |
1267 def next(ui, repo, **opts): | |
1268 """print the name of the next patch""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1269 repo.mq.next(repo) |
1808 | 1270 return 0 |
1271 | |
1272 def prev(ui, repo, **opts): | |
1273 """print the name of the previous patch""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1274 repo.mq.prev(repo) |
1808 | 1275 return 0 |
1276 | |
1277 def new(ui, repo, patch, **opts): | |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1278 """create a new patch |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1279 |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1280 qnew creates a new patch on top of the currently-applied patch |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1281 (if any). It will refuse to run if there are any outstanding |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1282 changes unless -f is specified, in which case the patch will |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1283 be initialised with them. |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1284 |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1285 -m or -l set the patch header as well as the commit message. |
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1286 If neither is specified, the patch header is empty and the |
2770
5f8259e4d292
Clean up qnew help text.
Brendan Cully <brendan@kublai.com>
parents:
2767
diff
changeset
|
1287 commit message is 'New patch: PATCH'""" |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1288 q = repo.mq |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1289 message=commands.logmessage(**opts) |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1290 q.new(repo, patch, msg=message, force=opts['force']) |
1808 | 1291 q.save_dirty() |
1292 return 0 | |
1293 | |
1294 def refresh(ui, repo, **opts): | |
1295 """update the current patch""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1296 q = repo.mq |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1297 message=commands.logmessage(**opts) |
2746
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1298 if opts['edit']: |
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1299 if message: |
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1300 raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1301 patch = q.applied[-1].split(':')[1] |
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1302 (message, comment, user, date, hasdiff) = q.readheaders(patch) |
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1303 message = ui.edit('\n'.join(message), user or ui.username()) |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1304 q.refresh(repo, msg=message, short=opts['short']) |
1808 | 1305 q.save_dirty() |
1306 return 0 | |
1307 | |
1308 def diff(ui, repo, *files, **opts): | |
1309 """diff of the current patch""" | |
2097
4d2c2597876f
Fix hg qdiff <file>
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2086
diff
changeset
|
1310 # deep in the dirstate code, the walkhelper method wants a list, not a tuple |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1311 repo.mq.diff(repo, list(files)) |
1808 | 1312 return 0 |
1313 | |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1314 def fold(ui, repo, *files, **opts): |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1315 """fold the named patches into the current patch |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1316 |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1317 Patches must not yet be applied. Each patch will be successively |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1318 applied to the current patch in the order given. If all the |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1319 patches apply successfully, the current patch will be refreshed |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1320 with the new cumulative patch, and the folded patches will |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1321 be deleted. With -f/--force, the folded patch files will |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1322 be removed afterwards. |
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1323 |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1324 The header for each folded patch will be concatenated with |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1325 the current patch header, separated by a line of '* * *'.""" |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1326 |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1327 q = repo.mq |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1328 |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1329 if not files: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1330 raise util.Abort(_('qfold requires at least one patch name')) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1331 if not q.check_toppatch(repo): |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1332 raise util.Abort(_('No patches applied\n')) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1333 |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1334 message=commands.logmessage(**opts) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1335 if opts['edit']: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1336 if message: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1337 raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1338 |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1339 parent = q.lookup('qtip') |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1340 patches = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1341 messages = [] |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1342 for f in files: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1343 patch = q.lookup(f) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1344 if patch in patches or patch == parent: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1345 self.ui.warn(_('Skipping already folded patch %s') % patch) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1346 if q.isapplied(patch): |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1347 raise util.Abort(_('qfold cannot fold already applied patch %s') % patch) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1348 patches.append(patch) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1349 |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1350 for patch in patches: |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1351 if not message: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1352 messages.append(q.readheaders(patch)[0]) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1353 pf = os.path.join(q.path, patch) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1354 (patchsuccess, files, fuzz) = q.patch(repo, pf) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1355 if not patchsuccess: |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1356 raise util.Abort(_('Error folding patch %s') % patch) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1357 |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1358 if not message: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1359 message, comments, user = q.readheaders(parent)[0:3] |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1360 for msg in messages: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1361 message.append('* * *') |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1362 message.extend(msg) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1363 message = '\n'.join(message) |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1364 |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1365 if opts['edit']: |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1366 message = ui.edit(message, user or ui.username()) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1367 |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1368 q.refresh(repo, msg=message) |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1369 |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1370 for patch in patches: |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1371 q.delete(repo, patch, force=opts['force']) |
2748
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1372 |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1373 q.save_dirty() |
752b9475a700
New mq command qfold: Merge patches into the current patch.
Brendan Cully <brendan@kublai.com>
parents:
2747
diff
changeset
|
1374 |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1375 def header(ui, repo, patch=None): |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1376 """Print the header of the topmost or specified patch""" |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1377 q = repo.mq |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1378 |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1379 if patch: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1380 patch = q.lookup(patch) |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1381 else: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1382 if not q.applied: |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1383 ui.write('No patches applied\n') |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1384 return |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1385 patch = q.lookup('qtip') |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1386 message = repo.mq.readheaders(patch)[0] |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1387 |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1388 ui.write('\n'.join(message) + '\n') |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1389 |
1808 | 1390 def lastsavename(path): |
1391 (dir, base) = os.path.split(path) | |
1392 names = os.listdir(dir) | |
1393 namere = re.compile("%s.([0-9]+)" % base) | |
1394 max = None | |
1395 maxname = None | |
1396 for f in names: | |
1397 m = namere.match(f) | |
1398 if m: | |
1399 index = int(m.group(1)) | |
1400 if max == None or index > max: | |
1401 max = index | |
1402 maxname = f | |
1403 if maxname: | |
1404 return (os.path.join(dir, maxname), max) | |
1405 return (None, None) | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1406 |
1808 | 1407 def savename(path): |
1408 (last, index) = lastsavename(path) | |
1409 if last is None: | |
1410 index = 0 | |
1411 newpath = path + ".%d" % (index + 1) | |
1412 return newpath | |
1413 | |
1414 def push(ui, repo, patch=None, **opts): | |
1415 """push the next patch onto the stack""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1416 q = repo.mq |
1808 | 1417 mergeq = None |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1418 |
1808 | 1419 if opts['all']: |
1420 patch = q.series[-1] | |
1421 if opts['merge']: | |
1422 if opts['name']: | |
1423 newpath = opts['name'] | |
1424 else: | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1425 newpath, i = lastsavename(q.path) |
1808 | 1426 if not newpath: |
1427 ui.warn("no saved queues found, please use -n\n") | |
1428 return 1 | |
1429 mergeq = queue(ui, repo.join(""), newpath) | |
1430 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
|
1431 ret = q.push(repo, patch, force=opts['force'], list=opts['list'], |
1808 | 1432 mergeq=mergeq) |
1433 q.save_dirty() | |
1434 return ret | |
1435 | |
1436 def pop(ui, repo, patch=None, **opts): | |
1437 """pop the current patch off the stack""" | |
1438 localupdate = True | |
1439 if opts['name']: | |
1440 q = queue(ui, repo.join(""), repo.join(opts['name'])) | |
1441 ui.warn('using patch queue: %s\n' % q.path) | |
1442 localupdate = False | |
1443 else: | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1444 q = repo.mq |
2697
6c540dd14c38
mq: qpop should act like quilt pop
Chris Mason <mason@suse.com>
parents:
2696
diff
changeset
|
1445 q.pop(repo, patch, force=opts['force'], update=localupdate, all=opts['all']) |
1808 | 1446 q.save_dirty() |
1447 return 0 | |
1448 | |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1449 def rename(ui, repo, patch, name=None, **opts): |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1450 """rename a patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1451 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1452 With one argument, renames the current patch to PATCH1. |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1453 With two arguments, renames PATCH1 to PATCH2.""" |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1454 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1455 q = repo.mq |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1456 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1457 if not name: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1458 name = patch |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1459 patch = None |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1460 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1461 if name in q.series: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1462 raise util.Abort(_('A patch named %s already exists in the series file') % name) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1463 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1464 absdest = os.path.join(q.path, name) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1465 if os.path.exists(absdest): |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1466 raise util.Abort(_('%s already exists') % absdest) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1467 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1468 if patch: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1469 patch = q.lookup(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1470 else: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1471 if not q.applied: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1472 ui.write(_('No patches applied\n')) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1473 return |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1474 patch = q.lookup('qtip') |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1475 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1476 if ui.verbose: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1477 ui.write('Renaming %s to %s\n' % (patch, name)) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1478 i = q.find_series(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1479 q.full_series[i] = name |
2767
60683ab1ed33
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2766
diff
changeset
|
1480 q.parse_series() |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1481 q.series_dirty = 1 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1482 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1483 info = q.isapplied(patch) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1484 if info: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1485 q.applied[info[0]] = info[1] + ':' + name |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1486 q.applied_dirty = 1 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1487 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1488 util.rename(os.path.join(q.path, patch), absdest) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1489 r = q.qrepo() |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1490 if r: |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1491 wlock = r.wlock() |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1492 if r.dirstate.state(name) == 'r': |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1493 r.undelete([name], wlock) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1494 r.copy(patch, name, wlock) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1495 r.remove([patch], False, wlock) |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1496 |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1497 q.save_dirty() |
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1498 |
1808 | 1499 def restore(ui, repo, rev, **opts): |
1500 """restore the queue state saved by a rev""" | |
1501 rev = repo.lookup(rev) | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1502 q = repo.mq |
1808 | 1503 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
|
1504 qupdate=opts['update']) |
1808 | 1505 q.save_dirty() |
1506 return 0 | |
1507 | |
1508 def save(ui, repo, **opts): | |
1509 """save current queue state""" | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1510 q = repo.mq |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1511 message=commands.logmessage(**opts) |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1512 ret = q.save(repo, msg=message) |
1808 | 1513 if ret: |
1514 return ret | |
1515 q.save_dirty() | |
1516 if opts['copy']: | |
1517 path = q.path | |
1518 if opts['name']: | |
1519 newpath = os.path.join(q.basepath, opts['name']) | |
1520 if os.path.exists(newpath): | |
1521 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
|
1522 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
|
1523 'a directory') % newpath) |
1808 | 1524 if not opts['force']: |
2711
8e5cd8d11b51
mq: move many error messages to util.Abort
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2710
diff
changeset
|
1525 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
|
1526 'use -f to force') % newpath) |
1808 | 1527 else: |
1528 newpath = savename(path) | |
1529 ui.warn("copy %s to %s\n" % (path, newpath)) | |
1530 util.copyfiles(path, newpath) | |
1531 if opts['empty']: | |
1532 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
|
1533 os.unlink(os.path.join(q.path, q.status_path)) |
1808 | 1534 except: |
1535 pass | |
1536 return 0 | |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1537 |
1808 | 1538 def strip(ui, repo, rev, **opts): |
1539 """strip a revision and all later revs on the same branch""" | |
1540 rev = repo.lookup(rev) | |
1541 backup = 'all' | |
1542 if opts['backup']: | |
1543 backup = 'strip' | |
1544 elif opts['nobackup']: | |
1545 backup = 'none' | |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1546 repo.mq.strip(repo, rev, backup=backup) |
1808 | 1547 return 0 |
1548 | |
1549 def version(ui, q=None): | |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1550 """print the version number of the mq extension""" |
1808 | 1551 ui.write("mq version %s\n" % versionstr) |
1552 return 0 | |
1553 | |
1554 def reposetup(ui, repo): | |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1555 class MqRepo(repo.__class__): |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1556 def tags(self): |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1557 if self.tagscache: |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1558 return self.tagscache |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1559 |
2742
2f13f8d3fe80
mq: correct the use of super
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2738
diff
changeset
|
1560 tagscache = super(MqRepo, self).tags() |
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1561 |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1562 q = self.mq |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1563 if not q.applied: |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1564 return tagscache |
2663
96950d39171d
Mq: modify repo.lookup to resolve applied patches too.
Brendan Cully <brendan@kublai.com>
parents:
2554
diff
changeset
|
1565 |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1566 mqtags = [patch.split(':') for patch in q.applied] |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1567 mqtags.append((mqtags[-1][0], 'qtip')) |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1568 mqtags.append((mqtags[0][0], 'qbase')) |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1569 for patch in mqtags: |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1570 if patch[1] in tagscache: |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1571 self.ui.warn('Tag %s overrides mq patch of the same name\n' % patch[1]) |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1572 else: |
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1573 tagscache[patch[1]] = revlog.bin(patch[0]) |
2682
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1574 |
4e2dc5c16e61
Add mq patch names to tagscache instead of overriding lookup.
Brendan Cully <brendan@kublai.com>
parents:
2677
diff
changeset
|
1575 return tagscache |
2664
9b8df8dceeed
Add qtip and qbase to mq qlookup.
Brendan Cully <brendan@kublai.com>
parents:
2663
diff
changeset
|
1576 |
2723
04d9b31faeca
mq: do not hold a reference to repo in tags override
Brendan Cully <brendan@kublai.com>
parents:
2720
diff
changeset
|
1577 repo.__class__ = MqRepo |
2724
9c41ae1908c7
mq: replace module-wide repo hash with a repo attribute
Brendan Cully <brendan@kublai.com>
parents:
2723
diff
changeset
|
1578 repo.mq = queue(ui, repo.join("")) |
1808 | 1579 |
1580 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
|
1581 "qapplied": (applied, [], 'hg qapplied [PATCH]'), |
2720
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1582 "qclone": (clone, |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1583 [('', 'pull', None, _('use pull protocol to copy metadata')), |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1584 ('U', 'noupdate', None, _('do not update the new working directories')), |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1585 ('', 'uncompressed', None, |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1586 _('use uncompressed transfer (fast over LAN)')), |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1587 ('e', 'ssh', '', _('specify ssh command to use')), |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1588 ('p', 'patches', '', _('location of source patch repo')), |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1589 ('', 'remotecmd', '', |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1590 _('specify hg command to run on the remote side'))], |
c91ca61c8953
mq: add qclone command
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2712
diff
changeset
|
1591 'hg qclone [OPTION]... SOURCE [DEST]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1592 "qcommit|qci": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1593 (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
|
1594 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
|
1595 '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
|
1596 "^qdiff": (diff, [], 'hg qdiff [FILE]...'), |
2752
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1597 "qdelete": |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1598 (delete, |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1599 [('f', 'force', None, _('delete patch file'))], |
5dfeda163bb7
Add -f option to qdelete, to remove patch file.
Brendan Cully <brendan@kublai.com>
parents:
2751
diff
changeset
|
1600 'hg qdelete [-f] PATCH'), |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1601 'qfold': |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1602 (fold, |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1603 [('e', 'edit', None, _('edit patch header')), |
2771
519bf0cd28d2
Add -f option to qfold; improve qfold documentation.
Brendan Cully <brendan@kublai.com>
parents:
2770
diff
changeset
|
1604 ('f', 'force', None, _('delete folded patch files')), |
2753
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1605 ('m', 'message', '', _('set patch header to <text>')), |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1606 ('l', 'logfile', '', _('set patch header to contents of <file>'))], |
84218111e80f
Add -m, -l, -e options to qfold.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1607 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'), |
2747
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1608 'qheader': (header, [], |
0016fc748f61
Add command qheader to display the header of a given patch.
Brendan Cully <brendan@kublai.com>
parents:
2746
diff
changeset
|
1609 _('hg qheader [PATCH]')), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1610 "^qimport": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1611 (qimport, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1612 [('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
|
1613 ('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
|
1614 ('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
|
1615 '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
|
1616 "^qinit": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1617 (init, |
2526
37785f986260
mq: Added help for qcommit, consistently talk about queue repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2488
diff
changeset
|
1618 [('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
|
1619 'hg qinit [-c]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1620 "qnew": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1621 (new, |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1622 [('m', 'message', '', _('use <text> as commit message')), |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1623 ('l', 'logfile', '', _('read the commit message from <file>')), |
2754
19041b8cbc86
Add more verbose help text to mq commands.
Brendan Cully <brendan@kublai.com>
parents:
2753
diff
changeset
|
1624 ('f', 'force', None, _('import uncommitted changes into patch'))], |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1625 '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
|
1626 "qnext": (next, [], 'hg qnext'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1627 "qprev": (prev, [], 'hg qprev'), |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1628 "^qpop": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1629 (pop, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1630 [('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
|
1631 ('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
|
1632 ('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
|
1633 '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
|
1634 "^qpush": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1635 (push, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1636 [('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
|
1637 ('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
|
1638 ('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
|
1639 ('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
|
1640 ('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
|
1641 '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
|
1642 "^qrefresh": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1643 (refresh, |
2746
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1644 [('e', 'edit', None, _('edit commit message')), |
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1645 ('m', 'message', '', _('change commit message with <text>')), |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1646 ('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
|
1647 ('s', 'short', None, 'short refresh')], |
2746
0503eb5c0a33
Add option -e/--edit to qrefresh, to edit the existing header.
Brendan Cully <brendan@kublai.com>
parents:
2745
diff
changeset
|
1648 'hg qrefresh [-e] [-m TEXT] [-l FILE] [-s]'), |
2751
7d1de4545728
mq: add qmv as alias for qrename
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2750
diff
changeset
|
1649 'qrename|qmv': |
2750
8c814c1ab31e
New self-explanatory command qrename.
Brendan Cully <brendan@kublai.com>
parents:
2748
diff
changeset
|
1650 (rename, [], 'hg qrename PATCH1 [PATCH2]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1651 "qrestore": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1652 (restore, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1653 [('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
|
1654 ('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
|
1655 '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
|
1656 "qsave": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1657 (save, |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1658 [('m', 'message', '', _('use <text> as commit message')), |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1659 ('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
|
1660 ('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
|
1661 ('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
|
1662 ('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
|
1663 ('f', 'force', None, 'force copy')], |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2682
diff
changeset
|
1664 '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
|
1665 "qseries": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1666 (series, |
2756
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
1667 [('m', 'missing', None, 'print patches not in series'), |
caa6d992608b
Add -s option to qseries: display first line of patch header.
Brendan Cully <brendan@kublai.com>
parents:
2754
diff
changeset
|
1668 ('s', 'summary', None, _('print first line of patch header'))], |
2185
5acd648770d0
Better help for mq: Corrected synopses, get qcommit options from commands.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2097
diff
changeset
|
1669 'hg qseries [-m]'), |
1810
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1670 "^strip": |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1671 (strip, |
7596611ab3d5
Whitespace, tab and formatting cleanups, mainly in mq.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1808
diff
changeset
|
1672 [('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
|
1673 ('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
|
1674 ('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
|
1675 '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
|
1676 "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
|
1677 "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
|
1678 "qversion": (version, [], 'hg qversion') |
1808 | 1679 } |
1680 |