5 imerge - interactive merge |
5 imerge - interactive merge |
6 ''' |
6 ''' |
7 |
7 |
8 from mercurial.i18n import _ |
8 from mercurial.i18n import _ |
9 from mercurial.node import * |
9 from mercurial.node import * |
10 from mercurial import commands, cmdutil, fancyopts, hg, merge, util |
10 from mercurial import commands, cmdutil, dispatch, fancyopts, hg, merge, util |
11 import os, tarfile |
11 import os, tarfile |
12 |
12 |
13 class InvalidStateFileException(Exception): pass |
13 class InvalidStateFileException(Exception): pass |
14 |
14 |
15 class ImergeStateFile(object): |
15 class ImergeStateFile(object): |
111 |
111 |
112 def filemerge(self, fn): |
112 def filemerge(self, fn): |
113 wlock = self.repo.wlock() |
113 wlock = self.repo.wlock() |
114 |
114 |
115 (fd, fo) = self.conflicts[fn] |
115 (fd, fo) = self.conflicts[fn] |
116 p2 = self.wctx.parents()[1] |
116 p1, p2 = self.wctx.parents() |
117 return merge.filemerge(self.repo, fn, fd, fo, self.wctx, p2) |
117 # The filemerge ancestor algorithm does not work if self.wctx |
|
118 # already has two parents (in normal merge it doesn't yet). But |
|
119 # this is very dirty. |
|
120 self.wctx._parents.pop() |
|
121 try: |
|
122 return merge.filemerge(self.repo, fn, fd, fo, self.wctx, p2) |
|
123 finally: |
|
124 self.wctx._parents.append(p2) |
118 |
125 |
119 def start(self, rev=None): |
126 def start(self, rev=None): |
120 _filemerge = merge.filemerge |
127 _filemerge = merge.filemerge |
121 def filemerge(repo, fw, fd, fo, wctx, mctx): |
128 def filemerge(repo, fw, fd, fo, wctx, mctx): |
122 self.conflicts[fw] = (fd, fo) |
129 self.conflicts[fw] = (fd, fo) |
267 ('', 'resolved', None, _('only show resolved conflicts')), |
274 ('', 'resolved', None, _('only show resolved conflicts')), |
268 ('', 'unresolved', None, _('only show unresolved conflicts'))]), |
275 ('', 'unresolved', None, _('only show unresolved conflicts'))]), |
269 'unresolve': (unresolve, []) |
276 'unresolve': (unresolve, []) |
270 } |
277 } |
271 |
278 |
272 def dispatch(im, args, opts): |
279 def dispatch_(im, args, opts): |
273 def complete(s, choices): |
280 def complete(s, choices): |
274 candidates = [] |
281 candidates = [] |
275 for choice in choices: |
282 for choice in choices: |
276 if choice.startswith(s): |
283 if choice.startswith(s): |
277 candidates.append(choice) |
284 candidates.append(choice) |
290 opts = {} |
297 opts = {} |
291 try: |
298 try: |
292 args = fancyopts.fancyopts(args, optlist, opts) |
299 args = fancyopts.fancyopts(args, optlist, opts) |
293 return func(im, *args, **opts) |
300 return func(im, *args, **opts) |
294 except fancyopts.getopt.GetoptError, inst: |
301 except fancyopts.getopt.GetoptError, inst: |
295 raise cmdutil.ParseError('imerge', '%s: %s' % (cmd, inst)) |
302 raise dispatch.ParseError('imerge', '%s: %s' % (cmd, inst)) |
296 except TypeError: |
303 except TypeError: |
297 raise cmdutil.ParseError('imerge', _('%s: invalid arguments') % cmd) |
304 raise dispatch.ParseError('imerge', _('%s: invalid arguments') % cmd) |
298 |
305 |
299 def imerge(ui, repo, *args, **opts): |
306 def imerge(ui, repo, *args, **opts): |
300 '''interactive merge |
307 '''interactive merge |
301 |
308 |
302 imerge lets you split a merge into pieces. When you start a merge |
309 imerge lets you split a merge into pieces. When you start a merge |
315 |
322 |
316 The following subcommands are available: |
323 The following subcommands are available: |
317 |
324 |
318 status: |
325 status: |
319 show the current state of the merge |
326 show the current state of the merge |
|
327 options: |
|
328 -n --no-status: do not print the status prefix |
|
329 --resolved: only print resolved conflicts |
|
330 --unresolved: only print unresolved conflicts |
320 next: |
331 next: |
321 show the next unresolved file merge |
332 show the next unresolved file merge |
322 merge [<file>]: |
333 merge [<file>]: |
323 merge <file>. If the file merge is successful, the file will be |
334 merge <file>. If the file merge is successful, the file will be |
324 recorded as resolved. If no file is given, the next unresolved |
335 recorded as resolved. If no file is given, the next unresolved |