172 % (rev, short(node))) |
172 % (rev, short(node))) |
173 skipmerge = True |
173 skipmerge = True |
174 else: |
174 else: |
175 parent = source.lookup(opts['parent']) |
175 parent = source.lookup(opts['parent']) |
176 if parent not in parents: |
176 if parent not in parents: |
177 raise util.Abort(_('%s is not a parent of %s') % |
177 raise error.Abort(_('%s is not a parent of %s') % |
178 (short(parent), short(node))) |
178 (short(parent), short(node))) |
179 else: |
179 else: |
180 parent = parents[0] |
180 parent = parents[0] |
181 |
181 |
182 if skipmerge: |
182 if skipmerge: |
243 self.ui.system('%s %s %s' % (filter, util.shellquote(headerfile), |
243 self.ui.system('%s %s %s' % (filter, util.shellquote(headerfile), |
244 util.shellquote(patchfile)), |
244 util.shellquote(patchfile)), |
245 environ={'HGUSER': changelog[1], |
245 environ={'HGUSER': changelog[1], |
246 'HGREVISION': revlog.hex(node), |
246 'HGREVISION': revlog.hex(node), |
247 }, |
247 }, |
248 onerr=util.Abort, errprefix=_('filter failed')) |
248 onerr=error.Abort, errprefix=_('filter failed')) |
249 user, date, msg = self.parselog(file(headerfile))[1:4] |
249 user, date, msg = self.parselog(file(headerfile))[1:4] |
250 finally: |
250 finally: |
251 os.unlink(headerfile) |
251 os.unlink(headerfile) |
252 |
252 |
253 return (user, date, msg) |
253 return (user, date, msg) |
267 |
267 |
268 self.ui.status(_('applying %s\n') % short(node)) |
268 self.ui.status(_('applying %s\n') % short(node)) |
269 self.ui.note('%s %s\n%s\n' % (user, date, message)) |
269 self.ui.note('%s %s\n%s\n' % (user, date, message)) |
270 |
270 |
271 if not patchfile and not merge: |
271 if not patchfile and not merge: |
272 raise util.Abort(_('can only omit patchfile if merging')) |
272 raise error.Abort(_('can only omit patchfile if merging')) |
273 if patchfile: |
273 if patchfile: |
274 try: |
274 try: |
275 files = set() |
275 files = set() |
276 patch.patch(self.ui, repo, patchfile, files=files, eolmode=None) |
276 patch.patch(self.ui, repo, patchfile, files=files, eolmode=None) |
277 files = list(files) |
277 files = list(files) |
330 '''commit working directory using journal metadata''' |
330 '''commit working directory using journal metadata''' |
331 node, user, date, message, parents = self.readlog() |
331 node, user, date, message, parents = self.readlog() |
332 merge = False |
332 merge = False |
333 |
333 |
334 if not user or not date or not message or not parents[0]: |
334 if not user or not date or not message or not parents[0]: |
335 raise util.Abort(_('transplant log file is corrupt')) |
335 raise error.Abort(_('transplant log file is corrupt')) |
336 |
336 |
337 parent = parents[0] |
337 parent = parents[0] |
338 if len(parents) > 1: |
338 if len(parents) > 1: |
339 if opts.get('parent'): |
339 if opts.get('parent'): |
340 parent = source.lookup(opts['parent']) |
340 parent = source.lookup(opts['parent']) |
341 if parent not in parents: |
341 if parent not in parents: |
342 raise util.Abort(_('%s is not a parent of %s') % |
342 raise error.Abort(_('%s is not a parent of %s') % |
343 (short(parent), short(node))) |
343 (short(parent), short(node))) |
344 else: |
344 else: |
345 merge = True |
345 merge = True |
346 |
346 |
347 extra = {'transplant_source': node} |
347 extra = {'transplant_source': node} |
348 wlock = repo.wlock() |
348 wlock = repo.wlock() |
349 try: |
349 try: |
350 p1, p2 = repo.dirstate.parents() |
350 p1, p2 = repo.dirstate.parents() |
351 if p1 != parent: |
351 if p1 != parent: |
352 raise util.Abort(_('working directory not at transplant ' |
352 raise error.Abort(_('working directory not at transplant ' |
353 'parent %s') % revlog.hex(parent)) |
353 'parent %s') % revlog.hex(parent)) |
354 if merge: |
354 if merge: |
355 repo.setparents(p1, parents[1]) |
355 repo.setparents(p1, parents[1]) |
356 modified, added, removed, deleted = repo.status()[:4] |
356 modified, added, removed, deleted = repo.status()[:4] |
357 if merge or modified or added or removed or deleted: |
357 if merge or modified or added or removed or deleted: |
358 n = repo.commit(message, user, date, extra=extra, |
358 n = repo.commit(message, user, date, extra=extra, |
359 editor=self.getcommiteditor()) |
359 editor=self.getcommiteditor()) |
360 if not n: |
360 if not n: |
361 raise util.Abort(_('commit failed')) |
361 raise error.Abort(_('commit failed')) |
362 if not merge: |
362 if not merge: |
363 self.transplants.set(n, node) |
363 self.transplants.set(n, node) |
364 else: |
364 else: |
365 n = None |
365 n = None |
366 self.unlog() |
366 self.unlog() |
416 parents.append(revlog.bin(line[9:])) |
416 parents.append(revlog.bin(line[9:])) |
417 elif not line.startswith('# '): |
417 elif not line.startswith('# '): |
418 inmsg = True |
418 inmsg = True |
419 message.append(line) |
419 message.append(line) |
420 if None in (user, date): |
420 if None in (user, date): |
421 raise util.Abort(_("filter corrupted changeset (no user or date)")) |
421 raise error.Abort(_("filter corrupted changeset (no user or date)")) |
422 return (node, user, date, '\n'.join(message), parents) |
422 return (node, user, date, '\n'.join(message), parents) |
423 |
423 |
424 def log(self, user, date, message, p1, p2, merge=False): |
424 def log(self, user, date, message, p1, p2, merge=False): |
425 '''journal changelog metadata for later recover''' |
425 '''journal changelog metadata for later recover''' |
426 |
426 |
592 yield node |
592 yield node |
593 |
593 |
594 def checkopts(opts, revs): |
594 def checkopts(opts, revs): |
595 if opts.get('continue'): |
595 if opts.get('continue'): |
596 if opts.get('branch') or opts.get('all') or opts.get('merge'): |
596 if opts.get('branch') or opts.get('all') or opts.get('merge'): |
597 raise util.Abort(_('--continue is incompatible with ' |
597 raise error.Abort(_('--continue is incompatible with ' |
598 '--branch, --all and --merge')) |
598 '--branch, --all and --merge')) |
599 return |
599 return |
600 if not (opts.get('source') or revs or |
600 if not (opts.get('source') or revs or |
601 opts.get('merge') or opts.get('branch')): |
601 opts.get('merge') or opts.get('branch')): |
602 raise util.Abort(_('no source URL, branch revision or revision ' |
602 raise error.Abort(_('no source URL, branch revision or revision ' |
603 'list provided')) |
603 'list provided')) |
604 if opts.get('all'): |
604 if opts.get('all'): |
605 if not opts.get('branch'): |
605 if not opts.get('branch'): |
606 raise util.Abort(_('--all requires a branch revision')) |
606 raise error.Abort(_('--all requires a branch revision')) |
607 if revs: |
607 if revs: |
608 raise util.Abort(_('--all is incompatible with a ' |
608 raise error.Abort(_('--all is incompatible with a ' |
609 'revision list')) |
609 'revision list')) |
610 |
610 |
611 checkopts(opts, revs) |
611 checkopts(opts, revs) |
612 |
612 |
613 if not opts.get('log'): |
613 if not opts.get('log'): |
620 tp = transplanter(ui, repo, opts) |
620 tp = transplanter(ui, repo, opts) |
621 |
621 |
622 cmdutil.checkunfinished(repo) |
622 cmdutil.checkunfinished(repo) |
623 p1, p2 = repo.dirstate.parents() |
623 p1, p2 = repo.dirstate.parents() |
624 if len(repo) > 0 and p1 == revlog.nullid: |
624 if len(repo) > 0 and p1 == revlog.nullid: |
625 raise util.Abort(_('no revision checked out')) |
625 raise error.Abort(_('no revision checked out')) |
626 if not opts.get('continue'): |
626 if not opts.get('continue'): |
627 if p2 != revlog.nullid: |
627 if p2 != revlog.nullid: |
628 raise util.Abort(_('outstanding uncommitted merges')) |
628 raise error.Abort(_('outstanding uncommitted merges')) |
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 raise util.Abort(_('outstanding local changes')) |
631 raise error.Abort(_('outstanding local changes')) |
632 |
632 |
633 sourcerepo = opts.get('source') |
633 sourcerepo = opts.get('source') |
634 if sourcerepo: |
634 if sourcerepo: |
635 peer = hg.peer(repo, opts, ui.expandpath(sourcerepo)) |
635 peer = hg.peer(repo, opts, ui.expandpath(sourcerepo)) |
636 heads = map(peer.lookup, opts.get('branch', ())) |
636 heads = map(peer.lookup, opts.get('branch', ())) |