Mercurial > hg
comparison hgext/rebase.py @ 29474:56641501adde
rebase: make collapsing use explicit logic to decide on the rev to reuse
This code:
for rev in sortedstate:
...
...
newnode = concludenode(repo, rev, p1, rbsrt.external,
commitmsg=commitmsg,
extrafn=extrafn, editor=editor,
keepbranches=rbsrt.keepbranchesf,
date=rbsrt.date)
uses 'rev' variable in 'concludenode' function invocation. It is not
explicitly assigned before, but its value comes as last value or 'rev' in
a for loop, e.g. last element in a 'sortedstate'. IMO this a bad style and it
also makes it hard to refactor the function, so it is better to explicitly
define the value passed to 'concludenode'.
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Fri, 01 Jul 2016 14:09:53 +0200 |
parents | e25da98052a4 |
children | fb7fc877ed17 |
comparison
equal
deleted
inserted
replaced
29473:e25da98052a4 | 29474:56641501adde |
---|---|
497 if rbsrt.activebookmark: | 497 if rbsrt.activebookmark: |
498 bookmarks.deactivate(repo) | 498 bookmarks.deactivate(repo) |
499 | 499 |
500 extrafn = _makeextrafn(rbsrt.extrafns) | 500 extrafn = _makeextrafn(rbsrt.extrafns) |
501 | 501 |
502 sortedstate = sorted(rbsrt.state) | 502 rbsrt.sortedstate = sorted(rbsrt.state) |
503 total = len(sortedstate) | 503 total = len(rbsrt.sortedstate) |
504 pos = 0 | 504 pos = 0 |
505 for rev in sortedstate: | 505 for rev in rbsrt.sortedstate: |
506 ctx = repo[rev] | 506 ctx = repo[rev] |
507 desc = '%d:%s "%s"' % (ctx.rev(), ctx, | 507 desc = '%d:%s "%s"' % (ctx.rev(), ctx, |
508 ctx.description().split('\n', 1)[0]) | 508 ctx.description().split('\n', 1)[0]) |
509 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) | 509 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
510 if names: | 510 if names: |
597 if rebased not in rbsrt.skipped and\ | 597 if rebased not in rbsrt.skipped and\ |
598 rbsrt.state[rebased] > nullmerge: | 598 rbsrt.state[rebased] > nullmerge: |
599 commitmsg += '\n* %s' % repo[rebased].description() | 599 commitmsg += '\n* %s' % repo[rebased].description() |
600 editopt = True | 600 editopt = True |
601 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) | 601 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) |
602 newnode = concludenode(repo, rev, p1, rbsrt.external, | 602 revtoreuse = rbsrt.sortedstate[-1] |
603 newnode = concludenode(repo, revtoreuse, p1, rbsrt.external, | |
603 commitmsg=commitmsg, | 604 commitmsg=commitmsg, |
604 extrafn=extrafn, editor=editor, | 605 extrafn=extrafn, editor=editor, |
605 keepbranches=rbsrt.keepbranchesf, | 606 keepbranches=rbsrt.keepbranchesf, |
606 date=rbsrt.date) | 607 date=rbsrt.date) |
607 if newnode is None: | 608 if newnode is None: |