Show More
@@ -7,7 +7,7 b' imerge - interactive merge' | |||
|
7 | 7 | |
|
8 | 8 | from mercurial.i18n import _ |
|
9 | 9 | from mercurial.node import * |
|
10 | from mercurial import commands, cmdutil, hg, merge, util | |
|
10 | from mercurial import commands, cmdutil, fancyopts, hg, merge, util | |
|
11 | 11 | import os, tarfile |
|
12 | 12 | |
|
13 | 13 | class InvalidStateFileException(Exception): pass |
@@ -135,27 +135,6 b' class Imerge(object):' | |||
|
135 | 135 | if p1.node() != dp[0] or p2.node() != dp[1]: |
|
136 | 136 | raise util.Abort('imerge state does not match working directory') |
|
137 | 137 | |
|
138 | def status(self): | |
|
139 | p1, p2 = self.wctx.parents() | |
|
140 | self.ui.write('merging %s and %s\n' % \ | |
|
141 | (short(p1.node()), short(p2.node()))) | |
|
142 | ||
|
143 | if self.resolved: | |
|
144 | self.ui.write('resolved:\n') | |
|
145 | for fn in self.resolved: | |
|
146 | self.ui.write(' %s\n' % fn) | |
|
147 | remaining = [f for f in self.conflicts if f not in self.resolved] | |
|
148 | if remaining: | |
|
149 | self.ui.write('remaining:\n') | |
|
150 | for fn in remaining: | |
|
151 | (fd, fo) = self.conflicts[fn] | |
|
152 | if fn == fo: | |
|
153 | self.ui.write(' %s\n' % (fn,)) | |
|
154 | else: | |
|
155 | self.ui.write(' %s (%s)\n' % (fn, fd)) | |
|
156 | else: | |
|
157 | self.ui.write('all conflicts resolved\n') | |
|
158 | ||
|
159 | 138 | def next(self): |
|
160 | 139 | remaining = self.remaining() |
|
161 | 140 | return remaining and remaining[0] |
@@ -202,7 +181,7 b' def load(im, source):' | |||
|
202 | 181 | |
|
203 | 182 | rc = im.unpickle(source) |
|
204 | 183 | if not rc: |
|
205 |
|
|
|
184 | status(im) | |
|
206 | 185 | return rc |
|
207 | 186 | |
|
208 | 187 | def merge_(im, filename=None): |
@@ -236,8 +215,39 b' def resolve(im, *files):' | |||
|
236 | 215 | def save(im, dest): |
|
237 | 216 | return im.pickle(dest) |
|
238 | 217 | |
|
239 | def status(im): | |
|
240 | im.status() | |
|
218 | def status(im, **opts): | |
|
219 | if not opts.get('resolved') and not opts.get('unresolved'): | |
|
220 | opts['resolved'] = True | |
|
221 | opts['unresolved'] = True | |
|
222 | ||
|
223 | if im.ui.verbose: | |
|
224 | p1, p2 = [short(p.node()) for p in im.wctx.parents()] | |
|
225 | im.ui.note(_('merging %s and %s\n') % (p1, p2)) | |
|
226 | ||
|
227 | conflicts = im.conflicts.keys() | |
|
228 | conflicts.sort() | |
|
229 | remaining = dict.fromkeys(im.remaining()) | |
|
230 | st = [] | |
|
231 | for fn in conflicts: | |
|
232 | if opts.get('no_status'): | |
|
233 | mode = '' | |
|
234 | elif fn in remaining: | |
|
235 | mode = 'U ' | |
|
236 | else: | |
|
237 | mode = 'R ' | |
|
238 | if ((opts.get('resolved') and fn not in remaining) | |
|
239 | or (opts.get('unresolved') and fn in remaining)): | |
|
240 | st.append((mode, fn)) | |
|
241 | st.sort() | |
|
242 | for (mode, fn) in st: | |
|
243 | if im.ui.verbose: | |
|
244 | fo, fd = im.conflicts[fn] | |
|
245 | if fd != fn: | |
|
246 | fn = '%s (%s)' % (fn, fd) | |
|
247 | im.ui.write('%s%s\n' % (mode, fn)) | |
|
248 | if opts.get('unresolved') and not remaining: | |
|
249 | im.ui.write(_('all conflicts resolved\n')) | |
|
250 | ||
|
241 | 251 | return 0 |
|
242 | 252 | |
|
243 | 253 | def unresolve(im, *files): |
@@ -246,13 +256,16 b' def unresolve(im, *files):' | |||
|
246 | 256 | return im.unresolve(files) |
|
247 | 257 | |
|
248 | 258 | subcmdtable = { |
|
249 | 'load': load, | |
|
250 | 'merge': merge_, | |
|
251 | 'next': next, | |
|
252 | 'resolve': resolve, | |
|
253 | 'save': save, | |
|
254 | 'status': status, | |
|
255 | 'unresolve': unresolve | |
|
259 | 'load': (load, []), | |
|
260 | 'merge': (merge_, []), | |
|
261 | 'next': (next, []), | |
|
262 | 'resolve': (resolve, []), | |
|
263 | 'save': (save, []), | |
|
264 | 'status': (status, | |
|
265 | [('n', 'no-status', None, _('hide status prefix')), | |
|
266 | ('', 'resolved', None, _('only show resolved conflicts')), | |
|
267 | ('', 'unresolved', None, _('only show unresolved conflicts'))]), | |
|
268 | 'unresolve': (unresolve, []) | |
|
256 | 269 | } |
|
257 | 270 | |
|
258 | 271 | def dispatch(im, args, opts): |
@@ -263,7 +276,7 b' def dispatch(im, args, opts):' | |||
|
263 | 276 | candidates.append(choice) |
|
264 | 277 | return candidates |
|
265 | 278 | |
|
266 | c, args = args[0], args[1:] | |
|
279 | c, args = args[0], list(args[1:]) | |
|
267 | 280 | cmd = complete(c, subcmdtable.keys()) |
|
268 | 281 | if not cmd: |
|
269 | 282 | raise cmdutil.UnknownCommand('imerge ' + c) |
@@ -272,11 +285,15 b' def dispatch(im, args, opts):' | |||
|
272 | 285 | raise cmdutil.AmbiguousCommand('imerge ' + c, cmd) |
|
273 | 286 | cmd = cmd[0] |
|
274 | 287 | |
|
275 | func = subcmdtable[cmd] | |
|
288 | func, optlist = subcmdtable[cmd] | |
|
289 | opts = {} | |
|
276 | 290 | try: |
|
277 | return func(im, *args) | |
|
291 | args = fancyopts.fancyopts(args, optlist, opts) | |
|
292 | return func(im, *args, **opts) | |
|
293 | except fancyopts.getopt.GetoptError, inst: | |
|
294 | raise cmdutil.ParseError('imerge', '%s: %s' % (cmd, inst)) | |
|
278 | 295 | except TypeError: |
|
279 | raise cmdutil.ParseError('imerge', '%s: invalid arguments' % cmd) | |
|
296 | raise cmdutil.ParseError('imerge', _('%s: invalid arguments') % cmd) | |
|
280 | 297 | |
|
281 | 298 | def imerge(ui, repo, *args, **opts): |
|
282 | 299 | '''interactive merge |
@@ -27,8 +27,8 b' hg imerge' | |||
|
27 | 27 | cat foo2 |
|
28 | 28 | cat bar |
|
29 | 29 | |
|
30 | echo % status | |
|
31 | hg imerge st | |
|
30 | echo % status -v | |
|
31 | hg -v imerge st | |
|
32 | 32 | |
|
33 | 33 | echo % next |
|
34 | 34 | hg imerge next |
@@ -4,17 +4,14 b' 1 files updated, 0 files merged, 1 files' | |||
|
4 | 4 | % start imerge |
|
5 | 5 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
6 | 6 | (branch merge, don't forget to commit) |
|
7 | merging e6da46716401 and 30d266f502e7 | |
|
8 | remaining: | |
|
9 | foo (foo2) | |
|
7 | U foo | |
|
10 | 8 | foo |
|
11 | 9 | bar |
|
12 | 10 | bar |
|
13 | 11 | bar |
|
14 | % status | |
|
12 | % status -v | |
|
15 | 13 | merging e6da46716401 and 30d266f502e7 |
|
16 | remaining: | |
|
17 | foo (foo2) | |
|
14 | U foo (foo2) | |
|
18 | 15 | % next |
|
19 | 16 | foo |
|
20 | 17 | % merge next |
@@ -30,9 +27,7 b' 2 files updated, 0 files merged, 1 files' | |||
|
30 | 27 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
31 | 28 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
32 | 29 | (branch merge, don't forget to commit) |
|
33 | merging e6da46716401 and 30d266f502e7 | |
|
34 | resolved: | |
|
35 | foo | |
|
30 | R foo | |
|
36 | 31 | all conflicts resolved |
|
37 | 32 | foo |
|
38 | 33 | changeset: 3:fa9a6defdcaf |
General Comments 0
You need to be logged in to leave comments.
Login now