diff -r 69a0d60f9c99 -r 425c0700aabd hgext/evolve.py --- a/hgext/evolve.py Fri Dec 04 14:00:59 2015 -0800 +++ b/hgext/evolve.py Fri Dec 04 15:10:53 2015 -0800 @@ -124,7 +124,8 @@ def memfilectx(repo, *args, **kwargs): return oldmemfilectx(*args, **kwargs) else: - raise ImportError('evolve needs version %s or above' % min(testedwith.split())) + raise ImportError('evolve needs version %s or above' % + min(testedwith.split())) aliases, entry = cmdutil.findcmd('commit', commands.table) hasinteractivemode = any(['interactive' in e for e in entry[1]]) @@ -415,8 +416,8 @@ if not matchingevolvecommands: raise error.Abort(_('unknown command: %s') % cmd) elif len(matchingevolvecommands) > 1: - raise error.Abort(_('ambiguous command specification: "%s" matches %r') - % (cmd, matchingevolvecommands)) + msg = _('ambiguous command specification: "%s" matches %r') + raise error.Abort(msg % (cmd, matchingevolvecommands)) else: whitelist.add(matchingevolvecommands[0]) for disabledcmd in set(cmdtable) - whitelist: @@ -747,7 +748,7 @@ """ try: return orig(repo, *args, **opts) - except util.Abort, ex: + except error.Abort as ex: hint = _("use 'hg evolve' to get a stable history " "or --force to ignore warnings") if (len(ex.args) >= 1 @@ -789,13 +790,13 @@ if rebase: extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) except KeyError: - pass # rebase not found + pass # rebase not found try: histedit = extensions.find('histedit') if histedit: extensions.wrapcommand(histedit.cmdtable, 'histedit', warnobserrors) except KeyError: - pass # rebase not found + pass # rebase not found ##################################################################### ### Old Evolve extension content ### @@ -892,22 +893,23 @@ finally: lockmod.release(lock, wlock, tr) -class MergeFailure(util.Abort): +class MergeFailure(error.Abort): pass def relocate(repo, orig, dest, keepbranch=False): """rewrite on dest""" if orig.rev() == dest.rev(): - raise util.Abort(_('tried to relocate a node on top of itself'), + raise error.Abort(_('tried to relocate a node on top of itself'), hint=_("This shouldn't happen. If you still " "need to move changesets, please do so " "manually with nothing to rebase - working " "directory parent is also destination")) if not orig.p2().rev() == node.nullrev: - raise util.Abort( + raise error.Abort( 'no support for evolving merge changesets yet', - hint="Redo the merge and use `hg prune --succ ` to obsolete the old one") + hint="Redo the merge and use `hg prune --succ ` " + "to obsolete the old one") destbookmarks = repo.nodebookmarks(dest.node()) nodesrc = orig.node() destphase = repo[nodesrc].phase() @@ -949,7 +951,7 @@ repo.dirstate.setbranch(orig.branch()) r = merge.graft(repo, orig, orig.p1(), ['local', 'graft']) if r[-1]: #some conflict - raise util.Abort( + raise error.Abort( 'unresolved merge conflicts (see hg help resolve)') if commitmsg is None: commitmsg = orig.description() @@ -967,7 +969,7 @@ date=orig.date(), extra=extra) finally: repo.ui.restoreconfig(backup) - except util.Abort, exc: + except error.Abort as exc: repo.dirstate.beginparentchange() repo.setparents(repo['.'].node(), nullid) writedirstate(repo.dirstate, tr) @@ -1155,7 +1157,7 @@ store.create(tr, mark[0], mark[1], mark[2], marks[3], parents=parents) if len(store._all) - before: - ui.write('created new markers for %i\n' % rev) + ui.write(_('created new markers for %i\n') % rev) ui.progress(pgop, idx, total=pgtotal) tr.close() ui.progress(pgop, None) @@ -1185,7 +1187,7 @@ store = repo.obsstore unfi = repo.unfiltered() nm = unfi.changelog.nodemap - ui.write('markers total: %9i\n' % len(store._all)) + ui.write(_('markers total: %9i\n') % len(store._all)) sucscount = [0, 0 , 0, 0] known = 0 parentsdata = 0 @@ -1194,7 +1196,7 @@ # a cluster is a (set(nodes), set(markers)) tuple clustersmap = {} # same data using parent information - pclustersmap= {} + pclustersmap = {} for mark in store: if mark[0] in nm: known += 1 @@ -1227,47 +1229,50 @@ fc = (frozenset(c[0]), frozenset(c[1])) for n in fc[0]: pclustersmap[n] = fc - ui.write(' for known precursors: %9i\n' % known) - ui.write(' with parents data: %9i\n' % parentsdata) + ui.write((' for known precursors: %9i\n' % known)) + ui.write((' with parents data: %9i\n' % parentsdata)) # successors data - ui.write('markers with no successors: %9i\n' % sucscount[0]) - ui.write(' 1 successors: %9i\n' % sucscount[1]) - ui.write(' 2 successors: %9i\n' % sucscount[2]) - ui.write(' more than 2 successors: %9i\n' % sucscount[3]) + ui.write(('markers with no successors: %9i\n' % sucscount[0])) + ui.write((' 1 successors: %9i\n' % sucscount[1])) + ui.write((' 2 successors: %9i\n' % sucscount[2])) + ui.write((' more than 2 successors: %9i\n' % sucscount[3])) # meta data info - ui.write(' available keys:\n') + ui.write((' available keys:\n')) for key in sorted(metakeys): - ui.write(' %15s: %9i\n' % (key, metakeys[key])) + ui.write((' %15s: %9i\n' % (key, metakeys[key]))) allclusters = list(set(clustersmap.values())) allclusters.sort(key=lambda x: len(x[1])) - ui.write('disconnected clusters: %9i\n' % len(allclusters)) + ui.write(('disconnected clusters: %9i\n' % len(allclusters))) ui.write(' any known node: %9i\n' % len([c for c in allclusters if [n for n in c[0] if nm.get(n) is not None]])) if allclusters: nbcluster = len(allclusters) - ui.write(' smallest length: %9i\n' % len(allclusters[0][1])) - ui.write(' longer length: %9i\n' % len(allclusters[-1][1])) + ui.write((' smallest length: %9i\n' % len(allclusters[0][1]))) + ui.write((' longer length: %9i\n' + % len(allclusters[-1][1]))) median = len(allclusters[nbcluster//2][1]) - ui.write(' median length: %9i\n' % median) + ui.write((' median length: %9i\n' % median)) mean = sum(len(x[1]) for x in allclusters) // nbcluster - ui.write(' mean length: %9i\n' % mean) + ui.write((' mean length: %9i\n' % mean)) allpclusters = list(set(pclustersmap.values())) allpclusters.sort(key=lambda x: len(x[1])) - ui.write(' using parents data: %9i\n' % len(allpclusters)) + ui.write((' using parents data: %9i\n' % len(allpclusters))) ui.write(' any known node: %9i\n' % len([c for c in allclusters if [n for n in c[0] if nm.get(n) is not None]])) if allpclusters: nbcluster = len(allpclusters) - ui.write(' smallest length: %9i\n' % len(allpclusters[0][1])) - ui.write(' longer length: %9i\n' % len(allpclusters[-1][1])) + ui.write((' smallest length: %9i\n' + % len(allpclusters[0][1]))) + ui.write((' longer length: %9i\n' + % len(allpclusters[-1][1]))) median = len(allpclusters[nbcluster//2][1]) - ui.write(' median length: %9i\n' % median) + ui.write((' median length: %9i\n' % median)) mean = sum(len(x[1]) for x in allpclusters) // nbcluster - ui.write(' mean length: %9i\n' % mean) + ui.write((' mean length: %9i\n' % mean)) def _solveone(ui, repo, ctx, dryrun, confirm, progresscb, category): """Resolve the troubles affecting one revision""" @@ -1366,8 +1371,8 @@ else: l = len(troubled[targetcat]) if l: - hint = (_("%d other %s in the repository, do you want --any or --rev") - % (l, targetcat)) + hint = _("%d other %s in the repository, do you want --any " + "or --rev") % (l, targetcat) else: othertroubles = [] for cat in unselectedcategories: @@ -1388,7 +1393,7 @@ def _cleanup(ui, repo, startnode, showprogress): if showprogress: - ui.progress('evolve', None) + ui.progress(_('evolve'), None) if repo['.'] != startnode: ui.status(_('working directory is now at %s\n') % repo['.']) @@ -1441,7 +1446,7 @@ for p in repo[r].parents(): try: succ = _singlesuccessor(repo, p) - except MultipleSuccessorsError, exc: + except MultipleSuccessorsError as exc: dependencies[r] = exc.successorssets continue if succ in revs: @@ -1475,7 +1480,8 @@ if revopt: revs = scmutil.revrange(repo, revopt) & revs elif not anyopt and targetcat == 'unstable': - revs = set(_aspiringdescendant(repo, repo.revs('(.::) - obsolete()::'))) + revs = set(_aspiringdescendant(repo, + repo.revs('(.::) - obsolete()::'))) if targetcat == 'divergent': # Pick one divergent per group of divergents revs = _dedupedivergents(repo, revs) @@ -1533,22 +1539,24 @@ _('do not perform actions, just print what would be done')), ('', 'confirm', False, _('ask for confirmation before performing the action')), - ('A', 'any', False, _('also consider troubled changesets unrelated to current working directory')), + ('A', 'any', False, + _('also consider troubled changesets unrelated to current working ' + 'directory')), ('r', 'rev', [], _('solves troubles of these revisions')), ('', 'bumped', False, _('solves only bumped changesets')), ('', 'divergent', False, _('solves only divergent changesets')), ('', 'unstable', False, _('solves only unstable changesets (default)')), - ('a', 'all', False, _('evolve all troubled changesets related to the current ' - 'working directory and its descendants')), + ('a', 'all', False, _('evolve all troubled changesets related to the ' + 'current working directory and its descendants')), ('c', 'continue', False, _('continue an interrupted evolution')), ] + mergetoolopts, _('[OPTIONS]...')) def evolve(ui, repo, **opts): """solve troubled changesets in your repository - Modifying history can lead to various types of troubled changesets: unstable, - bumped, or divergent. The evolve command resolves your troubles by executing one - of the following actions: + Modifying history can lead to various types of troubled changesets: + unstable, bumped, or divergent. The evolve command resolves your troubles + by executing one of the following actions: - update working copy to a successor - rebase an unstable changeset @@ -1556,53 +1564,57 @@ - fuse divergent changesets back together If you pass no arguments, evolve works in automatic mode: it will execute a - single action to reduce instability related to your working copy. There are two - cases for this action. First, if the parent of your working copy is obsolete, - evolve updates to the parent's successor. Second, if the working copy parent is - not obsolete but has obsolete predecessors, then evolve determines if there is an - unstable changeset that can be rebased onto the working copy parent in order to - reduce instability. If so, evolve rebases that changeset. If not, evolve refuses - to guess your intention, and gives a hint about what you might want to do next. + single action to reduce instability related to your working copy. There are + two cases for this action. First, if the parent of your working copy is + obsolete, evolve updates to the parent's successor. Second, if the working + copy parent is not obsolete but has obsolete predecessors, then evolve + determines if there is an unstable changeset that can be rebased onto the + working copy parent in order to reduce instability. + If so, evolve rebases that changeset. If not, evolve refuses to guess your + intention, and gives a hint about what you might want to do next. Any time evolve creates a changeset, it updates the working copy to the new - changeset. (Currently, every successful evolve operation involves an update as - well; this may change in future.) + changeset. (Currently, every successful evolve operation involves an update + as well; this may change in future.) Automatic mode only handles common use cases. For example, it avoids taking - action in the case of ambiguity, and it ignores unstable changesets that are not - related to your working copy. It also refuses to solve bumped or divergent - changesets unless you explicity request such behavior (see below). + action in the case of ambiguity, and it ignores unstable changesets that + are not related to your working copy. + It also refuses to solve bumped or divergent changesets unless you explicity + request such behavior (see below). Eliminating all instability around your working copy may require multiple - invocations of :hg:`evolve`. Alternately, use ``--all`` to recursively select and - evolve all unstable changesets that can be rebased onto the working copy parent. + invocations of :hg:`evolve`. Alternately, use ``--all`` to recursively + select and evolve all unstable changesets that can be rebased onto the + working copy parent. This is more powerful than successive invocations, since ``--all`` handles - ambiguous cases (e.g. unstable changesets with multiple children) by evolving all - branches. - - When your repository cannot be handled by automatic mode, you might need to use - ``--rev`` to specify a changeset to evolve. For example, if you have an unstable - changeset that is not related to the working copy parent, you could use ``--rev`` - to evolve it. Or, if some changeset has multiple unstable children, evolve in - automatic mode refuses to guess which one to evolve; you have to use ``--rev`` - in that case. + ambiguous cases (e.g. unstable changesets with multiple children) by + evolving all branches. + + When your repository cannot be handled by automatic mode, you might need to + use ``--rev`` to specify a changeset to evolve. For example, if you have + an unstable changeset that is not related to the working copy parent, + you could use ``--rev`` to evolve it. Or, if some changeset has multiple + unstable children, evolve in automatic mode refuses to guess which one to + evolve; you have to use ``--rev`` in that case. Alternately, ``--any`` makes evolve search for the next evolvable changeset regardless of whether it is related to the working copy parent. - You can supply multiple revisions to evolve multiple troubled changesets in a - single invocation. In revset terms, ``--any`` is equivalent to ``--rev + You can supply multiple revisions to evolve multiple troubled changesets + in a single invocation. In revset terms, ``--any`` is equivalent to ``--rev first(unstable())``. ``--rev`` and ``--all`` are mutually exclusive, as are ``--rev`` and ``--any``. ``hg evolve --any --all`` is useful for cleaning up instability across all branches, letting evolve figure out the appropriate order and destination. - When you have troubled changesets that are not unstable, :hg:`evolve` refuses to - consider them unless you specify the category of trouble you wish to resolve, - with ``--bumped`` or ``--divergent``. These options are currently mutually - exclusive with each other and with ``--unstable`` (the default). You can combine - ``--bumped`` or ``--divergent`` with ``--rev``, ``--all``, or ``--any``. + When you have troubled changesets that are not unstable, :hg:`evolve` + refuses to consider them unless you specify the category of trouble you + wish to resolve, with ``--bumped`` or ``--divergent``. These options are + currently mutually exclusive with each other and with ``--unstable`` + (the default). You can combine ``--bumped`` or ``--divergent`` with + ``--rev``, ``--all``, or ``--any``. """ @@ -1619,15 +1631,16 @@ targetcat = 'unstable' if 1 < len(specifiedcategories): msg = _('cannot specify more than one trouble category to solve (yet)') - raise util.Abort(msg) + raise error.Abort(msg) elif len(specifiedcategories) == 1: targetcat = specifiedcategories[0] elif repo['.'].obsolete(): - displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) + displayer = cmdutil.show_changeset(ui, repo, + {'template': shorttemplate}) # no args and parent is obsolete, update to successors try: ctx = repo[_singlesuccessor(repo, repo['.'])] - except MultipleSuccessorsError, exc: + except MultipleSuccessorsError as exc: repo.ui.write_err('parent is obsolete with multiple successors:\n') for ln in exc.successorssets: for n in ln: @@ -1656,23 +1669,23 @@ def progresscb(): if revopt or allopt: - ui.progress('evolve', seen, unit='changesets', total=count) + ui.progress(_('evolve'), seen, unit='changesets', total=count) # Continuation handling if contopt: if anyopt: - raise util.Abort('cannot specify both "--any" and "--continue"') + raise error.Abort('cannot specify both "--any" and "--continue"') if allopt: - raise util.Abort('cannot specify both "--all" and "--continue"') + raise error.Abort('cannot specify both "--all" and "--continue"') graftcmd = commands.table['graft'][0] return graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) cmdutil.bailifchanged(repo) if revopt and allopt: - raise util.Abort('cannot specify both "--rev" and "--all"') + raise error.Abort('cannot specify both "--rev" and "--all"') if revopt and anyopt: - raise util.Abort('cannot specify both "--rev" and "--any"') + raise error.Abort('cannot specify both "--rev" and "--any"') revs = _selectrevs(repo, allopt, revopt, anyopt, targetcat) @@ -1753,7 +1766,7 @@ obs = orig.parents()[1] # second parent is obsolete ? if not obs.obsolete(): - ui.warn("cannot solve instability of %s, skipping\n" % orig) + ui.warn(_("cannot solve instability of %s, skipping\n") % orig) return False newer = obsolete.successorssets(repo, obs.node()) # search of a parent which is not killed @@ -1764,7 +1777,8 @@ obs = obs.parents()[0] newer = obsolete.successorssets(repo, obs.node()) if len(newer) > 1: - msg = _("skipping %s: divergent rewriting. can't choose destination\n") % obs + msg = _("skipping %s: divergent rewriting. can't choose " + "destination\n") % obs ui.write_err(msg) return 2 targets = newer[0] @@ -1789,7 +1803,7 @@ repo.ui.write(_('atop:')) displayer.show(target) if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y': - raise util.Abort(_('evolve aborted by user')) + raise error.Abort(_('evolve aborted by user')) if progresscb: progresscb() todo = 'hg rebase -r %s -d %s\n' % (orig, target) if dryrun: @@ -1821,7 +1835,8 @@ prec = repo.set('last(allprecursors(%d) and public())', bumped).next() # For now we deny target merge if len(prec.parents()) > 1: - msg = _('skipping: %s: public version is a merge, this not handled yet\n') % prec + msg = _('skipping: %s: public version is a merge, ' + 'this is not handled yet\n') % prec ui.write_err(msg) return 2 @@ -1832,13 +1847,13 @@ repo.ui.write(_('atop:')) displayer.show(prec) if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y': - raise util.Abort(_('evolve aborted by user')) + raise error.Abort(_('evolve aborted by user')) if dryrun: todo = 'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1()) repo.ui.write(todo) - repo.ui.write('hg update %s;\n' % prec) - repo.ui.write('hg revert --all --rev %s;\n' % bumped) - repo.ui.write('hg commit --msg "bumped update to %s"') + repo.ui.write(('hg update %s;\n' % prec)) + 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() newid = tmpctx = None @@ -1926,7 +1941,8 @@ base, others = divergentdata(divergent) if len(others) > 1: othersstr = "[%s]" % (','.join([str(i) for i in others])) - msg = _("skipping %d:divergent with a changeset that got splitted into multiple ones:\n" + msg = _("skipping %d:divergent with a changeset that got splitted" + " into multiple ones:\n" "|[%s]\n" "| This is not handled by automatic evolution yet\n" "| You have to fallback to manual handling with commands " @@ -1935,12 +1951,13 @@ "| - hg prune\n" "| \n" "| You should contact your local evolution Guru for help.\n" - % (divergent, othersstr)) + ) % (divergent, othersstr) ui.write_err(msg) return 2 other = others[0] if len(other.parents()) > 1: - msg = _("skipping %s: divergent changeset can't be a merge (yet)\n" % divergent) + msg = _("skipping %s: divergent changeset can't be " + "a merge (yet)\n") % divergent ui.write_err(msg) hint = _("You have to fallback to solving this by hand...\n" "| This probably means redoing the merge and using \n" @@ -1948,7 +1965,8 @@ ui.write_err(hint) return 2 if other.p1() not in divergent.parents(): - msg = _("skipping %s: have a different parent than %s (not handled yet)\n") % (divergent, other) + msg = _("skipping %s: have a different parent than %s " + "(not handled yet)\n") % (divergent, other) hint = _("| %(d)s, %(o)s are not based on the same changeset.\n" "| With the current state of its implementation, \n" "| evolve does not work in that case.\n" @@ -1956,7 +1974,7 @@ "| this command again.\n" "| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n" "| - or: hg rebase --dest 'p1(%(o)s)' -r %(d)s\n" - % {'d': divergent, 'o': other}) + ) % {'d': divergent, 'o': other} ui.write_err(msg) ui.write_err(hint) return 2 @@ -1970,16 +1988,16 @@ ui.write(_('base: ')) displayer.show(base) if confirm and ui.prompt(_('perform evolve? [Ny]'), 'n') != 'y': - raise util.Abort(_('evolve aborted by user')) + raise error.Abort(_('evolve aborted by user')) if dryrun: - ui.write('hg update -c %s &&\n' % divergent) - ui.write('hg merge %s &&\n' % other) - ui.write('hg commit -m "auto merge resolving conflict between ' - '%s and %s"&&\n' % (divergent, other)) - ui.write('hg up -C %s &&\n' % base) - ui.write('hg revert --all --rev tip &&\n') - ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' - % divergent) + ui.write(('hg update -c %s &&\n' % divergent)) + ui.write(('hg merge %s &&\n' % other)) + ui.write(('hg commit -m "auto merge resolving conflict between ' + '%s and %s"&&\n' % (divergent, other))) + ui.write(('hg up -C %s &&\n' % base)) + ui.write(('hg revert --all --rev tip &&\n')) + ui.write(('hg commit -m "`hg log -r %s --template={desc}`";\n' + % divergent)) return if divergent not in repo[None].parents(): repo.ui.status(_('updating to "local" conflict\n')) @@ -1998,7 +2016,7 @@ repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg update -C .' to abandon\n")) if stats[3] > 0: - raise util.Abort('merge conflict between several amendments ' + raise error.Abort('merge conflict between several amendments ' '(this is not automated yet)', hint="""/!\ You can try: /!\ * manual merge + resolve => new cset X @@ -2043,7 +2061,7 @@ newer = [n for n in newer if n and ctx.node() not in n] if newer: return base, tuple(ctx._repo[o] for o in newer[0]) - raise util.Abort("base of divergent changeset %s not found" % ctx, + raise error.Abort("base of divergent changeset %s not found" % ctx, hint='this case is not yet handled') @@ -2054,7 +2072,8 @@ [('B', 'move-bookmark', False, _('move active bookmark after update')), ('', 'merge', False, _('bring uncommitted change along')), - ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))], + ('n', 'dry-run', False, + _('do not perform actions, just print what would be done'))], '[OPTION]...') def cmdprevious(ui, repo, **opts): """update to parent and display summary lines""" @@ -2062,11 +2081,11 @@ wparents = wkctx.parents() dryrunopt = opts['dry_run'] if len(wparents) != 1: - raise util.Abort('merge in progress') + raise error.Abort('merge in progress') if not opts['merge']: try: cmdutil.bailifchanged(repo) - except error.Abort, exc: + except error.Abort as exc: exc.hint = _('do you want --merge?') raise @@ -2077,9 +2096,9 @@ bm = bmactive(repo) shouldmove = opts.get('move_bookmark') and bm is not None if dryrunopt: - ui.write('hg update %s;\n' % p.rev()) + ui.write(('hg update %s;\n' % p.rev())) if shouldmove: - ui.write('hg bookmark %s -r %s;\n' % (bm, p.rev())) + ui.write(('hg bookmark %s -r %s;\n' % (bm, p.rev()))) else: ret = hg.update(repo, p.rev()) if not ret: @@ -2105,8 +2124,9 @@ _('move active bookmark after update')), ('', 'merge', False, _('bring uncommitted change along')), ('', 'evolve', False, _('evolve the next changeset if necessary')), - ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))], - '[OPTION]...') + ('n', 'dry-run', False, + _('do not perform actions, just print what would be done'))], + '[OPTION]...') def cmdnext(ui, repo, **opts): """update to next child @@ -2117,11 +2137,11 @@ wparents = wkctx.parents() dryrunopt = opts['dry_run'] if len(wparents) != 1: - raise util.Abort('merge in progress') + raise error.Abort('merge in progress') if not opts['merge']: try: cmdutil.bailifchanged(repo) - except error.Abort, exc: + except error.Abort as exc: exc.hint = _('do you want --merge?') raise @@ -2132,9 +2152,9 @@ bm = bmactive(repo) shouldmove = opts.get('move_bookmark') and bm is not None if dryrunopt: - ui.write('hg update %s;\n' % c.rev()) + ui.write(('hg update %s;\n' % c.rev())) if shouldmove: - ui.write('hg bookmark %s -r %s;\n' % (bm, c.rev())) + ui.write(('hg bookmark %s -r %s;\n' % (bm, c.rev()))) else: ret = hg.update(repo, c.rev()) if not ret: @@ -2150,7 +2170,7 @@ displayer.show(c) result = 0 elif children: - ui.warn("ambigious next changeset:\n") + ui.warn(_("ambigious next changeset:\n")) for c in children: displayer.show(c) ui.warn(_('explicitly update to one of them\n')) @@ -2186,7 +2206,7 @@ """ marks = repo._bookmarks if mark not in marks: - raise util.Abort(_("bookmark '%s' not found") % mark) + raise error.Abort(_("bookmark '%s' not found") % mark) # If the requested bookmark is not the only one pointing to a # a revision we have to only delete the bookmark and not strip @@ -2242,8 +2262,10 @@ ('r', 'rev', [], _("revisions to prune")), ('k', 'keep', None, _("does not modify working copy during prune")), ('', 'biject', False, _("do a 1-1 map between rev and successor ranges")), - ('', 'fold', False, _("record a fold (multiple precursors, one successors)")), - ('', 'split', False, _("record a split (on precursor, multiple successors)")), + ('', 'fold', False, + _("record a fold (multiple precursors, one successors)")), + ('', 'split', False, + _("record a split (on precursor, multiple successors)")), ('B', 'bookmark', '', _("remove revs only reachable from given" " bookmark"))] + metadataopts, _('[OPTION] [-r] REV...')) @@ -2281,16 +2303,16 @@ options = [o for o in ('biject', 'fold', 'split') if opts.get(o)] if 1 < len(options): - raise util.Abort(_("can only specify one of %s") % ', '.join(options)) + raise error.Abort(_("can only specify one of %s") % ', '.join(options)) if bookmark: - marks,revs = _reachablefrombookmark(repo, revs, bookmark) + marks, revs = _reachablefrombookmark(repo, revs, bookmark) if not revs: # no revisions to prune - delete bookmark immediately _deletebookmark(repo, marks, bookmark) if not revs: - raise util.Abort(_('nothing to prune')) + raise error.Abort(_('nothing to prune')) wlock = lock = tr = None try: @@ -2304,15 +2326,15 @@ cp = repo[p] if not cp.mutable(): # note: createmarkers() would have raised something anyway - raise util.Abort('cannot prune immutable changeset: %s' % cp, + raise error.Abort('cannot prune immutable changeset: %s' % cp, hint='see "hg help phases" for details') precs.append(cp) if not precs: - raise util.Abort('nothing to prune') + raise error.Abort('nothing to prune') if not obsolete.isenabled(repo, obsolete.allowunstableopt): if repo.revs("(%ld::) - %ld", revs, revs): - raise util.Abort(_("cannot prune in the middle of a stack")) + raise error.Abort(_("cannot prune in the middle of a stack")) # defines successors changesets sucs = scmutil.revrange(repo, succs) @@ -2320,17 +2342,17 @@ sucs = tuple(repo[n] for n in sucs) if not biject and len(sucs) > 1 and len(precs) > 1: msg = "Can't use multiple successors for multiple precursors" - raise util.Abort(msg) + raise error.Abort(msg) elif biject and len(sucs) != len(precs): msg = "Can't use %d successors for %d precursors" \ % (len(sucs), len(precs)) - raise util.Abort(msg) + raise error.Abort(msg) elif (len(precs) == 1 and len(sucs) > 1) and not split: msg = "please add --split if you want to do a split" - raise util.Abort(msg) + raise error.Abort(msg) elif len(sucs) == 1 and len(precs) > 1 and not fold: msg = "please add --fold if you want to do a fold" - raise util.Abort(msg) + raise error.Abort(msg) elif biject: relations = [(p, (s,)) for p, s in zip(precs, sucs)] else: @@ -2360,14 +2382,16 @@ descendantrevs = repo.revs("%d::." % newnode.rev()) changedfiles = [] for rev in descendantrevs: - # blindly reset the files, regardless of what actually changed + # blindly reset the files, regardless of what actually + # changed changedfiles.extend(repo[rev].files()) # reset files that only changed in the dirstate too dirstate = repo.dirstate dirchanges = [f for f in dirstate if dirstate[f] != 'n'] changedfiles.extend(dirchanges) - repo.dirstate.rebuild(newnode.node(), newnode.manifest(), changedfiles) + repo.dirstate.rebuild(newnode.node(), newnode.manifest(), + changedfiles) writedirstate(dirstate, tr) else: bookactive = bmactive(repo) @@ -2581,14 +2605,14 @@ lock = repo.lock() wctx = repo[None] if len(wctx.parents()) <= 0: - raise util.Abort(_("cannot uncommit null changeset")) + raise error.Abort(_("cannot uncommit null changeset")) if len(wctx.parents()) > 1: - raise util.Abort(_("cannot uncommit while merging")) + raise error.Abort(_("cannot uncommit while merging")) old = repo['.'] if old.phase() == phases.public: - raise util.Abort(_("cannot rewrite immutable changeset")) + raise error.Abort(_("cannot rewrite immutable changeset")) if len(old.parents()) > 1: - raise util.Abort(_("cannot uncommit merge changeset")) + raise error.Abort(_("cannot uncommit merge changeset")) oldphase = old.phase() @@ -2597,12 +2621,13 @@ rev = scmutil.revsingle(repo, opts.get('rev')) ctx = repo[None] if ctx.p1() == rev or ctx.p2() == rev: - raise util.Abort(_("cannot uncommit to parent changeset")) + raise error.Abort(_("cannot uncommit to parent changeset")) onahead = old.rev() in repo.changelog.headrevs() - disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt) + disallowunstable = not obsolete.isenabled(repo, + obsolete.allowunstableopt) if disallowunstable and not onahead: - raise util.Abort(_("cannot uncommit in the middle of a stack")) + raise error.Abort(_("cannot uncommit in the middle of a stack")) # Recommit the filtered changeset tr = repo.transaction('uncommit') @@ -2613,7 +2638,7 @@ match = scmutil.match(old, pats, opts) newid = _commitfiltered(repo, old, match, target=rev) if newid is None: - raise util.Abort(_('nothing to uncommit'), + raise error.Abort(_('nothing to uncommit'), hint=_("use --all to uncommit all files")) # Move local changes on filtered changeset obsolete.createmarkers(repo, [(old, (repo[newid],))]) @@ -2678,7 +2703,7 @@ if revopt: revs = scmutil.revrange(repo, revopt) if len(revs) != 1: - raise util.Abort(_("you can only specify one revision to split")) + raise error.Abort(_("you can only specify one revision to split")) else: rev = list(revs)[0] else: @@ -2696,10 +2721,10 @@ if disallowunstable: # XXX We should check head revs if repo.revs("(%d::) - %d", rev, rev): - raise util.Abort(_("cannot split commit: %s not a head") % ctx) + raise error.Abort(_("cannot split commit: %s not a head") % ctx) if len(ctx.parents()) > 1: - raise util.Abort(_("cannot split merge commits")) + raise error.Abort(_("cannot split merge commits")) prev = ctx.p1() bmupdate = _bookmarksupdater(repo, ctx.node(), tr) bookactive = bmactive(repo) @@ -2729,7 +2754,7 @@ newcommits.append(repo['.']) break else: - ui.status("no more change to split\n") + ui.status(_("no more change to split\n")) tip = repo[newcommits[-1]] bmupdate(tip.node()) @@ -2773,7 +2798,8 @@ # allow to choose the seed ? _('[-r] revs')) def touch(ui, repo, *revs, **opts): - """create successors that are identical to their predecessors except for the changeset ID + """create successors that are identical to their predecessors except + for the changeset ID This is used to "resurrect" changesets """ @@ -2787,7 +2813,7 @@ ui.write_err('no revision to touch\n') return 1 if not duplicate and repo.revs('public() and %ld', revs): - raise util.Abort("can't touch public revision") + raise error.Abort("can't touch public revision") wlock = lock = tr = None try: wlock = repo.wlock() @@ -2865,7 +2891,7 @@ revs = list(revs) revs.extend(opts['rev']) if not revs: - raise util.Abort(_('no revisions specified')) + raise error.Abort(_('no revisions specified')) revs = scmutil.revrange(repo, revs) @@ -2874,7 +2900,7 @@ extrevs = repo.revs('(%ld::.) or (.::%ld)', revs, revs) discardedrevs = [r for r in revs if r not in extrevs] if discardedrevs: - raise util.Abort(_("cannot fold non-linear revisions"), + raise error.Abort(_("cannot fold non-linear revisions"), hint=_("given revisions are unrelated to parent " "of working directory")) revs = extrevs @@ -2885,20 +2911,20 @@ roots = repo.revs('roots(%ld)', revs) if len(roots) > 1: - raise util.Abort(_("cannot fold non-linear revisions " + raise error.Abort(_("cannot fold non-linear revisions " "(multiple roots given)")) root = repo[roots.first()] if root.phase() <= phases.public: - raise util.Abort(_("cannot fold public revisions")) + raise error.Abort(_("cannot fold public revisions")) heads = repo.revs('heads(%ld)', revs) if len(heads) > 1: - raise util.Abort(_("cannot fold non-linear revisions " + raise error.Abort(_("cannot fold non-linear revisions " "(multiple heads given)")) head = repo[heads.first()] disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt) if disallowunstable: if repo.revs("(%ld::) - %ld", revs, revs): - raise util.Abort(_("cannot fold chain not ending with a head "\ + raise error.Abort(_("cannot fold chain not ending with a head "\ "or with branching")) wlock = lock = None try: @@ -2920,7 +2946,8 @@ commitopts['edit'] = True newid, unusedvariable = rewrite(repo, root, allctx, head, - [root.p1().node(), root.p2().node()], + [root.p1().node(), + root.p2().node()], commitopts=commitopts) phases.retractboundary(repo, tr, targetphase, [newid]) obsolete.createmarkers(repo, [(ctx, (repo[newid],)) @@ -3028,7 +3055,8 @@ obsexcmsg(repo.ui, "looking for common markers in %i nodes\n" % len(revs)) commonrevs = list(unfi.revs('::%ln', pushop.outgoing.commonheads)) - common = findcommonobsmarkers(pushop.ui, unfi, pushop.remote, commonrevs) + common = findcommonobsmarkers(pushop.ui, unfi, pushop.remote, + commonrevs) revs = list(unfi.revs('%ld - (::%ln)', revs, common)) nodes = [cl.node(r) for r in revs] @@ -3060,8 +3088,9 @@ wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes') wireproto.commands['evoext_obshash1'] = (srv_obshash1, 'nodes') if getattr(exchange, '_pushdiscoveryobsmarkers', None) is None: - ui.warn('evolve: your mercurial version is too old\n' - 'evolve: (running in degraded mode, push will includes all markers)\n') + ui.warn(_('evolve: your mercurial version is too old\n' + 'evolve: (running in degraded mode, push will ' + 'includes all markers)\n')) else: olddisco = exchange.pushdiscoverymapping['obsmarker'] def newdisco(pushop): @@ -3088,7 +3117,8 @@ return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes))) def srv_obshash1(repo, proto, nodes): - return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes), version=1)) + return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes), + version=1)) @eh.addattr(localrepo.localpeer, 'evoext_obshash') def local_obshash(peer, nodes): @@ -3125,7 +3155,7 @@ common = set() undecided = set(probeset) totalnb = len(undecided) - ui.progress("comparing with other", 0, total=totalnb) + ui.progress(_("comparing with other"), 0, total=totalnb) _takefullsample = setdiscovery._takefullsample if remote.capable('_evoext_obshash_1'): getremotehash = remote.evoext_obshash1 @@ -3143,7 +3173,7 @@ sample = _takefullsample(dag, undecided, size=fullsamplesize) roundtrips += 1 - ui.progress("comparing with other", totalnb - len(undecided), + ui.progress(_("comparing with other"), totalnb - len(undecided), total=totalnb) ui.debug("query %i; still undecided: %i, sample size is: %i\n" % (roundtrips, len(undecided), len(sample))) @@ -3164,7 +3194,7 @@ undecided.difference_update(common) - ui.progress("comparing with other", None, total=totalnb) + ui.progress(_("comparing with other"), None, total=totalnb) result = dag.headsetofconnecteds(common) ui.debug("%d total queries\n" % roundtrips) @@ -3228,10 +3258,11 @@ else: rslts = [] remotedata = _pushkeyescape(markers).items() - totalbytes = sum(len(d) for k,d in remotedata) + totalbytes = sum(len(d) for k, d in remotedata) sentbytes = 0 - obsexcmsg(repo.ui, "pushing %i obsolescence markers in %i pushkey payload (%i bytes)\n" - % (len(markers), len(remotedata), totalbytes), + obsexcmsg(repo.ui, "pushing %i obsolescence markers in %i " + "pushkey payload (%i bytes)\n" + % (len(markers), len(remotedata), totalbytes), True) for key, data in remotedata: obsexcprg(repo.ui, sentbytes, item=key, unit="bytes", @@ -3273,10 +3304,10 @@ if l.strip(): self.ui.status(_('remote: '), l) return vals[0] - except socket.error, err: + except socket.error as err: if err.args[0] in (errno.ECONNRESET, errno.EPIPE): - raise util.Abort(_('push failed: %s') % err.args[1]) - raise util.Abort(err.args[1]) + raise error.Abort(_('push failed: %s') % err.args[1]) + raise error.Abort(err.args[1]) @eh.wrapfunction(localrepo.localrepository, '_restrictcapabilities') def local_pushobsmarker_capabilities(orig, repo, caps): @@ -3335,7 +3366,8 @@ @eh.wrapfunction(exchange, '_pullbundle2extraprepare') def _addobscommontob2pull(orig, pullop, kwargs): ret = orig(pullop, kwargs) - if 'obsmarkers' in kwargs and pullop.remote.capable('_evoext_getbundle_obscommon'): + if ('obsmarkers' in kwargs and + pullop.remote.capable('_evoext_getbundle_obscommon')): boundaries = _buildpullobsmarkersboundaries(pullop) common = boundaries['common'] if common != [nullid]: @@ -3448,7 +3480,7 @@ ui = self.ui obsexcprg(ui, current, unit="bytes", total=length) while current < length: - readsize = min(length-current, chunk) + readsize = min(length - current, chunk) data.write(f.read(readsize)) current += readsize obsexcprg(ui, current, unit="bytes", total=length) @@ -3483,7 +3515,7 @@ cache = [] unfi = repo.unfiltered() markercache = {} - repo.ui.progress("preparing locally", 0, total=len(unfi)) + repo.ui.progress(_("preparing locally"), 0, total=len(unfi)) for i in unfi: ctx = unfi[i] entry = 0 @@ -3513,14 +3545,13 @@ cache.append((ctx.node(), sha.digest())) else: cache.append((ctx.node(), nullid)) - repo.ui.progress("preparing locally", i, total=len(unfi)) - repo.ui.progress("preparing locally", None) + repo.ui.progress(_("preparing locally"), i, total=len(unfi)) + repo.ui.progress(_("preparing locally"), None) return cache @command('debugobsrelsethashtree', [('', 'v0', None, 'hash on marker format "0"'), - ('', 'v1', None, 'hash on marker format "1" (default)') - ,] , _('')) + ('', 'v1', None, 'hash on marker format "1" (default)')] , _('')) def debugobsrelsethashtree(ui, repo, v0=False, v1=False): """display Obsolete markers, Relevant Set, Hash Tree changeset-node obsrelsethashtree-node @@ -3528,7 +3559,7 @@ It computed form the "orsht" of its parent and markers relevant to the changeset itself.""" if v0 and v1: - raise util.Abort('cannot only specify one format') + raise error.Abort('cannot only specify one format') elif v0: treefunc = _obsrelsethashtreefm0 else: @@ -3551,7 +3582,7 @@ return for mark in markers: if node.nullid in mark[1]: - raise util.Abort(_('bad obsolescence marker detected: ' + raise error.Abort(_('bad obsolescence marker detected: ' 'invalid successors nullid'), hint=_('You should run `hg debugobsconvert`')) @@ -3563,7 +3594,7 @@ origmarkers = repo.obsstore._all # settle version if new_format == repo.obsstore._version: msg = _('New format is the same as the old format, not upgrading!') - raise util.Abort(msg) + raise error.Abort(msg) f = repo.svfs('obsstore', 'wb', atomictemp=True) known = set() markers = []