Mercurial > hg
changeset 26745:8af610bce239
rebase: reduce scope of try catch in restorestate
Refactoring by reduce the scope of the try catch block so that it only captures
what it needs. I could have made it smaller but another patch in the series
will add onto it.
author | Christian Delahousse <cdelahousse@fb.com> |
---|---|
date | Thu, 15 Oct 2015 15:20:44 -0700 |
parents | 21e50e36de02 |
children | 3c1d297fe929 |
files | hgext/rebase.py |
diffstat | 1 files changed, 25 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Thu Oct 15 12:13:46 2015 -0700 +++ b/hgext/rebase.py Thu Oct 15 15:20:44 2015 -0700 @@ -845,13 +845,14 @@ def restorestatus(repo): 'Restore a previously stored status' + keepbranches = None + target = None + collapse = False + external = nullrev + activebookmark = None + state = {} + try: - keepbranches = None - target = None - collapse = False - external = nullrev - activebookmark = None - state = {} f = repo.vfs("rebasestate") for i, l in enumerate(f.read().splitlines()): if i == 0: @@ -881,28 +882,29 @@ else: state[repo[oldrev].rev()] = repo[newrev].rev() - if keepbranches is None: - raise error.Abort(_('.hg/rebasestate is incomplete')) - - skipped = set() - # recompute the set of skipped revs - if not collapse: - seen = set([target]) - for old, new in sorted(state.items()): - if new != revtodo and new in seen: - skipped.add(old) - seen.add(new) - repo.ui.debug('computed skipped revs: %s\n' % - (' '.join(str(r) for r in sorted(skipped)) or None)) - repo.ui.debug('rebase status resumed\n') - _setrebasesetvisibility(repo, state.keys()) - return (originalwd, target, state, skipped, - collapse, keep, keepbranches, external, activebookmark) except IOError as err: if err.errno != errno.ENOENT: raise raise error.Abort(_('no rebase in progress')) + if keepbranches is None: + raise error.Abort(_('.hg/rebasestate is incomplete')) + + skipped = set() + # recompute the set of skipped revs + if not collapse: + seen = set([target]) + for old, new in sorted(state.items()): + if new != revtodo and new in seen: + skipped.add(old) + seen.add(new) + repo.ui.debug('computed skipped revs: %s\n' % + (' '.join(str(r) for r in sorted(skipped)) or None)) + repo.ui.debug('rebase status resumed\n') + _setrebasesetvisibility(repo, state.keys()) + return (originalwd, target, state, skipped, + collapse, keep, keepbranches, external, activebookmark) + def needupdate(repo, state): '''check whether we should `update --clean` away from a merge, or if somehow the working dir got forcibly updated, e.g. by older hg'''