Mercurial > hg-stable
changeset 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 |
files | hgext/rebase.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Fri Jul 01 14:09:53 2016 +0200 +++ b/hgext/rebase.py Fri Jul 01 14:09:53 2016 +0200 @@ -499,10 +499,10 @@ extrafn = _makeextrafn(rbsrt.extrafns) - sortedstate = sorted(rbsrt.state) - total = len(sortedstate) + rbsrt.sortedstate = sorted(rbsrt.state) + total = len(rbsrt.sortedstate) pos = 0 - for rev in sortedstate: + for rev in rbsrt.sortedstate: ctx = repo[rev] desc = '%d:%s "%s"' % (ctx.rev(), ctx, ctx.description().split('\n', 1)[0]) @@ -599,7 +599,8 @@ commitmsg += '\n* %s' % repo[rebased].description() editopt = True editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) - newnode = concludenode(repo, rev, p1, rbsrt.external, + revtoreuse = rbsrt.sortedstate[-1] + newnode = concludenode(repo, revtoreuse, p1, rbsrt.external, commitmsg=commitmsg, extrafn=extrafn, editor=editor, keepbranches=rbsrt.keepbranchesf,