Show More
@@ -3425,3 +3425,90 b' def hgabortgraft(ui, repo):' | |||||
3425 | with repo.wlock(): |
|
3425 | with repo.wlock(): | |
3426 | graftstate = statemod.cmdstate(repo, 'graftstate') |
|
3426 | graftstate = statemod.cmdstate(repo, 'graftstate') | |
3427 | return abortgraft(ui, repo, graftstate) |
|
3427 | return abortgraft(ui, repo, graftstate) | |
|
3428 | ||||
|
3429 | def continuegraft(ui, repo): | |||
|
3430 | """logic to resume interrupted graft using 'hg continue'""" | |||
|
3431 | with repo.wlock(): | |||
|
3432 | graftstate = statemod.cmdstate(repo, 'graftstate') | |||
|
3433 | statedata = readgraftstate(repo, graftstate) | |||
|
3434 | opts = {} | |||
|
3435 | cont = True | |||
|
3436 | if statedata.get('date'): | |||
|
3437 | opts['date'] = statedata['date'] | |||
|
3438 | if statedata.get('user'): | |||
|
3439 | opts['user'] = statedata['user'] | |||
|
3440 | if statedata.get('log'): | |||
|
3441 | opts['log'] = True | |||
|
3442 | if statedata.get('no_commit'): | |||
|
3443 | opts['no_commit'] = statedata.get('no_commit') | |||
|
3444 | nodes = statedata['nodes'] | |||
|
3445 | revs = [repo[node].rev() for node in nodes] | |||
|
3446 | ||||
|
3447 | skipped = set() | |||
|
3448 | for rev in repo.revs('%ld and merge()', revs): | |||
|
3449 | ui.warn(_('skipping ungraftable merge revision %d\n') % rev) | |||
|
3450 | skipped.add(rev) | |||
|
3451 | revs = [r for r in revs if r not in skipped] | |||
|
3452 | if not revs: | |||
|
3453 | return -1 | |||
|
3454 | ||||
|
3455 | for pos, ctx in enumerate(repo.set("%ld", revs)): | |||
|
3456 | desc = '%d:%s "%s"' % (ctx.rev(), ctx, | |||
|
3457 | ctx.description().split('\n', 1)[0]) | |||
|
3458 | names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) | |||
|
3459 | if names: | |||
|
3460 | desc += ' (%s)' % ' '.join(names) | |||
|
3461 | ui.status(_('grafting %s\n') % desc) | |||
|
3462 | ||||
|
3463 | source = ctx.extra().get('source') | |||
|
3464 | extra = {} | |||
|
3465 | if source: | |||
|
3466 | extra['source'] = source | |||
|
3467 | extra['intermediate-source'] = ctx.hex() | |||
|
3468 | else: | |||
|
3469 | extra['source'] = ctx.hex() | |||
|
3470 | user = ctx.user() | |||
|
3471 | if opts.get('user'): | |||
|
3472 | user = opts['user'] | |||
|
3473 | statedata['user'] = user | |||
|
3474 | date = ctx.date() | |||
|
3475 | if opts.get('date'): | |||
|
3476 | date = opts['date'] | |||
|
3477 | statedata['date'] = date | |||
|
3478 | message = ctx.description() | |||
|
3479 | if opts.get('log'): | |||
|
3480 | message += '\n(grafted from %s)' % ctx.hex() | |||
|
3481 | statedata['log'] = True | |||
|
3482 | if not cont: | |||
|
3483 | # perform the graft merge with p1(rev) as 'ancestor' | |||
|
3484 | overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | |||
|
3485 | base = ctx.p1() | |||
|
3486 | with ui.configoverride(overrides, 'graft'): | |||
|
3487 | stats = mergemod.graft(repo, ctx, base, ['local', 'graft']) | |||
|
3488 | # report any conflicts | |||
|
3489 | if stats.unresolvedcount > 0: | |||
|
3490 | # write out state for --continue | |||
|
3491 | nodes = [repo[rev].hex() for rev in revs[pos:]] | |||
|
3492 | statedata['nodes'] = nodes | |||
|
3493 | stateversion = 1 | |||
|
3494 | graftstate.save(stateversion, statedata) | |||
|
3495 | hint = _("use 'hg resolve' and 'hg graft --continue'") | |||
|
3496 | raise error.Abort( | |||
|
3497 | _("unresolved conflicts, can't continue"), | |||
|
3498 | hint=hint) | |||
|
3499 | else: | |||
|
3500 | cont = False | |||
|
3501 | editor = getcommiteditor(editform='graft', | |||
|
3502 | **pycompat.strkwargs(opts)) | |||
|
3503 | if not opts.get('no_commit'): | |||
|
3504 | node = repo.commit(text=message, user=user, date=date, | |||
|
3505 | extra=extra, editor=editor) | |||
|
3506 | if node is None: | |||
|
3507 | ui.warn( | |||
|
3508 | _('note: graft of %d:%s created no changes to commit\n') % | |||
|
3509 | (ctx.rev(), ctx)) | |||
|
3510 | # checking that newnodes exist because old state files won't have it | |||
|
3511 | if statedata.get('newnodes') is not None: | |||
|
3512 | statedata['newnodes'].append(node) | |||
|
3513 | graftstate.delete() | |||
|
3514 | return 0 |
@@ -2706,6 +2706,7 b' def _stopgraft(ui, repo, graftstate):' | |||||
2706 | statemod.addunfinished( |
|
2706 | statemod.addunfinished( | |
2707 | 'graft', fname='graftstate', clearable=True, stopflag=True, |
|
2707 | 'graft', fname='graftstate', clearable=True, stopflag=True, | |
2708 | continueflag=True, abortfunc=cmdutil.hgabortgraft, |
|
2708 | continueflag=True, abortfunc=cmdutil.hgabortgraft, | |
|
2709 | continuefunc=cmdutil.continuegraft, | |||
2709 | cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop") |
|
2710 | cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop") | |
2710 | ) |
|
2711 | ) | |
2711 |
|
2712 |
@@ -1,4 +1,4 b'' | |||||
1 | #testcases abortcommand abortflag |
|
1 | #testcases abortcommand abortflag continueflag continuecommand | |
2 |
|
2 | |||
3 | $ cat >> $HGRCPATH <<EOF |
|
3 | $ cat >> $HGRCPATH <<EOF | |
4 | > [extdiff] |
|
4 | > [extdiff] | |
@@ -13,6 +13,13 b'' | |||||
13 | > EOF |
|
13 | > EOF | |
14 | #endif |
|
14 | #endif | |
15 |
|
15 | |||
|
16 | #if continueflag | |||
|
17 | $ cat >> $HGRCPATH <<EOF | |||
|
18 | > [alias] | |||
|
19 | > continue = graft --continue | |||
|
20 | > EOF | |||
|
21 | #endif | |||
|
22 | ||||
16 | Create a repo with some stuff in it: |
|
23 | Create a repo with some stuff in it: | |
17 |
|
24 | |||
18 | $ hg init a |
|
25 | $ hg init a | |
@@ -92,9 +99,11 b" Can't continue without starting:" | |||||
92 |
|
99 | |||
93 | $ hg -q up -cr tip |
|
100 | $ hg -q up -cr tip | |
94 | $ hg rm -q e |
|
101 | $ hg rm -q e | |
95 |
$ hg |
|
102 | $ hg continue | |
96 | abort: no graft in progress |
|
103 | abort: no graft in progress (continueflag !) | |
|
104 | abort: no operation in progress (no-continueflag !) | |||
97 | [255] |
|
105 | [255] | |
|
106 | ||||
98 | $ hg revert -r . -q e |
|
107 | $ hg revert -r . -q e | |
99 |
|
108 | |||
100 | Need to specify a rev: |
|
109 | Need to specify a rev: | |
@@ -1697,7 +1706,13 b' Writing the nodes in old format to graft' | |||||
1697 | $ hg resolve -m |
|
1706 | $ hg resolve -m | |
1698 | (no more unresolved files) |
|
1707 | (no more unresolved files) | |
1699 | continue: hg graft --continue |
|
1708 | continue: hg graft --continue | |
1700 | $ hg graft --continue |
|
1709 | ||
|
1710 | #if continuecommand | |||
|
1711 | $ hg continue --dry-run | |||
|
1712 | graft in progress, will be resumed | |||
|
1713 | #endif | |||
|
1714 | ||||
|
1715 | $ hg continue | |||
1701 | grafting 1:80e6d2c47cfe "added b" |
|
1716 | grafting 1:80e6d2c47cfe "added b" | |
1702 | grafting 2:8be98ac1a569 "added c" |
|
1717 | grafting 2:8be98ac1a569 "added c" | |
1703 |
|
1718 | |||
@@ -1754,7 +1769,7 b' running `hg graft --continue`' | |||||
1754 | (no more unresolved files) |
|
1769 | (no more unresolved files) | |
1755 | continue: hg graft --continue |
|
1770 | continue: hg graft --continue | |
1756 |
|
1771 | |||
1757 |
$ hg |
|
1772 | $ hg continue | |
1758 | grafting 1:80e6d2c47cfe "added b" |
|
1773 | grafting 1:80e6d2c47cfe "added b" | |
1759 | grafting 2:8be98ac1a569 "added c" |
|
1774 | grafting 2:8be98ac1a569 "added c" | |
1760 |
|
1775 | |||
@@ -1803,7 +1818,7 b' Test that --date is preserved and reused' | |||||
1803 | $ hg resolve -m |
|
1818 | $ hg resolve -m | |
1804 | (no more unresolved files) |
|
1819 | (no more unresolved files) | |
1805 | continue: hg graft --continue |
|
1820 | continue: hg graft --continue | |
1806 |
$ hg |
|
1821 | $ hg continue | |
1807 | grafting 1:80e6d2c47cfe "added b" |
|
1822 | grafting 1:80e6d2c47cfe "added b" | |
1808 | grafting 2:8be98ac1a569 "added c" |
|
1823 | grafting 2:8be98ac1a569 "added c" | |
1809 |
|
1824 | |||
@@ -1843,7 +1858,7 b' Test that --log is preserved and reused ' | |||||
1843 | (no more unresolved files) |
|
1858 | (no more unresolved files) | |
1844 | continue: hg graft --continue |
|
1859 | continue: hg graft --continue | |
1845 |
|
1860 | |||
1846 |
$ hg |
|
1861 | $ hg continue | |
1847 | grafting 1:80e6d2c47cfe "added b" |
|
1862 | grafting 1:80e6d2c47cfe "added b" | |
1848 | grafting 2:8be98ac1a569 "added c" |
|
1863 | grafting 2:8be98ac1a569 "added c" | |
1849 |
|
1864 | |||
@@ -1997,7 +2012,7 b' before the graft' | |||||
1997 |
|
2012 | |||
1998 | $ hg abort |
|
2013 | $ hg abort | |
1999 | abort: no interrupted graft to abort (abortflag !) |
|
2014 | abort: no interrupted graft to abort (abortflag !) | |
2000 |
abort: no operation in progress ( |
|
2015 | abort: no operation in progress (no-abortflag !) | |
2001 | [255] |
|
2016 | [255] | |
2002 |
|
2017 | |||
2003 | when stripping is required |
|
2018 | when stripping is required | |
@@ -2273,7 +2288,7 b' Resolve conflict:' | |||||
2273 | (no more unresolved files) |
|
2288 | (no more unresolved files) | |
2274 | continue: hg graft --continue |
|
2289 | continue: hg graft --continue | |
2275 |
|
2290 | |||
2276 |
$ hg |
|
2291 | $ hg continue | |
2277 | grafting 3:09e253b87e17 "A in file a" |
|
2292 | grafting 3:09e253b87e17 "A in file a" | |
2278 | $ hg log -GT "{rev}:{node|short} {desc}\n" |
|
2293 | $ hg log -GT "{rev}:{node|short} {desc}\n" | |
2279 | @ 4:2aa9ad1006ff B in file a |
|
2294 | @ 4:2aa9ad1006ff B in file a | |
@@ -2350,7 +2365,7 b' When there is conflict:' | |||||
2350 | $ hg resolve --mark |
|
2365 | $ hg resolve --mark | |
2351 | (no more unresolved files) |
|
2366 | (no more unresolved files) | |
2352 | continue: hg graft --continue |
|
2367 | continue: hg graft --continue | |
2353 |
$ hg |
|
2368 | $ hg continue | |
2354 | grafting 3:09e253b87e17 "A in file a" |
|
2369 | grafting 3:09e253b87e17 "A in file a" | |
2355 | $ hg diff |
|
2370 | $ hg diff | |
2356 | diff -r 2aa9ad1006ff a |
|
2371 | diff -r 2aa9ad1006ff a |
General Comments 0
You need to be logged in to leave comments.
Login now