--- a/hgext/evolve.py Tue Jan 07 16:07:43 2014 -0800
+++ b/hgext/evolve.py Tue Oct 22 11:16:55 2013 +0200
@@ -925,31 +925,53 @@
ui.write_err(_('no troubled changesets\n'))
return 1
+ def progresscb():
+ if allopt:
+ ui.progress('evolve', seen, unit='changesets', total=count)
+ seen = 1
+ count = allopt and _counttroubled(ui, repo) or 1
+
while tr is not None:
- result = _evolveany(ui, repo, tr, dryrunopt)
+ progresscb()
+ result = _evolveany(ui, repo, tr, dryrunopt, progresscb=progresscb)
+ progresscb()
+ seen += 1
if not allopt:
return result
+ progresscb()
tr = _picknexttroubled(ui, repo, anyopt or allopt)
+ if allopt:
+ ui.progress('evolve', None)
-def _evolveany(ui, repo, tr, dryrunopt):
+
+def _evolveany(ui, repo, tr, dryrunopt, progresscb):
repo = repo.unfiltered()
tr = repo[tr.rev()]
cmdutil.bailifchanged(repo)
troubles = tr.troubles()
if 'unstable' in troubles:
- return _solveunstable(ui, repo, tr, dryrunopt)
+ return _solveunstable(ui, repo, tr, dryrunopt, progresscb)
elif 'bumped' in troubles:
- return _solvebumped(ui, repo, tr, dryrunopt)
+ return _solvebumped(ui, repo, tr, dryrunopt, progresscb)
elif 'divergent' in troubles:
repo = repo.unfiltered()
tr = repo[tr.rev()]
- return _solvedivergent(ui, repo, tr, dryrunopt)
+ return _solvedivergent(ui, repo, tr, dryrunopt, progresscb)
else:
assert False # WHAT? unknown troubles
-def _picknexttroubled(ui, repo, pickany=False):
+def _counttroubled(ui, repo):
+ """Count the amount of troubled changesets"""
+ troubled = set()
+ troubled.update(getrevs(repo, 'unstable'))
+ troubled.update(getrevs(repo, 'bumped'))
+ troubled.update(getrevs(repo, 'divergent'))
+ return len(troubled)
+
+def _picknexttroubled(ui, repo, pickany=False, progresscb=None):
"""Pick a the next trouble changeset to solve"""
+ if progresscb: progresscb()
tr = _stabilizableunstable(repo, repo['.'])
if tr is None:
wdp = repo['.']
@@ -988,7 +1010,7 @@
return child
return None
-def _solveunstable(ui, repo, orig, dryrun=False):
+def _solveunstable(ui, repo, orig, dryrun=False, progresscb=None):
"""Stabilize a unstable changeset"""
obs = orig.parents()[0]
if not obs.obsolete():
@@ -1019,11 +1041,13 @@
repo.ui.status(_('atop:'))
if not ui.quiet:
displayer.show(target)
+ if progresscb: progresscb()
todo = 'hg rebase -r %s -d %s\n' % (orig, target)
if dryrun:
repo.ui.write(todo)
else:
repo.ui.note(todo)
+ if progresscb: progresscb()
lock = repo.lock()
try:
relocate(repo, orig, target)
@@ -1035,7 +1059,7 @@
finally:
lock.release()
-def _solvebumped(ui, repo, bumped, dryrun=False):
+def _solvebumped(ui, repo, bumped, dryrun=False, progresscb=None):
"""Stabilize a bumped changeset"""
# For now we deny bumped merge
if len(bumped.parents()) > 1:
@@ -1061,6 +1085,7 @@
repo.ui.write('hg revert --all --rev %s;\n' % bumped)
repo.ui.write('hg commit --msg "bumped update to %s"')
return 0
+ if progresscb: progresscb()
wlock = repo.wlock()
try:
newid = tmpctx = None
@@ -1137,7 +1162,7 @@
finally:
wlock.release()
-def _solvedivergent(ui, repo, divergent, dryrun=False):
+def _solvedivergent(ui, repo, divergent, dryrun=False, progresscb=None):
base, others = divergentdata(divergent)
if len(others) > 1:
othersstr = "[%s]" % (','.join([str(i) for i in others]))
@@ -1200,6 +1225,7 @@
repo.ui.status(_('updating to "local" conflict\n'))
hg.update(repo, divergent.rev())
repo.ui.note(_('merging divergent changeset\n'))
+ if progresscb: progresscb()
stats = merge.update(repo,
other.node(),
branchmerge=True,
@@ -1220,6 +1246,7 @@
/!\ * hg ci -m "same message as the amended changeset" => new cset Y
/!\ * hg kill -n Y W Z
""")
+ if progresscb: progresscb()
tr = repo.transaction('stabilize-divergent')
try:
repo.dirstate.setparents(divergent.node(), node.nullid)