|
@@
-1,2520
+1,2529
|
|
1
|
# mq.py - patch queues for mercurial
|
|
1
|
# mq.py - patch queues for mercurial
|
|
2
|
#
|
|
2
|
#
|
|
3
|
# Copyright 2005, 2006 Chris Mason <mason@suse.com>
|
|
3
|
# Copyright 2005, 2006 Chris Mason <mason@suse.com>
|
|
4
|
#
|
|
4
|
#
|
|
5
|
# This software may be used and distributed according to the terms
|
|
5
|
# This software may be used and distributed according to the terms
|
|
6
|
# of the GNU General Public License, incorporated herein by reference.
|
|
6
|
# of the GNU General Public License, incorporated herein by reference.
|
|
7
|
|
|
7
|
|
|
8
|
'''patch management and development
|
|
8
|
'''patch management and development
|
|
9
|
|
|
9
|
|
|
10
|
This extension lets you work with a stack of patches in a Mercurial
|
|
10
|
This extension lets you work with a stack of patches in a Mercurial
|
|
11
|
repository. It manages two stacks of patches - all known patches, and
|
|
11
|
repository. It manages two stacks of patches - all known patches, and
|
|
12
|
applied patches (subset of known patches).
|
|
12
|
applied patches (subset of known patches).
|
|
13
|
|
|
13
|
|
|
14
|
Known patches are represented as patch files in the .hg/patches
|
|
14
|
Known patches are represented as patch files in the .hg/patches
|
|
15
|
directory. Applied patches are both patch files and changesets.
|
|
15
|
directory. Applied patches are both patch files and changesets.
|
|
16
|
|
|
16
|
|
|
17
|
Common tasks (use "hg help command" for more details):
|
|
17
|
Common tasks (use "hg help command" for more details):
|
|
18
|
|
|
18
|
|
|
19
|
prepare repository to work with patches qinit
|
|
19
|
prepare repository to work with patches qinit
|
|
20
|
create new patch qnew
|
|
20
|
create new patch qnew
|
|
21
|
import existing patch qimport
|
|
21
|
import existing patch qimport
|
|
22
|
|
|
22
|
|
|
23
|
print patch series qseries
|
|
23
|
print patch series qseries
|
|
24
|
print applied patches qapplied
|
|
24
|
print applied patches qapplied
|
|
25
|
print name of top applied patch qtop
|
|
25
|
print name of top applied patch qtop
|
|
26
|
|
|
26
|
|
|
27
|
add known patch to applied stack qpush
|
|
27
|
add known patch to applied stack qpush
|
|
28
|
remove patch from applied stack qpop
|
|
28
|
remove patch from applied stack qpop
|
|
29
|
refresh contents of top applied patch qrefresh
|
|
29
|
refresh contents of top applied patch qrefresh
|
|
30
|
'''
|
|
30
|
'''
|
|
31
|
|
|
31
|
|
|
32
|
from mercurial.i18n import _
|
|
32
|
from mercurial.i18n import _
|
|
33
|
from mercurial.node import bin, hex, short
|
|
33
|
from mercurial.node import bin, hex, short
|
|
34
|
from mercurial.repo import RepoError
|
|
34
|
from mercurial.repo import RepoError
|
|
35
|
from mercurial import commands, cmdutil, hg, patch, revlog, util
|
|
35
|
from mercurial import commands, cmdutil, hg, patch, revlog, util
|
|
36
|
from mercurial import repair, extensions, url
|
|
36
|
from mercurial import repair, extensions, url
|
|
37
|
import os, sys, re, errno
|
|
37
|
import os, sys, re, errno
|
|
38
|
|
|
38
|
|
|
39
|
commands.norepo += " qclone"
|
|
39
|
commands.norepo += " qclone"
|
|
40
|
|
|
40
|
|
|
41
|
# Patch names looks like unix-file names.
|
|
41
|
# Patch names looks like unix-file names.
|
|
42
|
# They must be joinable with queue directory and result in the patch path.
|
|
42
|
# They must be joinable with queue directory and result in the patch path.
|
|
43
|
normname = util.normpath
|
|
43
|
normname = util.normpath
|
|
44
|
|
|
44
|
|
|
45
|
class statusentry:
|
|
45
|
class statusentry:
|
|
46
|
def __init__(self, rev, name=None):
|
|
46
|
def __init__(self, rev, name=None):
|
|
47
|
if not name:
|
|
47
|
if not name:
|
|
48
|
fields = rev.split(':', 1)
|
|
48
|
fields = rev.split(':', 1)
|
|
49
|
if len(fields) == 2:
|
|
49
|
if len(fields) == 2:
|
|
50
|
self.rev, self.name = fields
|
|
50
|
self.rev, self.name = fields
|
|
51
|
else:
|
|
51
|
else:
|
|
52
|
self.rev, self.name = None, None
|
|
52
|
self.rev, self.name = None, None
|
|
53
|
else:
|
|
53
|
else:
|
|
54
|
self.rev, self.name = rev, name
|
|
54
|
self.rev, self.name = rev, name
|
|
55
|
|
|
55
|
|
|
56
|
def __str__(self):
|
|
56
|
def __str__(self):
|
|
57
|
return self.rev + ':' + self.name
|
|
57
|
return self.rev + ':' + self.name
|
|
58
|
|
|
58
|
|
|
59
|
class queue:
|
|
59
|
class queue:
|
|
60
|
def __init__(self, ui, path, patchdir=None):
|
|
60
|
def __init__(self, ui, path, patchdir=None):
|
|
61
|
self.basepath = path
|
|
61
|
self.basepath = path
|
|
62
|
self.path = patchdir or os.path.join(path, "patches")
|
|
62
|
self.path = patchdir or os.path.join(path, "patches")
|
|
63
|
self.opener = util.opener(self.path)
|
|
63
|
self.opener = util.opener(self.path)
|
|
64
|
self.ui = ui
|
|
64
|
self.ui = ui
|
|
65
|
self.applied = []
|
|
65
|
self.applied = []
|
|
66
|
self.full_series = []
|
|
66
|
self.full_series = []
|
|
67
|
self.applied_dirty = 0
|
|
67
|
self.applied_dirty = 0
|
|
68
|
self.series_dirty = 0
|
|
68
|
self.series_dirty = 0
|
|
69
|
self.series_path = "series"
|
|
69
|
self.series_path = "series"
|
|
70
|
self.status_path = "status"
|
|
70
|
self.status_path = "status"
|
|
71
|
self.guards_path = "guards"
|
|
71
|
self.guards_path = "guards"
|
|
72
|
self.active_guards = None
|
|
72
|
self.active_guards = None
|
|
73
|
self.guards_dirty = False
|
|
73
|
self.guards_dirty = False
|
|
74
|
self._diffopts = None
|
|
74
|
self._diffopts = None
|
|
75
|
|
|
75
|
|
|
76
|
if os.path.exists(self.join(self.series_path)):
|
|
76
|
if os.path.exists(self.join(self.series_path)):
|
|
77
|
self.full_series = self.opener(self.series_path).read().splitlines()
|
|
77
|
self.full_series = self.opener(self.series_path).read().splitlines()
|
|
78
|
self.parse_series()
|
|
78
|
self.parse_series()
|
|
79
|
|
|
79
|
|
|
80
|
if os.path.exists(self.join(self.status_path)):
|
|
80
|
if os.path.exists(self.join(self.status_path)):
|
|
81
|
lines = self.opener(self.status_path).read().splitlines()
|
|
81
|
lines = self.opener(self.status_path).read().splitlines()
|
|
82
|
self.applied = [statusentry(l) for l in lines]
|
|
82
|
self.applied = [statusentry(l) for l in lines]
|
|
83
|
|
|
83
|
|
|
84
|
def diffopts(self):
|
|
84
|
def diffopts(self):
|
|
85
|
if self._diffopts is None:
|
|
85
|
if self._diffopts is None:
|
|
86
|
self._diffopts = patch.diffopts(self.ui)
|
|
86
|
self._diffopts = patch.diffopts(self.ui)
|
|
87
|
return self._diffopts
|
|
87
|
return self._diffopts
|
|
88
|
|
|
88
|
|
|
89
|
def join(self, *p):
|
|
89
|
def join(self, *p):
|
|
90
|
return os.path.join(self.path, *p)
|
|
90
|
return os.path.join(self.path, *p)
|
|
91
|
|
|
91
|
|
|
92
|
def find_series(self, patch):
|
|
92
|
def find_series(self, patch):
|
|
93
|
pre = re.compile("(\s*)([^#]+)")
|
|
93
|
pre = re.compile("(\s*)([^#]+)")
|
|
94
|
index = 0
|
|
94
|
index = 0
|
|
95
|
for l in self.full_series:
|
|
95
|
for l in self.full_series:
|
|
96
|
m = pre.match(l)
|
|
96
|
m = pre.match(l)
|
|
97
|
if m:
|
|
97
|
if m:
|
|
98
|
s = m.group(2)
|
|
98
|
s = m.group(2)
|
|
99
|
s = s.rstrip()
|
|
99
|
s = s.rstrip()
|
|
100
|
if s == patch:
|
|
100
|
if s == patch:
|
|
101
|
return index
|
|
101
|
return index
|
|
102
|
index += 1
|
|
102
|
index += 1
|
|
103
|
return None
|
|
103
|
return None
|
|
104
|
|
|
104
|
|
|
105
|
guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
|
|
105
|
guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
|
|
106
|
|
|
106
|
|
|
107
|
def parse_series(self):
|
|
107
|
def parse_series(self):
|
|
108
|
self.series = []
|
|
108
|
self.series = []
|
|
109
|
self.series_guards = []
|
|
109
|
self.series_guards = []
|
|
110
|
for l in self.full_series:
|
|
110
|
for l in self.full_series:
|
|
111
|
h = l.find('#')
|
|
111
|
h = l.find('#')
|
|
112
|
if h == -1:
|
|
112
|
if h == -1:
|
|
113
|
patch = l
|
|
113
|
patch = l
|
|
114
|
comment = ''
|
|
114
|
comment = ''
|
|
115
|
elif h == 0:
|
|
115
|
elif h == 0:
|
|
116
|
continue
|
|
116
|
continue
|
|
117
|
else:
|
|
117
|
else:
|
|
118
|
patch = l[:h]
|
|
118
|
patch = l[:h]
|
|
119
|
comment = l[h:]
|
|
119
|
comment = l[h:]
|
|
120
|
patch = patch.strip()
|
|
120
|
patch = patch.strip()
|
|
121
|
if patch:
|
|
121
|
if patch:
|
|
122
|
if patch in self.series:
|
|
122
|
if patch in self.series:
|
|
123
|
raise util.Abort(_('%s appears more than once in %s') %
|
|
123
|
raise util.Abort(_('%s appears more than once in %s') %
|
|
124
|
(patch, self.join(self.series_path)))
|
|
124
|
(patch, self.join(self.series_path)))
|
|
125
|
self.series.append(patch)
|
|
125
|
self.series.append(patch)
|
|
126
|
self.series_guards.append(self.guard_re.findall(comment))
|
|
126
|
self.series_guards.append(self.guard_re.findall(comment))
|
|
127
|
|
|
127
|
|
|
128
|
def check_guard(self, guard):
|
|
128
|
def check_guard(self, guard):
|
|
129
|
if not guard:
|
|
129
|
if not guard:
|
|
130
|
return _('guard cannot be an empty string')
|
|
130
|
return _('guard cannot be an empty string')
|
|
131
|
bad_chars = '# \t\r\n\f'
|
|
131
|
bad_chars = '# \t\r\n\f'
|
|
132
|
first = guard[0]
|
|
132
|
first = guard[0]
|
|
133
|
for c in '-+':
|
|
133
|
for c in '-+':
|
|
134
|
if first == c:
|
|
134
|
if first == c:
|
|
135
|
return (_('guard %r starts with invalid character: %r') %
|
|
135
|
return (_('guard %r starts with invalid character: %r') %
|
|
136
|
(guard, c))
|
|
136
|
(guard, c))
|
|
137
|
for c in bad_chars:
|
|
137
|
for c in bad_chars:
|
|
138
|
if c in guard:
|
|
138
|
if c in guard:
|
|
139
|
return _('invalid character in guard %r: %r') % (guard, c)
|
|
139
|
return _('invalid character in guard %r: %r') % (guard, c)
|
|
140
|
|
|
140
|
|
|
141
|
def set_active(self, guards):
|
|
141
|
def set_active(self, guards):
|
|
142
|
for guard in guards:
|
|
142
|
for guard in guards:
|
|
143
|
bad = self.check_guard(guard)
|
|
143
|
bad = self.check_guard(guard)
|
|
144
|
if bad:
|
|
144
|
if bad:
|
|
145
|
raise util.Abort(bad)
|
|
145
|
raise util.Abort(bad)
|
|
146
|
guards = util.sort(util.unique(guards))
|
|
146
|
guards = util.sort(util.unique(guards))
|
|
147
|
self.ui.debug(_('active guards: %s\n') % ' '.join(guards))
|
|
147
|
self.ui.debug(_('active guards: %s\n') % ' '.join(guards))
|
|
148
|
self.active_guards = guards
|
|
148
|
self.active_guards = guards
|
|
149
|
self.guards_dirty = True
|
|
149
|
self.guards_dirty = True
|
|
150
|
|
|
150
|
|
|
151
|
def active(self):
|
|
151
|
def active(self):
|
|
152
|
if self.active_guards is None:
|
|
152
|
if self.active_guards is None:
|
|
153
|
self.active_guards = []
|
|
153
|
self.active_guards = []
|
|
154
|
try:
|
|
154
|
try:
|
|
155
|
guards = self.opener(self.guards_path).read().split()
|
|
155
|
guards = self.opener(self.guards_path).read().split()
|
|
156
|
except IOError, err:
|
|
156
|
except IOError, err:
|
|
157
|
if err.errno != errno.ENOENT: raise
|
|
157
|
if err.errno != errno.ENOENT: raise
|
|
158
|
guards = []
|
|
158
|
guards = []
|
|
159
|
for i, guard in enumerate(guards):
|
|
159
|
for i, guard in enumerate(guards):
|
|
160
|
bad = self.check_guard(guard)
|
|
160
|
bad = self.check_guard(guard)
|
|
161
|
if bad:
|
|
161
|
if bad:
|
|
162
|
self.ui.warn('%s:%d: %s\n' %
|
|
162
|
self.ui.warn('%s:%d: %s\n' %
|
|
163
|
(self.join(self.guards_path), i + 1, bad))
|
|
163
|
(self.join(self.guards_path), i + 1, bad))
|
|
164
|
else:
|
|
164
|
else:
|
|
165
|
self.active_guards.append(guard)
|
|
165
|
self.active_guards.append(guard)
|
|
166
|
return self.active_guards
|
|
166
|
return self.active_guards
|
|
167
|
|
|
167
|
|
|
168
|
def set_guards(self, idx, guards):
|
|
168
|
def set_guards(self, idx, guards):
|
|
169
|
for g in guards:
|
|
169
|
for g in guards:
|
|
170
|
if len(g) < 2:
|
|
170
|
if len(g) < 2:
|
|
171
|
raise util.Abort(_('guard %r too short') % g)
|
|
171
|
raise util.Abort(_('guard %r too short') % g)
|
|
172
|
if g[0] not in '-+':
|
|
172
|
if g[0] not in '-+':
|
|
173
|
raise util.Abort(_('guard %r starts with invalid char') % g)
|
|
173
|
raise util.Abort(_('guard %r starts with invalid char') % g)
|
|
174
|
bad = self.check_guard(g[1:])
|
|
174
|
bad = self.check_guard(g[1:])
|
|
175
|
if bad:
|
|
175
|
if bad:
|
|
176
|
raise util.Abort(bad)
|
|
176
|
raise util.Abort(bad)
|
|
177
|
drop = self.guard_re.sub('', self.full_series[idx])
|
|
177
|
drop = self.guard_re.sub('', self.full_series[idx])
|
|
178
|
self.full_series[idx] = drop + ''.join([' #' + g for g in guards])
|
|
178
|
self.full_series[idx] = drop + ''.join([' #' + g for g in guards])
|
|
179
|
self.parse_series()
|
|
179
|
self.parse_series()
|
|
180
|
self.series_dirty = True
|
|
180
|
self.series_dirty = True
|
|
181
|
|
|
181
|
|
|
182
|
def pushable(self, idx):
|
|
182
|
def pushable(self, idx):
|
|
183
|
if isinstance(idx, str):
|
|
183
|
if isinstance(idx, str):
|
|
184
|
idx = self.series.index(idx)
|
|
184
|
idx = self.series.index(idx)
|
|
185
|
patchguards = self.series_guards[idx]
|
|
185
|
patchguards = self.series_guards[idx]
|
|
186
|
if not patchguards:
|
|
186
|
if not patchguards:
|
|
187
|
return True, None
|
|
187
|
return True, None
|
|
188
|
guards = self.active()
|
|
188
|
guards = self.active()
|
|
189
|
exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards]
|
|
189
|
exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards]
|
|
190
|
if exactneg:
|
|
190
|
if exactneg:
|
|
191
|
return False, exactneg[0]
|
|
191
|
return False, exactneg[0]
|
|
192
|
pos = [g for g in patchguards if g[0] == '+']
|
|
192
|
pos = [g for g in patchguards if g[0] == '+']
|
|
193
|
exactpos = [g for g in pos if g[1:] in guards]
|
|
193
|
exactpos = [g for g in pos if g[1:] in guards]
|
|
194
|
if pos:
|
|
194
|
if pos:
|
|
195
|
if exactpos:
|
|
195
|
if exactpos:
|
|
196
|
return True, exactpos[0]
|
|
196
|
return True, exactpos[0]
|
|
197
|
return False, pos
|
|
197
|
return False, pos
|
|
198
|
return True, ''
|
|
198
|
return True, ''
|
|
199
|
|
|
199
|
|
|
200
|
def explain_pushable(self, idx, all_patches=False):
|
|
200
|
def explain_pushable(self, idx, all_patches=False):
|
|
201
|
write = all_patches and self.ui.write or self.ui.warn
|
|
201
|
write = all_patches and self.ui.write or self.ui.warn
|
|
202
|
if all_patches or self.ui.verbose:
|
|
202
|
if all_patches or self.ui.verbose:
|
|
203
|
if isinstance(idx, str):
|
|
203
|
if isinstance(idx, str):
|
|
204
|
idx = self.series.index(idx)
|
|
204
|
idx = self.series.index(idx)
|
|
205
|
pushable, why = self.pushable(idx)
|
|
205
|
pushable, why = self.pushable(idx)
|
|
206
|
if all_patches and pushable:
|
|
206
|
if all_patches and pushable:
|
|
207
|
if why is None:
|
|
207
|
if why is None:
|
|
208
|
write(_('allowing %s - no guards in effect\n') %
|
|
208
|
write(_('allowing %s - no guards in effect\n') %
|
|
209
|
self.series[idx])
|
|
209
|
self.series[idx])
|
|
210
|
else:
|
|
210
|
else:
|
|
211
|
if not why:
|
|
211
|
if not why:
|
|
212
|
write(_('allowing %s - no matching negative guards\n') %
|
|
212
|
write(_('allowing %s - no matching negative guards\n') %
|
|
213
|
self.series[idx])
|
|
213
|
self.series[idx])
|
|
214
|
else:
|
|
214
|
else:
|
|
215
|
write(_('allowing %s - guarded by %r\n') %
|
|
215
|
write(_('allowing %s - guarded by %r\n') %
|
|
216
|
(self.series[idx], why))
|
|
216
|
(self.series[idx], why))
|
|
217
|
if not pushable:
|
|
217
|
if not pushable:
|
|
218
|
if why:
|
|
218
|
if why:
|
|
219
|
write(_('skipping %s - guarded by %r\n') %
|
|
219
|
write(_('skipping %s - guarded by %r\n') %
|
|
220
|
(self.series[idx], why))
|
|
220
|
(self.series[idx], why))
|
|
221
|
else:
|
|
221
|
else:
|
|
222
|
write(_('skipping %s - no matching guards\n') %
|
|
222
|
write(_('skipping %s - no matching guards\n') %
|
|
223
|
self.series[idx])
|
|
223
|
self.series[idx])
|
|
224
|
|
|
224
|
|
|
225
|
def save_dirty(self):
|
|
225
|
def save_dirty(self):
|
|
226
|
def write_list(items, path):
|
|
226
|
def write_list(items, path):
|
|
227
|
fp = self.opener(path, 'w')
|
|
227
|
fp = self.opener(path, 'w')
|
|
228
|
for i in items:
|
|
228
|
for i in items:
|
|
229
|
fp.write("%s\n" % i)
|
|
229
|
fp.write("%s\n" % i)
|
|
230
|
fp.close()
|
|
230
|
fp.close()
|
|
231
|
if self.applied_dirty: write_list(map(str, self.applied), self.status_path)
|
|
231
|
if self.applied_dirty: write_list(map(str, self.applied), self.status_path)
|
|
232
|
if self.series_dirty: write_list(self.full_series, self.series_path)
|
|
232
|
if self.series_dirty: write_list(self.full_series, self.series_path)
|
|
233
|
if self.guards_dirty: write_list(self.active_guards, self.guards_path)
|
|
233
|
if self.guards_dirty: write_list(self.active_guards, self.guards_path)
|
|
234
|
|
|
234
|
|
|
235
|
def readheaders(self, patch):
|
|
235
|
def readheaders(self, patch):
|
|
236
|
def eatdiff(lines):
|
|
236
|
def eatdiff(lines):
|
|
237
|
while lines:
|
|
237
|
while lines:
|
|
238
|
l = lines[-1]
|
|
238
|
l = lines[-1]
|
|
239
|
if (l.startswith("diff -") or
|
|
239
|
if (l.startswith("diff -") or
|
|
240
|
l.startswith("Index:") or
|
|
240
|
l.startswith("Index:") or
|
|
241
|
l.startswith("===========")):
|
|
241
|
l.startswith("===========")):
|
|
242
|
del lines[-1]
|
|
242
|
del lines[-1]
|
|
243
|
else:
|
|
243
|
else:
|
|
244
|
break
|
|
244
|
break
|
|
245
|
def eatempty(lines):
|
|
245
|
def eatempty(lines):
|
|
246
|
while lines:
|
|
246
|
while lines:
|
|
247
|
l = lines[-1]
|
|
247
|
l = lines[-1]
|
|
248
|
if re.match('\s*$', l):
|
|
248
|
if re.match('\s*$', l):
|
|
249
|
del lines[-1]
|
|
249
|
del lines[-1]
|
|
250
|
else:
|
|
250
|
else:
|
|
251
|
break
|
|
251
|
break
|
|
252
|
|
|
252
|
|
|
253
|
pf = self.join(patch)
|
|
253
|
pf = self.join(patch)
|
|
254
|
message = []
|
|
254
|
message = []
|
|
255
|
comments = []
|
|
255
|
comments = []
|
|
256
|
user = None
|
|
256
|
user = None
|
|
257
|
date = None
|
|
257
|
date = None
|
|
258
|
format = None
|
|
258
|
format = None
|
|
259
|
subject = None
|
|
259
|
subject = None
|
|
260
|
diffstart = 0
|
|
260
|
diffstart = 0
|
|
261
|
|
|
261
|
|
|
262
|
for line in file(pf):
|
|
262
|
for line in file(pf):
|
|
263
|
line = line.rstrip()
|
|
263
|
line = line.rstrip()
|
|
264
|
if line.startswith('diff --git'):
|
|
264
|
if line.startswith('diff --git'):
|
|
265
|
diffstart = 2
|
|
265
|
diffstart = 2
|
|
266
|
break
|
|
266
|
break
|
|
267
|
if diffstart:
|
|
267
|
if diffstart:
|
|
268
|
if line.startswith('+++ '):
|
|
268
|
if line.startswith('+++ '):
|
|
269
|
diffstart = 2
|
|
269
|
diffstart = 2
|
|
270
|
break
|
|
270
|
break
|
|
271
|
if line.startswith("--- "):
|
|
271
|
if line.startswith("--- "):
|
|
272
|
diffstart = 1
|
|
272
|
diffstart = 1
|
|
273
|
continue
|
|
273
|
continue
|
|
274
|
elif format == "hgpatch":
|
|
274
|
elif format == "hgpatch":
|
|
275
|
# parse values when importing the result of an hg export
|
|
275
|
# parse values when importing the result of an hg export
|
|
276
|
if line.startswith("# User "):
|
|
276
|
if line.startswith("# User "):
|
|
277
|
user = line[7:]
|
|
277
|
user = line[7:]
|
|
278
|
elif line.startswith("# Date "):
|
|
278
|
elif line.startswith("# Date "):
|
|
279
|
date = line[7:]
|
|
279
|
date = line[7:]
|
|
280
|
elif not line.startswith("# ") and line:
|
|
280
|
elif not line.startswith("# ") and line:
|
|
281
|
message.append(line)
|
|
281
|
message.append(line)
|
|
282
|
format = None
|
|
282
|
format = None
|
|
283
|
elif line == '# HG changeset patch':
|
|
283
|
elif line == '# HG changeset patch':
|
|
284
|
format = "hgpatch"
|
|
284
|
format = "hgpatch"
|
|
285
|
elif (format != "tagdone" and (line.startswith("Subject: ") or
|
|
285
|
elif (format != "tagdone" and (line.startswith("Subject: ") or
|
|
286
|
line.startswith("subject: "))):
|
|
286
|
line.startswith("subject: "))):
|
|
287
|
subject = line[9:]
|
|
287
|
subject = line[9:]
|
|
288
|
format = "tag"
|
|
288
|
format = "tag"
|
|
289
|
elif (format != "tagdone" and (line.startswith("From: ") or
|
|
289
|
elif (format != "tagdone" and (line.startswith("From: ") or
|
|
290
|
line.startswith("from: "))):
|
|
290
|
line.startswith("from: "))):
|
|
291
|
user = line[6:]
|
|
291
|
user = line[6:]
|
|
292
|
format = "tag"
|
|
292
|
format = "tag"
|
|
293
|
elif format == "tag" and line == "":
|
|
293
|
elif format == "tag" and line == "":
|
|
294
|
# when looking for tags (subject: from: etc) they
|
|
294
|
# when looking for tags (subject: from: etc) they
|
|
295
|
# end once you find a blank line in the source
|
|
295
|
# end once you find a blank line in the source
|
|
296
|
format = "tagdone"
|
|
296
|
format = "tagdone"
|
|
297
|
elif message or line:
|
|
297
|
elif message or line:
|
|
298
|
message.append(line)
|
|
298
|
message.append(line)
|
|
299
|
comments.append(line)
|
|
299
|
comments.append(line)
|
|
300
|
|
|
300
|
|
|
301
|
eatdiff(message)
|
|
301
|
eatdiff(message)
|
|
302
|
eatdiff(comments)
|
|
302
|
eatdiff(comments)
|
|
303
|
eatempty(message)
|
|
303
|
eatempty(message)
|
|
304
|
eatempty(comments)
|
|
304
|
eatempty(comments)
|
|
305
|
|
|
305
|
|
|
306
|
# make sure message isn't empty
|
|
306
|
# make sure message isn't empty
|
|
307
|
if format and format.startswith("tag") and subject:
|
|
307
|
if format and format.startswith("tag") and subject:
|
|
308
|
message.insert(0, "")
|
|
308
|
message.insert(0, "")
|
|
309
|
message.insert(0, subject)
|
|
309
|
message.insert(0, subject)
|
|
310
|
return (message, comments, user, date, diffstart > 1)
|
|
310
|
return (message, comments, user, date, diffstart > 1)
|
|
311
|
|
|
311
|
|
|
312
|
def removeundo(self, repo):
|
|
312
|
def removeundo(self, repo):
|
|
313
|
undo = repo.sjoin('undo')
|
|
313
|
undo = repo.sjoin('undo')
|
|
314
|
if not os.path.exists(undo):
|
|
314
|
if not os.path.exists(undo):
|
|
315
|
return
|
|
315
|
return
|
|
316
|
try:
|
|
316
|
try:
|
|
317
|
os.unlink(undo)
|
|
317
|
os.unlink(undo)
|
|
318
|
except OSError, inst:
|
|
318
|
except OSError, inst:
|
|
319
|
self.ui.warn(_('error removing undo: %s\n') % str(inst))
|
|
319
|
self.ui.warn(_('error removing undo: %s\n') % str(inst))
|
|
320
|
|
|
320
|
|
|
321
|
def printdiff(self, repo, node1, node2=None, files=None,
|
|
321
|
def printdiff(self, repo, node1, node2=None, files=None,
|
|
322
|
fp=None, changes=None, opts={}):
|
|
322
|
fp=None, changes=None, opts={}):
|
|
323
|
m = cmdutil.match(repo, files, opts)
|
|
323
|
m = cmdutil.match(repo, files, opts)
|
|
324
|
chunks = patch.diff(repo, node1, node2, m, changes, self.diffopts())
|
|
324
|
chunks = patch.diff(repo, node1, node2, m, changes, self.diffopts())
|
|
325
|
write = fp is None and repo.ui.write or fp.write
|
|
325
|
write = fp is None and repo.ui.write or fp.write
|
|
326
|
for chunk in chunks:
|
|
326
|
for chunk in chunks:
|
|
327
|
write(chunk)
|
|
327
|
write(chunk)
|
|
328
|
|
|
328
|
|
|
329
|
def mergeone(self, repo, mergeq, head, patch, rev):
|
|
329
|
def mergeone(self, repo, mergeq, head, patch, rev):
|
|
330
|
# first try just applying the patch
|
|
330
|
# first try just applying the patch
|
|
331
|
(err, n) = self.apply(repo, [ patch ], update_status=False,
|
|
331
|
(err, n) = self.apply(repo, [ patch ], update_status=False,
|
|
332
|
strict=True, merge=rev)
|
|
332
|
strict=True, merge=rev)
|
|
333
|
|
|
333
|
|
|
334
|
if err == 0:
|
|
334
|
if err == 0:
|
|
335
|
return (err, n)
|
|
335
|
return (err, n)
|
|
336
|
|
|
336
|
|
|
337
|
if n is None:
|
|
337
|
if n is None:
|
|
338
|
raise util.Abort(_("apply failed for patch %s") % patch)
|
|
338
|
raise util.Abort(_("apply failed for patch %s") % patch)
|
|
339
|
|
|
339
|
|
|
340
|
self.ui.warn(_("patch didn't work out, merging %s\n") % patch)
|
|
340
|
self.ui.warn(_("patch didn't work out, merging %s\n") % patch)
|
|
341
|
|
|
341
|
|
|
342
|
# apply failed, strip away that rev and merge.
|
|
342
|
# apply failed, strip away that rev and merge.
|
|
343
|
hg.clean(repo, head)
|
|
343
|
hg.clean(repo, head)
|
|
344
|
self.strip(repo, n, update=False, backup='strip')
|
|
344
|
self.strip(repo, n, update=False, backup='strip')
|
|
345
|
|
|
345
|
|
|
346
|
ctx = repo[rev]
|
|
346
|
ctx = repo[rev]
|
|
347
|
ret = hg.merge(repo, rev)
|
|
347
|
ret = hg.merge(repo, rev)
|
|
348
|
if ret:
|
|
348
|
if ret:
|
|
349
|
raise util.Abort(_("update returned %d") % ret)
|
|
349
|
raise util.Abort(_("update returned %d") % ret)
|
|
350
|
n = repo.commit(None, ctx.description(), ctx.user(), force=1)
|
|
350
|
n = repo.commit(None, ctx.description(), ctx.user(), force=1)
|
|
351
|
if n == None:
|
|
351
|
if n == None:
|
|
352
|
raise util.Abort(_("repo commit failed"))
|
|
352
|
raise util.Abort(_("repo commit failed"))
|
|
353
|
try:
|
|
353
|
try:
|
|
354
|
message, comments, user, date, patchfound = mergeq.readheaders(patch)
|
|
354
|
message, comments, user, date, patchfound = mergeq.readheaders(patch)
|
|
355
|
except:
|
|
355
|
except:
|
|
356
|
raise util.Abort(_("unable to read %s") % patch)
|
|
356
|
raise util.Abort(_("unable to read %s") % patch)
|
|
357
|
|
|
357
|
|
|
358
|
patchf = self.opener(patch, "w")
|
|
358
|
patchf = self.opener(patch, "w")
|
|
359
|
if comments:
|
|
359
|
if comments:
|
|
360
|
comments = "\n".join(comments) + '\n\n'
|
|
360
|
comments = "\n".join(comments) + '\n\n'
|
|
361
|
patchf.write(comments)
|
|
361
|
patchf.write(comments)
|
|
362
|
self.printdiff(repo, head, n, fp=patchf)
|
|
362
|
self.printdiff(repo, head, n, fp=patchf)
|
|
363
|
patchf.close()
|
|
363
|
patchf.close()
|
|
364
|
self.removeundo(repo)
|
|
364
|
self.removeundo(repo)
|
|
365
|
return (0, n)
|
|
365
|
return (0, n)
|
|
366
|
|
|
366
|
|
|
367
|
def qparents(self, repo, rev=None):
|
|
367
|
def qparents(self, repo, rev=None):
|
|
368
|
if rev is None:
|
|
368
|
if rev is None:
|
|
369
|
(p1, p2) = repo.dirstate.parents()
|
|
369
|
(p1, p2) = repo.dirstate.parents()
|
|
370
|
if p2 == revlog.nullid:
|
|
370
|
if p2 == revlog.nullid:
|
|
371
|
return p1
|
|
371
|
return p1
|
|
372
|
if len(self.applied) == 0:
|
|
372
|
if len(self.applied) == 0:
|
|
373
|
return None
|
|
373
|
return None
|
|
374
|
return revlog.bin(self.applied[-1].rev)
|
|
374
|
return revlog.bin(self.applied[-1].rev)
|
|
375
|
pp = repo.changelog.parents(rev)
|
|
375
|
pp = repo.changelog.parents(rev)
|
|
376
|
if pp[1] != revlog.nullid:
|
|
376
|
if pp[1] != revlog.nullid:
|
|
377
|
arevs = [ x.rev for x in self.applied ]
|
|
377
|
arevs = [ x.rev for x in self.applied ]
|
|
378
|
p0 = revlog.hex(pp[0])
|
|
378
|
p0 = revlog.hex(pp[0])
|
|
379
|
p1 = revlog.hex(pp[1])
|
|
379
|
p1 = revlog.hex(pp[1])
|
|
380
|
if p0 in arevs:
|
|
380
|
if p0 in arevs:
|
|
381
|
return pp[0]
|
|
381
|
return pp[0]
|
|
382
|
if p1 in arevs:
|
|
382
|
if p1 in arevs:
|
|
383
|
return pp[1]
|
|
383
|
return pp[1]
|
|
384
|
return pp[0]
|
|
384
|
return pp[0]
|
|
385
|
|
|
385
|
|
|
386
|
def mergepatch(self, repo, mergeq, series):
|
|
386
|
def mergepatch(self, repo, mergeq, series):
|
|
387
|
if len(self.applied) == 0:
|
|
387
|
if len(self.applied) == 0:
|
|
388
|
# each of the patches merged in will have two parents. This
|
|
388
|
# each of the patches merged in will have two parents. This
|
|
389
|
# can confuse the qrefresh, qdiff, and strip code because it
|
|
389
|
# can confuse the qrefresh, qdiff, and strip code because it
|
|
390
|
# needs to know which parent is actually in the patch queue.
|
|
390
|
# needs to know which parent is actually in the patch queue.
|
|
391
|
# so, we insert a merge marker with only one parent. This way
|
|
391
|
# so, we insert a merge marker with only one parent. This way
|
|
392
|
# the first patch in the queue is never a merge patch
|
|
392
|
# the first patch in the queue is never a merge patch
|
|
393
|
#
|
|
393
|
#
|
|
394
|
pname = ".hg.patches.merge.marker"
|
|
394
|
pname = ".hg.patches.merge.marker"
|
|
395
|
n = repo.commit(None, '[mq]: merge marker', user=None, force=1)
|
|
395
|
n = repo.commit(None, '[mq]: merge marker', user=None, force=1)
|
|
396
|
self.removeundo(repo)
|
|
396
|
self.removeundo(repo)
|
|
397
|
self.applied.append(statusentry(revlog.hex(n), pname))
|
|
397
|
self.applied.append(statusentry(revlog.hex(n), pname))
|
|
398
|
self.applied_dirty = 1
|
|
398
|
self.applied_dirty = 1
|
|
399
|
|
|
399
|
|
|
400
|
head = self.qparents(repo)
|
|
400
|
head = self.qparents(repo)
|
|
401
|
|
|
401
|
|
|
402
|
for patch in series:
|
|
402
|
for patch in series:
|
|
403
|
patch = mergeq.lookup(patch, strict=True)
|
|
403
|
patch = mergeq.lookup(patch, strict=True)
|
|
404
|
if not patch:
|
|
404
|
if not patch:
|
|
405
|
self.ui.warn(_("patch %s does not exist\n") % patch)
|
|
405
|
self.ui.warn(_("patch %s does not exist\n") % patch)
|
|
406
|
return (1, None)
|
|
406
|
return (1, None)
|
|
407
|
pushable, reason = self.pushable(patch)
|
|
407
|
pushable, reason = self.pushable(patch)
|
|
408
|
if not pushable:
|
|
408
|
if not pushable:
|
|
409
|
self.explain_pushable(patch, all_patches=True)
|
|
409
|
self.explain_pushable(patch, all_patches=True)
|
|
410
|
continue
|
|
410
|
continue
|
|
411
|
info = mergeq.isapplied(patch)
|
|
411
|
info = mergeq.isapplied(patch)
|
|
412
|
if not info:
|
|
412
|
if not info:
|
|
413
|
self.ui.warn(_("patch %s is not applied\n") % patch)
|
|
413
|
self.ui.warn(_("patch %s is not applied\n") % patch)
|
|
414
|
return (1, None)
|
|
414
|
return (1, None)
|
|
415
|
rev = revlog.bin(info[1])
|
|
415
|
rev = revlog.bin(info[1])
|
|
416
|
(err, head) = self.mergeone(repo, mergeq, head, patch, rev)
|
|
416
|
(err, head) = self.mergeone(repo, mergeq, head, patch, rev)
|
|
417
|
if head:
|
|
417
|
if head:
|
|
418
|
self.applied.append(statusentry(revlog.hex(head), patch))
|
|
418
|
self.applied.append(statusentry(revlog.hex(head), patch))
|
|
419
|
self.applied_dirty = 1
|
|
419
|
self.applied_dirty = 1
|
|
420
|
if err:
|
|
420
|
if err:
|
|
421
|
return (err, head)
|
|
421
|
return (err, head)
|
|
422
|
self.save_dirty()
|
|
422
|
self.save_dirty()
|
|
423
|
return (0, head)
|
|
423
|
return (0, head)
|
|
424
|
|
|
424
|
|
|
425
|
def patch(self, repo, patchfile):
|
|
425
|
def patch(self, repo, patchfile):
|
|
426
|
'''Apply patchfile to the working directory.
|
|
426
|
'''Apply patchfile to the working directory.
|
|
427
|
patchfile: file name of patch'''
|
|
427
|
patchfile: file name of patch'''
|
|
428
|
files = {}
|
|
428
|
files = {}
|
|
429
|
try:
|
|
429
|
try:
|
|
430
|
fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root,
|
|
430
|
fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root,
|
|
431
|
files=files)
|
|
431
|
files=files)
|
|
432
|
except Exception, inst:
|
|
432
|
except Exception, inst:
|
|
433
|
self.ui.note(str(inst) + '\n')
|
|
433
|
self.ui.note(str(inst) + '\n')
|
|
434
|
if not self.ui.verbose:
|
|
434
|
if not self.ui.verbose:
|
|
435
|
self.ui.warn(_("patch failed, unable to continue (try -v)\n"))
|
|
435
|
self.ui.warn(_("patch failed, unable to continue (try -v)\n"))
|
|
436
|
return (False, files, False)
|
|
436
|
return (False, files, False)
|
|
437
|
|
|
437
|
|
|
438
|
return (True, files, fuzz)
|
|
438
|
return (True, files, fuzz)
|
|
439
|
|
|
439
|
|
|
440
|
def apply(self, repo, series, list=False, update_status=True,
|
|
440
|
def apply(self, repo, series, list=False, update_status=True,
|
|
441
|
strict=False, patchdir=None, merge=None, all_files={}):
|
|
441
|
strict=False, patchdir=None, merge=None, all_files={}):
|
|
442
|
wlock = lock = tr = None
|
|
442
|
wlock = lock = tr = None
|
|
443
|
try:
|
|
443
|
try:
|
|
444
|
wlock = repo.wlock()
|
|
444
|
wlock = repo.wlock()
|
|
445
|
lock = repo.lock()
|
|
445
|
lock = repo.lock()
|
|
446
|
tr = repo.transaction()
|
|
446
|
tr = repo.transaction()
|
|
447
|
try:
|
|
447
|
try:
|
|
448
|
ret = self._apply(repo, series, list, update_status,
|
|
448
|
ret = self._apply(repo, series, list, update_status,
|
|
449
|
strict, patchdir, merge, all_files=all_files)
|
|
449
|
strict, patchdir, merge, all_files=all_files)
|
|
450
|
tr.close()
|
|
450
|
tr.close()
|
|
451
|
self.save_dirty()
|
|
451
|
self.save_dirty()
|
|
452
|
return ret
|
|
452
|
return ret
|
|
453
|
except:
|
|
453
|
except:
|
|
454
|
try:
|
|
454
|
try:
|
|
455
|
tr.abort()
|
|
455
|
tr.abort()
|
|
456
|
finally:
|
|
456
|
finally:
|
|
457
|
repo.invalidate()
|
|
457
|
repo.invalidate()
|
|
458
|
repo.dirstate.invalidate()
|
|
458
|
repo.dirstate.invalidate()
|
|
459
|
raise
|
|
459
|
raise
|
|
460
|
finally:
|
|
460
|
finally:
|
|
461
|
del tr, lock, wlock
|
|
461
|
del tr, lock, wlock
|
|
462
|
self.removeundo(repo)
|
|
462
|
self.removeundo(repo)
|
|
463
|
|
|
463
|
|
|
464
|
def _apply(self, repo, series, list=False, update_status=True,
|
|
464
|
def _apply(self, repo, series, list=False, update_status=True,
|
|
465
|
strict=False, patchdir=None, merge=None, all_files={}):
|
|
465
|
strict=False, patchdir=None, merge=None, all_files={}):
|
|
466
|
# TODO unify with commands.py
|
|
466
|
# TODO unify with commands.py
|
|
467
|
if not patchdir:
|
|
467
|
if not patchdir:
|
|
468
|
patchdir = self.path
|
|
468
|
patchdir = self.path
|
|
469
|
err = 0
|
|
469
|
err = 0
|
|
470
|
n = None
|
|
470
|
n = None
|
|
471
|
for patchname in series:
|
|
471
|
for patchname in series:
|
|
472
|
pushable, reason = self.pushable(patchname)
|
|
472
|
pushable, reason = self.pushable(patchname)
|
|
473
|
if not pushable:
|
|
473
|
if not pushable:
|
|
474
|
self.explain_pushable(patchname, all_patches=True)
|
|
474
|
self.explain_pushable(patchname, all_patches=True)
|
|
475
|
continue
|
|
475
|
continue
|
|
476
|
self.ui.warn(_("applying %s\n") % patchname)
|
|
476
|
self.ui.warn(_("applying %s\n") % patchname)
|
|
477
|
pf = os.path.join(patchdir, patchname)
|
|
477
|
pf = os.path.join(patchdir, patchname)
|
|
478
|
|
|
478
|
|
|
479
|
try:
|
|
479
|
try:
|
|
480
|
message, comments, user, date, patchfound = self.readheaders(patchname)
|
|
480
|
message, comments, user, date, patchfound = self.readheaders(patchname)
|
|
481
|
except:
|
|
481
|
except:
|
|
482
|
self.ui.warn(_("Unable to read %s\n") % patchname)
|
|
482
|
self.ui.warn(_("Unable to read %s\n") % patchname)
|
|
483
|
err = 1
|
|
483
|
err = 1
|
|
484
|
break
|
|
484
|
break
|
|
485
|
|
|
485
|
|
|
486
|
if not message:
|
|
486
|
if not message:
|
|
487
|
message = _("imported patch %s\n") % patchname
|
|
487
|
message = _("imported patch %s\n") % patchname
|
|
488
|
else:
|
|
488
|
else:
|
|
489
|
if list:
|
|
489
|
if list:
|
|
490
|
message.append(_("\nimported patch %s") % patchname)
|
|
490
|
message.append(_("\nimported patch %s") % patchname)
|
|
491
|
message = '\n'.join(message)
|
|
491
|
message = '\n'.join(message)
|
|
492
|
|
|
492
|
|
|
493
|
(patcherr, files, fuzz) = self.patch(repo, pf)
|
|
493
|
(patcherr, files, fuzz) = self.patch(repo, pf)
|
|
494
|
all_files.update(files)
|
|
494
|
all_files.update(files)
|
|
495
|
patcherr = not patcherr
|
|
495
|
patcherr = not patcherr
|
|
496
|
|
|
496
|
|
|
497
|
if merge and files:
|
|
497
|
if merge and files:
|
|
498
|
# Mark as removed/merged and update dirstate parent info
|
|
498
|
# Mark as removed/merged and update dirstate parent info
|
|
499
|
removed = []
|
|
499
|
removed = []
|
|
500
|
merged = []
|
|
500
|
merged = []
|
|
501
|
for f in files:
|
|
501
|
for f in files:
|
|
502
|
if os.path.exists(repo.wjoin(f)):
|
|
502
|
if os.path.exists(repo.wjoin(f)):
|
|
503
|
merged.append(f)
|
|
503
|
merged.append(f)
|
|
504
|
else:
|
|
504
|
else:
|
|
505
|
removed.append(f)
|
|
505
|
removed.append(f)
|
|
506
|
for f in removed:
|
|
506
|
for f in removed:
|
|
507
|
repo.dirstate.remove(f)
|
|
507
|
repo.dirstate.remove(f)
|
|
508
|
for f in merged:
|
|
508
|
for f in merged:
|
|
509
|
repo.dirstate.merge(f)
|
|
509
|
repo.dirstate.merge(f)
|
|
510
|
p1, p2 = repo.dirstate.parents()
|
|
510
|
p1, p2 = repo.dirstate.parents()
|
|
511
|
repo.dirstate.setparents(p1, merge)
|
|
511
|
repo.dirstate.setparents(p1, merge)
|
|
512
|
|
|
512
|
|
|
513
|
files = patch.updatedir(self.ui, repo, files)
|
|
513
|
files = patch.updatedir(self.ui, repo, files)
|
|
514
|
match = cmdutil.matchfiles(repo, files or [])
|
|
514
|
match = cmdutil.matchfiles(repo, files or [])
|
|
515
|
n = repo.commit(files, message, user, date, match=match,
|
|
515
|
n = repo.commit(files, message, user, date, match=match,
|
|
516
|
force=True)
|
|
516
|
force=True)
|
|
517
|
|
|
517
|
|
|
518
|
if n == None:
|
|
518
|
if n == None:
|
|
519
|
raise util.Abort(_("repo commit failed"))
|
|
519
|
raise util.Abort(_("repo commit failed"))
|
|
520
|
|
|
520
|
|
|
521
|
if update_status:
|
|
521
|
if update_status:
|
|
522
|
self.applied.append(statusentry(revlog.hex(n), patchname))
|
|
522
|
self.applied.append(statusentry(revlog.hex(n), patchname))
|
|
523
|
|
|
523
|
|
|
524
|
if patcherr:
|
|
524
|
if patcherr:
|
|
525
|
if not patchfound:
|
|
525
|
if not patchfound:
|
|
526
|
self.ui.warn(_("patch %s is empty\n") % patchname)
|
|
526
|
self.ui.warn(_("patch %s is empty\n") % patchname)
|
|
527
|
err = 0
|
|
527
|
err = 0
|
|
528
|
else:
|
|
528
|
else:
|
|
529
|
self.ui.warn(_("patch failed, rejects left in working dir\n"))
|
|
529
|
self.ui.warn(_("patch failed, rejects left in working dir\n"))
|
|
530
|
err = 1
|
|
530
|
err = 1
|
|
531
|
break
|
|
531
|
break
|
|
532
|
|
|
532
|
|
|
533
|
if fuzz and strict:
|
|
533
|
if fuzz and strict:
|
|
534
|
self.ui.warn(_("fuzz found when applying patch, stopping\n"))
|
|
534
|
self.ui.warn(_("fuzz found when applying patch, stopping\n"))
|
|
535
|
err = 1
|
|
535
|
err = 1
|
|
536
|
break
|
|
536
|
break
|
|
537
|
return (err, n)
|
|
537
|
return (err, n)
|
|
538
|
|
|
538
|
|
|
539
|
def _clean_series(self, patches):
|
|
539
|
def _clean_series(self, patches):
|
|
540
|
indices = util.sort([self.find_series(p) for p in patches])
|
|
540
|
indices = util.sort([self.find_series(p) for p in patches])
|
|
541
|
for i in indices[-1::-1]:
|
|
541
|
for i in indices[-1::-1]:
|
|
542
|
del self.full_series[i]
|
|
542
|
del self.full_series[i]
|
|
543
|
self.parse_series()
|
|
543
|
self.parse_series()
|
|
544
|
self.series_dirty = 1
|
|
544
|
self.series_dirty = 1
|
|
545
|
|
|
545
|
|
|
546
|
def finish(self, repo, revs):
|
|
546
|
def finish(self, repo, revs):
|
|
547
|
revs.sort()
|
|
547
|
revs.sort()
|
|
548
|
firstrev = repo[self.applied[0].rev].rev()
|
|
548
|
firstrev = repo[self.applied[0].rev].rev()
|
|
549
|
appliedbase = 0
|
|
549
|
appliedbase = 0
|
|
550
|
patches = []
|
|
550
|
patches = []
|
|
551
|
for rev in util.sort(revs):
|
|
551
|
for rev in util.sort(revs):
|
|
552
|
if rev < firstrev:
|
|
552
|
if rev < firstrev:
|
|
553
|
raise util.Abort(_('revision %d is not managed') % rev)
|
|
553
|
raise util.Abort(_('revision %d is not managed') % rev)
|
|
554
|
base = revlog.bin(self.applied[appliedbase].rev)
|
|
554
|
base = revlog.bin(self.applied[appliedbase].rev)
|
|
555
|
node = repo.changelog.node(rev)
|
|
555
|
node = repo.changelog.node(rev)
|
|
556
|
if node != base:
|
|
556
|
if node != base:
|
|
557
|
raise util.Abort(_('cannot delete revision %d above '
|
|
557
|
raise util.Abort(_('cannot delete revision %d above '
|
|
558
|
'applied patches') % rev)
|
|
558
|
'applied patches') % rev)
|
|
559
|
patches.append(self.applied[appliedbase].name)
|
|
559
|
patches.append(self.applied[appliedbase].name)
|
|
560
|
appliedbase += 1
|
|
560
|
appliedbase += 1
|
|
561
|
|
|
561
|
|
|
562
|
r = self.qrepo()
|
|
562
|
r = self.qrepo()
|
|
563
|
if r:
|
|
563
|
if r:
|
|
564
|
r.remove(patches, True)
|
|
564
|
r.remove(patches, True)
|
|
565
|
else:
|
|
565
|
else:
|
|
566
|
for p in patches:
|
|
566
|
for p in patches:
|
|
567
|
os.unlink(self.join(p))
|
|
567
|
os.unlink(self.join(p))
|
|
568
|
|
|
568
|
|
|
569
|
del self.applied[:appliedbase]
|
|
569
|
del self.applied[:appliedbase]
|
|
570
|
self.applied_dirty = 1
|
|
570
|
self.applied_dirty = 1
|
|
571
|
self._clean_series(patches)
|
|
571
|
self._clean_series(patches)
|
|
572
|
|
|
572
|
|
|
573
|
def delete(self, repo, patches, opts):
|
|
573
|
def delete(self, repo, patches, opts):
|
|
574
|
if not patches and not opts.get('rev'):
|
|
574
|
if not patches and not opts.get('rev'):
|
|
575
|
raise util.Abort(_('qdelete requires at least one revision or '
|
|
575
|
raise util.Abort(_('qdelete requires at least one revision or '
|
|
576
|
'patch name'))
|
|
576
|
'patch name'))
|
|
577
|
|
|
577
|
|
|
578
|
realpatches = []
|
|
578
|
realpatches = []
|
|
579
|
for patch in patches:
|
|
579
|
for patch in patches:
|
|
580
|
patch = self.lookup(patch, strict=True)
|
|
580
|
patch = self.lookup(patch, strict=True)
|
|
581
|
info = self.isapplied(patch)
|
|
581
|
info = self.isapplied(patch)
|
|
582
|
if info:
|
|
582
|
if info:
|
|
583
|
raise util.Abort(_("cannot delete applied patch %s") % patch)
|
|
583
|
raise util.Abort(_("cannot delete applied patch %s") % patch)
|
|
584
|
if patch not in self.series:
|
|
584
|
if patch not in self.series:
|
|
585
|
raise util.Abort(_("patch %s not in series file") % patch)
|
|
585
|
raise util.Abort(_("patch %s not in series file") % patch)
|
|
586
|
realpatches.append(patch)
|
|
586
|
realpatches.append(patch)
|
|
587
|
|
|
587
|
|
|
588
|
appliedbase = 0
|
|
588
|
appliedbase = 0
|
|
589
|
if opts.get('rev'):
|
|
589
|
if opts.get('rev'):
|
|
590
|
if not self.applied:
|
|
590
|
if not self.applied:
|
|
591
|
raise util.Abort(_('no patches applied'))
|
|
591
|
raise util.Abort(_('no patches applied'))
|
|
592
|
revs = cmdutil.revrange(repo, opts['rev'])
|
|
592
|
revs = cmdutil.revrange(repo, opts['rev'])
|
|
593
|
if len(revs) > 1 and revs[0] > revs[1]:
|
|
593
|
if len(revs) > 1 and revs[0] > revs[1]:
|
|
594
|
revs.reverse()
|
|
594
|
revs.reverse()
|
|
595
|
for rev in revs:
|
|
595
|
for rev in revs:
|
|
596
|
if appliedbase >= len(self.applied):
|
|
596
|
if appliedbase >= len(self.applied):
|
|
597
|
raise util.Abort(_("revision %d is not managed") % rev)
|
|
597
|
raise util.Abort(_("revision %d is not managed") % rev)
|
|
598
|
|
|
598
|
|
|
599
|
base = revlog.bin(self.applied[appliedbase].rev)
|
|
599
|
base = revlog.bin(self.applied[appliedbase].rev)
|
|
600
|
node = repo.changelog.node(rev)
|
|
600
|
node = repo.changelog.node(rev)
|
|
601
|
if node != base:
|
|
601
|
if node != base:
|
|
602
|
raise util.Abort(_("cannot delete revision %d above "
|
|
602
|
raise util.Abort(_("cannot delete revision %d above "
|
|
603
|
"applied patches") % rev)
|
|
603
|
"applied patches") % rev)
|
|
604
|
realpatches.append(self.applied[appliedbase].name)
|
|
604
|
realpatches.append(self.applied[appliedbase].name)
|
|
605
|
appliedbase += 1
|
|
605
|
appliedbase += 1
|
|
606
|
|
|
606
|
|
|
607
|
if not opts.get('keep'):
|
|
607
|
if not opts.get('keep'):
|
|
608
|
r = self.qrepo()
|
|
608
|
r = self.qrepo()
|
|
609
|
if r:
|
|
609
|
if r:
|
|
610
|
r.remove(realpatches, True)
|
|
610
|
r.remove(realpatches, True)
|
|
611
|
else:
|
|
611
|
else:
|
|
612
|
for p in realpatches:
|
|
612
|
for p in realpatches:
|
|
613
|
os.unlink(self.join(p))
|
|
613
|
os.unlink(self.join(p))
|
|
614
|
|
|
614
|
|
|
615
|
if appliedbase:
|
|
615
|
if appliedbase:
|
|
616
|
del self.applied[:appliedbase]
|
|
616
|
del self.applied[:appliedbase]
|
|
617
|
self.applied_dirty = 1
|
|
617
|
self.applied_dirty = 1
|
|
618
|
self._clean_series(realpatches)
|
|
618
|
self._clean_series(realpatches)
|
|
619
|
|
|
619
|
|
|
620
|
def check_toppatch(self, repo):
|
|
620
|
def check_toppatch(self, repo):
|
|
621
|
if len(self.applied) > 0:
|
|
621
|
if len(self.applied) > 0:
|
|
622
|
top = revlog.bin(self.applied[-1].rev)
|
|
622
|
top = revlog.bin(self.applied[-1].rev)
|
|
623
|
pp = repo.dirstate.parents()
|
|
623
|
pp = repo.dirstate.parents()
|
|
624
|
if top not in pp:
|
|
624
|
if top not in pp:
|
|
625
|
raise util.Abort(_("working directory revision is not qtip"))
|
|
625
|
raise util.Abort(_("working directory revision is not qtip"))
|
|
626
|
return top
|
|
626
|
return top
|
|
627
|
return None
|
|
627
|
return None
|
|
628
|
def check_localchanges(self, repo, force=False, refresh=True):
|
|
628
|
def check_localchanges(self, repo, force=False, refresh=True):
|
|
629
|
m, a, r, d = repo.status()[:4]
|
|
629
|
m, a, r, d = repo.status()[:4]
|
|
630
|
if m or a or r or d:
|
|
630
|
if m or a or r or d:
|
|
631
|
if not force:
|
|
631
|
if not force:
|
|
632
|
if refresh:
|
|
632
|
if refresh:
|
|
633
|
raise util.Abort(_("local changes found, refresh first"))
|
|
633
|
raise util.Abort(_("local changes found, refresh first"))
|
|
634
|
else:
|
|
634
|
else:
|
|
635
|
raise util.Abort(_("local changes found"))
|
|
635
|
raise util.Abort(_("local changes found"))
|
|
636
|
return m, a, r, d
|
|
636
|
return m, a, r, d
|
|
637
|
|
|
637
|
|
|
638
|
_reserved = ('series', 'status', 'guards')
|
|
638
|
_reserved = ('series', 'status', 'guards')
|
|
639
|
def check_reserved_name(self, name):
|
|
639
|
def check_reserved_name(self, name):
|
|
640
|
if (name in self._reserved or name.startswith('.hg')
|
|
640
|
if (name in self._reserved or name.startswith('.hg')
|
|
641
|
or name.startswith('.mq')):
|
|
641
|
or name.startswith('.mq')):
|
|
642
|
raise util.Abort(_('"%s" cannot be used as the name of a patch')
|
|
642
|
raise util.Abort(_('"%s" cannot be used as the name of a patch')
|
|
643
|
% name)
|
|
643
|
% name)
|
|
644
|
|
|
644
|
|
|
645
|
def new(self, repo, patchfn, *pats, **opts):
|
|
645
|
def new(self, repo, patchfn, *pats, **opts):
|
|
646
|
"""options:
|
|
646
|
"""options:
|
|
647
|
msg: a string or a no-argument function returning a string
|
|
647
|
msg: a string or a no-argument function returning a string
|
|
648
|
"""
|
|
648
|
"""
|
|
649
|
msg = opts.get('msg')
|
|
649
|
msg = opts.get('msg')
|
|
650
|
force = opts.get('force')
|
|
650
|
force = opts.get('force')
|
|
651
|
user = opts.get('user')
|
|
651
|
user = opts.get('user')
|
|
652
|
date = opts.get('date')
|
|
652
|
date = opts.get('date')
|
|
653
|
if date:
|
|
653
|
if date:
|
|
654
|
date = util.parsedate(date)
|
|
654
|
date = util.parsedate(date)
|
|
655
|
self.check_reserved_name(patchfn)
|
|
655
|
self.check_reserved_name(patchfn)
|
|
656
|
if os.path.exists(self.join(patchfn)):
|
|
656
|
if os.path.exists(self.join(patchfn)):
|
|
657
|
raise util.Abort(_('patch "%s" already exists') % patchfn)
|
|
657
|
raise util.Abort(_('patch "%s" already exists') % patchfn)
|
|
658
|
if opts.get('include') or opts.get('exclude') or pats:
|
|
658
|
if opts.get('include') or opts.get('exclude') or pats:
|
|
659
|
match = cmdutil.match(repo, pats, opts)
|
|
659
|
match = cmdutil.match(repo, pats, opts)
|
|
660
|
# detect missing files in pats
|
|
660
|
# detect missing files in pats
|
|
661
|
def badfn(f, msg):
|
|
661
|
def badfn(f, msg):
|
|
662
|
raise util.Abort('%s: %s' % (f, msg))
|
|
662
|
raise util.Abort('%s: %s' % (f, msg))
|
|
663
|
match.bad = badfn
|
|
663
|
match.bad = badfn
|
|
664
|
m, a, r, d = repo.status(match=match)[:4]
|
|
664
|
m, a, r, d = repo.status(match=match)[:4]
|
|
665
|
else:
|
|
665
|
else:
|
|
666
|
m, a, r, d = self.check_localchanges(repo, force)
|
|
666
|
m, a, r, d = self.check_localchanges(repo, force)
|
|
667
|
match = cmdutil.matchfiles(repo, m + a + r)
|
|
667
|
match = cmdutil.matchfiles(repo, m + a + r)
|
|
668
|
commitfiles = m + a + r
|
|
668
|
commitfiles = m + a + r
|
|
669
|
self.check_toppatch(repo)
|
|
669
|
self.check_toppatch(repo)
|
|
670
|
insert = self.full_series_end()
|
|
670
|
insert = self.full_series_end()
|
|
671
|
wlock = repo.wlock()
|
|
671
|
wlock = repo.wlock()
|
|
672
|
try:
|
|
672
|
try:
|
|
673
|
# if patch file write fails, abort early
|
|
673
|
# if patch file write fails, abort early
|
|
674
|
p = self.opener(patchfn, "w")
|
|
674
|
p = self.opener(patchfn, "w")
|
|
675
|
try:
|
|
675
|
try:
|
|
676
|
if date:
|
|
676
|
if date:
|
|
677
|
p.write("# HG changeset patch\n")
|
|
677
|
p.write("# HG changeset patch\n")
|
|
678
|
if user:
|
|
678
|
if user:
|
|
679
|
p.write("# User " + user + "\n")
|
|
679
|
p.write("# User " + user + "\n")
|
|
680
|
p.write("# Date %d %d\n\n" % date)
|
|
680
|
p.write("# Date %d %d\n\n" % date)
|
|
681
|
elif user:
|
|
681
|
elif user:
|
|
682
|
p.write("From: " + user + "\n\n")
|
|
682
|
p.write("From: " + user + "\n\n")
|
|
683
|
|
|
683
|
|
|
684
|
if callable(msg):
|
|
684
|
if callable(msg):
|
|
685
|
msg = msg()
|
|
685
|
msg = msg()
|
|
686
|
commitmsg = msg and msg or ("[mq]: %s" % patchfn)
|
|
686
|
commitmsg = msg and msg or ("[mq]: %s" % patchfn)
|
|
687
|
n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
|
|
687
|
n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
|
|
688
|
if n == None:
|
|
688
|
if n == None:
|
|
689
|
raise util.Abort(_("repo commit failed"))
|
|
689
|
raise util.Abort(_("repo commit failed"))
|
|
690
|
try:
|
|
690
|
try:
|
|
691
|
self.full_series[insert:insert] = [patchfn]
|
|
691
|
self.full_series[insert:insert] = [patchfn]
|
|
692
|
self.applied.append(statusentry(revlog.hex(n), patchfn))
|
|
692
|
self.applied.append(statusentry(revlog.hex(n), patchfn))
|
|
693
|
self.parse_series()
|
|
693
|
self.parse_series()
|
|
694
|
self.series_dirty = 1
|
|
694
|
self.series_dirty = 1
|
|
695
|
self.applied_dirty = 1
|
|
695
|
self.applied_dirty = 1
|
|
696
|
if msg:
|
|
696
|
if msg:
|
|
697
|
msg = msg + "\n"
|
|
697
|
msg = msg + "\n"
|
|
698
|
p.write(msg)
|
|
698
|
p.write(msg)
|
|
699
|
if commitfiles:
|
|
699
|
if commitfiles:
|
|
700
|
diffopts = self.diffopts()
|
|
700
|
diffopts = self.diffopts()
|
|
701
|
if opts.get('git'): diffopts.git = True
|
|
701
|
if opts.get('git'): diffopts.git = True
|
|
702
|
parent = self.qparents(repo, n)
|
|
702
|
parent = self.qparents(repo, n)
|
|
703
|
chunks = patch.diff(repo, node1=parent, node2=n,
|
|
703
|
chunks = patch.diff(repo, node1=parent, node2=n,
|
|
704
|
match=match, opts=diffopts)
|
|
704
|
match=match, opts=diffopts)
|
|
705
|
for chunk in chunks:
|
|
705
|
for chunk in chunks:
|
|
706
|
p.write(chunk)
|
|
706
|
p.write(chunk)
|
|
707
|
p.close()
|
|
707
|
p.close()
|
|
708
|
wlock = None
|
|
708
|
wlock = None
|
|
709
|
r = self.qrepo()
|
|
709
|
r = self.qrepo()
|
|
710
|
if r: r.add([patchfn])
|
|
710
|
if r: r.add([patchfn])
|
|
711
|
except:
|
|
711
|
except:
|
|
712
|
repo.rollback()
|
|
712
|
repo.rollback()
|
|
713
|
raise
|
|
713
|
raise
|
|
714
|
except Exception:
|
|
714
|
except Exception:
|
|
715
|
patchpath = self.join(patchfn)
|
|
715
|
patchpath = self.join(patchfn)
|
|
716
|
try:
|
|
716
|
try:
|
|
717
|
os.unlink(patchpath)
|
|
717
|
os.unlink(patchpath)
|
|
718
|
except:
|
|
718
|
except:
|
|
719
|
self.ui.warn(_('error unlinking %s\n') % patchpath)
|
|
719
|
self.ui.warn(_('error unlinking %s\n') % patchpath)
|
|
720
|
raise
|
|
720
|
raise
|
|
721
|
self.removeundo(repo)
|
|
721
|
self.removeundo(repo)
|
|
722
|
finally:
|
|
722
|
finally:
|
|
723
|
del wlock
|
|
723
|
del wlock
|
|
724
|
|
|
724
|
|
|
725
|
def strip(self, repo, rev, update=True, backup="all", force=None):
|
|
725
|
def strip(self, repo, rev, update=True, backup="all", force=None):
|
|
726
|
wlock = lock = None
|
|
726
|
wlock = lock = None
|
|
727
|
try:
|
|
727
|
try:
|
|
728
|
wlock = repo.wlock()
|
|
728
|
wlock = repo.wlock()
|
|
729
|
lock = repo.lock()
|
|
729
|
lock = repo.lock()
|
|
730
|
|
|
730
|
|
|
731
|
if update:
|
|
731
|
if update:
|
|
732
|
self.check_localchanges(repo, force=force, refresh=False)
|
|
732
|
self.check_localchanges(repo, force=force, refresh=False)
|
|
733
|
urev = self.qparents(repo, rev)
|
|
733
|
urev = self.qparents(repo, rev)
|
|
734
|
hg.clean(repo, urev)
|
|
734
|
hg.clean(repo, urev)
|
|
735
|
repo.dirstate.write()
|
|
735
|
repo.dirstate.write()
|
|
736
|
|
|
736
|
|
|
737
|
self.removeundo(repo)
|
|
737
|
self.removeundo(repo)
|
|
738
|
repair.strip(self.ui, repo, rev, backup)
|
|
738
|
repair.strip(self.ui, repo, rev, backup)
|
|
739
|
# strip may have unbundled a set of backed up revisions after
|
|
739
|
# strip may have unbundled a set of backed up revisions after
|
|
740
|
# the actual strip
|
|
740
|
# the actual strip
|
|
741
|
self.removeundo(repo)
|
|
741
|
self.removeundo(repo)
|
|
742
|
finally:
|
|
742
|
finally:
|
|
743
|
del lock, wlock
|
|
743
|
del lock, wlock
|
|
744
|
|
|
744
|
|
|
745
|
def isapplied(self, patch):
|
|
745
|
def isapplied(self, patch):
|
|
746
|
"""returns (index, rev, patch)"""
|
|
746
|
"""returns (index, rev, patch)"""
|
|
747
|
for i in xrange(len(self.applied)):
|
|
747
|
for i in xrange(len(self.applied)):
|
|
748
|
a = self.applied[i]
|
|
748
|
a = self.applied[i]
|
|
749
|
if a.name == patch:
|
|
749
|
if a.name == patch:
|
|
750
|
return (i, a.rev, a.name)
|
|
750
|
return (i, a.rev, a.name)
|
|
751
|
return None
|
|
751
|
return None
|
|
752
|
|
|
752
|
|
|
753
|
# if the exact patch name does not exist, we try a few
|
|
753
|
# if the exact patch name does not exist, we try a few
|
|
754
|
# variations. If strict is passed, we try only #1
|
|
754
|
# variations. If strict is passed, we try only #1
|
|
755
|
#
|
|
755
|
#
|
|
756
|
# 1) a number to indicate an offset in the series file
|
|
756
|
# 1) a number to indicate an offset in the series file
|
|
757
|
# 2) a unique substring of the patch name was given
|
|
757
|
# 2) a unique substring of the patch name was given
|
|
758
|
# 3) patchname[-+]num to indicate an offset in the series file
|
|
758
|
# 3) patchname[-+]num to indicate an offset in the series file
|
|
759
|
def lookup(self, patch, strict=False):
|
|
759
|
def lookup(self, patch, strict=False):
|
|
760
|
patch = patch and str(patch)
|
|
760
|
patch = patch and str(patch)
|
|
761
|
|
|
761
|
|
|
762
|
def partial_name(s):
|
|
762
|
def partial_name(s):
|
|
763
|
if s in self.series:
|
|
763
|
if s in self.series:
|
|
764
|
return s
|
|
764
|
return s
|
|
765
|
matches = [x for x in self.series if s in x]
|
|
765
|
matches = [x for x in self.series if s in x]
|
|
766
|
if len(matches) > 1:
|
|
766
|
if len(matches) > 1:
|
|
767
|
self.ui.warn(_('patch name "%s" is ambiguous:\n') % s)
|
|
767
|
self.ui.warn(_('patch name "%s" is ambiguous:\n') % s)
|
|
768
|
for m in matches:
|
|
768
|
for m in matches:
|
|
769
|
self.ui.warn(' %s\n' % m)
|
|
769
|
self.ui.warn(' %s\n' % m)
|
|
770
|
return None
|
|
770
|
return None
|
|
771
|
if matches:
|
|
771
|
if matches:
|
|
772
|
return matches[0]
|
|
772
|
return matches[0]
|
|
773
|
if len(self.series) > 0 and len(self.applied) > 0:
|
|
773
|
if len(self.series) > 0 and len(self.applied) > 0:
|
|
774
|
if s == 'qtip':
|
|
774
|
if s == 'qtip':
|
|
775
|
return self.series[self.series_end(True)-1]
|
|
775
|
return self.series[self.series_end(True)-1]
|
|
776
|
if s == 'qbase':
|
|
776
|
if s == 'qbase':
|
|
777
|
return self.series[0]
|
|
777
|
return self.series[0]
|
|
778
|
return None
|
|
778
|
return None
|
|
779
|
if patch == None:
|
|
779
|
if patch == None:
|
|
780
|
return None
|
|
780
|
return None
|
|
781
|
|
|
781
|
|
|
782
|
# we don't want to return a partial match until we make
|
|
782
|
# we don't want to return a partial match until we make
|
|
783
|
# sure the file name passed in does not exist (checked below)
|
|
783
|
# sure the file name passed in does not exist (checked below)
|
|
784
|
res = partial_name(patch)
|
|
784
|
res = partial_name(patch)
|
|
785
|
if res and res == patch:
|
|
785
|
if res and res == patch:
|
|
786
|
return res
|
|
786
|
return res
|
|
787
|
|
|
787
|
|
|
788
|
if not os.path.isfile(self.join(patch)):
|
|
788
|
if not os.path.isfile(self.join(patch)):
|
|
789
|
try:
|
|
789
|
try:
|
|
790
|
sno = int(patch)
|
|
790
|
sno = int(patch)
|
|
791
|
except(ValueError, OverflowError):
|
|
791
|
except(ValueError, OverflowError):
|
|
792
|
pass
|
|
792
|
pass
|
|
793
|
else:
|
|
793
|
else:
|
|
794
|
if sno < len(self.series):
|
|
794
|
if sno < len(self.series):
|
|
795
|
return self.series[sno]
|
|
795
|
return self.series[sno]
|
|
796
|
if not strict:
|
|
796
|
if not strict:
|
|
797
|
# return any partial match made above
|
|
797
|
# return any partial match made above
|
|
798
|
if res:
|
|
798
|
if res:
|
|
799
|
return res
|
|
799
|
return res
|
|
800
|
minus = patch.rfind('-')
|
|
800
|
minus = patch.rfind('-')
|
|
801
|
if minus >= 0:
|
|
801
|
if minus >= 0:
|
|
802
|
res = partial_name(patch[:minus])
|
|
802
|
res = partial_name(patch[:minus])
|
|
803
|
if res:
|
|
803
|
if res:
|
|
804
|
i = self.series.index(res)
|
|
804
|
i = self.series.index(res)
|
|
805
|
try:
|
|
805
|
try:
|
|
806
|
off = int(patch[minus+1:] or 1)
|
|
806
|
off = int(patch[minus+1:] or 1)
|
|
807
|
except(ValueError, OverflowError):
|
|
807
|
except(ValueError, OverflowError):
|
|
808
|
pass
|
|
808
|
pass
|
|
809
|
else:
|
|
809
|
else:
|
|
810
|
if i - off >= 0:
|
|
810
|
if i - off >= 0:
|
|
811
|
return self.series[i - off]
|
|
811
|
return self.series[i - off]
|
|
812
|
plus = patch.rfind('+')
|
|
812
|
plus = patch.rfind('+')
|
|
813
|
if plus >= 0:
|
|
813
|
if plus >= 0:
|
|
814
|
res = partial_name(patch[:plus])
|
|
814
|
res = partial_name(patch[:plus])
|
|
815
|
if res:
|
|
815
|
if res:
|
|
816
|
i = self.series.index(res)
|
|
816
|
i = self.series.index(res)
|
|
817
|
try:
|
|
817
|
try:
|
|
818
|
off = int(patch[plus+1:] or 1)
|
|
818
|
off = int(patch[plus+1:] or 1)
|
|
819
|
except(ValueError, OverflowError):
|
|
819
|
except(ValueError, OverflowError):
|
|
820
|
pass
|
|
820
|
pass
|
|
821
|
else:
|
|
821
|
else:
|
|
822
|
if i + off < len(self.series):
|
|
822
|
if i + off < len(self.series):
|
|
823
|
return self.series[i + off]
|
|
823
|
return self.series[i + off]
|
|
824
|
raise util.Abort(_("patch %s not in series") % patch)
|
|
824
|
raise util.Abort(_("patch %s not in series") % patch)
|
|
825
|
|
|
825
|
|
|
826
|
def push(self, repo, patch=None, force=False, list=False,
|
|
826
|
def push(self, repo, patch=None, force=False, list=False,
|
|
827
|
mergeq=None):
|
|
827
|
mergeq=None, all=False):
|
|
828
|
wlock = repo.wlock()
|
|
828
|
wlock = repo.wlock()
|
|
829
|
if repo.dirstate.parents()[0] != repo.changelog.tip():
|
|
829
|
if repo.dirstate.parents()[0] != repo.changelog.tip():
|
|
830
|
self.ui.status(_("(working directory not at tip)\n"))
|
|
830
|
self.ui.status(_("(working directory not at tip)\n"))
|
|
831
|
|
|
831
|
|
|
|
|
|
832
|
if not self.series:
|
|
|
|
|
833
|
self.ui.warn(_('no patches in series\n'))
|
|
|
|
|
834
|
return 0
|
|
|
|
|
835
|
|
|
832
|
try:
|
|
836
|
try:
|
|
833
|
patch = self.lookup(patch)
|
|
837
|
patch = self.lookup(patch)
|
|
834
|
# Suppose our series file is: A B C and the current 'top'
|
|
838
|
# Suppose our series file is: A B C and the current 'top'
|
|
835
|
# patch is B. qpush C should be performed (moving forward)
|
|
839
|
# patch is B. qpush C should be performed (moving forward)
|
|
836
|
# qpush B is a NOP (no change) qpush A is an error (can't
|
|
840
|
# qpush B is a NOP (no change) qpush A is an error (can't
|
|
837
|
# go backwards with qpush)
|
|
841
|
# go backwards with qpush)
|
|
838
|
if patch:
|
|
842
|
if patch:
|
|
839
|
info = self.isapplied(patch)
|
|
843
|
info = self.isapplied(patch)
|
|
840
|
if info:
|
|
844
|
if info:
|
|
841
|
if info[0] < len(self.applied) - 1:
|
|
845
|
if info[0] < len(self.applied) - 1:
|
|
842
|
raise util.Abort(
|
|
846
|
raise util.Abort(
|
|
843
|
_("cannot push to a previous patch: %s") % patch)
|
|
847
|
_("cannot push to a previous patch: %s") % patch)
|
|
844
|
if info[0] < len(self.series) - 1:
|
|
848
|
self.ui.warn(
|
|
845
|
self.ui.warn(
|
|
849
|
_('qpush: %s is already at the top\n') % patch)
|
|
846
|
_('qpush: %s is already at the top\n') % patch)
|
|
850
|
return
|
|
|
|
|
851
|
pushable, reason = self.pushable(patch)
|
|
|
|
|
852
|
if not pushable:
|
|
|
|
|
853
|
if reason:
|
|
|
|
|
854
|
reason = _('guarded by %r') % reason
|
|
847
|
else:
|
|
855
|
else:
|
|
848
|
self.ui.warn(_('all patches are currently applied\n'))
|
|
856
|
reason = _('no matching guards')
|
|
849
|
return
|
|
857
|
self.ui.warn(_("cannot push '%s' - %s\n") % (patch, reason))
|
|
|
|
|
858
|
return 1
|
|
|
|
|
859
|
elif all:
|
|
|
|
|
860
|
patch = self.series[-1]
|
|
|
|
|
861
|
if self.isapplied(patch):
|
|
|
|
|
862
|
self.ui.warn(_('all patches are currently applied\n'))
|
|
|
|
|
863
|
return 0
|
|
850
|
|
|
864
|
|
|
851
|
# Following the above example, starting at 'top' of B:
|
|
865
|
# Following the above example, starting at 'top' of B:
|
|
852
|
# qpush should be performed (pushes C), but a subsequent
|
|
866
|
# qpush should be performed (pushes C), but a subsequent
|
|
853
|
# qpush without an argument is an error (nothing to
|
|
867
|
# qpush without an argument is an error (nothing to
|
|
854
|
# apply). This allows a loop of "...while hg qpush..." to
|
|
868
|
# apply). This allows a loop of "...while hg qpush..." to
|
|
855
|
# work as it detects an error when done
|
|
869
|
# work as it detects an error when done
|
|
856
|
if self.series_end() == len(self.series):
|
|
870
|
start = self.series_end()
|
|
|
|
|
871
|
if start == len(self.series):
|
|
857
|
self.ui.warn(_('patch series already fully applied\n'))
|
|
872
|
self.ui.warn(_('patch series already fully applied\n'))
|
|
858
|
return 1
|
|
873
|
return 1
|
|
859
|
if not force:
|
|
874
|
if not force:
|
|
860
|
self.check_localchanges(repo)
|
|
875
|
self.check_localchanges(repo)
|
|
861
|
|
|
876
|
|
|
862
|
self.applied_dirty = 1;
|
|
877
|
self.applied_dirty = 1
|
|
863
|
start = self.series_end()
|
|
|
|
|
864
|
if start > 0:
|
|
878
|
if start > 0:
|
|
865
|
self.check_toppatch(repo)
|
|
879
|
self.check_toppatch(repo)
|
|
866
|
if not patch:
|
|
880
|
if not patch:
|
|
867
|
patch = self.series[start]
|
|
881
|
patch = self.series[start]
|
|
868
|
end = start + 1
|
|
882
|
end = start + 1
|
|
869
|
else:
|
|
883
|
else:
|
|
870
|
end = self.series.index(patch, start) + 1
|
|
884
|
end = self.series.index(patch, start) + 1
|
|
871
|
s = self.series[start:end]
|
|
885
|
s = self.series[start:end]
|
|
872
|
all_files = {}
|
|
886
|
all_files = {}
|
|
873
|
try:
|
|
887
|
try:
|
|
874
|
if mergeq:
|
|
888
|
if mergeq:
|
|
875
|
ret = self.mergepatch(repo, mergeq, s)
|
|
889
|
ret = self.mergepatch(repo, mergeq, s)
|
|
876
|
else:
|
|
890
|
else:
|
|
877
|
ret = self.apply(repo, s, list, all_files=all_files)
|
|
891
|
ret = self.apply(repo, s, list, all_files=all_files)
|
|
878
|
except:
|
|
892
|
except:
|
|
879
|
self.ui.warn(_('cleaning up working directory...'))
|
|
893
|
self.ui.warn(_('cleaning up working directory...'))
|
|
880
|
node = repo.dirstate.parents()[0]
|
|
894
|
node = repo.dirstate.parents()[0]
|
|
881
|
hg.revert(repo, node, None)
|
|
895
|
hg.revert(repo, node, None)
|
|
882
|
unknown = repo.status(unknown=True)[4]
|
|
896
|
unknown = repo.status(unknown=True)[4]
|
|
883
|
# only remove unknown files that we know we touched or
|
|
897
|
# only remove unknown files that we know we touched or
|
|
884
|
# created while patching
|
|
898
|
# created while patching
|
|
885
|
for f in unknown:
|
|
899
|
for f in unknown:
|
|
886
|
if f in all_files:
|
|
900
|
if f in all_files:
|
|
887
|
util.unlink(repo.wjoin(f))
|
|
901
|
util.unlink(repo.wjoin(f))
|
|
888
|
self.ui.warn(_('done\n'))
|
|
902
|
self.ui.warn(_('done\n'))
|
|
889
|
raise
|
|
903
|
raise
|
|
890
|
top = self.applied[-1].name
|
|
904
|
top = self.applied[-1].name
|
|
891
|
if ret[0]:
|
|
905
|
if ret[0]:
|
|
892
|
self.ui.write(
|
|
906
|
self.ui.write(
|
|
893
|
"Errors during apply, please fix and refresh %s\n" % top)
|
|
907
|
"Errors during apply, please fix and refresh %s\n" % top)
|
|
894
|
else:
|
|
908
|
else:
|
|
895
|
self.ui.write("Now at: %s\n" % top)
|
|
909
|
self.ui.write("Now at: %s\n" % top)
|
|
896
|
return ret[0]
|
|
910
|
return ret[0]
|
|
897
|
finally:
|
|
911
|
finally:
|
|
898
|
del wlock
|
|
912
|
del wlock
|
|
899
|
|
|
913
|
|
|
900
|
def pop(self, repo, patch=None, force=False, update=True, all=False):
|
|
914
|
def pop(self, repo, patch=None, force=False, update=True, all=False):
|
|
901
|
def getfile(f, rev, flags):
|
|
915
|
def getfile(f, rev, flags):
|
|
902
|
t = repo.file(f).read(rev)
|
|
916
|
t = repo.file(f).read(rev)
|
|
903
|
repo.wwrite(f, t, flags)
|
|
917
|
repo.wwrite(f, t, flags)
|
|
904
|
|
|
918
|
|
|
905
|
wlock = repo.wlock()
|
|
919
|
wlock = repo.wlock()
|
|
906
|
try:
|
|
920
|
try:
|
|
907
|
if patch:
|
|
921
|
if patch:
|
|
908
|
# index, rev, patch
|
|
922
|
# index, rev, patch
|
|
909
|
info = self.isapplied(patch)
|
|
923
|
info = self.isapplied(patch)
|
|
910
|
if not info:
|
|
924
|
if not info:
|
|
911
|
patch = self.lookup(patch)
|
|
925
|
patch = self.lookup(patch)
|
|
912
|
info = self.isapplied(patch)
|
|
926
|
info = self.isapplied(patch)
|
|
913
|
if not info:
|
|
927
|
if not info:
|
|
914
|
raise util.Abort(_("patch %s is not applied") % patch)
|
|
928
|
raise util.Abort(_("patch %s is not applied") % patch)
|
|
915
|
|
|
929
|
|
|
916
|
if len(self.applied) == 0:
|
|
930
|
if len(self.applied) == 0:
|
|
917
|
# Allow qpop -a to work repeatedly,
|
|
931
|
# Allow qpop -a to work repeatedly,
|
|
918
|
# but not qpop without an argument
|
|
932
|
# but not qpop without an argument
|
|
919
|
self.ui.warn(_("no patches applied\n"))
|
|
933
|
self.ui.warn(_("no patches applied\n"))
|
|
920
|
return not all
|
|
934
|
return not all
|
|
921
|
|
|
935
|
|
|
922
|
if not update:
|
|
936
|
if not update:
|
|
923
|
parents = repo.dirstate.parents()
|
|
937
|
parents = repo.dirstate.parents()
|
|
924
|
rr = [ revlog.bin(x.rev) for x in self.applied ]
|
|
938
|
rr = [ revlog.bin(x.rev) for x in self.applied ]
|
|
925
|
for p in parents:
|
|
939
|
for p in parents:
|
|
926
|
if p in rr:
|
|
940
|
if p in rr:
|
|
927
|
self.ui.warn(_("qpop: forcing dirstate update\n"))
|
|
941
|
self.ui.warn(_("qpop: forcing dirstate update\n"))
|
|
928
|
update = True
|
|
942
|
update = True
|
|
929
|
|
|
943
|
|
|
930
|
if not force and update:
|
|
944
|
if not force and update:
|
|
931
|
self.check_localchanges(repo)
|
|
945
|
self.check_localchanges(repo)
|
|
932
|
|
|
946
|
|
|
933
|
self.applied_dirty = 1;
|
|
947
|
self.applied_dirty = 1;
|
|
934
|
end = len(self.applied)
|
|
948
|
end = len(self.applied)
|
|
935
|
if not patch:
|
|
949
|
if not patch:
|
|
936
|
if all:
|
|
950
|
if all:
|
|
937
|
popi = 0
|
|
951
|
popi = 0
|
|
938
|
else:
|
|
952
|
else:
|
|
939
|
popi = len(self.applied) - 1
|
|
953
|
popi = len(self.applied) - 1
|
|
940
|
else:
|
|
954
|
else:
|
|
941
|
popi = info[0] + 1
|
|
955
|
popi = info[0] + 1
|
|
942
|
if popi >= end:
|
|
956
|
if popi >= end:
|
|
943
|
self.ui.warn(_("qpop: %s is already at the top\n") % patch)
|
|
957
|
self.ui.warn(_("qpop: %s is already at the top\n") % patch)
|
|
944
|
return
|
|
958
|
return
|
|
945
|
info = [ popi ] + [self.applied[popi].rev, self.applied[popi].name]
|
|
959
|
info = [ popi ] + [self.applied[popi].rev, self.applied[popi].name]
|
|
946
|
|
|
960
|
|
|
947
|
start = info[0]
|
|
961
|
start = info[0]
|
|
948
|
rev = revlog.bin(info[1])
|
|
962
|
rev = revlog.bin(info[1])
|
|
949
|
|
|
963
|
|
|
950
|
if update:
|
|
964
|
if update:
|
|
951
|
top = self.check_toppatch(repo)
|
|
965
|
top = self.check_toppatch(repo)
|
|
952
|
|
|
966
|
|
|
953
|
if repo.changelog.heads(rev) != [revlog.bin(self.applied[-1].rev)]:
|
|
967
|
if repo.changelog.heads(rev) != [revlog.bin(self.applied[-1].rev)]:
|
|
954
|
raise util.Abort(_("popping would remove a revision not "
|
|
968
|
raise util.Abort(_("popping would remove a revision not "
|
|
955
|
"managed by this patch queue"))
|
|
969
|
"managed by this patch queue"))
|
|
956
|
|
|
970
|
|
|
957
|
# we know there are no local changes, so we can make a simplified
|
|
971
|
# we know there are no local changes, so we can make a simplified
|
|
958
|
# form of hg.update.
|
|
972
|
# form of hg.update.
|
|
959
|
if update:
|
|
973
|
if update:
|
|
960
|
qp = self.qparents(repo, rev)
|
|
974
|
qp = self.qparents(repo, rev)
|
|
961
|
changes = repo.changelog.read(qp)
|
|
975
|
changes = repo.changelog.read(qp)
|
|
962
|
mmap = repo.manifest.read(changes[0])
|
|
976
|
mmap = repo.manifest.read(changes[0])
|
|
963
|
m, a, r, d = repo.status(qp, top)[:4]
|
|
977
|
m, a, r, d = repo.status(qp, top)[:4]
|
|
964
|
if d:
|
|
978
|
if d:
|
|
965
|
raise util.Abort(_("deletions found between repo revs"))
|
|
979
|
raise util.Abort(_("deletions found between repo revs"))
|
|
966
|
for f in m:
|
|
980
|
for f in m:
|
|
967
|
getfile(f, mmap[f], mmap.flags(f))
|
|
981
|
getfile(f, mmap[f], mmap.flags(f))
|
|
968
|
for f in r:
|
|
982
|
for f in r:
|
|
969
|
getfile(f, mmap[f], mmap.flags(f))
|
|
983
|
getfile(f, mmap[f], mmap.flags(f))
|
|
970
|
for f in m + r:
|
|
984
|
for f in m + r:
|
|
971
|
repo.dirstate.normal(f)
|
|
985
|
repo.dirstate.normal(f)
|
|
972
|
for f in a:
|
|
986
|
for f in a:
|
|
973
|
try:
|
|
987
|
try:
|
|
974
|
os.unlink(repo.wjoin(f))
|
|
988
|
os.unlink(repo.wjoin(f))
|
|
975
|
except OSError, e:
|
|
989
|
except OSError, e:
|
|
976
|
if e.errno != errno.ENOENT:
|
|
990
|
if e.errno != errno.ENOENT:
|
|
977
|
raise
|
|
991
|
raise
|
|
978
|
try: os.removedirs(os.path.dirname(repo.wjoin(f)))
|
|
992
|
try: os.removedirs(os.path.dirname(repo.wjoin(f)))
|
|
979
|
except: pass
|
|
993
|
except: pass
|
|
980
|
repo.dirstate.forget(f)
|
|
994
|
repo.dirstate.forget(f)
|
|
981
|
repo.dirstate.setparents(qp, revlog.nullid)
|
|
995
|
repo.dirstate.setparents(qp, revlog.nullid)
|
|
982
|
del self.applied[start:end]
|
|
996
|
del self.applied[start:end]
|
|
983
|
self.strip(repo, rev, update=False, backup='strip')
|
|
997
|
self.strip(repo, rev, update=False, backup='strip')
|
|
984
|
if len(self.applied):
|
|
998
|
if len(self.applied):
|
|
985
|
self.ui.write(_("Now at: %s\n") % self.applied[-1].name)
|
|
999
|
self.ui.write(_("Now at: %s\n") % self.applied[-1].name)
|
|
986
|
else:
|
|
1000
|
else:
|
|
987
|
self.ui.write(_("Patch queue now empty\n"))
|
|
1001
|
self.ui.write(_("Patch queue now empty\n"))
|
|
988
|
finally:
|
|
1002
|
finally:
|
|
989
|
del wlock
|
|
1003
|
del wlock
|
|
990
|
|
|
1004
|
|
|
991
|
def diff(self, repo, pats, opts):
|
|
1005
|
def diff(self, repo, pats, opts):
|
|
992
|
top = self.check_toppatch(repo)
|
|
1006
|
top = self.check_toppatch(repo)
|
|
993
|
if not top:
|
|
1007
|
if not top:
|
|
994
|
self.ui.write(_("No patches applied\n"))
|
|
1008
|
self.ui.write(_("No patches applied\n"))
|
|
995
|
return
|
|
1009
|
return
|
|
996
|
qp = self.qparents(repo, top)
|
|
1010
|
qp = self.qparents(repo, top)
|
|
997
|
self._diffopts = patch.diffopts(self.ui, opts)
|
|
1011
|
self._diffopts = patch.diffopts(self.ui, opts)
|
|
998
|
self.printdiff(repo, qp, files=pats, opts=opts)
|
|
1012
|
self.printdiff(repo, qp, files=pats, opts=opts)
|
|
999
|
|
|
1013
|
|
|
1000
|
def refresh(self, repo, pats=None, **opts):
|
|
1014
|
def refresh(self, repo, pats=None, **opts):
|
|
1001
|
if len(self.applied) == 0:
|
|
1015
|
if len(self.applied) == 0:
|
|
1002
|
self.ui.write(_("No patches applied\n"))
|
|
1016
|
self.ui.write(_("No patches applied\n"))
|
|
1003
|
return 1
|
|
1017
|
return 1
|
|
1004
|
newdate = opts.get('date')
|
|
1018
|
newdate = opts.get('date')
|
|
1005
|
if newdate:
|
|
1019
|
if newdate:
|
|
1006
|
newdate = '%d %d' % util.parsedate(newdate)
|
|
1020
|
newdate = '%d %d' % util.parsedate(newdate)
|
|
1007
|
wlock = repo.wlock()
|
|
1021
|
wlock = repo.wlock()
|
|
1008
|
try:
|
|
1022
|
try:
|
|
1009
|
self.check_toppatch(repo)
|
|
1023
|
self.check_toppatch(repo)
|
|
1010
|
(top, patchfn) = (self.applied[-1].rev, self.applied[-1].name)
|
|
1024
|
(top, patchfn) = (self.applied[-1].rev, self.applied[-1].name)
|
|
1011
|
top = revlog.bin(top)
|
|
1025
|
top = revlog.bin(top)
|
|
1012
|
if repo.changelog.heads(top) != [top]:
|
|
1026
|
if repo.changelog.heads(top) != [top]:
|
|
1013
|
raise util.Abort(_("cannot refresh a revision with children"))
|
|
1027
|
raise util.Abort(_("cannot refresh a revision with children"))
|
|
1014
|
cparents = repo.changelog.parents(top)
|
|
1028
|
cparents = repo.changelog.parents(top)
|
|
1015
|
patchparent = self.qparents(repo, top)
|
|
1029
|
patchparent = self.qparents(repo, top)
|
|
1016
|
message, comments, user, date, patchfound = self.readheaders(patchfn)
|
|
1030
|
message, comments, user, date, patchfound = self.readheaders(patchfn)
|
|
1017
|
|
|
1031
|
|
|
1018
|
patchf = self.opener(patchfn, 'r+')
|
|
1032
|
patchf = self.opener(patchfn, 'r+')
|
|
1019
|
|
|
1033
|
|
|
1020
|
# if the patch was a git patch, refresh it as a git patch
|
|
1034
|
# if the patch was a git patch, refresh it as a git patch
|
|
1021
|
for line in patchf:
|
|
1035
|
for line in patchf:
|
|
1022
|
if line.startswith('diff --git'):
|
|
1036
|
if line.startswith('diff --git'):
|
|
1023
|
self.diffopts().git = True
|
|
1037
|
self.diffopts().git = True
|
|
1024
|
break
|
|
1038
|
break
|
|
1025
|
|
|
1039
|
|
|
1026
|
msg = opts.get('msg', '').rstrip()
|
|
1040
|
msg = opts.get('msg', '').rstrip()
|
|
1027
|
if msg and comments:
|
|
1041
|
if msg and comments:
|
|
1028
|
# Remove existing message, keeping the rest of the comments
|
|
1042
|
# Remove existing message, keeping the rest of the comments
|
|
1029
|
# fields.
|
|
1043
|
# fields.
|
|
1030
|
# If comments contains 'subject: ', message will prepend
|
|
1044
|
# If comments contains 'subject: ', message will prepend
|
|
1031
|
# the field and a blank line.
|
|
1045
|
# the field and a blank line.
|
|
1032
|
if message:
|
|
1046
|
if message:
|
|
1033
|
subj = 'subject: ' + message[0].lower()
|
|
1047
|
subj = 'subject: ' + message[0].lower()
|
|
1034
|
for i in xrange(len(comments)):
|
|
1048
|
for i in xrange(len(comments)):
|
|
1035
|
if subj == comments[i].lower():
|
|
1049
|
if subj == comments[i].lower():
|
|
1036
|
del comments[i]
|
|
1050
|
del comments[i]
|
|
1037
|
message = message[2:]
|
|
1051
|
message = message[2:]
|
|
1038
|
break
|
|
1052
|
break
|
|
1039
|
ci = 0
|
|
1053
|
ci = 0
|
|
1040
|
for mi in xrange(len(message)):
|
|
1054
|
for mi in xrange(len(message)):
|
|
1041
|
while message[mi] != comments[ci]:
|
|
1055
|
while message[mi] != comments[ci]:
|
|
1042
|
ci += 1
|
|
1056
|
ci += 1
|
|
1043
|
del comments[ci]
|
|
1057
|
del comments[ci]
|
|
1044
|
|
|
1058
|
|
|
1045
|
def setheaderfield(comments, prefixes, new):
|
|
1059
|
def setheaderfield(comments, prefixes, new):
|
|
1046
|
# Update all references to a field in the patch header.
|
|
1060
|
# Update all references to a field in the patch header.
|
|
1047
|
# If none found, add it email style.
|
|
1061
|
# If none found, add it email style.
|
|
1048
|
res = False
|
|
1062
|
res = False
|
|
1049
|
for prefix in prefixes:
|
|
1063
|
for prefix in prefixes:
|
|
1050
|
for i in xrange(len(comments)):
|
|
1064
|
for i in xrange(len(comments)):
|
|
1051
|
if comments[i].startswith(prefix):
|
|
1065
|
if comments[i].startswith(prefix):
|
|
1052
|
comments[i] = prefix + new
|
|
1066
|
comments[i] = prefix + new
|
|
1053
|
res = True
|
|
1067
|
res = True
|
|
1054
|
break
|
|
1068
|
break
|
|
1055
|
return res
|
|
1069
|
return res
|
|
1056
|
|
|
1070
|
|
|
1057
|
newuser = opts.get('user')
|
|
1071
|
newuser = opts.get('user')
|
|
1058
|
if newuser:
|
|
1072
|
if newuser:
|
|
1059
|
if not setheaderfield(comments, ['From: ', '# User '], newuser):
|
|
1073
|
if not setheaderfield(comments, ['From: ', '# User '], newuser):
|
|
1060
|
try:
|
|
1074
|
try:
|
|
1061
|
patchheaderat = comments.index('# HG changeset patch')
|
|
1075
|
patchheaderat = comments.index('# HG changeset patch')
|
|
1062
|
comments.insert(patchheaderat + 1,'# User ' + newuser)
|
|
1076
|
comments.insert(patchheaderat + 1,'# User ' + newuser)
|
|
1063
|
except ValueError:
|
|
1077
|
except ValueError:
|
|
1064
|
comments = ['From: ' + newuser, ''] + comments
|
|
1078
|
comments = ['From: ' + newuser, ''] + comments
|
|
1065
|
user = newuser
|
|
1079
|
user = newuser
|
|
1066
|
|
|
1080
|
|
|
1067
|
if newdate:
|
|
1081
|
if newdate:
|
|
1068
|
if setheaderfield(comments, ['# Date '], newdate):
|
|
1082
|
if setheaderfield(comments, ['# Date '], newdate):
|
|
1069
|
date = newdate
|
|
1083
|
date = newdate
|
|
1070
|
|
|
1084
|
|
|
1071
|
if msg:
|
|
1085
|
if msg:
|
|
1072
|
comments.append(msg)
|
|
1086
|
comments.append(msg)
|
|
1073
|
|
|
1087
|
|
|
1074
|
patchf.seek(0)
|
|
1088
|
patchf.seek(0)
|
|
1075
|
patchf.truncate()
|
|
1089
|
patchf.truncate()
|
|
1076
|
|
|
1090
|
|
|
1077
|
if comments:
|
|
1091
|
if comments:
|
|
1078
|
comments = "\n".join(comments) + '\n\n'
|
|
1092
|
comments = "\n".join(comments) + '\n\n'
|
|
1079
|
patchf.write(comments)
|
|
1093
|
patchf.write(comments)
|
|
1080
|
|
|
1094
|
|
|
1081
|
if opts.get('git'):
|
|
1095
|
if opts.get('git'):
|
|
1082
|
self.diffopts().git = True
|
|
1096
|
self.diffopts().git = True
|
|
1083
|
tip = repo.changelog.tip()
|
|
1097
|
tip = repo.changelog.tip()
|
|
1084
|
if top == tip:
|
|
1098
|
if top == tip:
|
|
1085
|
# if the top of our patch queue is also the tip, there is an
|
|
1099
|
# if the top of our patch queue is also the tip, there is an
|
|
1086
|
# optimization here. We update the dirstate in place and strip
|
|
1100
|
# optimization here. We update the dirstate in place and strip
|
|
1087
|
# off the tip commit. Then just commit the current directory
|
|
1101
|
# off the tip commit. Then just commit the current directory
|
|
1088
|
# tree. We can also send repo.commit the list of files
|
|
1102
|
# tree. We can also send repo.commit the list of files
|
|
1089
|
# changed to speed up the diff
|
|
1103
|
# changed to speed up the diff
|
|
1090
|
#
|
|
1104
|
#
|
|
1091
|
# in short mode, we only diff the files included in the
|
|
1105
|
# in short mode, we only diff the files included in the
|
|
1092
|
# patch already plus specified files
|
|
1106
|
# patch already plus specified files
|
|
1093
|
#
|
|
1107
|
#
|
|
1094
|
# this should really read:
|
|
1108
|
# this should really read:
|
|
1095
|
# mm, dd, aa, aa2 = repo.status(tip, patchparent)[:4]
|
|
1109
|
# mm, dd, aa, aa2 = repo.status(tip, patchparent)[:4]
|
|
1096
|
# but we do it backwards to take advantage of manifest/chlog
|
|
1110
|
# but we do it backwards to take advantage of manifest/chlog
|
|
1097
|
# caching against the next repo.status call
|
|
1111
|
# caching against the next repo.status call
|
|
1098
|
#
|
|
1112
|
#
|
|
1099
|
mm, aa, dd, aa2 = repo.status(patchparent, tip)[:4]
|
|
1113
|
mm, aa, dd, aa2 = repo.status(patchparent, tip)[:4]
|
|
1100
|
changes = repo.changelog.read(tip)
|
|
1114
|
changes = repo.changelog.read(tip)
|
|
1101
|
man = repo.manifest.read(changes[0])
|
|
1115
|
man = repo.manifest.read(changes[0])
|
|
1102
|
aaa = aa[:]
|
|
1116
|
aaa = aa[:]
|
|
1103
|
matchfn = cmdutil.match(repo, pats, opts)
|
|
1117
|
matchfn = cmdutil.match(repo, pats, opts)
|
|
1104
|
if opts.get('short'):
|
|
1118
|
if opts.get('short'):
|
|
1105
|
# if amending a patch, we start with existing
|
|
1119
|
# if amending a patch, we start with existing
|
|
1106
|
# files plus specified files - unfiltered
|
|
1120
|
# files plus specified files - unfiltered
|
|
1107
|
match = cmdutil.matchfiles(repo, mm + aa + dd + matchfn.files())
|
|
1121
|
match = cmdutil.matchfiles(repo, mm + aa + dd + matchfn.files())
|
|
1108
|
# filter with inc/exl options
|
|
1122
|
# filter with inc/exl options
|
|
1109
|
matchfn = cmdutil.match(repo, opts=opts)
|
|
1123
|
matchfn = cmdutil.match(repo, opts=opts)
|
|
1110
|
else:
|
|
1124
|
else:
|
|
1111
|
match = cmdutil.matchall(repo)
|
|
1125
|
match = cmdutil.matchall(repo)
|
|
1112
|
m, a, r, d = repo.status(match=match)[:4]
|
|
1126
|
m, a, r, d = repo.status(match=match)[:4]
|
|
1113
|
|
|
1127
|
|
|
1114
|
# we might end up with files that were added between
|
|
1128
|
# we might end up with files that were added between
|
|
1115
|
# tip and the dirstate parent, but then changed in the
|
|
1129
|
# tip and the dirstate parent, but then changed in the
|
|
1116
|
# local dirstate. in this case, we want them to only
|
|
1130
|
# local dirstate. in this case, we want them to only
|
|
1117
|
# show up in the added section
|
|
1131
|
# show up in the added section
|
|
1118
|
for x in m:
|
|
1132
|
for x in m:
|
|
1119
|
if x not in aa:
|
|
1133
|
if x not in aa:
|
|
1120
|
mm.append(x)
|
|
1134
|
mm.append(x)
|
|
1121
|
# we might end up with files added by the local dirstate that
|
|
1135
|
# we might end up with files added by the local dirstate that
|
|
1122
|
# were deleted by the patch. In this case, they should only
|
|
1136
|
# were deleted by the patch. In this case, they should only
|
|
1123
|
# show up in the changed section.
|
|
1137
|
# show up in the changed section.
|
|
1124
|
for x in a:
|
|
1138
|
for x in a:
|
|
1125
|
if x in dd:
|
|
1139
|
if x in dd:
|
|
1126
|
del dd[dd.index(x)]
|
|
1140
|
del dd[dd.index(x)]
|
|
1127
|
mm.append(x)
|
|
1141
|
mm.append(x)
|
|
1128
|
else:
|
|
1142
|
else:
|
|
1129
|
aa.append(x)
|
|
1143
|
aa.append(x)
|
|
1130
|
# make sure any files deleted in the local dirstate
|
|
1144
|
# make sure any files deleted in the local dirstate
|
|
1131
|
# are not in the add or change column of the patch
|
|
1145
|
# are not in the add or change column of the patch
|
|
1132
|
forget = []
|
|
1146
|
forget = []
|
|
1133
|
for x in d + r:
|
|
1147
|
for x in d + r:
|
|
1134
|
if x in aa:
|
|
1148
|
if x in aa:
|
|
1135
|
del aa[aa.index(x)]
|
|
1149
|
del aa[aa.index(x)]
|
|
1136
|
forget.append(x)
|
|
1150
|
forget.append(x)
|
|
1137
|
continue
|
|
1151
|
continue
|
|
1138
|
elif x in mm:
|
|
1152
|
elif x in mm:
|
|
1139
|
del mm[mm.index(x)]
|
|
1153
|
del mm[mm.index(x)]
|
|
1140
|
dd.append(x)
|
|
1154
|
dd.append(x)
|
|
1141
|
|
|
1155
|
|
|
1142
|
m = util.unique(mm)
|
|
1156
|
m = util.unique(mm)
|
|
1143
|
r = util.unique(dd)
|
|
1157
|
r = util.unique(dd)
|
|
1144
|
a = util.unique(aa)
|
|
1158
|
a = util.unique(aa)
|
|
1145
|
c = [filter(matchfn, l) for l in (m, a, r)]
|
|
1159
|
c = [filter(matchfn, l) for l in (m, a, r)]
|
|
1146
|
match = cmdutil.matchfiles(repo, util.unique(c[0] + c[1] + c[2]))
|
|
1160
|
match = cmdutil.matchfiles(repo, util.unique(c[0] + c[1] + c[2]))
|
|
1147
|
chunks = patch.diff(repo, patchparent, match=match,
|
|
1161
|
chunks = patch.diff(repo, patchparent, match=match,
|
|
1148
|
changes=c, opts=self.diffopts())
|
|
1162
|
changes=c, opts=self.diffopts())
|
|
1149
|
for chunk in chunks:
|
|
1163
|
for chunk in chunks:
|
|
1150
|
patchf.write(chunk)
|
|
1164
|
patchf.write(chunk)
|
|
1151
|
patchf.close()
|
|
1165
|
patchf.close()
|
|
1152
|
|
|
1166
|
|
|
1153
|
repo.dirstate.setparents(*cparents)
|
|
1167
|
repo.dirstate.setparents(*cparents)
|
|
1154
|
copies = {}
|
|
1168
|
copies = {}
|
|
1155
|
for dst in a:
|
|
1169
|
for dst in a:
|
|
1156
|
src = repo.dirstate.copied(dst)
|
|
1170
|
src = repo.dirstate.copied(dst)
|
|
1157
|
if src is not None:
|
|
1171
|
if src is not None:
|
|
1158
|
copies.setdefault(src, []).append(dst)
|
|
1172
|
copies.setdefault(src, []).append(dst)
|
|
1159
|
repo.dirstate.add(dst)
|
|
1173
|
repo.dirstate.add(dst)
|
|
1160
|
# remember the copies between patchparent and tip
|
|
1174
|
# remember the copies between patchparent and tip
|
|
1161
|
# this may be slow, so don't do it if we're not tracking copies
|
|
1175
|
# this may be slow, so don't do it if we're not tracking copies
|
|
1162
|
if self.diffopts().git:
|
|
1176
|
if self.diffopts().git:
|
|
1163
|
for dst in aaa:
|
|
1177
|
for dst in aaa:
|
|
1164
|
f = repo.file(dst)
|
|
1178
|
f = repo.file(dst)
|
|
1165
|
src = f.renamed(man[dst])
|
|
1179
|
src = f.renamed(man[dst])
|
|
1166
|
if src:
|
|
1180
|
if src:
|
|
1167
|
copies.setdefault(src[0], []).extend(copies.get(dst, []))
|
|
1181
|
copies.setdefault(src[0], []).extend(copies.get(dst, []))
|
|
1168
|
if dst in a:
|
|
1182
|
if dst in a:
|
|
1169
|
copies[src[0]].append(dst)
|
|
1183
|
copies[src[0]].append(dst)
|
|
1170
|
# we can't copy a file created by the patch itself
|
|
1184
|
# we can't copy a file created by the patch itself
|
|
1171
|
if dst in copies:
|
|
1185
|
if dst in copies:
|
|
1172
|
del copies[dst]
|
|
1186
|
del copies[dst]
|
|
1173
|
for src, dsts in copies.iteritems():
|
|
1187
|
for src, dsts in copies.iteritems():
|
|
1174
|
for dst in dsts:
|
|
1188
|
for dst in dsts:
|
|
1175
|
repo.dirstate.copy(src, dst)
|
|
1189
|
repo.dirstate.copy(src, dst)
|
|
1176
|
for f in r:
|
|
1190
|
for f in r:
|
|
1177
|
repo.dirstate.remove(f)
|
|
1191
|
repo.dirstate.remove(f)
|
|
1178
|
# if the patch excludes a modified file, mark that
|
|
1192
|
# if the patch excludes a modified file, mark that
|
|
1179
|
# file with mtime=0 so status can see it.
|
|
1193
|
# file with mtime=0 so status can see it.
|
|
1180
|
mm = []
|
|
1194
|
mm = []
|
|
1181
|
for i in xrange(len(m)-1, -1, -1):
|
|
1195
|
for i in xrange(len(m)-1, -1, -1):
|
|
1182
|
if not matchfn(m[i]):
|
|
1196
|
if not matchfn(m[i]):
|
|
1183
|
mm.append(m[i])
|
|
1197
|
mm.append(m[i])
|
|
1184
|
del m[i]
|
|
1198
|
del m[i]
|
|
1185
|
for f in m:
|
|
1199
|
for f in m:
|
|
1186
|
repo.dirstate.normal(f)
|
|
1200
|
repo.dirstate.normal(f)
|
|
1187
|
for f in mm:
|
|
1201
|
for f in mm:
|
|
1188
|
repo.dirstate.normallookup(f)
|
|
1202
|
repo.dirstate.normallookup(f)
|
|
1189
|
for f in forget:
|
|
1203
|
for f in forget:
|
|
1190
|
repo.dirstate.forget(f)
|
|
1204
|
repo.dirstate.forget(f)
|
|
1191
|
|
|
1205
|
|
|
1192
|
if not msg:
|
|
1206
|
if not msg:
|
|
1193
|
if not message:
|
|
1207
|
if not message:
|
|
1194
|
message = "[mq]: %s\n" % patchfn
|
|
1208
|
message = "[mq]: %s\n" % patchfn
|
|
1195
|
else:
|
|
1209
|
else:
|
|
1196
|
message = "\n".join(message)
|
|
1210
|
message = "\n".join(message)
|
|
1197
|
else:
|
|
1211
|
else:
|
|
1198
|
message = msg
|
|
1212
|
message = msg
|
|
1199
|
|
|
1213
|
|
|
1200
|
if not user:
|
|
1214
|
if not user:
|
|
1201
|
user = changes[1]
|
|
1215
|
user = changes[1]
|
|
1202
|
|
|
1216
|
|
|
1203
|
self.applied.pop()
|
|
1217
|
self.applied.pop()
|
|
1204
|
self.applied_dirty = 1
|
|
1218
|
self.applied_dirty = 1
|
|
1205
|
self.strip(repo, top, update=False,
|
|
1219
|
self.strip(repo, top, update=False,
|
|
1206
|
backup='strip')
|
|
1220
|
backup='strip')
|
|
1207
|
n = repo.commit(match.files(), message, user, date, match=match,
|
|
1221
|
n = repo.commit(match.files(), message, user, date, match=match,
|
|
1208
|
force=1)
|
|
1222
|
force=1)
|
|
1209
|
self.applied.append(statusentry(revlog.hex(n), patchfn))
|
|
1223
|
self.applied.append(statusentry(revlog.hex(n), patchfn))
|
|
1210
|
self.removeundo(repo)
|
|
1224
|
self.removeundo(repo)
|
|
1211
|
else:
|
|
1225
|
else:
|
|
1212
|
self.printdiff(repo, patchparent, fp=patchf)
|
|
1226
|
self.printdiff(repo, patchparent, fp=patchf)
|
|
1213
|
patchf.close()
|
|
1227
|
patchf.close()
|
|
1214
|
added = repo.status()[1]
|
|
1228
|
added = repo.status()[1]
|
|
1215
|
for a in added:
|
|
1229
|
for a in added:
|
|
1216
|
f = repo.wjoin(a)
|
|
1230
|
f = repo.wjoin(a)
|
|
1217
|
try:
|
|
1231
|
try:
|
|
1218
|
os.unlink(f)
|
|
1232
|
os.unlink(f)
|
|
1219
|
except OSError, e:
|
|
1233
|
except OSError, e:
|
|
1220
|
if e.errno != errno.ENOENT:
|
|
1234
|
if e.errno != errno.ENOENT:
|
|
1221
|
raise
|
|
1235
|
raise
|
|
1222
|
try: os.removedirs(os.path.dirname(f))
|
|
1236
|
try: os.removedirs(os.path.dirname(f))
|
|
1223
|
except: pass
|
|
1237
|
except: pass
|
|
1224
|
# forget the file copies in the dirstate
|
|
1238
|
# forget the file copies in the dirstate
|
|
1225
|
# push should readd the files later on
|
|
1239
|
# push should readd the files later on
|
|
1226
|
repo.dirstate.forget(a)
|
|
1240
|
repo.dirstate.forget(a)
|
|
1227
|
self.pop(repo, force=True)
|
|
1241
|
self.pop(repo, force=True)
|
|
1228
|
self.push(repo, force=True)
|
|
1242
|
self.push(repo, force=True)
|
|
1229
|
finally:
|
|
1243
|
finally:
|
|
1230
|
del wlock
|
|
1244
|
del wlock
|
|
1231
|
|
|
1245
|
|
|
1232
|
def init(self, repo, create=False):
|
|
1246
|
def init(self, repo, create=False):
|
|
1233
|
if not create and os.path.isdir(self.path):
|
|
1247
|
if not create and os.path.isdir(self.path):
|
|
1234
|
raise util.Abort(_("patch queue directory already exists"))
|
|
1248
|
raise util.Abort(_("patch queue directory already exists"))
|
|
1235
|
try:
|
|
1249
|
try:
|
|
1236
|
os.mkdir(self.path)
|
|
1250
|
os.mkdir(self.path)
|
|
1237
|
except OSError, inst:
|
|
1251
|
except OSError, inst:
|
|
1238
|
if inst.errno != errno.EEXIST or not create:
|
|
1252
|
if inst.errno != errno.EEXIST or not create:
|
|
1239
|
raise
|
|
1253
|
raise
|
|
1240
|
if create:
|
|
1254
|
if create:
|
|
1241
|
return self.qrepo(create=True)
|
|
1255
|
return self.qrepo(create=True)
|
|
1242
|
|
|
1256
|
|
|
1243
|
def unapplied(self, repo, patch=None):
|
|
1257
|
def unapplied(self, repo, patch=None):
|
|
1244
|
if patch and patch not in self.series:
|
|
1258
|
if patch and patch not in self.series:
|
|
1245
|
raise util.Abort(_("patch %s is not in series file") % patch)
|
|
1259
|
raise util.Abort(_("patch %s is not in series file") % patch)
|
|
1246
|
if not patch:
|
|
1260
|
if not patch:
|
|
1247
|
start = self.series_end()
|
|
1261
|
start = self.series_end()
|
|
1248
|
else:
|
|
1262
|
else:
|
|
1249
|
start = self.series.index(patch) + 1
|
|
1263
|
start = self.series.index(patch) + 1
|
|
1250
|
unapplied = []
|
|
1264
|
unapplied = []
|
|
1251
|
for i in xrange(start, len(self.series)):
|
|
1265
|
for i in xrange(start, len(self.series)):
|
|
1252
|
pushable, reason = self.pushable(i)
|
|
1266
|
pushable, reason = self.pushable(i)
|
|
1253
|
if pushable:
|
|
1267
|
if pushable:
|
|
1254
|
unapplied.append((i, self.series[i]))
|
|
1268
|
unapplied.append((i, self.series[i]))
|
|
1255
|
self.explain_pushable(i)
|
|
1269
|
self.explain_pushable(i)
|
|
1256
|
return unapplied
|
|
1270
|
return unapplied
|
|
1257
|
|
|
1271
|
|
|
1258
|
def qseries(self, repo, missing=None, start=0, length=None, status=None,
|
|
1272
|
def qseries(self, repo, missing=None, start=0, length=None, status=None,
|
|
1259
|
summary=False):
|
|
1273
|
summary=False):
|
|
1260
|
def displayname(patchname):
|
|
1274
|
def displayname(patchname):
|
|
1261
|
if summary:
|
|
1275
|
if summary:
|
|
1262
|
msg = self.readheaders(patchname)[0]
|
|
1276
|
msg = self.readheaders(patchname)[0]
|
|
1263
|
msg = msg and ': ' + msg[0] or ': '
|
|
1277
|
msg = msg and ': ' + msg[0] or ': '
|
|
1264
|
else:
|
|
1278
|
else:
|
|
1265
|
msg = ''
|
|
1279
|
msg = ''
|
|
1266
|
return '%s%s' % (patchname, msg)
|
|
1280
|
return '%s%s' % (patchname, msg)
|
|
1267
|
|
|
1281
|
|
|
1268
|
applied = dict.fromkeys([p.name for p in self.applied])
|
|
1282
|
applied = dict.fromkeys([p.name for p in self.applied])
|
|
1269
|
if length is None:
|
|
1283
|
if length is None:
|
|
1270
|
length = len(self.series) - start
|
|
1284
|
length = len(self.series) - start
|
|
1271
|
if not missing:
|
|
1285
|
if not missing:
|
|
1272
|
for i in xrange(start, start+length):
|
|
1286
|
for i in xrange(start, start+length):
|
|
1273
|
patch = self.series[i]
|
|
1287
|
patch = self.series[i]
|
|
1274
|
if patch in applied:
|
|
1288
|
if patch in applied:
|
|
1275
|
stat = 'A'
|
|
1289
|
stat = 'A'
|
|
1276
|
elif self.pushable(i)[0]:
|
|
1290
|
elif self.pushable(i)[0]:
|
|
1277
|
stat = 'U'
|
|
1291
|
stat = 'U'
|
|
1278
|
else:
|
|
1292
|
else:
|
|
1279
|
stat = 'G'
|
|
1293
|
stat = 'G'
|
|
1280
|
pfx = ''
|
|
1294
|
pfx = ''
|
|
1281
|
if self.ui.verbose:
|
|
1295
|
if self.ui.verbose:
|
|
1282
|
pfx = '%d %s ' % (i, stat)
|
|
1296
|
pfx = '%d %s ' % (i, stat)
|
|
1283
|
elif status and status != stat:
|
|
1297
|
elif status and status != stat:
|
|
1284
|
continue
|
|
1298
|
continue
|
|
1285
|
self.ui.write('%s%s\n' % (pfx, displayname(patch)))
|
|
1299
|
self.ui.write('%s%s\n' % (pfx, displayname(patch)))
|
|
1286
|
else:
|
|
1300
|
else:
|
|
1287
|
msng_list = []
|
|
1301
|
msng_list = []
|
|
1288
|
for root, dirs, files in os.walk(self.path):
|
|
1302
|
for root, dirs, files in os.walk(self.path):
|
|
1289
|
d = root[len(self.path) + 1:]
|
|
1303
|
d = root[len(self.path) + 1:]
|
|
1290
|
for f in files:
|
|
1304
|
for f in files:
|
|
1291
|
fl = os.path.join(d, f)
|
|
1305
|
fl = os.path.join(d, f)
|
|
1292
|
if (fl not in self.series and
|
|
1306
|
if (fl not in self.series and
|
|
1293
|
fl not in (self.status_path, self.series_path,
|
|
1307
|
fl not in (self.status_path, self.series_path,
|
|
1294
|
self.guards_path)
|
|
1308
|
self.guards_path)
|
|
1295
|
and not fl.startswith('.')):
|
|
1309
|
and not fl.startswith('.')):
|
|
1296
|
msng_list.append(fl)
|
|
1310
|
msng_list.append(fl)
|
|
1297
|
for x in util.sort(msng_list):
|
|
1311
|
for x in util.sort(msng_list):
|
|
1298
|
pfx = self.ui.verbose and ('D ') or ''
|
|
1312
|
pfx = self.ui.verbose and ('D ') or ''
|
|
1299
|
self.ui.write("%s%s\n" % (pfx, displayname(x)))
|
|
1313
|
self.ui.write("%s%s\n" % (pfx, displayname(x)))
|
|
1300
|
|
|
1314
|
|
|
1301
|
def issaveline(self, l):
|
|
1315
|
def issaveline(self, l):
|
|
1302
|
if l.name == '.hg.patches.save.line':
|
|
1316
|
if l.name == '.hg.patches.save.line':
|
|
1303
|
return True
|
|
1317
|
return True
|
|
1304
|
|
|
1318
|
|
|
1305
|
def qrepo(self, create=False):
|
|
1319
|
def qrepo(self, create=False):
|
|
1306
|
if create or os.path.isdir(self.join(".hg")):
|
|
1320
|
if create or os.path.isdir(self.join(".hg")):
|
|
1307
|
return hg.repository(self.ui, path=self.path, create=create)
|
|
1321
|
return hg.repository(self.ui, path=self.path, create=create)
|
|
1308
|
|
|
1322
|
|
|
1309
|
def restore(self, repo, rev, delete=None, qupdate=None):
|
|
1323
|
def restore(self, repo, rev, delete=None, qupdate=None):
|
|
1310
|
c = repo.changelog.read(rev)
|
|
1324
|
c = repo.changelog.read(rev)
|
|
1311
|
desc = c[4].strip()
|
|
1325
|
desc = c[4].strip()
|
|
1312
|
lines = desc.splitlines()
|
|
1326
|
lines = desc.splitlines()
|
|
1313
|
i = 0
|
|
1327
|
i = 0
|
|
1314
|
datastart = None
|
|
1328
|
datastart = None
|
|
1315
|
series = []
|
|
1329
|
series = []
|
|
1316
|
applied = []
|
|
1330
|
applied = []
|
|
1317
|
qpp = None
|
|
1331
|
qpp = None
|
|
1318
|
for i in xrange(0, len(lines)):
|
|
1332
|
for i in xrange(0, len(lines)):
|
|
1319
|
if lines[i] == 'Patch Data:':
|
|
1333
|
if lines[i] == 'Patch Data:':
|
|
1320
|
datastart = i + 1
|
|
1334
|
datastart = i + 1
|
|
1321
|
elif lines[i].startswith('Dirstate:'):
|
|
1335
|
elif lines[i].startswith('Dirstate:'):
|
|
1322
|
l = lines[i].rstrip()
|
|
1336
|
l = lines[i].rstrip()
|
|
1323
|
l = l[10:].split(' ')
|
|
1337
|
l = l[10:].split(' ')
|
|
1324
|
qpp = [ bin(x) for x in l ]
|
|
1338
|
qpp = [ bin(x) for x in l ]
|
|
1325
|
elif datastart != None:
|
|
1339
|
elif datastart != None:
|
|
1326
|
l = lines[i].rstrip()
|
|
1340
|
l = lines[i].rstrip()
|
|
1327
|
se = statusentry(l)
|
|
1341
|
se = statusentry(l)
|
|
1328
|
file_ = se.name
|
|
1342
|
file_ = se.name
|
|
1329
|
if se.rev:
|
|
1343
|
if se.rev:
|
|
1330
|
applied.append(se)
|
|
1344
|
applied.append(se)
|
|
1331
|
else:
|
|
1345
|
else:
|
|
1332
|
series.append(file_)
|
|
1346
|
series.append(file_)
|
|
1333
|
if datastart == None:
|
|
1347
|
if datastart == None:
|
|
1334
|
self.ui.warn(_("No saved patch data found\n"))
|
|
1348
|
self.ui.warn(_("No saved patch data found\n"))
|
|
1335
|
return 1
|
|
1349
|
return 1
|
|
1336
|
self.ui.warn(_("restoring status: %s\n") % lines[0])
|
|
1350
|
self.ui.warn(_("restoring status: %s\n") % lines[0])
|
|
1337
|
self.full_series = series
|
|
1351
|
self.full_series = series
|
|
1338
|
self.applied = applied
|
|
1352
|
self.applied = applied
|
|
1339
|
self.parse_series()
|
|
1353
|
self.parse_series()
|
|
1340
|
self.series_dirty = 1
|
|
1354
|
self.series_dirty = 1
|
|
1341
|
self.applied_dirty = 1
|
|
1355
|
self.applied_dirty = 1
|
|
1342
|
heads = repo.changelog.heads()
|
|
1356
|
heads = repo.changelog.heads()
|
|
1343
|
if delete:
|
|
1357
|
if delete:
|
|
1344
|
if rev not in heads:
|
|
1358
|
if rev not in heads:
|
|
1345
|
self.ui.warn(_("save entry has children, leaving it alone\n"))
|
|
1359
|
self.ui.warn(_("save entry has children, leaving it alone\n"))
|
|
1346
|
else:
|
|
1360
|
else:
|
|
1347
|
self.ui.warn(_("removing save entry %s\n") % short(rev))
|
|
1361
|
self.ui.warn(_("removing save entry %s\n") % short(rev))
|
|
1348
|
pp = repo.dirstate.parents()
|
|
1362
|
pp = repo.dirstate.parents()
|
|
1349
|
if rev in pp:
|
|
1363
|
if rev in pp:
|
|
1350
|
update = True
|
|
1364
|
update = True
|
|
1351
|
else:
|
|
1365
|
else:
|
|
1352
|
update = False
|
|
1366
|
update = False
|
|
1353
|
self.strip(repo, rev, update=update, backup='strip')
|
|
1367
|
self.strip(repo, rev, update=update, backup='strip')
|
|
1354
|
if qpp:
|
|
1368
|
if qpp:
|
|
1355
|
self.ui.warn(_("saved queue repository parents: %s %s\n") %
|
|
1369
|
self.ui.warn(_("saved queue repository parents: %s %s\n") %
|
|
1356
|
(short(qpp[0]), short(qpp[1])))
|
|
1370
|
(short(qpp[0]), short(qpp[1])))
|
|
1357
|
if qupdate:
|
|
1371
|
if qupdate:
|
|
1358
|
self.ui.status(_("queue directory updating\n"))
|
|
1372
|
self.ui.status(_("queue directory updating\n"))
|
|
1359
|
r = self.qrepo()
|
|
1373
|
r = self.qrepo()
|
|
1360
|
if not r:
|
|
1374
|
if not r:
|
|
1361
|
self.ui.warn(_("Unable to load queue repository\n"))
|
|
1375
|
self.ui.warn(_("Unable to load queue repository\n"))
|
|
1362
|
return 1
|
|
1376
|
return 1
|
|
1363
|
hg.clean(r, qpp[0])
|
|
1377
|
hg.clean(r, qpp[0])
|
|
1364
|
|
|
1378
|
|
|
1365
|
def save(self, repo, msg=None):
|
|
1379
|
def save(self, repo, msg=None):
|
|
1366
|
if len(self.applied) == 0:
|
|
1380
|
if len(self.applied) == 0:
|
|
1367
|
self.ui.warn(_("save: no patches applied, exiting\n"))
|
|
1381
|
self.ui.warn(_("save: no patches applied, exiting\n"))
|
|
1368
|
return 1
|
|
1382
|
return 1
|
|
1369
|
if self.issaveline(self.applied[-1]):
|
|
1383
|
if self.issaveline(self.applied[-1]):
|
|
1370
|
self.ui.warn(_("status is already saved\n"))
|
|
1384
|
self.ui.warn(_("status is already saved\n"))
|
|
1371
|
return 1
|
|
1385
|
return 1
|
|
1372
|
|
|
1386
|
|
|
1373
|
ar = [ ':' + x for x in self.full_series ]
|
|
1387
|
ar = [ ':' + x for x in self.full_series ]
|
|
1374
|
if not msg:
|
|
1388
|
if not msg:
|
|
1375
|
msg = _("hg patches saved state")
|
|
1389
|
msg = _("hg patches saved state")
|
|
1376
|
else:
|
|
1390
|
else:
|
|
1377
|
msg = "hg patches: " + msg.rstrip('\r\n')
|
|
1391
|
msg = "hg patches: " + msg.rstrip('\r\n')
|
|
1378
|
r = self.qrepo()
|
|
1392
|
r = self.qrepo()
|
|
1379
|
if r:
|
|
1393
|
if r:
|
|
1380
|
pp = r.dirstate.parents()
|
|
1394
|
pp = r.dirstate.parents()
|
|
1381
|
msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1]))
|
|
1395
|
msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1]))
|
|
1382
|
msg += "\n\nPatch Data:\n"
|
|
1396
|
msg += "\n\nPatch Data:\n"
|
|
1383
|
text = msg + "\n".join([str(x) for x in self.applied]) + '\n' + (ar and
|
|
1397
|
text = msg + "\n".join([str(x) for x in self.applied]) + '\n' + (ar and
|
|
1384
|
"\n".join(ar) + '\n' or "")
|
|
1398
|
"\n".join(ar) + '\n' or "")
|
|
1385
|
n = repo.commit(None, text, user=None, force=1)
|
|
1399
|
n = repo.commit(None, text, user=None, force=1)
|
|
1386
|
if not n:
|
|
1400
|
if not n:
|
|
1387
|
self.ui.warn(_("repo commit failed\n"))
|
|
1401
|
self.ui.warn(_("repo commit failed\n"))
|
|
1388
|
return 1
|
|
1402
|
return 1
|
|
1389
|
self.applied.append(statusentry(revlog.hex(n),'.hg.patches.save.line'))
|
|
1403
|
self.applied.append(statusentry(revlog.hex(n),'.hg.patches.save.line'))
|
|
1390
|
self.applied_dirty = 1
|
|
1404
|
self.applied_dirty = 1
|
|
1391
|
self.removeundo(repo)
|
|
1405
|
self.removeundo(repo)
|
|
1392
|
|
|
1406
|
|
|
1393
|
def full_series_end(self):
|
|
1407
|
def full_series_end(self):
|
|
1394
|
if len(self.applied) > 0:
|
|
1408
|
if len(self.applied) > 0:
|
|
1395
|
p = self.applied[-1].name
|
|
1409
|
p = self.applied[-1].name
|
|
1396
|
end = self.find_series(p)
|
|
1410
|
end = self.find_series(p)
|
|
1397
|
if end == None:
|
|
1411
|
if end == None:
|
|
1398
|
return len(self.full_series)
|
|
1412
|
return len(self.full_series)
|
|
1399
|
return end + 1
|
|
1413
|
return end + 1
|
|
1400
|
return 0
|
|
1414
|
return 0
|
|
1401
|
|
|
1415
|
|
|
1402
|
def series_end(self, all_patches=False):
|
|
1416
|
def series_end(self, all_patches=False):
|
|
1403
|
"""If all_patches is False, return the index of the next pushable patch
|
|
1417
|
"""If all_patches is False, return the index of the next pushable patch
|
|
1404
|
in the series, or the series length. If all_patches is True, return the
|
|
1418
|
in the series, or the series length. If all_patches is True, return the
|
|
1405
|
index of the first patch past the last applied one.
|
|
1419
|
index of the first patch past the last applied one.
|
|
1406
|
"""
|
|
1420
|
"""
|
|
1407
|
end = 0
|
|
1421
|
end = 0
|
|
1408
|
def next(start):
|
|
1422
|
def next(start):
|
|
1409
|
if all_patches:
|
|
1423
|
if all_patches:
|
|
1410
|
return start
|
|
1424
|
return start
|
|
1411
|
i = start
|
|
1425
|
i = start
|
|
1412
|
while i < len(self.series):
|
|
1426
|
while i < len(self.series):
|
|
1413
|
p, reason = self.pushable(i)
|
|
1427
|
p, reason = self.pushable(i)
|
|
1414
|
if p:
|
|
1428
|
if p:
|
|
1415
|
break
|
|
1429
|
break
|
|
1416
|
self.explain_pushable(i)
|
|
1430
|
self.explain_pushable(i)
|
|
1417
|
i += 1
|
|
1431
|
i += 1
|
|
1418
|
return i
|
|
1432
|
return i
|
|
1419
|
if len(self.applied) > 0:
|
|
1433
|
if len(self.applied) > 0:
|
|
1420
|
p = self.applied[-1].name
|
|
1434
|
p = self.applied[-1].name
|
|
1421
|
try:
|
|
1435
|
try:
|
|
1422
|
end = self.series.index(p)
|
|
1436
|
end = self.series.index(p)
|
|
1423
|
except ValueError:
|
|
1437
|
except ValueError:
|
|
1424
|
return 0
|
|
1438
|
return 0
|
|
1425
|
return next(end + 1)
|
|
1439
|
return next(end + 1)
|
|
1426
|
return next(end)
|
|
1440
|
return next(end)
|
|
1427
|
|
|
1441
|
|
|
1428
|
def appliedname(self, index):
|
|
1442
|
def appliedname(self, index):
|
|
1429
|
pname = self.applied[index].name
|
|
1443
|
pname = self.applied[index].name
|
|
1430
|
if not self.ui.verbose:
|
|
1444
|
if not self.ui.verbose:
|
|
1431
|
p = pname
|
|
1445
|
p = pname
|
|
1432
|
else:
|
|
1446
|
else:
|
|
1433
|
p = str(self.series.index(pname)) + " " + pname
|
|
1447
|
p = str(self.series.index(pname)) + " " + pname
|
|
1434
|
return p
|
|
1448
|
return p
|
|
1435
|
|
|
1449
|
|
|
1436
|
def qimport(self, repo, files, patchname=None, rev=None, existing=None,
|
|
1450
|
def qimport(self, repo, files, patchname=None, rev=None, existing=None,
|
|
1437
|
force=None, git=False):
|
|
1451
|
force=None, git=False):
|
|
1438
|
def checkseries(patchname):
|
|
1452
|
def checkseries(patchname):
|
|
1439
|
if patchname in self.series:
|
|
1453
|
if patchname in self.series:
|
|
1440
|
raise util.Abort(_('patch %s is already in the series file')
|
|
1454
|
raise util.Abort(_('patch %s is already in the series file')
|
|
1441
|
% patchname)
|
|
1455
|
% patchname)
|
|
1442
|
def checkfile(patchname):
|
|
1456
|
def checkfile(patchname):
|
|
1443
|
if not force and os.path.exists(self.join(patchname)):
|
|
1457
|
if not force and os.path.exists(self.join(patchname)):
|
|
1444
|
raise util.Abort(_('patch "%s" already exists')
|
|
1458
|
raise util.Abort(_('patch "%s" already exists')
|
|
1445
|
% patchname)
|
|
1459
|
% patchname)
|
|
1446
|
|
|
1460
|
|
|
1447
|
if rev:
|
|
1461
|
if rev:
|
|
1448
|
if files:
|
|
1462
|
if files:
|
|
1449
|
raise util.Abort(_('option "-r" not valid when importing '
|
|
1463
|
raise util.Abort(_('option "-r" not valid when importing '
|
|
1450
|
'files'))
|
|
1464
|
'files'))
|
|
1451
|
rev = cmdutil.revrange(repo, rev)
|
|
1465
|
rev = cmdutil.revrange(repo, rev)
|
|
1452
|
rev.sort(lambda x, y: cmp(y, x))
|
|
1466
|
rev.sort(lambda x, y: cmp(y, x))
|
|
1453
|
if (len(files) > 1 or len(rev) > 1) and patchname:
|
|
1467
|
if (len(files) > 1 or len(rev) > 1) and patchname:
|
|
1454
|
raise util.Abort(_('option "-n" not valid when importing multiple '
|
|
1468
|
raise util.Abort(_('option "-n" not valid when importing multiple '
|
|
1455
|
'patches'))
|
|
1469
|
'patches'))
|
|
1456
|
i = 0
|
|
1470
|
i = 0
|
|
1457
|
added = []
|
|
1471
|
added = []
|
|
1458
|
if rev:
|
|
1472
|
if rev:
|
|
1459
|
# If mq patches are applied, we can only import revisions
|
|
1473
|
# If mq patches are applied, we can only import revisions
|
|
1460
|
# that form a linear path to qbase.
|
|
1474
|
# that form a linear path to qbase.
|
|
1461
|
# Otherwise, they should form a linear path to a head.
|
|
1475
|
# Otherwise, they should form a linear path to a head.
|
|
1462
|
heads = repo.changelog.heads(repo.changelog.node(rev[-1]))
|
|
1476
|
heads = repo.changelog.heads(repo.changelog.node(rev[-1]))
|
|
1463
|
if len(heads) > 1:
|
|
1477
|
if len(heads) > 1:
|
|
1464
|
raise util.Abort(_('revision %d is the root of more than one '
|
|
1478
|
raise util.Abort(_('revision %d is the root of more than one '
|
|
1465
|
'branch') % rev[-1])
|
|
1479
|
'branch') % rev[-1])
|
|
1466
|
if self.applied:
|
|
1480
|
if self.applied:
|
|
1467
|
base = revlog.hex(repo.changelog.node(rev[0]))
|
|
1481
|
base = revlog.hex(repo.changelog.node(rev[0]))
|
|
1468
|
if base in [n.rev for n in self.applied]:
|
|
1482
|
if base in [n.rev for n in self.applied]:
|
|
1469
|
raise util.Abort(_('revision %d is already managed')
|
|
1483
|
raise util.Abort(_('revision %d is already managed')
|
|
1470
|
% rev[0])
|
|
1484
|
% rev[0])
|
|
1471
|
if heads != [revlog.bin(self.applied[-1].rev)]:
|
|
1485
|
if heads != [revlog.bin(self.applied[-1].rev)]:
|
|
1472
|
raise util.Abort(_('revision %d is not the parent of '
|
|
1486
|
raise util.Abort(_('revision %d is not the parent of '
|
|
1473
|
'the queue') % rev[0])
|
|
1487
|
'the queue') % rev[0])
|
|
1474
|
base = repo.changelog.rev(revlog.bin(self.applied[0].rev))
|
|
1488
|
base = repo.changelog.rev(revlog.bin(self.applied[0].rev))
|
|
1475
|
lastparent = repo.changelog.parentrevs(base)[0]
|
|
1489
|
lastparent = repo.changelog.parentrevs(base)[0]
|
|
1476
|
else:
|
|
1490
|
else:
|
|
1477
|
if heads != [repo.changelog.node(rev[0])]:
|
|
1491
|
if heads != [repo.changelog.node(rev[0])]:
|
|
1478
|
raise util.Abort(_('revision %d has unmanaged children')
|
|
1492
|
raise util.Abort(_('revision %d has unmanaged children')
|
|
1479
|
% rev[0])
|
|
1493
|
% rev[0])
|
|
1480
|
lastparent = None
|
|
1494
|
lastparent = None
|
|
1481
|
|
|
1495
|
|
|
1482
|
if git:
|
|
1496
|
if git:
|
|
1483
|
self.diffopts().git = True
|
|
1497
|
self.diffopts().git = True
|
|
1484
|
|
|
1498
|
|
|
1485
|
for r in rev:
|
|
1499
|
for r in rev:
|
|
1486
|
p1, p2 = repo.changelog.parentrevs(r)
|
|
1500
|
p1, p2 = repo.changelog.parentrevs(r)
|
|
1487
|
n = repo.changelog.node(r)
|
|
1501
|
n = repo.changelog.node(r)
|
|
1488
|
if p2 != revlog.nullrev:
|
|
1502
|
if p2 != revlog.nullrev:
|
|
1489
|
raise util.Abort(_('cannot import merge revision %d') % r)
|
|
1503
|
raise util.Abort(_('cannot import merge revision %d') % r)
|
|
1490
|
if lastparent and lastparent != r:
|
|
1504
|
if lastparent and lastparent != r:
|
|
1491
|
raise util.Abort(_('revision %d is not the parent of %d')
|
|
1505
|
raise util.Abort(_('revision %d is not the parent of %d')
|
|
1492
|
% (r, lastparent))
|
|
1506
|
% (r, lastparent))
|
|
1493
|
lastparent = p1
|
|
1507
|
lastparent = p1
|
|
1494
|
|
|
1508
|
|
|
1495
|
if not patchname:
|
|
1509
|
if not patchname:
|
|
1496
|
patchname = normname('%d.diff' % r)
|
|
1510
|
patchname = normname('%d.diff' % r)
|
|
1497
|
self.check_reserved_name(patchname)
|
|
1511
|
self.check_reserved_name(patchname)
|
|
1498
|
checkseries(patchname)
|
|
1512
|
checkseries(patchname)
|
|
1499
|
checkfile(patchname)
|
|
1513
|
checkfile(patchname)
|
|
1500
|
self.full_series.insert(0, patchname)
|
|
1514
|
self.full_series.insert(0, patchname)
|
|
1501
|
|
|
1515
|
|
|
1502
|
patchf = self.opener(patchname, "w")
|
|
1516
|
patchf = self.opener(patchname, "w")
|
|
1503
|
patch.export(repo, [n], fp=patchf, opts=self.diffopts())
|
|
1517
|
patch.export(repo, [n], fp=patchf, opts=self.diffopts())
|
|
1504
|
patchf.close()
|
|
1518
|
patchf.close()
|
|
1505
|
|
|
1519
|
|
|
1506
|
se = statusentry(revlog.hex(n), patchname)
|
|
1520
|
se = statusentry(revlog.hex(n), patchname)
|
|
1507
|
self.applied.insert(0, se)
|
|
1521
|
self.applied.insert(0, se)
|
|
1508
|
|
|
1522
|
|
|
1509
|
added.append(patchname)
|
|
1523
|
added.append(patchname)
|
|
1510
|
patchname = None
|
|
1524
|
patchname = None
|
|
1511
|
self.parse_series()
|
|
1525
|
self.parse_series()
|
|
1512
|
self.applied_dirty = 1
|
|
1526
|
self.applied_dirty = 1
|
|
1513
|
|
|
1527
|
|
|
1514
|
for filename in files:
|
|
1528
|
for filename in files:
|
|
1515
|
if existing:
|
|
1529
|
if existing:
|
|
1516
|
if filename == '-':
|
|
1530
|
if filename == '-':
|
|
1517
|
raise util.Abort(_('-e is incompatible with import from -'))
|
|
1531
|
raise util.Abort(_('-e is incompatible with import from -'))
|
|
1518
|
if not patchname:
|
|
1532
|
if not patchname:
|
|
1519
|
patchname = normname(filename)
|
|
1533
|
patchname = normname(filename)
|
|
1520
|
self.check_reserved_name(patchname)
|
|
1534
|
self.check_reserved_name(patchname)
|
|
1521
|
if not os.path.isfile(self.join(patchname)):
|
|
1535
|
if not os.path.isfile(self.join(patchname)):
|
|
1522
|
raise util.Abort(_("patch %s does not exist") % patchname)
|
|
1536
|
raise util.Abort(_("patch %s does not exist") % patchname)
|
|
1523
|
else:
|
|
1537
|
else:
|
|
1524
|
try:
|
|
1538
|
try:
|
|
1525
|
if filename == '-':
|
|
1539
|
if filename == '-':
|
|
1526
|
if not patchname:
|
|
1540
|
if not patchname:
|
|
1527
|
raise util.Abort(_('need --name to import a patch from -'))
|
|
1541
|
raise util.Abort(_('need --name to import a patch from -'))
|
|
1528
|
text = sys.stdin.read()
|
|
1542
|
text = sys.stdin.read()
|
|
1529
|
else:
|
|
1543
|
else:
|
|
1530
|
text = url.open(self.ui, filename).read()
|
|
1544
|
text = url.open(self.ui, filename).read()
|
|
1531
|
except IOError:
|
|
1545
|
except IOError:
|
|
1532
|
raise util.Abort(_("unable to read %s") % filename)
|
|
1546
|
raise util.Abort(_("unable to read %s") % filename)
|
|
1533
|
if not patchname:
|
|
1547
|
if not patchname:
|
|
1534
|
patchname = normname(os.path.basename(filename))
|
|
1548
|
patchname = normname(os.path.basename(filename))
|
|
1535
|
self.check_reserved_name(patchname)
|
|
1549
|
self.check_reserved_name(patchname)
|
|
1536
|
checkfile(patchname)
|
|
1550
|
checkfile(patchname)
|
|
1537
|
patchf = self.opener(patchname, "w")
|
|
1551
|
patchf = self.opener(patchname, "w")
|
|
1538
|
patchf.write(text)
|
|
1552
|
patchf.write(text)
|
|
1539
|
if not force:
|
|
1553
|
if not force:
|
|
1540
|
checkseries(patchname)
|
|
1554
|
checkseries(patchname)
|
|
1541
|
if patchname not in self.series:
|
|
1555
|
if patchname not in self.series:
|
|
1542
|
index = self.full_series_end() + i
|
|
1556
|
index = self.full_series_end() + i
|
|
1543
|
self.full_series[index:index] = [patchname]
|
|
1557
|
self.full_series[index:index] = [patchname]
|
|
1544
|
self.parse_series()
|
|
1558
|
self.parse_series()
|
|
1545
|
self.ui.warn("adding %s to series file\n" % patchname)
|
|
1559
|
self.ui.warn("adding %s to series file\n" % patchname)
|
|
1546
|
i += 1
|
|
1560
|
i += 1
|
|
1547
|
added.append(patchname)
|
|
1561
|
added.append(patchname)
|
|
1548
|
patchname = None
|
|
1562
|
patchname = None
|
|
1549
|
self.series_dirty = 1
|
|
1563
|
self.series_dirty = 1
|
|
1550
|
qrepo = self.qrepo()
|
|
1564
|
qrepo = self.qrepo()
|
|
1551
|
if qrepo:
|
|
1565
|
if qrepo:
|
|
1552
|
qrepo.add(added)
|
|
1566
|
qrepo.add(added)
|
|
1553
|
|
|
1567
|
|
|
1554
|
def delete(ui, repo, *patches, **opts):
|
|
1568
|
def delete(ui, repo, *patches, **opts):
|
|
1555
|
"""remove patches from queue
|
|
1569
|
"""remove patches from queue
|
|
1556
|
|
|
1570
|
|
|
1557
|
The patches must not be applied, unless they are arguments to
|
|
1571
|
The patches must not be applied, unless they are arguments to
|
|
1558
|
the --rev parameter. At least one patch or revision is required.
|
|
1572
|
the --rev parameter. At least one patch or revision is required.
|
|
1559
|
|
|
1573
|
|
|
1560
|
With --rev, mq will stop managing the named revisions (converting
|
|
1574
|
With --rev, mq will stop managing the named revisions (converting
|
|
1561
|
them to regular mercurial changesets). The qfinish command should be
|
|
1575
|
them to regular mercurial changesets). The qfinish command should be
|
|
1562
|
used as an alternative for qdel -r, as the latter option is deprecated.
|
|
1576
|
used as an alternative for qdel -r, as the latter option is deprecated.
|
|
1563
|
|
|
1577
|
|
|
1564
|
With --keep, the patch files are preserved in the patch directory."""
|
|
1578
|
With --keep, the patch files are preserved in the patch directory."""
|
|
1565
|
q = repo.mq
|
|
1579
|
q = repo.mq
|
|
1566
|
q.delete(repo, patches, opts)
|
|
1580
|
q.delete(repo, patches, opts)
|
|
1567
|
q.save_dirty()
|
|
1581
|
q.save_dirty()
|
|
1568
|
return 0
|
|
1582
|
return 0
|
|
1569
|
|
|
1583
|
|
|
1570
|
def applied(ui, repo, patch=None, **opts):
|
|
1584
|
def applied(ui, repo, patch=None, **opts):
|
|
1571
|
"""print the patches already applied"""
|
|
1585
|
"""print the patches already applied"""
|
|
1572
|
q = repo.mq
|
|
1586
|
q = repo.mq
|
|
1573
|
if patch:
|
|
1587
|
if patch:
|
|
1574
|
if patch not in q.series:
|
|
1588
|
if patch not in q.series:
|
|
1575
|
raise util.Abort(_("patch %s is not in series file") % patch)
|
|
1589
|
raise util.Abort(_("patch %s is not in series file") % patch)
|
|
1576
|
end = q.series.index(patch) + 1
|
|
1590
|
end = q.series.index(patch) + 1
|
|
1577
|
else:
|
|
1591
|
else:
|
|
1578
|
end = q.series_end(True)
|
|
1592
|
end = q.series_end(True)
|
|
1579
|
return q.qseries(repo, length=end, status='A', summary=opts.get('summary'))
|
|
1593
|
return q.qseries(repo, length=end, status='A', summary=opts.get('summary'))
|
|
1580
|
|
|
1594
|
|
|
1581
|
def unapplied(ui, repo, patch=None, **opts):
|
|
1595
|
def unapplied(ui, repo, patch=None, **opts):
|
|
1582
|
"""print the patches not yet applied"""
|
|
1596
|
"""print the patches not yet applied"""
|
|
1583
|
q = repo.mq
|
|
1597
|
q = repo.mq
|
|
1584
|
if patch:
|
|
1598
|
if patch:
|
|
1585
|
if patch not in q.series:
|
|
1599
|
if patch not in q.series:
|
|
1586
|
raise util.Abort(_("patch %s is not in series file") % patch)
|
|
1600
|
raise util.Abort(_("patch %s is not in series file") % patch)
|
|
1587
|
start = q.series.index(patch) + 1
|
|
1601
|
start = q.series.index(patch) + 1
|
|
1588
|
else:
|
|
1602
|
else:
|
|
1589
|
start = q.series_end(True)
|
|
1603
|
start = q.series_end(True)
|
|
1590
|
q.qseries(repo, start=start, status='U', summary=opts.get('summary'))
|
|
1604
|
q.qseries(repo, start=start, status='U', summary=opts.get('summary'))
|
|
1591
|
|
|
1605
|
|
|
1592
|
def qimport(ui, repo, *filename, **opts):
|
|
1606
|
def qimport(ui, repo, *filename, **opts):
|
|
1593
|
"""import a patch
|
|
1607
|
"""import a patch
|
|
1594
|
|
|
1608
|
|
|
1595
|
The patch is inserted into the series after the last applied patch.
|
|
1609
|
The patch is inserted into the series after the last applied patch.
|
|
1596
|
If no patches have been applied, qimport prepends the patch
|
|
1610
|
If no patches have been applied, qimport prepends the patch
|
|
1597
|
to the series.
|
|
1611
|
to the series.
|
|
1598
|
|
|
1612
|
|
|
1599
|
The patch will have the same name as its source file unless you
|
|
1613
|
The patch will have the same name as its source file unless you
|
|
1600
|
give it a new one with --name.
|
|
1614
|
give it a new one with --name.
|
|
1601
|
|
|
1615
|
|
|
1602
|
You can register an existing patch inside the patch directory
|
|
1616
|
You can register an existing patch inside the patch directory
|
|
1603
|
with the --existing flag.
|
|
1617
|
with the --existing flag.
|
|
1604
|
|
|
1618
|
|
|
1605
|
With --force, an existing patch of the same name will be overwritten.
|
|
1619
|
With --force, an existing patch of the same name will be overwritten.
|
|
1606
|
|
|
1620
|
|
|
1607
|
An existing changeset may be placed under mq control with --rev
|
|
1621
|
An existing changeset may be placed under mq control with --rev
|
|
1608
|
(e.g. qimport --rev tip -n patch will place tip under mq control).
|
|
1622
|
(e.g. qimport --rev tip -n patch will place tip under mq control).
|
|
1609
|
With --git, patches imported with --rev will use the git diff
|
|
1623
|
With --git, patches imported with --rev will use the git diff
|
|
1610
|
format. See the gitdiffs help topic for information on why this is
|
|
1624
|
format. See the gitdiffs help topic for information on why this is
|
|
1611
|
important for preserving rename/copy information and permission changes.
|
|
1625
|
important for preserving rename/copy information and permission changes.
|
|
1612
|
"""
|
|
1626
|
"""
|
|
1613
|
q = repo.mq
|
|
1627
|
q = repo.mq
|
|
1614
|
q.qimport(repo, filename, patchname=opts['name'],
|
|
1628
|
q.qimport(repo, filename, patchname=opts['name'],
|
|
1615
|
existing=opts['existing'], force=opts['force'], rev=opts['rev'],
|
|
1629
|
existing=opts['existing'], force=opts['force'], rev=opts['rev'],
|
|
1616
|
git=opts['git'])
|
|
1630
|
git=opts['git'])
|
|
1617
|
q.save_dirty()
|
|
1631
|
q.save_dirty()
|
|
1618
|
return 0
|
|
1632
|
return 0
|
|
1619
|
|
|
1633
|
|
|
1620
|
def init(ui, repo, **opts):
|
|
1634
|
def init(ui, repo, **opts):
|
|
1621
|
"""init a new queue repository
|
|
1635
|
"""init a new queue repository
|
|
1622
|
|
|
1636
|
|
|
1623
|
The queue repository is unversioned by default. If -c is
|
|
1637
|
The queue repository is unversioned by default. If -c is
|
|
1624
|
specified, qinit will create a separate nested repository
|
|
1638
|
specified, qinit will create a separate nested repository
|
|
1625
|
for patches (qinit -c may also be run later to convert
|
|
1639
|
for patches (qinit -c may also be run later to convert
|
|
1626
|
an unversioned patch repository into a versioned one).
|
|
1640
|
an unversioned patch repository into a versioned one).
|
|
1627
|
You can use qcommit to commit changes to this queue repository."""
|
|
1641
|
You can use qcommit to commit changes to this queue repository."""
|
|
1628
|
q = repo.mq
|
|
1642
|
q = repo.mq
|
|
1629
|
r = q.init(repo, create=opts['create_repo'])
|
|
1643
|
r = q.init(repo, create=opts['create_repo'])
|
|
1630
|
q.save_dirty()
|
|
1644
|
q.save_dirty()
|
|
1631
|
if r:
|
|
1645
|
if r:
|
|
1632
|
if not os.path.exists(r.wjoin('.hgignore')):
|
|
1646
|
if not os.path.exists(r.wjoin('.hgignore')):
|
|
1633
|
fp = r.wopener('.hgignore', 'w')
|
|
1647
|
fp = r.wopener('.hgignore', 'w')
|
|
1634
|
fp.write('^\\.hg\n')
|
|
1648
|
fp.write('^\\.hg\n')
|
|
1635
|
fp.write('^\\.mq\n')
|
|
1649
|
fp.write('^\\.mq\n')
|
|
1636
|
fp.write('syntax: glob\n')
|
|
1650
|
fp.write('syntax: glob\n')
|
|
1637
|
fp.write('status\n')
|
|
1651
|
fp.write('status\n')
|
|
1638
|
fp.write('guards\n')
|
|
1652
|
fp.write('guards\n')
|
|
1639
|
fp.close()
|
|
1653
|
fp.close()
|
|
1640
|
if not os.path.exists(r.wjoin('series')):
|
|
1654
|
if not os.path.exists(r.wjoin('series')):
|
|
1641
|
r.wopener('series', 'w').close()
|
|
1655
|
r.wopener('series', 'w').close()
|
|
1642
|
r.add(['.hgignore', 'series'])
|
|
1656
|
r.add(['.hgignore', 'series'])
|
|
1643
|
commands.add(ui, r)
|
|
1657
|
commands.add(ui, r)
|
|
1644
|
return 0
|
|
1658
|
return 0
|
|
1645
|
|
|
1659
|
|
|
1646
|
def clone(ui, source, dest=None, **opts):
|
|
1660
|
def clone(ui, source, dest=None, **opts):
|
|
1647
|
'''clone main and patch repository at same time
|
|
1661
|
'''clone main and patch repository at same time
|
|
1648
|
|
|
1662
|
|
|
1649
|
If source is local, destination will have no patches applied. If
|
|
1663
|
If source is local, destination will have no patches applied. If
|
|
1650
|
source is remote, this command can not check if patches are
|
|
1664
|
source is remote, this command can not check if patches are
|
|
1651
|
applied in source, so cannot guarantee that patches are not
|
|
1665
|
applied in source, so cannot guarantee that patches are not
|
|
1652
|
applied in destination. If you clone remote repository, be sure
|
|
1666
|
applied in destination. If you clone remote repository, be sure
|
|
1653
|
before that it has no patches applied.
|
|
1667
|
before that it has no patches applied.
|
|
1654
|
|
|
1668
|
|
|
1655
|
Source patch repository is looked for in <src>/.hg/patches by
|
|
1669
|
Source patch repository is looked for in <src>/.hg/patches by
|
|
1656
|
default. Use -p <url> to change.
|
|
1670
|
default. Use -p <url> to change.
|
|
1657
|
|
|
1671
|
|
|
1658
|
The patch directory must be a nested mercurial repository, as
|
|
1672
|
The patch directory must be a nested mercurial repository, as
|
|
1659
|
would be created by qinit -c.
|
|
1673
|
would be created by qinit -c.
|
|
1660
|
'''
|
|
1674
|
'''
|
|
1661
|
def patchdir(repo):
|
|
1675
|
def patchdir(repo):
|
|
1662
|
url = repo.url()
|
|
1676
|
url = repo.url()
|
|
1663
|
if url.endswith('/'):
|
|
1677
|
if url.endswith('/'):
|
|
1664
|
url = url[:-1]
|
|
1678
|
url = url[:-1]
|
|
1665
|
return url + '/.hg/patches'
|
|
1679
|
return url + '/.hg/patches'
|
|
1666
|
cmdutil.setremoteconfig(ui, opts)
|
|
1680
|
cmdutil.setremoteconfig(ui, opts)
|
|
1667
|
if dest is None:
|
|
1681
|
if dest is None:
|
|
1668
|
dest = hg.defaultdest(source)
|
|
1682
|
dest = hg.defaultdest(source)
|
|
1669
|
sr = hg.repository(ui, ui.expandpath(source))
|
|
1683
|
sr = hg.repository(ui, ui.expandpath(source))
|
|
1670
|
patchespath = opts['patches'] or patchdir(sr)
|
|
1684
|
patchespath = opts['patches'] or patchdir(sr)
|
|
1671
|
try:
|
|
1685
|
try:
|
|
1672
|
pr = hg.repository(ui, patchespath)
|
|
1686
|
pr = hg.repository(ui, patchespath)
|
|
1673
|
except RepoError:
|
|
1687
|
except RepoError:
|
|
1674
|
raise util.Abort(_('versioned patch repository not found'
|
|
1688
|
raise util.Abort(_('versioned patch repository not found'
|
|
1675
|
' (see qinit -c)'))
|
|
1689
|
' (see qinit -c)'))
|
|
1676
|
qbase, destrev = None, None
|
|
1690
|
qbase, destrev = None, None
|
|
1677
|
if sr.local():
|
|
1691
|
if sr.local():
|
|
1678
|
if sr.mq.applied:
|
|
1692
|
if sr.mq.applied:
|
|
1679
|
qbase = revlog.bin(sr.mq.applied[0].rev)
|
|
1693
|
qbase = revlog.bin(sr.mq.applied[0].rev)
|
|
1680
|
if not hg.islocal(dest):
|
|
1694
|
if not hg.islocal(dest):
|
|
1681
|
heads = dict.fromkeys(sr.heads())
|
|
1695
|
heads = dict.fromkeys(sr.heads())
|
|
1682
|
for h in sr.heads(qbase):
|
|
1696
|
for h in sr.heads(qbase):
|
|
1683
|
del heads[h]
|
|
1697
|
del heads[h]
|
|
1684
|
destrev = heads.keys()
|
|
1698
|
destrev = heads.keys()
|
|
1685
|
destrev.append(sr.changelog.parents(qbase)[0])
|
|
1699
|
destrev.append(sr.changelog.parents(qbase)[0])
|
|
1686
|
elif sr.capable('lookup'):
|
|
1700
|
elif sr.capable('lookup'):
|
|
1687
|
try:
|
|
1701
|
try:
|
|
1688
|
qbase = sr.lookup('qbase')
|
|
1702
|
qbase = sr.lookup('qbase')
|
|
1689
|
except RepoError:
|
|
1703
|
except RepoError:
|
|
1690
|
pass
|
|
1704
|
pass
|
|
1691
|
ui.note(_('cloning main repo\n'))
|
|
1705
|
ui.note(_('cloning main repo\n'))
|
|
1692
|
sr, dr = hg.clone(ui, sr.url(), dest,
|
|
1706
|
sr, dr = hg.clone(ui, sr.url(), dest,
|
|
1693
|
pull=opts['pull'],
|
|
1707
|
pull=opts['pull'],
|
|
1694
|
rev=destrev,
|
|
1708
|
rev=destrev,
|
|
1695
|
update=False,
|
|
1709
|
update=False,
|
|
1696
|
stream=opts['uncompressed'])
|
|
1710
|
stream=opts['uncompressed'])
|
|
1697
|
ui.note(_('cloning patch repo\n'))
|
|
1711
|
ui.note(_('cloning patch repo\n'))
|
|
1698
|
spr, dpr = hg.clone(ui, opts['patches'] or patchdir(sr), patchdir(dr),
|
|
1712
|
spr, dpr = hg.clone(ui, opts['patches'] or patchdir(sr), patchdir(dr),
|
|
1699
|
pull=opts['pull'], update=not opts['noupdate'],
|
|
1713
|
pull=opts['pull'], update=not opts['noupdate'],
|
|
1700
|
stream=opts['uncompressed'])
|
|
1714
|
stream=opts['uncompressed'])
|
|
1701
|
if dr.local():
|
|
1715
|
if dr.local():
|
|
1702
|
if qbase:
|
|
1716
|
if qbase:
|
|
1703
|
ui.note(_('stripping applied patches from destination repo\n'))
|
|
1717
|
ui.note(_('stripping applied patches from destination repo\n'))
|
|
1704
|
dr.mq.strip(dr, qbase, update=False, backup=None)
|
|
1718
|
dr.mq.strip(dr, qbase, update=False, backup=None)
|
|
1705
|
if not opts['noupdate']:
|
|
1719
|
if not opts['noupdate']:
|
|
1706
|
ui.note(_('updating destination repo\n'))
|
|
1720
|
ui.note(_('updating destination repo\n'))
|
|
1707
|
hg.update(dr, dr.changelog.tip())
|
|
1721
|
hg.update(dr, dr.changelog.tip())
|
|
1708
|
|
|
1722
|
|
|
1709
|
def commit(ui, repo, *pats, **opts):
|
|
1723
|
def commit(ui, repo, *pats, **opts):
|
|
1710
|
"""commit changes in the queue repository"""
|
|
1724
|
"""commit changes in the queue repository"""
|
|
1711
|
q = repo.mq
|
|
1725
|
q = repo.mq
|
|
1712
|
r = q.qrepo()
|
|
1726
|
r = q.qrepo()
|
|
1713
|
if not r: raise util.Abort('no queue repository')
|
|
1727
|
if not r: raise util.Abort('no queue repository')
|
|
1714
|
commands.commit(r.ui, r, *pats, **opts)
|
|
1728
|
commands.commit(r.ui, r, *pats, **opts)
|
|
1715
|
|
|
1729
|
|
|
1716
|
def series(ui, repo, **opts):
|
|
1730
|
def series(ui, repo, **opts):
|
|
1717
|
"""print the entire series file"""
|
|
1731
|
"""print the entire series file"""
|
|
1718
|
repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary'])
|
|
1732
|
repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary'])
|
|
1719
|
return 0
|
|
1733
|
return 0
|
|
1720
|
|
|
1734
|
|
|
1721
|
def top(ui, repo, **opts):
|
|
1735
|
def top(ui, repo, **opts):
|
|
1722
|
"""print the name of the current patch"""
|
|
1736
|
"""print the name of the current patch"""
|
|
1723
|
q = repo.mq
|
|
1737
|
q = repo.mq
|
|
1724
|
t = q.applied and q.series_end(True) or 0
|
|
1738
|
t = q.applied and q.series_end(True) or 0
|
|
1725
|
if t:
|
|
1739
|
if t:
|
|
1726
|
return q.qseries(repo, start=t-1, length=1, status='A',
|
|
1740
|
return q.qseries(repo, start=t-1, length=1, status='A',
|
|
1727
|
summary=opts.get('summary'))
|
|
1741
|
summary=opts.get('summary'))
|
|
1728
|
else:
|
|
1742
|
else:
|
|
1729
|
ui.write("No patches applied\n")
|
|
1743
|
ui.write("No patches applied\n")
|
|
1730
|
return 1
|
|
1744
|
return 1
|
|
1731
|
|
|
1745
|
|
|
1732
|
def next(ui, repo, **opts):
|
|
1746
|
def next(ui, repo, **opts):
|
|
1733
|
"""print the name of the next patch"""
|
|
1747
|
"""print the name of the next patch"""
|
|
1734
|
q = repo.mq
|
|
1748
|
q = repo.mq
|
|
1735
|
end = q.series_end()
|
|
1749
|
end = q.series_end()
|
|
1736
|
if end == len(q.series):
|
|
1750
|
if end == len(q.series):
|
|
1737
|
ui.write("All patches applied\n")
|
|
1751
|
ui.write("All patches applied\n")
|
|
1738
|
return 1
|
|
1752
|
return 1
|
|
1739
|
return q.qseries(repo, start=end, length=1, summary=opts.get('summary'))
|
|
1753
|
return q.qseries(repo, start=end, length=1, summary=opts.get('summary'))
|
|
1740
|
|
|
1754
|
|
|
1741
|
def prev(ui, repo, **opts):
|
|
1755
|
def prev(ui, repo, **opts):
|
|
1742
|
"""print the name of the previous patch"""
|
|
1756
|
"""print the name of the previous patch"""
|
|
1743
|
q = repo.mq
|
|
1757
|
q = repo.mq
|
|
1744
|
l = len(q.applied)
|
|
1758
|
l = len(q.applied)
|
|
1745
|
if l == 1:
|
|
1759
|
if l == 1:
|
|
1746
|
ui.write("Only one patch applied\n")
|
|
1760
|
ui.write("Only one patch applied\n")
|
|
1747
|
return 1
|
|
1761
|
return 1
|
|
1748
|
if not l:
|
|
1762
|
if not l:
|
|
1749
|
ui.write("No patches applied\n")
|
|
1763
|
ui.write("No patches applied\n")
|
|
1750
|
return 1
|
|
1764
|
return 1
|
|
1751
|
return q.qseries(repo, start=l-2, length=1, status='A',
|
|
1765
|
return q.qseries(repo, start=l-2, length=1, status='A',
|
|
1752
|
summary=opts.get('summary'))
|
|
1766
|
summary=opts.get('summary'))
|
|
1753
|
|
|
1767
|
|
|
1754
|
def setupheaderopts(ui, opts):
|
|
1768
|
def setupheaderopts(ui, opts):
|
|
1755
|
def do(opt,val):
|
|
1769
|
def do(opt,val):
|
|
1756
|
if not opts[opt] and opts['current' + opt]:
|
|
1770
|
if not opts[opt] and opts['current' + opt]:
|
|
1757
|
opts[opt] = val
|
|
1771
|
opts[opt] = val
|
|
1758
|
do('user', ui.username())
|
|
1772
|
do('user', ui.username())
|
|
1759
|
do('date', "%d %d" % util.makedate())
|
|
1773
|
do('date', "%d %d" % util.makedate())
|
|
1760
|
|
|
1774
|
|
|
1761
|
def new(ui, repo, patch, *args, **opts):
|
|
1775
|
def new(ui, repo, patch, *args, **opts):
|
|
1762
|
"""create a new patch
|
|
1776
|
"""create a new patch
|
|
1763
|
|
|
1777
|
|
|
1764
|
qnew creates a new patch on top of the currently-applied patch (if any).
|
|
1778
|
qnew creates a new patch on top of the currently-applied patch (if any).
|
|
1765
|
It will refuse to run if there are any outstanding changes unless -f is
|
|
1779
|
It will refuse to run if there are any outstanding changes unless -f is
|
|
1766
|
specified, in which case the patch will be initialized with them. You
|
|
1780
|
specified, in which case the patch will be initialized with them. You
|
|
1767
|
may also use -I, -X, and/or a list of files after the patch name to add
|
|
1781
|
may also use -I, -X, and/or a list of files after the patch name to add
|
|
1768
|
only changes to matching files to the new patch, leaving the rest as
|
|
1782
|
only changes to matching files to the new patch, leaving the rest as
|
|
1769
|
uncommitted modifications.
|
|
1783
|
uncommitted modifications.
|
|
1770
|
|
|
1784
|
|
|
1771
|
-u and -d can be used to set the (given) user and date, respectively.
|
|
1785
|
-u and -d can be used to set the (given) user and date, respectively.
|
|
1772
|
-U and -D set user to current user and date to current date.
|
|
1786
|
-U and -D set user to current user and date to current date.
|
|
1773
|
|
|
1787
|
|
|
1774
|
-e, -m or -l set the patch header as well as the commit message. If none
|
|
1788
|
-e, -m or -l set the patch header as well as the commit message. If none
|
|
1775
|
is specified, the header is empty and the commit message is '[mq]: PATCH'.
|
|
1789
|
is specified, the header is empty and the commit message is '[mq]: PATCH'.
|
|
1776
|
|
|
1790
|
|
|
1777
|
Use the --git option to keep the patch in the git extended diff format.
|
|
1791
|
Use the --git option to keep the patch in the git extended diff format.
|
|
1778
|
Read the gitdiffs help topic for more information on why this is
|
|
1792
|
Read the gitdiffs help topic for more information on why this is
|
|
1779
|
important for preserving permission changes and copy/rename information.
|
|
1793
|
important for preserving permission changes and copy/rename information.
|
|
1780
|
"""
|
|
1794
|
"""
|
|
1781
|
msg = cmdutil.logmessage(opts)
|
|
1795
|
msg = cmdutil.logmessage(opts)
|
|
1782
|
def getmsg(): return ui.edit(msg, ui.username())
|
|
1796
|
def getmsg(): return ui.edit(msg, ui.username())
|
|
1783
|
q = repo.mq
|
|
1797
|
q = repo.mq
|
|
1784
|
opts['msg'] = msg
|
|
1798
|
opts['msg'] = msg
|
|
1785
|
if opts.get('edit'):
|
|
1799
|
if opts.get('edit'):
|
|
1786
|
opts['msg'] = getmsg
|
|
1800
|
opts['msg'] = getmsg
|
|
1787
|
else:
|
|
1801
|
else:
|
|
1788
|
opts['msg'] = msg
|
|
1802
|
opts['msg'] = msg
|
|
1789
|
setupheaderopts(ui, opts)
|
|
1803
|
setupheaderopts(ui, opts)
|
|
1790
|
q.new(repo, patch, *args, **opts)
|
|
1804
|
q.new(repo, patch, *args, **opts)
|
|
1791
|
q.save_dirty()
|
|
1805
|
q.save_dirty()
|
|
1792
|
return 0
|
|
1806
|
return 0
|
|
1793
|
|
|
1807
|
|
|
1794
|
def refresh(ui, repo, *pats, **opts):
|
|
1808
|
def refresh(ui, repo, *pats, **opts):
|
|
1795
|
"""update the current patch
|
|
1809
|
"""update the current patch
|
|
1796
|
|
|
1810
|
|
|
1797
|
If any file patterns are provided, the refreshed patch will contain only
|
|
1811
|
If any file patterns are provided, the refreshed patch will contain only
|
|
1798
|
the modifications that match those patterns; the remaining modifications
|
|
1812
|
the modifications that match those patterns; the remaining modifications
|
|
1799
|
will remain in the working directory.
|
|
1813
|
will remain in the working directory.
|
|
1800
|
|
|
1814
|
|
|
1801
|
If --short is specified, files currently included in the patch will
|
|
1815
|
If --short is specified, files currently included in the patch will
|
|
1802
|
be refreshed just like matched files and remain in the patch.
|
|
1816
|
be refreshed just like matched files and remain in the patch.
|
|
1803
|
|
|
1817
|
|
|
1804
|
hg add/remove/copy/rename work as usual, though you might want to use
|
|
1818
|
hg add/remove/copy/rename work as usual, though you might want to use
|
|
1805
|
git-style patches (--git or [diff] git=1) to track copies and renames.
|
|
1819
|
git-style patches (--git or [diff] git=1) to track copies and renames.
|
|
1806
|
See the gitdiffs help topic for more information on the git diff format.
|
|
1820
|
See the gitdiffs help topic for more information on the git diff format.
|
|
1807
|
"""
|
|
1821
|
"""
|
|
1808
|
q = repo.mq
|
|
1822
|
q = repo.mq
|
|
1809
|
message = cmdutil.logmessage(opts)
|
|
1823
|
message = cmdutil.logmessage(opts)
|
|
1810
|
if opts['edit']:
|
|
1824
|
if opts['edit']:
|
|
1811
|
if not q.applied:
|
|
1825
|
if not q.applied:
|
|
1812
|
ui.write(_("No patches applied\n"))
|
|
1826
|
ui.write(_("No patches applied\n"))
|
|
1813
|
return 1
|
|
1827
|
return 1
|
|
1814
|
if message:
|
|
1828
|
if message:
|
|
1815
|
raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
|
|
1829
|
raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
|
|
1816
|
patch = q.applied[-1].name
|
|
1830
|
patch = q.applied[-1].name
|
|
1817
|
(message, comment, user, date, hasdiff) = q.readheaders(patch)
|
|
1831
|
(message, comment, user, date, hasdiff) = q.readheaders(patch)
|
|
1818
|
message = ui.edit('\n'.join(message), user or ui.username())
|
|
1832
|
message = ui.edit('\n'.join(message), user or ui.username())
|
|
1819
|
setupheaderopts(ui, opts)
|
|
1833
|
setupheaderopts(ui, opts)
|
|
1820
|
ret = q.refresh(repo, pats, msg=message, **opts)
|
|
1834
|
ret = q.refresh(repo, pats, msg=message, **opts)
|
|
1821
|
q.save_dirty()
|
|
1835
|
q.save_dirty()
|
|
1822
|
return ret
|
|
1836
|
return ret
|
|
1823
|
|
|
1837
|
|
|
1824
|
def diff(ui, repo, *pats, **opts):
|
|
1838
|
def diff(ui, repo, *pats, **opts):
|
|
1825
|
"""diff of the current patch and subsequent modifications
|
|
1839
|
"""diff of the current patch and subsequent modifications
|
|
1826
|
|
|
1840
|
|
|
1827
|
Shows a diff which includes the current patch as well as any changes which
|
|
1841
|
Shows a diff which includes the current patch as well as any changes which
|
|
1828
|
have been made in the working directory since the last refresh (thus
|
|
1842
|
have been made in the working directory since the last refresh (thus
|
|
1829
|
showing what the current patch would become after a qrefresh).
|
|
1843
|
showing what the current patch would become after a qrefresh).
|
|
1830
|
|
|
1844
|
|
|
1831
|
Use 'hg diff' if you only want to see the changes made since the last
|
|
1845
|
Use 'hg diff' if you only want to see the changes made since the last
|
|
1832
|
qrefresh, or 'hg export qtip' if you want to see changes made by the
|
|
1846
|
qrefresh, or 'hg export qtip' if you want to see changes made by the
|
|
1833
|
current patch without including changes made since the qrefresh.
|
|
1847
|
current patch without including changes made since the qrefresh.
|
|
1834
|
"""
|
|
1848
|
"""
|
|
1835
|
repo.mq.diff(repo, pats, opts)
|
|
1849
|
repo.mq.diff(repo, pats, opts)
|
|
1836
|
return 0
|
|
1850
|
return 0
|
|
1837
|
|
|
1851
|
|
|
1838
|
def fold(ui, repo, *files, **opts):
|
|
1852
|
def fold(ui, repo, *files, **opts):
|
|
1839
|
"""fold the named patches into the current patch
|
|
1853
|
"""fold the named patches into the current patch
|
|
1840
|
|
|
1854
|
|
|
1841
|
Patches must not yet be applied. Each patch will be successively
|
|
1855
|
Patches must not yet be applied. Each patch will be successively
|
|
1842
|
applied to the current patch in the order given. If all the
|
|
1856
|
applied to the current patch in the order given. If all the
|
|
1843
|
patches apply successfully, the current patch will be refreshed
|
|
1857
|
patches apply successfully, the current patch will be refreshed
|
|
1844
|
with the new cumulative patch, and the folded patches will
|
|
1858
|
with the new cumulative patch, and the folded patches will
|
|
1845
|
be deleted. With -k/--keep, the folded patch files will not
|
|
1859
|
be deleted. With -k/--keep, the folded patch files will not
|
|
1846
|
be removed afterwards.
|
|
1860
|
be removed afterwards.
|
|
1847
|
|
|
1861
|
|
|
1848
|
The header for each folded patch will be concatenated with
|
|
1862
|
The header for each folded patch will be concatenated with
|
|
1849
|
the current patch header, separated by a line of '* * *'."""
|
|
1863
|
the current patch header, separated by a line of '* * *'."""
|
|
1850
|
|
|
1864
|
|
|
1851
|
q = repo.mq
|
|
1865
|
q = repo.mq
|
|
1852
|
|
|
1866
|
|
|
1853
|
if not files:
|
|
1867
|
if not files:
|
|
1854
|
raise util.Abort(_('qfold requires at least one patch name'))
|
|
1868
|
raise util.Abort(_('qfold requires at least one patch name'))
|
|
1855
|
if not q.check_toppatch(repo):
|
|
1869
|
if not q.check_toppatch(repo):
|
|
1856
|
raise util.Abort(_('No patches applied'))
|
|
1870
|
raise util.Abort(_('No patches applied'))
|
|
1857
|
|
|
1871
|
|
|
1858
|
message = cmdutil.logmessage(opts)
|
|
1872
|
message = cmdutil.logmessage(opts)
|
|
1859
|
if opts['edit']:
|
|
1873
|
if opts['edit']:
|
|
1860
|
if message:
|
|
1874
|
if message:
|
|
1861
|
raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
|
|
1875
|
raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
|
|
1862
|
|
|
1876
|
|
|
1863
|
parent = q.lookup('qtip')
|
|
1877
|
parent = q.lookup('qtip')
|
|
1864
|
patches = []
|
|
1878
|
patches = []
|
|
1865
|
messages = []
|
|
1879
|
messages = []
|
|
1866
|
for f in files:
|
|
1880
|
for f in files:
|
|
1867
|
p = q.lookup(f)
|
|
1881
|
p = q.lookup(f)
|
|
1868
|
if p in patches or p == parent:
|
|
1882
|
if p in patches or p == parent:
|
|
1869
|
ui.warn(_('Skipping already folded patch %s') % p)
|
|
1883
|
ui.warn(_('Skipping already folded patch %s') % p)
|
|
1870
|
if q.isapplied(p):
|
|
1884
|
if q.isapplied(p):
|
|
1871
|
raise util.Abort(_('qfold cannot fold already applied patch %s') % p)
|
|
1885
|
raise util.Abort(_('qfold cannot fold already applied patch %s') % p)
|
|
1872
|
patches.append(p)
|
|
1886
|
patches.append(p)
|
|
1873
|
|
|
1887
|
|
|
1874
|
for p in patches:
|
|
1888
|
for p in patches:
|
|
1875
|
if not message:
|
|
1889
|
if not message:
|
|
1876
|
messages.append(q.readheaders(p)[0])
|
|
1890
|
messages.append(q.readheaders(p)[0])
|
|
1877
|
pf = q.join(p)
|
|
1891
|
pf = q.join(p)
|
|
1878
|
(patchsuccess, files, fuzz) = q.patch(repo, pf)
|
|
1892
|
(patchsuccess, files, fuzz) = q.patch(repo, pf)
|
|
1879
|
if not patchsuccess:
|
|
1893
|
if not patchsuccess:
|
|
1880
|
raise util.Abort(_('Error folding patch %s') % p)
|
|
1894
|
raise util.Abort(_('Error folding patch %s') % p)
|
|
1881
|
patch.updatedir(ui, repo, files)
|
|
1895
|
patch.updatedir(ui, repo, files)
|
|
1882
|
|
|
1896
|
|
|
1883
|
if not message:
|
|
1897
|
if not message:
|
|
1884
|
message, comments, user = q.readheaders(parent)[0:3]
|
|
1898
|
message, comments, user = q.readheaders(parent)[0:3]
|
|
1885
|
for msg in messages:
|
|
1899
|
for msg in messages:
|
|
1886
|
message.append('* * *')
|
|
1900
|
message.append('* * *')
|
|
1887
|
message.extend(msg)
|
|
1901
|
message.extend(msg)
|
|
1888
|
message = '\n'.join(message)
|
|
1902
|
message = '\n'.join(message)
|
|
1889
|
|
|
1903
|
|
|
1890
|
if opts['edit']:
|
|
1904
|
if opts['edit']:
|
|
1891
|
message = ui.edit(message, user or ui.username())
|
|
1905
|
message = ui.edit(message, user or ui.username())
|
|
1892
|
|
|
1906
|
|
|
1893
|
q.refresh(repo, msg=message)
|
|
1907
|
q.refresh(repo, msg=message)
|
|
1894
|
q.delete(repo, patches, opts)
|
|
1908
|
q.delete(repo, patches, opts)
|
|
1895
|
q.save_dirty()
|
|
1909
|
q.save_dirty()
|
|
1896
|
|
|
1910
|
|
|
1897
|
def goto(ui, repo, patch, **opts):
|
|
1911
|
def goto(ui, repo, patch, **opts):
|
|
1898
|
'''push or pop patches until named patch is at top of stack'''
|
|
1912
|
'''push or pop patches until named patch is at top of stack'''
|
|
1899
|
q = repo.mq
|
|
1913
|
q = repo.mq
|
|
1900
|
patch = q.lookup(patch)
|
|
1914
|
patch = q.lookup(patch)
|
|
1901
|
if q.isapplied(patch):
|
|
1915
|
if q.isapplied(patch):
|
|
1902
|
ret = q.pop(repo, patch, force=opts['force'])
|
|
1916
|
ret = q.pop(repo, patch, force=opts['force'])
|
|
1903
|
else:
|
|
1917
|
else:
|
|
1904
|
ret = q.push(repo, patch, force=opts['force'])
|
|
1918
|
ret = q.push(repo, patch, force=opts['force'])
|
|
1905
|
q.save_dirty()
|
|
1919
|
q.save_dirty()
|
|
1906
|
return ret
|
|
1920
|
return ret
|
|
1907
|
|
|
1921
|
|
|
1908
|
def guard(ui, repo, *args, **opts):
|
|
1922
|
def guard(ui, repo, *args, **opts):
|
|
1909
|
'''set or print guards for a patch
|
|
1923
|
'''set or print guards for a patch
|
|
1910
|
|
|
1924
|
|
|
1911
|
Guards control whether a patch can be pushed. A patch with no
|
|
1925
|
Guards control whether a patch can be pushed. A patch with no
|
|
1912
|
guards is always pushed. A patch with a positive guard ("+foo") is
|
|
1926
|
guards is always pushed. A patch with a positive guard ("+foo") is
|
|
1913
|
pushed only if the qselect command has activated it. A patch with
|
|
1927
|
pushed only if the qselect command has activated it. A patch with
|
|
1914
|
a negative guard ("-foo") is never pushed if the qselect command
|
|
1928
|
a negative guard ("-foo") is never pushed if the qselect command
|
|
1915
|
has activated it.
|
|
1929
|
has activated it.
|
|
1916
|
|
|
1930
|
|
|
1917
|
With no arguments, print the currently active guards.
|
|
1931
|
With no arguments, print the currently active guards.
|
|
1918
|
With arguments, set guards for the named patch.
|
|
1932
|
With arguments, set guards for the named patch.
|
|
1919
|
|
|
1933
|
|
|
1920
|
To set a negative guard "-foo" on topmost patch ("--" is needed so
|
|
1934
|
To set a negative guard "-foo" on topmost patch ("--" is needed so
|
|
1921
|
hg will not interpret "-foo" as an option):
|
|
1935
|
hg will not interpret "-foo" as an option):
|
|
1922
|
hg qguard -- -foo
|
|
1936
|
hg qguard -- -foo
|
|
1923
|
|
|
1937
|
|
|
1924
|
To set guards on another patch:
|
|
1938
|
To set guards on another patch:
|
|
1925
|
hg qguard other.patch +2.6.17 -stable
|
|
1939
|
hg qguard other.patch +2.6.17 -stable
|
|
1926
|
'''
|
|
1940
|
'''
|
|
1927
|
def status(idx):
|
|
1941
|
def status(idx):
|
|
1928
|
guards = q.series_guards[idx] or ['unguarded']
|
|
1942
|
guards = q.series_guards[idx] or ['unguarded']
|
|
1929
|
ui.write('%s: %s\n' % (q.series[idx], ' '.join(guards)))
|
|
1943
|
ui.write('%s: %s\n' % (q.series[idx], ' '.join(guards)))
|
|
1930
|
q = repo.mq
|
|
1944
|
q = repo.mq
|
|
1931
|
patch = None
|
|
1945
|
patch = None
|
|
1932
|
args = list(args)
|
|
1946
|
args = list(args)
|
|
1933
|
if opts['list']:
|
|
1947
|
if opts['list']:
|
|
1934
|
if args or opts['none']:
|
|
1948
|
if args or opts['none']:
|
|
1935
|
raise util.Abort(_('cannot mix -l/--list with options or arguments'))
|
|
1949
|
raise util.Abort(_('cannot mix -l/--list with options or arguments'))
|
|
1936
|
for i in xrange(len(q.series)):
|
|
1950
|
for i in xrange(len(q.series)):
|
|
1937
|
status(i)
|
|
1951
|
status(i)
|
|
1938
|
return
|
|
1952
|
return
|
|
1939
|
if not args or args[0][0:1] in '-+':
|
|
1953
|
if not args or args[0][0:1] in '-+':
|
|
1940
|
if not q.applied:
|
|
1954
|
if not q.applied:
|
|
1941
|
raise util.Abort(_('no patches applied'))
|
|
1955
|
raise util.Abort(_('no patches applied'))
|
|
1942
|
patch = q.applied[-1].name
|
|
1956
|
patch = q.applied[-1].name
|
|
1943
|
if patch is None and args[0][0:1] not in '-+':
|
|
1957
|
if patch is None and args[0][0:1] not in '-+':
|
|
1944
|
patch = args.pop(0)
|
|
1958
|
patch = args.pop(0)
|
|
1945
|
if patch is None:
|
|
1959
|
if patch is None:
|
|
1946
|
raise util.Abort(_('no patch to work with'))
|
|
1960
|
raise util.Abort(_('no patch to work with'))
|
|
1947
|
if args or opts['none']:
|
|
1961
|
if args or opts['none']:
|
|
1948
|
idx = q.find_series(patch)
|
|
1962
|
idx = q.find_series(patch)
|
|
1949
|
if idx is None:
|
|
1963
|
if idx is None:
|
|
1950
|
raise util.Abort(_('no patch named %s') % patch)
|
|
1964
|
raise util.Abort(_('no patch named %s') % patch)
|
|
1951
|
q.set_guards(idx, args)
|
|
1965
|
q.set_guards(idx, args)
|
|
1952
|
q.save_dirty()
|
|
1966
|
q.save_dirty()
|
|
1953
|
else:
|
|
1967
|
else:
|
|
1954
|
status(q.series.index(q.lookup(patch)))
|
|
1968
|
status(q.series.index(q.lookup(patch)))
|
|
1955
|
|
|
1969
|
|
|
1956
|
def header(ui, repo, patch=None):
|
|
1970
|
def header(ui, repo, patch=None):
|
|
1957
|
"""Print the header of the topmost or specified patch"""
|
|
1971
|
"""Print the header of the topmost or specified patch"""
|
|
1958
|
q = repo.mq
|
|
1972
|
q = repo.mq
|
|
1959
|
|
|
1973
|
|
|
1960
|
if patch:
|
|
1974
|
if patch:
|
|
1961
|
patch = q.lookup(patch)
|
|
1975
|
patch = q.lookup(patch)
|
|
1962
|
else:
|
|
1976
|
else:
|
|
1963
|
if not q.applied:
|
|
1977
|
if not q.applied:
|
|
1964
|
ui.write('No patches applied\n')
|
|
1978
|
ui.write('No patches applied\n')
|
|
1965
|
return 1
|
|
1979
|
return 1
|
|
1966
|
patch = q.lookup('qtip')
|
|
1980
|
patch = q.lookup('qtip')
|
|
1967
|
message = repo.mq.readheaders(patch)[0]
|
|
1981
|
message = repo.mq.readheaders(patch)[0]
|
|
1968
|
|
|
1982
|
|
|
1969
|
ui.write('\n'.join(message) + '\n')
|
|
1983
|
ui.write('\n'.join(message) + '\n')
|
|
1970
|
|
|
1984
|
|
|
1971
|
def lastsavename(path):
|
|
1985
|
def lastsavename(path):
|
|
1972
|
(directory, base) = os.path.split(path)
|
|
1986
|
(directory, base) = os.path.split(path)
|
|
1973
|
names = os.listdir(directory)
|
|
1987
|
names = os.listdir(directory)
|
|
1974
|
namere = re.compile("%s.([0-9]+)" % base)
|
|
1988
|
namere = re.compile("%s.([0-9]+)" % base)
|
|
1975
|
maxindex = None
|
|
1989
|
maxindex = None
|
|
1976
|
maxname = None
|
|
1990
|
maxname = None
|
|
1977
|
for f in names:
|
|
1991
|
for f in names:
|
|
1978
|
m = namere.match(f)
|
|
1992
|
m = namere.match(f)
|
|
1979
|
if m:
|
|
1993
|
if m:
|
|
1980
|
index = int(m.group(1))
|
|
1994
|
index = int(m.group(1))
|
|
1981
|
if maxindex == None or index > maxindex:
|
|
1995
|
if maxindex == None or index > maxindex:
|
|
1982
|
maxindex = index
|
|
1996
|
maxindex = index
|
|
1983
|
maxname = f
|
|
1997
|
maxname = f
|
|
1984
|
if maxname:
|
|
1998
|
if maxname:
|
|
1985
|
return (os.path.join(directory, maxname), maxindex)
|
|
1999
|
return (os.path.join(directory, maxname), maxindex)
|
|
1986
|
return (None, None)
|
|
2000
|
return (None, None)
|
|
1987
|
|
|
2001
|
|
|
1988
|
def savename(path):
|
|
2002
|
def savename(path):
|
|
1989
|
(last, index) = lastsavename(path)
|
|
2003
|
(last, index) = lastsavename(path)
|
|
1990
|
if last is None:
|
|
2004
|
if last is None:
|
|
1991
|
index = 0
|
|
2005
|
index = 0
|
|
1992
|
newpath = path + ".%d" % (index + 1)
|
|
2006
|
newpath = path + ".%d" % (index + 1)
|
|
1993
|
return newpath
|
|
2007
|
return newpath
|
|
1994
|
|
|
2008
|
|
|
1995
|
def push(ui, repo, patch=None, **opts):
|
|
2009
|
def push(ui, repo, patch=None, **opts):
|
|
1996
|
"""push the next patch onto the stack
|
|
2010
|
"""push the next patch onto the stack
|
|
1997
|
|
|
2011
|
|
|
1998
|
When --force is applied, all local changes in patched files will be lost.
|
|
2012
|
When --force is applied, all local changes in patched files will be lost.
|
|
1999
|
"""
|
|
2013
|
"""
|
|
2000
|
q = repo.mq
|
|
2014
|
q = repo.mq
|
|
2001
|
mergeq = None
|
|
2015
|
mergeq = None
|
|
2002
|
|
|
2016
|
|
|
2003
|
if opts['all']:
|
|
|
|
|
2004
|
if not q.series:
|
|
|
|
|
2005
|
ui.warn(_('no patches in series\n'))
|
|
|
|
|
2006
|
return 0
|
|
|
|
|
2007
|
patch = q.series[-1]
|
|
|
|
|
2008
|
if opts['merge']:
|
|
2017
|
if opts['merge']:
|
|
2009
|
if opts['name']:
|
|
2018
|
if opts['name']:
|
|
2010
|
newpath = repo.join(opts['name'])
|
|
2019
|
newpath = repo.join(opts['name'])
|
|
2011
|
else:
|
|
2020
|
else:
|
|
2012
|
newpath, i = lastsavename(q.path)
|
|
2021
|
newpath, i = lastsavename(q.path)
|
|
2013
|
if not newpath:
|
|
2022
|
if not newpath:
|
|
2014
|
ui.warn(_("no saved queues found, please use -n\n"))
|
|
2023
|
ui.warn(_("no saved queues found, please use -n\n"))
|
|
2015
|
return 1
|
|
2024
|
return 1
|
|
2016
|
mergeq = queue(ui, repo.join(""), newpath)
|
|
2025
|
mergeq = queue(ui, repo.join(""), newpath)
|
|
2017
|
ui.warn(_("merging with queue at: %s\n") % mergeq.path)
|
|
2026
|
ui.warn(_("merging with queue at: %s\n") % mergeq.path)
|
|
2018
|
ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
|
|
2027
|
ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
|
|
2019
|
mergeq=mergeq)
|
|
2028
|
mergeq=mergeq, all=opts.get('all'))
|
|
2020
|
return ret
|
|
2029
|
return ret
|
|
2021
|
|
|
2030
|
|
|
2022
|
def pop(ui, repo, patch=None, **opts):
|
|
2031
|
def pop(ui, repo, patch=None, **opts):
|
|
2023
|
"""pop the current patch off the stack
|
|
2032
|
"""pop the current patch off the stack
|
|
2024
|
|
|
2033
|
|
|
2025
|
By default, pops off the top of the patch stack. If given a patch name,
|
|
2034
|
By default, pops off the top of the patch stack. If given a patch name,
|
|
2026
|
keeps popping off patches until the named patch is at the top of the stack.
|
|
2035
|
keeps popping off patches until the named patch is at the top of the stack.
|
|
2027
|
"""
|
|
2036
|
"""
|
|
2028
|
localupdate = True
|
|
2037
|
localupdate = True
|
|
2029
|
if opts['name']:
|
|
2038
|
if opts['name']:
|
|
2030
|
q = queue(ui, repo.join(""), repo.join(opts['name']))
|
|
2039
|
q = queue(ui, repo.join(""), repo.join(opts['name']))
|
|
2031
|
ui.warn(_('using patch queue: %s\n') % q.path)
|
|
2040
|
ui.warn(_('using patch queue: %s\n') % q.path)
|
|
2032
|
localupdate = False
|
|
2041
|
localupdate = False
|
|
2033
|
else:
|
|
2042
|
else:
|
|
2034
|
q = repo.mq
|
|
2043
|
q = repo.mq
|
|
2035
|
ret = q.pop(repo, patch, force=opts['force'], update=localupdate,
|
|
2044
|
ret = q.pop(repo, patch, force=opts['force'], update=localupdate,
|
|
2036
|
all=opts['all'])
|
|
2045
|
all=opts['all'])
|
|
2037
|
q.save_dirty()
|
|
2046
|
q.save_dirty()
|
|
2038
|
return ret
|
|
2047
|
return ret
|
|
2039
|
|
|
2048
|
|
|
2040
|
def rename(ui, repo, patch, name=None, **opts):
|
|
2049
|
def rename(ui, repo, patch, name=None, **opts):
|
|
2041
|
"""rename a patch
|
|
2050
|
"""rename a patch
|
|
2042
|
|
|
2051
|
|
|
2043
|
With one argument, renames the current patch to PATCH1.
|
|
2052
|
With one argument, renames the current patch to PATCH1.
|
|
2044
|
With two arguments, renames PATCH1 to PATCH2."""
|
|
2053
|
With two arguments, renames PATCH1 to PATCH2."""
|
|
2045
|
|
|
2054
|
|
|
2046
|
q = repo.mq
|
|
2055
|
q = repo.mq
|
|
2047
|
|
|
2056
|
|
|
2048
|
if not name:
|
|
2057
|
if not name:
|
|
2049
|
name = patch
|
|
2058
|
name = patch
|
|
2050
|
patch = None
|
|
2059
|
patch = None
|
|
2051
|
|
|
2060
|
|
|
2052
|
if patch:
|
|
2061
|
if patch:
|
|
2053
|
patch = q.lookup(patch)
|
|
2062
|
patch = q.lookup(patch)
|
|
2054
|
else:
|
|
2063
|
else:
|
|
2055
|
if not q.applied:
|
|
2064
|
if not q.applied:
|
|
2056
|
ui.write(_('No patches applied\n'))
|
|
2065
|
ui.write(_('No patches applied\n'))
|
|
2057
|
return
|
|
2066
|
return
|
|
2058
|
patch = q.lookup('qtip')
|
|
2067
|
patch = q.lookup('qtip')
|
|
2059
|
absdest = q.join(name)
|
|
2068
|
absdest = q.join(name)
|
|
2060
|
if os.path.isdir(absdest):
|
|
2069
|
if os.path.isdir(absdest):
|
|
2061
|
name = normname(os.path.join(name, os.path.basename(patch)))
|
|
2070
|
name = normname(os.path.join(name, os.path.basename(patch)))
|
|
2062
|
absdest = q.join(name)
|
|
2071
|
absdest = q.join(name)
|
|
2063
|
if os.path.exists(absdest):
|
|
2072
|
if os.path.exists(absdest):
|
|
2064
|
raise util.Abort(_('%s already exists') % absdest)
|
|
2073
|
raise util.Abort(_('%s already exists') % absdest)
|
|
2065
|
|
|
2074
|
|
|
2066
|
if name in q.series:
|
|
2075
|
if name in q.series:
|
|
2067
|
raise util.Abort(_('A patch named %s already exists in the series file') % name)
|
|
2076
|
raise util.Abort(_('A patch named %s already exists in the series file') % name)
|
|
2068
|
|
|
2077
|
|
|
2069
|
if ui.verbose:
|
|
2078
|
if ui.verbose:
|
|
2070
|
ui.write('Renaming %s to %s\n' % (patch, name))
|
|
2079
|
ui.write('Renaming %s to %s\n' % (patch, name))
|
|
2071
|
i = q.find_series(patch)
|
|
2080
|
i = q.find_series(patch)
|
|
2072
|
guards = q.guard_re.findall(q.full_series[i])
|
|
2081
|
guards = q.guard_re.findall(q.full_series[i])
|
|
2073
|
q.full_series[i] = name + ''.join([' #' + g for g in guards])
|
|
2082
|
q.full_series[i] = name + ''.join([' #' + g for g in guards])
|
|
2074
|
q.parse_series()
|
|
2083
|
q.parse_series()
|
|
2075
|
q.series_dirty = 1
|
|
2084
|
q.series_dirty = 1
|
|
2076
|
|
|
2085
|
|
|
2077
|
info = q.isapplied(patch)
|
|
2086
|
info = q.isapplied(patch)
|
|
2078
|
if info:
|
|
2087
|
if info:
|
|
2079
|
q.applied[info[0]] = statusentry(info[1], name)
|
|
2088
|
q.applied[info[0]] = statusentry(info[1], name)
|
|
2080
|
q.applied_dirty = 1
|
|
2089
|
q.applied_dirty = 1
|
|
2081
|
|
|
2090
|
|
|
2082
|
util.rename(q.join(patch), absdest)
|
|
2091
|
util.rename(q.join(patch), absdest)
|
|
2083
|
r = q.qrepo()
|
|
2092
|
r = q.qrepo()
|
|
2084
|
if r:
|
|
2093
|
if r:
|
|
2085
|
wlock = r.wlock()
|
|
2094
|
wlock = r.wlock()
|
|
2086
|
try:
|
|
2095
|
try:
|
|
2087
|
if r.dirstate[patch] == 'a':
|
|
2096
|
if r.dirstate[patch] == 'a':
|
|
2088
|
r.dirstate.forget(patch)
|
|
2097
|
r.dirstate.forget(patch)
|
|
2089
|
r.dirstate.add(name)
|
|
2098
|
r.dirstate.add(name)
|
|
2090
|
else:
|
|
2099
|
else:
|
|
2091
|
if r.dirstate[name] == 'r':
|
|
2100
|
if r.dirstate[name] == 'r':
|
|
2092
|
r.undelete([name])
|
|
2101
|
r.undelete([name])
|
|
2093
|
r.copy(patch, name)
|
|
2102
|
r.copy(patch, name)
|
|
2094
|
r.remove([patch], False)
|
|
2103
|
r.remove([patch], False)
|
|
2095
|
finally:
|
|
2104
|
finally:
|
|
2096
|
del wlock
|
|
2105
|
del wlock
|
|
2097
|
|
|
2106
|
|
|
2098
|
q.save_dirty()
|
|
2107
|
q.save_dirty()
|
|
2099
|
|
|
2108
|
|
|
2100
|
def restore(ui, repo, rev, **opts):
|
|
2109
|
def restore(ui, repo, rev, **opts):
|
|
2101
|
"""restore the queue state saved by a rev"""
|
|
2110
|
"""restore the queue state saved by a rev"""
|
|
2102
|
rev = repo.lookup(rev)
|
|
2111
|
rev = repo.lookup(rev)
|
|
2103
|
q = repo.mq
|
|
2112
|
q = repo.mq
|
|
2104
|
q.restore(repo, rev, delete=opts['delete'],
|
|
2113
|
q.restore(repo, rev, delete=opts['delete'],
|
|
2105
|
qupdate=opts['update'])
|
|
2114
|
qupdate=opts['update'])
|
|
2106
|
q.save_dirty()
|
|
2115
|
q.save_dirty()
|
|
2107
|
return 0
|
|
2116
|
return 0
|
|
2108
|
|
|
2117
|
|
|
2109
|
def save(ui, repo, **opts):
|
|
2118
|
def save(ui, repo, **opts):
|
|
2110
|
"""save current queue state"""
|
|
2119
|
"""save current queue state"""
|
|
2111
|
q = repo.mq
|
|
2120
|
q = repo.mq
|
|
2112
|
message = cmdutil.logmessage(opts)
|
|
2121
|
message = cmdutil.logmessage(opts)
|
|
2113
|
ret = q.save(repo, msg=message)
|
|
2122
|
ret = q.save(repo, msg=message)
|
|
2114
|
if ret:
|
|
2123
|
if ret:
|
|
2115
|
return ret
|
|
2124
|
return ret
|
|
2116
|
q.save_dirty()
|
|
2125
|
q.save_dirty()
|
|
2117
|
if opts['copy']:
|
|
2126
|
if opts['copy']:
|
|
2118
|
path = q.path
|
|
2127
|
path = q.path
|
|
2119
|
if opts['name']:
|
|
2128
|
if opts['name']:
|
|
2120
|
newpath = os.path.join(q.basepath, opts['name'])
|
|
2129
|
newpath = os.path.join(q.basepath, opts['name'])
|
|
2121
|
if os.path.exists(newpath):
|
|
2130
|
if os.path.exists(newpath):
|
|
2122
|
if not os.path.isdir(newpath):
|
|
2131
|
if not os.path.isdir(newpath):
|
|
2123
|
raise util.Abort(_('destination %s exists and is not '
|
|
2132
|
raise util.Abort(_('destination %s exists and is not '
|
|
2124
|
'a directory') % newpath)
|
|
2133
|
'a directory') % newpath)
|
|
2125
|
if not opts['force']:
|
|
2134
|
if not opts['force']:
|
|
2126
|
raise util.Abort(_('destination %s exists, '
|
|
2135
|
raise util.Abort(_('destination %s exists, '
|
|
2127
|
'use -f to force') % newpath)
|
|
2136
|
'use -f to force') % newpath)
|
|
2128
|
else:
|
|
2137
|
else:
|
|
2129
|
newpath = savename(path)
|
|
2138
|
newpath = savename(path)
|
|
2130
|
ui.warn(_("copy %s to %s\n") % (path, newpath))
|
|
2139
|
ui.warn(_("copy %s to %s\n") % (path, newpath))
|
|
2131
|
util.copyfiles(path, newpath)
|
|
2140
|
util.copyfiles(path, newpath)
|
|
2132
|
if opts['empty']:
|
|
2141
|
if opts['empty']:
|
|
2133
|
try:
|
|
2142
|
try:
|
|
2134
|
os.unlink(q.join(q.status_path))
|
|
2143
|
os.unlink(q.join(q.status_path))
|
|
2135
|
except:
|
|
2144
|
except:
|
|
2136
|
pass
|
|
2145
|
pass
|
|
2137
|
return 0
|
|
2146
|
return 0
|
|
2138
|
|
|
2147
|
|
|
2139
|
def strip(ui, repo, rev, **opts):
|
|
2148
|
def strip(ui, repo, rev, **opts):
|
|
2140
|
"""strip a revision and all its descendants from the repository
|
|
2149
|
"""strip a revision and all its descendants from the repository
|
|
2141
|
|
|
2150
|
|
|
2142
|
If one of the working dir's parent revisions is stripped, the working
|
|
2151
|
If one of the working dir's parent revisions is stripped, the working
|
|
2143
|
directory will be updated to the parent of the stripped revision.
|
|
2152
|
directory will be updated to the parent of the stripped revision.
|
|
2144
|
"""
|
|
2153
|
"""
|
|
2145
|
backup = 'all'
|
|
2154
|
backup = 'all'
|
|
2146
|
if opts['backup']:
|
|
2155
|
if opts['backup']:
|
|
2147
|
backup = 'strip'
|
|
2156
|
backup = 'strip'
|
|
2148
|
elif opts['nobackup']:
|
|
2157
|
elif opts['nobackup']:
|
|
2149
|
backup = 'none'
|
|
2158
|
backup = 'none'
|
|
2150
|
|
|
2159
|
|
|
2151
|
rev = repo.lookup(rev)
|
|
2160
|
rev = repo.lookup(rev)
|
|
2152
|
p = repo.dirstate.parents()
|
|
2161
|
p = repo.dirstate.parents()
|
|
2153
|
cl = repo.changelog
|
|
2162
|
cl = repo.changelog
|
|
2154
|
update = True
|
|
2163
|
update = True
|
|
2155
|
if p[0] == revlog.nullid:
|
|
2164
|
if p[0] == revlog.nullid:
|
|
2156
|
update = False
|
|
2165
|
update = False
|
|
2157
|
elif p[1] == revlog.nullid and rev != cl.ancestor(p[0], rev):
|
|
2166
|
elif p[1] == revlog.nullid and rev != cl.ancestor(p[0], rev):
|
|
2158
|
update = False
|
|
2167
|
update = False
|
|
2159
|
elif rev not in (cl.ancestor(p[0], rev), cl.ancestor(p[1], rev)):
|
|
2168
|
elif rev not in (cl.ancestor(p[0], rev), cl.ancestor(p[1], rev)):
|
|
2160
|
update = False
|
|
2169
|
update = False
|
|
2161
|
|
|
2170
|
|
|
2162
|
repo.mq.strip(repo, rev, backup=backup, update=update, force=opts['force'])
|
|
2171
|
repo.mq.strip(repo, rev, backup=backup, update=update, force=opts['force'])
|
|
2163
|
return 0
|
|
2172
|
return 0
|
|
2164
|
|
|
2173
|
|
|
2165
|
def select(ui, repo, *args, **opts):
|
|
2174
|
def select(ui, repo, *args, **opts):
|
|
2166
|
'''set or print guarded patches to push
|
|
2175
|
'''set or print guarded patches to push
|
|
2167
|
|
|
2176
|
|
|
2168
|
Use the qguard command to set or print guards on patch, then use
|
|
2177
|
Use the qguard command to set or print guards on patch, then use
|
|
2169
|
qselect to tell mq which guards to use. A patch will be pushed if it
|
|
2178
|
qselect to tell mq which guards to use. A patch will be pushed if it
|
|
2170
|
has no guards or any positive guards match the currently selected guard,
|
|
2179
|
has no guards or any positive guards match the currently selected guard,
|
|
2171
|
but will not be pushed if any negative guards match the current guard.
|
|
2180
|
but will not be pushed if any negative guards match the current guard.
|
|
2172
|
For example:
|
|
2181
|
For example:
|
|
2173
|
|
|
2182
|
|
|
2174
|
qguard foo.patch -stable (negative guard)
|
|
2183
|
qguard foo.patch -stable (negative guard)
|
|
2175
|
qguard bar.patch +stable (positive guard)
|
|
2184
|
qguard bar.patch +stable (positive guard)
|
|
2176
|
qselect stable
|
|
2185
|
qselect stable
|
|
2177
|
|
|
2186
|
|
|
2178
|
This activates the "stable" guard. mq will skip foo.patch (because
|
|
2187
|
This activates the "stable" guard. mq will skip foo.patch (because
|
|
2179
|
it has a negative match) but push bar.patch (because it
|
|
2188
|
it has a negative match) but push bar.patch (because it
|
|
2180
|
has a positive match).
|
|
2189
|
has a positive match).
|
|
2181
|
|
|
2190
|
|
|
2182
|
With no arguments, prints the currently active guards.
|
|
2191
|
With no arguments, prints the currently active guards.
|
|
2183
|
With one argument, sets the active guard.
|
|
2192
|
With one argument, sets the active guard.
|
|
2184
|
|
|
2193
|
|
|
2185
|
Use -n/--none to deactivate guards (no other arguments needed).
|
|
2194
|
Use -n/--none to deactivate guards (no other arguments needed).
|
|
2186
|
When no guards are active, patches with positive guards are skipped
|
|
2195
|
When no guards are active, patches with positive guards are skipped
|
|
2187
|
and patches with negative guards are pushed.
|
|
2196
|
and patches with negative guards are pushed.
|
|
2188
|
|
|
2197
|
|
|
2189
|
qselect can change the guards on applied patches. It does not pop
|
|
2198
|
qselect can change the guards on applied patches. It does not pop
|
|
2190
|
guarded patches by default. Use --pop to pop back to the last applied
|
|
2199
|
guarded patches by default. Use --pop to pop back to the last applied
|
|
2191
|
patch that is not guarded. Use --reapply (which implies --pop) to push
|
|
2200
|
patch that is not guarded. Use --reapply (which implies --pop) to push
|
|
2192
|
back to the current patch afterwards, but skip guarded patches.
|
|
2201
|
back to the current patch afterwards, but skip guarded patches.
|
|
2193
|
|
|
2202
|
|
|
2194
|
Use -s/--series to print a list of all guards in the series file (no
|
|
2203
|
Use -s/--series to print a list of all guards in the series file (no
|
|
2195
|
other arguments needed). Use -v for more information.'''
|
|
2204
|
other arguments needed). Use -v for more information.'''
|
|
2196
|
|
|
2205
|
|
|
2197
|
q = repo.mq
|
|
2206
|
q = repo.mq
|
|
2198
|
guards = q.active()
|
|
2207
|
guards = q.active()
|
|
2199
|
if args or opts['none']:
|
|
2208
|
if args or opts['none']:
|
|
2200
|
old_unapplied = q.unapplied(repo)
|
|
2209
|
old_unapplied = q.unapplied(repo)
|
|
2201
|
old_guarded = [i for i in xrange(len(q.applied)) if
|
|
2210
|
old_guarded = [i for i in xrange(len(q.applied)) if
|
|
2202
|
not q.pushable(i)[0]]
|
|
2211
|
not q.pushable(i)[0]]
|
|
2203
|
q.set_active(args)
|
|
2212
|
q.set_active(args)
|
|
2204
|
q.save_dirty()
|
|
2213
|
q.save_dirty()
|
|
2205
|
if not args:
|
|
2214
|
if not args:
|
|
2206
|
ui.status(_('guards deactivated\n'))
|
|
2215
|
ui.status(_('guards deactivated\n'))
|
|
2207
|
if not opts['pop'] and not opts['reapply']:
|
|
2216
|
if not opts['pop'] and not opts['reapply']:
|
|
2208
|
unapplied = q.unapplied(repo)
|
|
2217
|
unapplied = q.unapplied(repo)
|
|
2209
|
guarded = [i for i in xrange(len(q.applied))
|
|
2218
|
guarded = [i for i in xrange(len(q.applied))
|
|
2210
|
if not q.pushable(i)[0]]
|
|
2219
|
if not q.pushable(i)[0]]
|
|
2211
|
if len(unapplied) != len(old_unapplied):
|
|
2220
|
if len(unapplied) != len(old_unapplied):
|
|
2212
|
ui.status(_('number of unguarded, unapplied patches has '
|
|
2221
|
ui.status(_('number of unguarded, unapplied patches has '
|
|
2213
|
'changed from %d to %d\n') %
|
|
2222
|
'changed from %d to %d\n') %
|
|
2214
|
(len(old_unapplied), len(unapplied)))
|
|
2223
|
(len(old_unapplied), len(unapplied)))
|
|
2215
|
if len(guarded) != len(old_guarded):
|
|
2224
|
if len(guarded) != len(old_guarded):
|
|
2216
|
ui.status(_('number of guarded, applied patches has changed '
|
|
2225
|
ui.status(_('number of guarded, applied patches has changed '
|
|
2217
|
'from %d to %d\n') %
|
|
2226
|
'from %d to %d\n') %
|
|
2218
|
(len(old_guarded), len(guarded)))
|
|
2227
|
(len(old_guarded), len(guarded)))
|
|
2219
|
elif opts['series']:
|
|
2228
|
elif opts['series']:
|
|
2220
|
guards = {}
|
|
2229
|
guards = {}
|
|
2221
|
noguards = 0
|
|
2230
|
noguards = 0
|
|
2222
|
for gs in q.series_guards:
|
|
2231
|
for gs in q.series_guards:
|
|
2223
|
if not gs:
|
|
2232
|
if not gs:
|
|
2224
|
noguards += 1
|
|
2233
|
noguards += 1
|
|
2225
|
for g in gs:
|
|
2234
|
for g in gs:
|
|
2226
|
guards.setdefault(g, 0)
|
|
2235
|
guards.setdefault(g, 0)
|
|
2227
|
guards[g] += 1
|
|
2236
|
guards[g] += 1
|
|
2228
|
if ui.verbose:
|
|
2237
|
if ui.verbose:
|
|
2229
|
guards['NONE'] = noguards
|
|
2238
|
guards['NONE'] = noguards
|
|
2230
|
guards = guards.items()
|
|
2239
|
guards = guards.items()
|
|
2231
|
guards.sort(lambda a, b: cmp(a[0][1:], b[0][1:]))
|
|
2240
|
guards.sort(lambda a, b: cmp(a[0][1:], b[0][1:]))
|
|
2232
|
if guards:
|
|
2241
|
if guards:
|
|
2233
|
ui.note(_('guards in series file:\n'))
|
|
2242
|
ui.note(_('guards in series file:\n'))
|
|
2234
|
for guard, count in guards:
|
|
2243
|
for guard, count in guards:
|
|
2235
|
ui.note('%2d ' % count)
|
|
2244
|
ui.note('%2d ' % count)
|
|
2236
|
ui.write(guard, '\n')
|
|
2245
|
ui.write(guard, '\n')
|
|
2237
|
else:
|
|
2246
|
else:
|
|
2238
|
ui.note(_('no guards in series file\n'))
|
|
2247
|
ui.note(_('no guards in series file\n'))
|
|
2239
|
else:
|
|
2248
|
else:
|
|
2240
|
if guards:
|
|
2249
|
if guards:
|
|
2241
|
ui.note(_('active guards:\n'))
|
|
2250
|
ui.note(_('active guards:\n'))
|
|
2242
|
for g in guards:
|
|
2251
|
for g in guards:
|
|
2243
|
ui.write(g, '\n')
|
|
2252
|
ui.write(g, '\n')
|
|
2244
|
else:
|
|
2253
|
else:
|
|
2245
|
ui.write(_('no active guards\n'))
|
|
2254
|
ui.write(_('no active guards\n'))
|
|
2246
|
reapply = opts['reapply'] and q.applied and q.appliedname(-1)
|
|
2255
|
reapply = opts['reapply'] and q.applied and q.appliedname(-1)
|
|
2247
|
popped = False
|
|
2256
|
popped = False
|
|
2248
|
if opts['pop'] or opts['reapply']:
|
|
2257
|
if opts['pop'] or opts['reapply']:
|
|
2249
|
for i in xrange(len(q.applied)):
|
|
2258
|
for i in xrange(len(q.applied)):
|
|
2250
|
pushable, reason = q.pushable(i)
|
|
2259
|
pushable, reason = q.pushable(i)
|
|
2251
|
if not pushable:
|
|
2260
|
if not pushable:
|
|
2252
|
ui.status(_('popping guarded patches\n'))
|
|
2261
|
ui.status(_('popping guarded patches\n'))
|
|
2253
|
popped = True
|
|
2262
|
popped = True
|
|
2254
|
if i == 0:
|
|
2263
|
if i == 0:
|
|
2255
|
q.pop(repo, all=True)
|
|
2264
|
q.pop(repo, all=True)
|
|
2256
|
else:
|
|
2265
|
else:
|
|
2257
|
q.pop(repo, i-1)
|
|
2266
|
q.pop(repo, i-1)
|
|
2258
|
break
|
|
2267
|
break
|
|
2259
|
if popped:
|
|
2268
|
if popped:
|
|
2260
|
try:
|
|
2269
|
try:
|
|
2261
|
if reapply:
|
|
2270
|
if reapply:
|
|
2262
|
ui.status(_('reapplying unguarded patches\n'))
|
|
2271
|
ui.status(_('reapplying unguarded patches\n'))
|
|
2263
|
q.push(repo, reapply)
|
|
2272
|
q.push(repo, reapply)
|
|
2264
|
finally:
|
|
2273
|
finally:
|
|
2265
|
q.save_dirty()
|
|
2274
|
q.save_dirty()
|
|
2266
|
|
|
2275
|
|
|
2267
|
def finish(ui, repo, *revrange, **opts):
|
|
2276
|
def finish(ui, repo, *revrange, **opts):
|
|
2268
|
"""move applied patches into repository history
|
|
2277
|
"""move applied patches into repository history
|
|
2269
|
|
|
2278
|
|
|
2270
|
Finishes the specified revisions (corresponding to applied patches) by
|
|
2279
|
Finishes the specified revisions (corresponding to applied patches) by
|
|
2271
|
moving them out of mq control into regular repository history.
|
|
2280
|
moving them out of mq control into regular repository history.
|
|
2272
|
|
|
2281
|
|
|
2273
|
Accepts a revision range or the --applied option. If --applied is
|
|
2282
|
Accepts a revision range or the --applied option. If --applied is
|
|
2274
|
specified, all applied mq revisions are removed from mq control.
|
|
2283
|
specified, all applied mq revisions are removed from mq control.
|
|
2275
|
Otherwise, the given revisions must be at the base of the stack of
|
|
2284
|
Otherwise, the given revisions must be at the base of the stack of
|
|
2276
|
applied patches.
|
|
2285
|
applied patches.
|
|
2277
|
|
|
2286
|
|
|
2278
|
This can be especially useful if your changes have been applied to an
|
|
2287
|
This can be especially useful if your changes have been applied to an
|
|
2279
|
upstream repository, or if you are about to push your changes to upstream.
|
|
2288
|
upstream repository, or if you are about to push your changes to upstream.
|
|
2280
|
"""
|
|
2289
|
"""
|
|
2281
|
if not opts['applied'] and not revrange:
|
|
2290
|
if not opts['applied'] and not revrange:
|
|
2282
|
raise util.Abort(_('no revisions specified'))
|
|
2291
|
raise util.Abort(_('no revisions specified'))
|
|
2283
|
elif opts['applied']:
|
|
2292
|
elif opts['applied']:
|
|
2284
|
revrange = ('qbase:qtip',) + revrange
|
|
2293
|
revrange = ('qbase:qtip',) + revrange
|
|
2285
|
|
|
2294
|
|
|
2286
|
q = repo.mq
|
|
2295
|
q = repo.mq
|
|
2287
|
if not q.applied:
|
|
2296
|
if not q.applied:
|
|
2288
|
ui.status(_('no patches applied\n'))
|
|
2297
|
ui.status(_('no patches applied\n'))
|
|
2289
|
return 0
|
|
2298
|
return 0
|
|
2290
|
|
|
2299
|
|
|
2291
|
revs = cmdutil.revrange(repo, revrange)
|
|
2300
|
revs = cmdutil.revrange(repo, revrange)
|
|
2292
|
q.finish(repo, revs)
|
|
2301
|
q.finish(repo, revs)
|
|
2293
|
q.save_dirty()
|
|
2302
|
q.save_dirty()
|
|
2294
|
return 0
|
|
2303
|
return 0
|
|
2295
|
|
|
2304
|
|
|
2296
|
def reposetup(ui, repo):
|
|
2305
|
def reposetup(ui, repo):
|
|
2297
|
class mqrepo(repo.__class__):
|
|
2306
|
class mqrepo(repo.__class__):
|
|
2298
|
def abort_if_wdir_patched(self, errmsg, force=False):
|
|
2307
|
def abort_if_wdir_patched(self, errmsg, force=False):
|
|
2299
|
if self.mq.applied and not force:
|
|
2308
|
if self.mq.applied and not force:
|
|
2300
|
parent = revlog.hex(self.dirstate.parents()[0])
|
|
2309
|
parent = revlog.hex(self.dirstate.parents()[0])
|
|
2301
|
if parent in [s.rev for s in self.mq.applied]:
|
|
2310
|
if parent in [s.rev for s in self.mq.applied]:
|
|
2302
|
raise util.Abort(errmsg)
|
|
2311
|
raise util.Abort(errmsg)
|
|
2303
|
|
|
2312
|
|
|
2304
|
def commit(self, *args, **opts):
|
|
2313
|
def commit(self, *args, **opts):
|
|
2305
|
if len(args) >= 6:
|
|
2314
|
if len(args) >= 6:
|
|
2306
|
force = args[5]
|
|
2315
|
force = args[5]
|
|
2307
|
else:
|
|
2316
|
else:
|
|
2308
|
force = opts.get('force')
|
|
2317
|
force = opts.get('force')
|
|
2309
|
self.abort_if_wdir_patched(
|
|
2318
|
self.abort_if_wdir_patched(
|
|
2310
|
_('cannot commit over an applied mq patch'),
|
|
2319
|
_('cannot commit over an applied mq patch'),
|
|
2311
|
force)
|
|
2320
|
force)
|
|
2312
|
|
|
2321
|
|
|
2313
|
return super(mqrepo, self).commit(*args, **opts)
|
|
2322
|
return super(mqrepo, self).commit(*args, **opts)
|
|
2314
|
|
|
2323
|
|
|
2315
|
def push(self, remote, force=False, revs=None):
|
|
2324
|
def push(self, remote, force=False, revs=None):
|
|
2316
|
if self.mq.applied and not force and not revs:
|
|
2325
|
if self.mq.applied and not force and not revs:
|
|
2317
|
raise util.Abort(_('source has mq patches applied'))
|
|
2326
|
raise util.Abort(_('source has mq patches applied'))
|
|
2318
|
return super(mqrepo, self).push(remote, force, revs)
|
|
2327
|
return super(mqrepo, self).push(remote, force, revs)
|
|
2319
|
|
|
2328
|
|
|
2320
|
def tags(self):
|
|
2329
|
def tags(self):
|
|
2321
|
if self.tagscache:
|
|
2330
|
if self.tagscache:
|
|
2322
|
return self.tagscache
|
|
2331
|
return self.tagscache
|
|
2323
|
|
|
2332
|
|
|
2324
|
tagscache = super(mqrepo, self).tags()
|
|
2333
|
tagscache = super(mqrepo, self).tags()
|
|
2325
|
|
|
2334
|
|
|
2326
|
q = self.mq
|
|
2335
|
q = self.mq
|
|
2327
|
if not q.applied:
|
|
2336
|
if not q.applied:
|
|
2328
|
return tagscache
|
|
2337
|
return tagscache
|
|
2329
|
|
|
2338
|
|
|
2330
|
mqtags = [(revlog.bin(patch.rev), patch.name) for patch in q.applied]
|
|
2339
|
mqtags = [(revlog.bin(patch.rev), patch.name) for patch in q.applied]
|
|
2331
|
|
|
2340
|
|
|
2332
|
if mqtags[-1][0] not in self.changelog.nodemap:
|
|
2341
|
if mqtags[-1][0] not in self.changelog.nodemap:
|
|
2333
|
self.ui.warn(_('mq status file refers to unknown node %s\n')
|
|
2342
|
self.ui.warn(_('mq status file refers to unknown node %s\n')
|
|
2334
|
% revlog.short(mqtags[-1][0]))
|
|
2343
|
% revlog.short(mqtags[-1][0]))
|
|
2335
|
return tagscache
|
|
2344
|
return tagscache
|
|
2336
|
|
|
2345
|
|
|
2337
|
mqtags.append((mqtags[-1][0], 'qtip'))
|
|
2346
|
mqtags.append((mqtags[-1][0], 'qtip'))
|
|
2338
|
mqtags.append((mqtags[0][0], 'qbase'))
|
|
2347
|
mqtags.append((mqtags[0][0], 'qbase'))
|
|
2339
|
mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent'))
|
|
2348
|
mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent'))
|
|
2340
|
for patch in mqtags:
|
|
2349
|
for patch in mqtags:
|
|
2341
|
if patch[1] in tagscache:
|
|
2350
|
if patch[1] in tagscache:
|
|
2342
|
self.ui.warn(_('Tag %s overrides mq patch of the same name\n')
|
|
2351
|
self.ui.warn(_('Tag %s overrides mq patch of the same name\n')
|
|
2343
|
% patch[1])
|
|
2352
|
% patch[1])
|
|
2344
|
else:
|
|
2353
|
else:
|
|
2345
|
tagscache[patch[1]] = patch[0]
|
|
2354
|
tagscache[patch[1]] = patch[0]
|
|
2346
|
|
|
2355
|
|
|
2347
|
return tagscache
|
|
2356
|
return tagscache
|
|
2348
|
|
|
2357
|
|
|
2349
|
def _branchtags(self, partial, lrev):
|
|
2358
|
def _branchtags(self, partial, lrev):
|
|
2350
|
q = self.mq
|
|
2359
|
q = self.mq
|
|
2351
|
if not q.applied:
|
|
2360
|
if not q.applied:
|
|
2352
|
return super(mqrepo, self)._branchtags(partial, lrev)
|
|
2361
|
return super(mqrepo, self)._branchtags(partial, lrev)
|
|
2353
|
|
|
2362
|
|
|
2354
|
cl = self.changelog
|
|
2363
|
cl = self.changelog
|
|
2355
|
qbasenode = revlog.bin(q.applied[0].rev)
|
|
2364
|
qbasenode = revlog.bin(q.applied[0].rev)
|
|
2356
|
if qbasenode not in cl.nodemap:
|
|
2365
|
if qbasenode not in cl.nodemap:
|
|
2357
|
self.ui.warn(_('mq status file refers to unknown node %s\n')
|
|
2366
|
self.ui.warn(_('mq status file refers to unknown node %s\n')
|
|
2358
|
% revlog.short(qbasenode))
|
|
2367
|
% revlog.short(qbasenode))
|
|
2359
|
return super(mqrepo, self)._branchtags(partial, lrev)
|
|
2368
|
return super(mqrepo, self)._branchtags(partial, lrev)
|
|
2360
|
|
|
2369
|
|
|
2361
|
qbase = cl.rev(qbasenode)
|
|
2370
|
qbase = cl.rev(qbasenode)
|
|
2362
|
start = lrev + 1
|
|
2371
|
start = lrev + 1
|
|
2363
|
if start < qbase:
|
|
2372
|
if start < qbase:
|
|
2364
|
# update the cache (excluding the patches) and save it
|
|
2373
|
# update the cache (excluding the patches) and save it
|
|
2365
|
self._updatebranchcache(partial, lrev+1, qbase)
|
|
2374
|
self._updatebranchcache(partial, lrev+1, qbase)
|
|
2366
|
self._writebranchcache(partial, cl.node(qbase-1), qbase-1)
|
|
2375
|
self._writebranchcache(partial, cl.node(qbase-1), qbase-1)
|
|
2367
|
start = qbase
|
|
2376
|
start = qbase
|
|
2368
|
# if start = qbase, the cache is as updated as it should be.
|
|
2377
|
# if start = qbase, the cache is as updated as it should be.
|
|
2369
|
# if start > qbase, the cache includes (part of) the patches.
|
|
2378
|
# if start > qbase, the cache includes (part of) the patches.
|
|
2370
|
# we might as well use it, but we won't save it.
|
|
2379
|
# we might as well use it, but we won't save it.
|
|
2371
|
|
|
2380
|
|
|
2372
|
# update the cache up to the tip
|
|
2381
|
# update the cache up to the tip
|
|
2373
|
self._updatebranchcache(partial, start, len(cl))
|
|
2382
|
self._updatebranchcache(partial, start, len(cl))
|
|
2374
|
|
|
2383
|
|
|
2375
|
return partial
|
|
2384
|
return partial
|
|
2376
|
|
|
2385
|
|
|
2377
|
if repo.local():
|
|
2386
|
if repo.local():
|
|
2378
|
repo.__class__ = mqrepo
|
|
2387
|
repo.__class__ = mqrepo
|
|
2379
|
repo.mq = queue(ui, repo.join(""))
|
|
2388
|
repo.mq = queue(ui, repo.join(""))
|
|
2380
|
|
|
2389
|
|
|
2381
|
def mqimport(orig, ui, repo, *args, **kwargs):
|
|
2390
|
def mqimport(orig, ui, repo, *args, **kwargs):
|
|
2382
|
if hasattr(repo, 'abort_if_wdir_patched'):
|
|
2391
|
if hasattr(repo, 'abort_if_wdir_patched'):
|
|
2383
|
repo.abort_if_wdir_patched(_('cannot import over an applied patch'),
|
|
2392
|
repo.abort_if_wdir_patched(_('cannot import over an applied patch'),
|
|
2384
|
kwargs.get('force'))
|
|
2393
|
kwargs.get('force'))
|
|
2385
|
return orig(ui, repo, *args, **kwargs)
|
|
2394
|
return orig(ui, repo, *args, **kwargs)
|
|
2386
|
|
|
2395
|
|
|
2387
|
def uisetup(ui):
|
|
2396
|
def uisetup(ui):
|
|
2388
|
extensions.wrapcommand(commands.table, 'import', mqimport)
|
|
2397
|
extensions.wrapcommand(commands.table, 'import', mqimport)
|
|
2389
|
|
|
2398
|
|
|
2390
|
seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
|
|
2399
|
seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
|
|
2391
|
|
|
2400
|
|
|
2392
|
cmdtable = {
|
|
2401
|
cmdtable = {
|
|
2393
|
"qapplied": (applied, [] + seriesopts, _('hg qapplied [-s] [PATCH]')),
|
|
2402
|
"qapplied": (applied, [] + seriesopts, _('hg qapplied [-s] [PATCH]')),
|
|
2394
|
"qclone":
|
|
2403
|
"qclone":
|
|
2395
|
(clone,
|
|
2404
|
(clone,
|
|
2396
|
[('', 'pull', None, _('use pull protocol to copy metadata')),
|
|
2405
|
[('', 'pull', None, _('use pull protocol to copy metadata')),
|
|
2397
|
('U', 'noupdate', None, _('do not update the new working directories')),
|
|
2406
|
('U', 'noupdate', None, _('do not update the new working directories')),
|
|
2398
|
('', 'uncompressed', None,
|
|
2407
|
('', 'uncompressed', None,
|
|
2399
|
_('use uncompressed transfer (fast over LAN)')),
|
|
2408
|
_('use uncompressed transfer (fast over LAN)')),
|
|
2400
|
('p', 'patches', '', _('location of source patch repo')),
|
|
2409
|
('p', 'patches', '', _('location of source patch repo')),
|
|
2401
|
] + commands.remoteopts,
|
|
2410
|
] + commands.remoteopts,
|
|
2402
|
_('hg qclone [OPTION]... SOURCE [DEST]')),
|
|
2411
|
_('hg qclone [OPTION]... SOURCE [DEST]')),
|
|
2403
|
"qcommit|qci":
|
|
2412
|
"qcommit|qci":
|
|
2404
|
(commit,
|
|
2413
|
(commit,
|
|
2405
|
commands.table["^commit|ci"][1],
|
|
2414
|
commands.table["^commit|ci"][1],
|
|
2406
|
_('hg qcommit [OPTION]... [FILE]...')),
|
|
2415
|
_('hg qcommit [OPTION]... [FILE]...')),
|
|
2407
|
"^qdiff":
|
|
2416
|
"^qdiff":
|
|
2408
|
(diff,
|
|
2417
|
(diff,
|
|
2409
|
commands.diffopts + commands.diffopts2 + commands.walkopts,
|
|
2418
|
commands.diffopts + commands.diffopts2 + commands.walkopts,
|
|
2410
|
_('hg qdiff [OPTION]... [FILE]...')),
|
|
2419
|
_('hg qdiff [OPTION]... [FILE]...')),
|
|
2411
|
"qdelete|qremove|qrm":
|
|
2420
|
"qdelete|qremove|qrm":
|
|
2412
|
(delete,
|
|
2421
|
(delete,
|
|
2413
|
[('k', 'keep', None, _('keep patch file')),
|
|
2422
|
[('k', 'keep', None, _('keep patch file')),
|
|
2414
|
('r', 'rev', [], _('stop managing a revision'))],
|
|
2423
|
('r', 'rev', [], _('stop managing a revision'))],
|
|
2415
|
_('hg qdelete [-k] [-r REV]... [PATCH]...')),
|
|
2424
|
_('hg qdelete [-k] [-r REV]... [PATCH]...')),
|
|
2416
|
'qfold':
|
|
2425
|
'qfold':
|
|
2417
|
(fold,
|
|
2426
|
(fold,
|
|
2418
|
[('e', 'edit', None, _('edit patch header')),
|
|
2427
|
[('e', 'edit', None, _('edit patch header')),
|
|
2419
|
('k', 'keep', None, _('keep folded patch files')),
|
|
2428
|
('k', 'keep', None, _('keep folded patch files')),
|
|
2420
|
] + commands.commitopts,
|
|
2429
|
] + commands.commitopts,
|
|
2421
|
_('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...')),
|
|
2430
|
_('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...')),
|
|
2422
|
'qgoto':
|
|
2431
|
'qgoto':
|
|
2423
|
(goto,
|
|
2432
|
(goto,
|
|
2424
|
[('f', 'force', None, _('overwrite any local changes'))],
|
|
2433
|
[('f', 'force', None, _('overwrite any local changes'))],
|
|
2425
|
_('hg qgoto [OPTION]... PATCH')),
|
|
2434
|
_('hg qgoto [OPTION]... PATCH')),
|
|
2426
|
'qguard':
|
|
2435
|
'qguard':
|
|
2427
|
(guard,
|
|
2436
|
(guard,
|
|
2428
|
[('l', 'list', None, _('list all patches and guards')),
|
|
2437
|
[('l', 'list', None, _('list all patches and guards')),
|
|
2429
|
('n', 'none', None, _('drop all guards'))],
|
|
2438
|
('n', 'none', None, _('drop all guards'))],
|
|
2430
|
_('hg qguard [-l] [-n] [PATCH] [+GUARD]... [-GUARD]...')),
|
|
2439
|
_('hg qguard [-l] [-n] [PATCH] [+GUARD]... [-GUARD]...')),
|
|
2431
|
'qheader': (header, [], _('hg qheader [PATCH]')),
|
|
2440
|
'qheader': (header, [], _('hg qheader [PATCH]')),
|
|
2432
|
"^qimport":
|
|
2441
|
"^qimport":
|
|
2433
|
(qimport,
|
|
2442
|
(qimport,
|
|
2434
|
[('e', 'existing', None, _('import file in patch dir')),
|
|
2443
|
[('e', 'existing', None, _('import file in patch dir')),
|
|
2435
|
('n', 'name', '', _('patch file name')),
|
|
2444
|
('n', 'name', '', _('patch file name')),
|
|
2436
|
('f', 'force', None, _('overwrite existing files')),
|
|
2445
|
('f', 'force', None, _('overwrite existing files')),
|
|
2437
|
('r', 'rev', [], _('place existing revisions under mq control')),
|
|
2446
|
('r', 'rev', [], _('place existing revisions under mq control')),
|
|
2438
|
('g', 'git', None, _('use git extended diff format'))],
|
|
2447
|
('g', 'git', None, _('use git extended diff format'))],
|
|
2439
|
_('hg qimport [-e] [-n NAME] [-f] [-g] [-r REV]... FILE...')),
|
|
2448
|
_('hg qimport [-e] [-n NAME] [-f] [-g] [-r REV]... FILE...')),
|
|
2440
|
"^qinit":
|
|
2449
|
"^qinit":
|
|
2441
|
(init,
|
|
2450
|
(init,
|
|
2442
|
[('c', 'create-repo', None, _('create queue repository'))],
|
|
2451
|
[('c', 'create-repo', None, _('create queue repository'))],
|
|
2443
|
_('hg qinit [-c]')),
|
|
2452
|
_('hg qinit [-c]')),
|
|
2444
|
"qnew":
|
|
2453
|
"qnew":
|
|
2445
|
(new,
|
|
2454
|
(new,
|
|
2446
|
[('e', 'edit', None, _('edit commit message')),
|
|
2455
|
[('e', 'edit', None, _('edit commit message')),
|
|
2447
|
('f', 'force', None, _('import uncommitted changes into patch')),
|
|
2456
|
('f', 'force', None, _('import uncommitted changes into patch')),
|
|
2448
|
('g', 'git', None, _('use git extended diff format')),
|
|
2457
|
('g', 'git', None, _('use git extended diff format')),
|
|
2449
|
('U', 'currentuser', None, _('add "From: <current user>" to patch')),
|
|
2458
|
('U', 'currentuser', None, _('add "From: <current user>" to patch')),
|
|
2450
|
('u', 'user', '', _('add "From: <given user>" to patch')),
|
|
2459
|
('u', 'user', '', _('add "From: <given user>" to patch')),
|
|
2451
|
('D', 'currentdate', None, _('add "Date: <current date>" to patch')),
|
|
2460
|
('D', 'currentdate', None, _('add "Date: <current date>" to patch')),
|
|
2452
|
('d', 'date', '', _('add "Date: <given date>" to patch'))
|
|
2461
|
('d', 'date', '', _('add "Date: <given date>" to patch'))
|
|
2453
|
] + commands.walkopts + commands.commitopts,
|
|
2462
|
] + commands.walkopts + commands.commitopts,
|
|
2454
|
_('hg qnew [-e] [-m TEXT] [-l FILE] [-f] PATCH [FILE]...')),
|
|
2463
|
_('hg qnew [-e] [-m TEXT] [-l FILE] [-f] PATCH [FILE]...')),
|
|
2455
|
"qnext": (next, [] + seriesopts, _('hg qnext [-s]')),
|
|
2464
|
"qnext": (next, [] + seriesopts, _('hg qnext [-s]')),
|
|
2456
|
"qprev": (prev, [] + seriesopts, _('hg qprev [-s]')),
|
|
2465
|
"qprev": (prev, [] + seriesopts, _('hg qprev [-s]')),
|
|
2457
|
"^qpop":
|
|
2466
|
"^qpop":
|
|
2458
|
(pop,
|
|
2467
|
(pop,
|
|
2459
|
[('a', 'all', None, _('pop all patches')),
|
|
2468
|
[('a', 'all', None, _('pop all patches')),
|
|
2460
|
('n', 'name', '', _('queue name to pop')),
|
|
2469
|
('n', 'name', '', _('queue name to pop')),
|
|
2461
|
('f', 'force', None, _('forget any local changes'))],
|
|
2470
|
('f', 'force', None, _('forget any local changes'))],
|
|
2462
|
_('hg qpop [-a] [-n NAME] [-f] [PATCH | INDEX]')),
|
|
2471
|
_('hg qpop [-a] [-n NAME] [-f] [PATCH | INDEX]')),
|
|
2463
|
"^qpush":
|
|
2472
|
"^qpush":
|
|
2464
|
(push,
|
|
2473
|
(push,
|
|
2465
|
[('f', 'force', None, _('apply if the patch has rejects')),
|
|
2474
|
[('f', 'force', None, _('apply if the patch has rejects')),
|
|
2466
|
('l', 'list', None, _('list patch name in commit text')),
|
|
2475
|
('l', 'list', None, _('list patch name in commit text')),
|
|
2467
|
('a', 'all', None, _('apply all patches')),
|
|
2476
|
('a', 'all', None, _('apply all patches')),
|
|
2468
|
('m', 'merge', None, _('merge from another queue')),
|
|
2477
|
('m', 'merge', None, _('merge from another queue')),
|
|
2469
|
('n', 'name', '', _('merge queue name'))],
|
|
2478
|
('n', 'name', '', _('merge queue name'))],
|
|
2470
|
_('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]')),
|
|
2479
|
_('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]')),
|
|
2471
|
"^qrefresh":
|
|
2480
|
"^qrefresh":
|
|
2472
|
(refresh,
|
|
2481
|
(refresh,
|
|
2473
|
[('e', 'edit', None, _('edit commit message')),
|
|
2482
|
[('e', 'edit', None, _('edit commit message')),
|
|
2474
|
('g', 'git', None, _('use git extended diff format')),
|
|
2483
|
('g', 'git', None, _('use git extended diff format')),
|
|
2475
|
('s', 'short', None, _('refresh only files already in the patch and specified files')),
|
|
2484
|
('s', 'short', None, _('refresh only files already in the patch and specified files')),
|
|
2476
|
('U', 'currentuser', None, _('add/update "From: <current user>" in patch')),
|
|
2485
|
('U', 'currentuser', None, _('add/update "From: <current user>" in patch')),
|
|
2477
|
('u', 'user', '', _('add/update "From: <given user>" in patch')),
|
|
2486
|
('u', 'user', '', _('add/update "From: <given user>" in patch')),
|
|
2478
|
('D', 'currentdate', None, _('update "Date: <current date>" in patch (if present)')),
|
|
2487
|
('D', 'currentdate', None, _('update "Date: <current date>" in patch (if present)')),
|
|
2479
|
('d', 'date', '', _('update "Date: <given date>" in patch (if present)'))
|
|
2488
|
('d', 'date', '', _('update "Date: <given date>" in patch (if present)'))
|
|
2480
|
] + commands.walkopts + commands.commitopts,
|
|
2489
|
] + commands.walkopts + commands.commitopts,
|
|
2481
|
_('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')),
|
|
2490
|
_('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')),
|
|
2482
|
'qrename|qmv':
|
|
2491
|
'qrename|qmv':
|
|
2483
|
(rename, [], _('hg qrename PATCH1 [PATCH2]')),
|
|
2492
|
(rename, [], _('hg qrename PATCH1 [PATCH2]')),
|
|
2484
|
"qrestore":
|
|
2493
|
"qrestore":
|
|
2485
|
(restore,
|
|
2494
|
(restore,
|
|
2486
|
[('d', 'delete', None, _('delete save entry')),
|
|
2495
|
[('d', 'delete', None, _('delete save entry')),
|
|
2487
|
('u', 'update', None, _('update queue working dir'))],
|
|
2496
|
('u', 'update', None, _('update queue working dir'))],
|
|
2488
|
_('hg qrestore [-d] [-u] REV')),
|
|
2497
|
_('hg qrestore [-d] [-u] REV')),
|
|
2489
|
"qsave":
|
|
2498
|
"qsave":
|
|
2490
|
(save,
|
|
2499
|
(save,
|
|
2491
|
[('c', 'copy', None, _('copy patch directory')),
|
|
2500
|
[('c', 'copy', None, _('copy patch directory')),
|
|
2492
|
('n', 'name', '', _('copy directory name')),
|
|
2501
|
('n', 'name', '', _('copy directory name')),
|
|
2493
|
('e', 'empty', None, _('clear queue status file')),
|
|
2502
|
('e', 'empty', None, _('clear queue status file')),
|
|
2494
|
('f', 'force', None, _('force copy'))] + commands.commitopts,
|
|
2503
|
('f', 'force', None, _('force copy'))] + commands.commitopts,
|
|
2495
|
_('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]')),
|
|
2504
|
_('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]')),
|
|
2496
|
"qselect":
|
|
2505
|
"qselect":
|
|
2497
|
(select,
|
|
2506
|
(select,
|
|
2498
|
[('n', 'none', None, _('disable all guards')),
|
|
2507
|
[('n', 'none', None, _('disable all guards')),
|
|
2499
|
('s', 'series', None, _('list all guards in series file')),
|
|
2508
|
('s', 'series', None, _('list all guards in series file')),
|
|
2500
|
('', 'pop', None, _('pop to before first guarded applied patch')),
|
|
2509
|
('', 'pop', None, _('pop to before first guarded applied patch')),
|
|
2501
|
('', 'reapply', None, _('pop, then reapply patches'))],
|
|
2510
|
('', 'reapply', None, _('pop, then reapply patches'))],
|
|
2502
|
_('hg qselect [OPTION]... [GUARD]...')),
|
|
2511
|
_('hg qselect [OPTION]... [GUARD]...')),
|
|
2503
|
"qseries":
|
|
2512
|
"qseries":
|
|
2504
|
(series,
|
|
2513
|
(series,
|
|
2505
|
[('m', 'missing', None, _('print patches not in series')),
|
|
2514
|
[('m', 'missing', None, _('print patches not in series')),
|
|
2506
|
] + seriesopts,
|
|
2515
|
] + seriesopts,
|
|
2507
|
_('hg qseries [-ms]')),
|
|
2516
|
_('hg qseries [-ms]')),
|
|
2508
|
"^strip":
|
|
2517
|
"^strip":
|
|
2509
|
(strip,
|
|
2518
|
(strip,
|
|
2510
|
[('f', 'force', None, _('force removal with local changes')),
|
|
2519
|
[('f', 'force', None, _('force removal with local changes')),
|
|
2511
|
('b', 'backup', None, _('bundle unrelated changesets')),
|
|
2520
|
('b', 'backup', None, _('bundle unrelated changesets')),
|
|
2512
|
('n', 'nobackup', None, _('no backups'))],
|
|
2521
|
('n', 'nobackup', None, _('no backups'))],
|
|
2513
|
_('hg strip [-f] [-b] [-n] REV')),
|
|
2522
|
_('hg strip [-f] [-b] [-n] REV')),
|
|
2514
|
"qtop": (top, [] + seriesopts, _('hg qtop [-s]')),
|
|
2523
|
"qtop": (top, [] + seriesopts, _('hg qtop [-s]')),
|
|
2515
|
"qunapplied": (unapplied, [] + seriesopts, _('hg qunapplied [-s] [PATCH]')),
|
|
2524
|
"qunapplied": (unapplied, [] + seriesopts, _('hg qunapplied [-s] [PATCH]')),
|
|
2516
|
"qfinish":
|
|
2525
|
"qfinish":
|
|
2517
|
(finish,
|
|
2526
|
(finish,
|
|
2518
|
[('a', 'applied', None, _('finish all applied changesets'))],
|
|
2527
|
[('a', 'applied', None, _('finish all applied changesets'))],
|
|
2519
|
_('hg qfinish [-a] [REV...]')),
|
|
2528
|
_('hg qfinish [-a] [REV...]')),
|
|
2520
|
}
|
|
2529
|
}
|