##// END OF EJS Templates
transplant: permit merge changesets via --parent...
Steven Stallion -
r16400:f2ba409d default
parent child Browse files
Show More
@@ -144,14 +144,26 b' class transplanter(object):'
144 if not hasnode(repo, node):
144 if not hasnode(repo, node):
145 repo.pull(source, heads=[node])
145 repo.pull(source, heads=[node])
146
146
147 skipmerge = False
147 if parents[1] != revlog.nullid:
148 if parents[1] != revlog.nullid:
148 self.ui.note(_('skipping merge changeset %s:%s\n')
149 if not opts.get('parent'):
149 % (rev, short(node)))
150 self.ui.note(_('skipping merge changeset %s:%s\n')
151 % (rev, short(node)))
152 skipmerge = True
153 else:
154 parent = source.lookup(opts['parent'])
155 if parent not in parents:
156 raise util.Abort(_('%s is not a parent of %s') %
157 (short(parent), short(node)))
158 else:
159 parent = parents[0]
160
161 if skipmerge:
150 patchfile = None
162 patchfile = None
151 else:
163 else:
152 fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
164 fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
153 fp = os.fdopen(fd, 'w')
165 fp = os.fdopen(fd, 'w')
154 gen = patch.diff(source, parents[0], node, opts=diffopts)
166 gen = patch.diff(source, parent, node, opts=diffopts)
155 for chunk in gen:
167 for chunk in gen:
156 fp.write(chunk)
168 fp.write(chunk)
157 fp.close()
169 fp.close()
@@ -295,19 +307,29 b' class transplanter(object):'
295 def recover(self, repo):
307 def recover(self, repo):
296 '''commit working directory using journal metadata'''
308 '''commit working directory using journal metadata'''
297 node, user, date, message, parents = self.readlog()
309 node, user, date, message, parents = self.readlog()
298 merge = len(parents) == 2
310 merge = False
299
311
300 if not user or not date or not message or not parents[0]:
312 if not user or not date or not message or not parents[0]:
301 raise util.Abort(_('transplant log file is corrupt'))
313 raise util.Abort(_('transplant log file is corrupt'))
302
314
315 parent = parents[0]
316 if len(parents) > 1:
317 if opts.get('parent'):
318 parent = source.lookup(opts['parent'])
319 if parent not in parents:
320 raise util.Abort(_('%s is not a parent of %s') %
321 (short(parent), short(node)))
322 else:
323 merge = True
324
303 extra = {'transplant_source': node}
325 extra = {'transplant_source': node}
304 wlock = repo.wlock()
326 wlock = repo.wlock()
305 try:
327 try:
306 p1, p2 = repo.dirstate.parents()
328 p1, p2 = repo.dirstate.parents()
307 if p1 != parents[0]:
329 if p1 != parent:
308 raise util.Abort(
330 raise util.Abort(
309 _('working dir not at transplant parent %s') %
331 _('working dir not at transplant parent %s') %
310 revlog.hex(parents[0]))
332 revlog.hex(parent))
311 if merge:
333 if merge:
312 repo.dirstate.setparents(p1, parents[1])
334 repo.dirstate.setparents(p1, parents[1])
313 n = repo.commit(message, user, date, extra=extra,
335 n = repo.commit(message, user, date, extra=extra,
@@ -468,6 +490,8 b' def browserevs(ui, repo, nodes, opts):'
468 ('a', 'all', None, _('pull all changesets up to BRANCH')),
490 ('a', 'all', None, _('pull all changesets up to BRANCH')),
469 ('p', 'prune', [], _('skip over REV'), _('REV')),
491 ('p', 'prune', [], _('skip over REV'), _('REV')),
470 ('m', 'merge', [], _('merge at REV'), _('REV')),
492 ('m', 'merge', [], _('merge at REV'), _('REV')),
493 ('', 'parent', '',
494 _('parent to choose when transplanting merge'), _('REV')),
471 ('e', 'edit', False, _('invoke editor on commit messages')),
495 ('e', 'edit', False, _('invoke editor on commit messages')),
472 ('', 'log', None, _('append transplant info to log message')),
496 ('', 'log', None, _('append transplant info to log message')),
473 ('c', 'continue', None, _('continue last transplant session '
497 ('c', 'continue', None, _('continue last transplant session '
@@ -510,6 +534,9 b' def transplant(ui, repo, *revs, **opts):'
510 of a merged transplant, and you can merge descendants of them
534 of a merged transplant, and you can merge descendants of them
511 normally instead of transplanting them.
535 normally instead of transplanting them.
512
536
537 Merge changesets may be transplanted directly by specifying the
538 proper parent changeset by calling :hg: `transplant --parent`.
539
513 If no merges or revisions are provided, :hg:`transplant` will
540 If no merges or revisions are provided, :hg:`transplant` will
514 start an interactive changeset browser.
541 start an interactive changeset browser.
515
542
@@ -424,3 +424,57 b' test with a win32ext like setup (differi'
424 a\r (esc)
424 a\r (esc)
425 b\r (esc)
425 b\r (esc)
426 $ cd ..
426 $ cd ..
427
428 test transplant with merge changeset is skipped
429
430 $ hg init merge1a
431 $ cd merge1a
432 $ echo a > a
433 $ hg ci -Am a
434 adding a
435 $ hg branch b
436 marked working directory as branch b
437 (branches are permanent and global, did you want a bookmark?)
438 $ hg ci -m branchb
439 $ echo b > b
440 $ hg ci -Am b
441 adding b
442 $ hg update default
443 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
444 $ hg merge b
445 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
446 (branch merge, don't forget to commit)
447 $ hg ci -m mergeb
448 $ cd ..
449
450 $ hg init merge1b
451 $ cd merge1b
452 $ hg transplant -s ../merge1a tip
453
454 test transplant with merge changeset accepts --parent
455
456 $ hg init merge2a
457 $ cd merge2a
458 $ echo a > a
459 $ hg ci -Am a
460 adding a
461 $ hg branch b
462 marked working directory as branch b
463 (branches are permanent and global, did you want a bookmark?)
464 $ hg ci -m branchb
465 $ echo b > b
466 $ hg ci -Am b
467 adding b
468 $ hg update default
469 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
470 $ hg merge b
471 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
472 (branch merge, don't forget to commit)
473 $ hg ci -m mergeb
474 $ cd ..
475
476 $ hg init merge2b
477 $ cd merge2b
478 $ hg transplant -s ../merge2a --parent 0 tip
479 applying be9f9b39483f
480 be9f9b39483f transplanted to 9959e51f94d1
General Comments 0
You need to be logged in to leave comments. Login now