Mercurial > evolve
changeset 2032:dd7e092a854a
flake8: update the code sources to fixes a horde of pyflake warnings
There is many of them, they all fixed.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 02 Mar 2017 19:29:37 +0100 |
parents | f7cb365ee169 |
children | 16df79bbbe87 |
files | hgext3rd/evolve/__init__.py hgext3rd/evolve/hack/directaccess.py hgext3rd/evolve/hack/drophack.py hgext3rd/evolve/hack/inhibit.py hgext3rd/evolve/legacy.py hgext3rd/evolve/serveronly.py |
diffstat | 6 files changed, 222 insertions(+), 220 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py Thu Mar 02 19:28:52 2017 +0100 +++ b/hgext3rd/evolve/__init__.py Thu Mar 02 19:29:37 2017 +0100 @@ -5,8 +5,7 @@ # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. - -'''extends Mercurial feature related to Changeset Evolution +"""extends Mercurial feature related to Changeset Evolution This extension provides several commands to mutate history and deal with resulting issues. @@ -17,14 +16,12 @@ - alters core commands and extensions that rewrite history to use this feature, - improves some aspect of the early implementation in Mercurial core -''' - +""" __version__ = '5.6.0' testedwith = '3.8.4 3.9.2 4.0.2 4.1' buglink = 'https://bz.mercurial-scm.org/' - evolutionhelptext = """ Obsolescence markers make it possible to mark changesets that have been deleted or superset in a new version of the changeset. @@ -60,20 +57,22 @@ via an extension).""".strip() -import sys, os +import os +import sys import random +import re +import collections +import socket +import errno +import struct + try: import StringIO as io StringIO = io.StringIO except ImportError: import io StringIO = io.StringIO -import re -import collections -import socket -import errno -import struct -sha1re = re.compile(r'\b[0-9a-f]{6,40}\b') + try: from mercurial import registrar @@ -90,9 +89,6 @@ if not obsolete._enabled: obsolete._enabled = True -# Flags for enabling optional parts of evolve -commandopt = 'allnewcommands' - from mercurial import ( bookmarks as bookmarksmod, cmdutil, @@ -123,6 +119,11 @@ from . import serveronly +sha1re = re.compile(r'\b[0-9a-f]{6,40}\b') + +# Flags for enabling optional parts of evolve +commandopt = 'allnewcommands' + obsexcmsg = serveronly.obsexcmsg cmdtable = {} @@ -298,7 +299,6 @@ return symbol return dec - def templatekw(self, keywordname): """Decorated function is a template keyword @@ -344,7 +344,7 @@ self._commandwrappers.append((command, wrapper, opts)) else: self._extcommandwrappers.append((extension, command, wrapper, - opts)) + opts)) return wrapper return dec @@ -480,17 +480,18 @@ 'evolve') if ui.config('alias', 'odiff', None) is None: ui.setconfig('alias', 'odiff', - "diff --hidden --rev 'limit(precursors(.),1)' --rev .", - 'evolve') + "diff --hidden --rev 'limit(precursors(.),1)' --rev .", + 'evolve') if ui.config('alias', 'grab', None) is None: if os.name == 'nt': ui.setconfig('alias', 'grab', - "! " + util.hgexecutable() + " rebase --dest . --rev $@ && " - + util.hgexecutable() + " up tip", + "! " + util.hgexecutable() + + " rebase --dest . --rev $@ && " + + util.hgexecutable() + " up tip", 'evolve') else: ui.setconfig('alias', 'grab', - "! $HG rebase --dest . --rev $@ && $HG up tip", + "! $HG rebase --dest . --rev $@ && $HG up tip", 'evolve') @@ -594,9 +595,6 @@ cs -= repo.changelog.filteredrevs # nodemap has no filtering return cs - - - ##################################################################### ### Extending revset and template ### ##################################################################### @@ -729,8 +727,6 @@ priorbumpeds = len(set(getrevs(repo, 'bumped')) - filtered) priordivergents = len(set(getrevs(repo, 'divergent')) - filtered) ret = orig(ui, repo, *args, **kwargs) - # workaround phase stupidity - #phases._filterunknown(ui, repo.changelog, repo._phasecache.phaseroots) filtered = repo.changelog.filteredrevs newunstables = \ len(set(getrevs(repo, 'unstable')) - filtered) - priorunstables @@ -823,7 +819,7 @@ wlock = repo.wlock() lock = repo.lock() tr = repo.transaction('rewrite') - if len(old.parents()) > 1: #XXX remove this unnecessary limitation. + if len(old.parents()) > 1: # XXX remove this unnecessary limitation. raise error.Abort(_('cannot amend merge changesets')) base = old.p1() updatebookmarks = _bookmarksupdater(repo, old.node(), tr) @@ -837,7 +833,6 @@ # Recompute copies (avoid recording a -> b -> a) copied = copies.pathcopies(base, head) - # prune files which were reverted by the updates def samefile(f): if f in head.manifest(): @@ -853,6 +848,7 @@ files = [f for f in files if not samefile(f)] # commit version of these files as defined by head headmf = head.manifest() + def filectxfn(repo, ctx, path): if path in headmf: fctx = head[path] @@ -902,10 +898,10 @@ """rewrite <rev> on dest""" if orig.rev() == dest.rev(): 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")) + 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 pctx is None: if len(orig.parents()) == 2: @@ -944,9 +940,9 @@ assert tr is not None try: r = _evolvemerge(repo, orig, dest, pctx, keepbranch) - if r[-1]: #some conflict - raise error.Abort( - 'unresolved merge conflicts (see hg help resolve)') + if r[-1]: # some conflict + raise error.Abort(_('unresolved merge conflicts ' + '(see hg help resolve)')) nodenew = _relocatecommit(repo, orig, commitmsg) except error.Abort as exc: repo.dirstate.beginparentchange() @@ -955,6 +951,7 @@ # fix up dirstate for copies and renames copies.duplicatecopies(repo, dest.rev(), orig.p1().rev()) repo.dirstate.endparentchange() + class LocalMergeFailure(MergeFailure, exc.__class__): pass exc.__class__ = LocalMergeFailure @@ -1047,11 +1044,12 @@ fn, opts, = entry deprecationwarning = _('%s have been deprecated in favor of %s\n') % ( oldalias, newalias) + def newfn(*args, **kwargs): ui = args[0] ui.warn(deprecationwarning) util.checksignature(fn)(*args, **kwargs) - newfn.__doc__ = deprecationwarning + newfn.__doc__ = deprecationwarning cmdwrapper = command(oldalias, opts, synopsis) cmdwrapper(newfn) @@ -1121,7 +1119,7 @@ unfi = repo.unfiltered() nm = unfi.changelog.nodemap ui.write(_('markers total: %9i\n') % len(store._all)) - sucscount = [0, 0 , 0, 0] + sucscount = [0, 0, 0, 0] known = 0 parentsdata = 0 metakeys = {} @@ -1186,7 +1184,7 @@ 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]) + median = len(allclusters[nbcluster // 2][1]) ui.write((' median length: %9i\n' % median)) mean = sum(len(x[1]) for x in allclusters) // nbcluster ui.write((' mean length: %9i\n' % mean)) @@ -1202,7 +1200,7 @@ % len(allpclusters[0][1]))) ui.write((' longer length: %9i\n' % len(allpclusters[-1][1]))) - median = len(allpclusters[nbcluster//2][1]) + median = len(allpclusters[nbcluster // 2][1]) ui.write((' median length: %9i\n' % median)) mean = sum(len(x[1]) for x in allpclusters) // nbcluster ui.write((' mean length: %9i\n' % mean)) @@ -1220,7 +1218,7 @@ result = _solvebumped(ui, repo, ctx, dryrun, confirm, progresscb) elif 'divergent' == category: result = _solvedivergent(ui, repo, ctx, dryrun, confirm, - progresscb) + progresscb) else: assert False, "unknown trouble category: %s" % (category) tr.close() @@ -1237,32 +1235,31 @@ hint = None troubled = { - "unstable": repo.revs("unstable()"), - "divergent": repo.revs("divergent()"), - "bumped": repo.revs("bumped()"), - "all": repo.revs("troubled()"), + "unstable": repo.revs("unstable()"), + "divergent": repo.revs("divergent()"), + "bumped": repo.revs("bumped()"), + "all": repo.revs("troubled()"), } - hintmap = { - 'bumped': _("do you want to use --bumped"), - 'bumped+divergent': _("do you want to use --bumped or --divergent"), - 'bumped+unstable': _("do you want to use --bumped or --unstable"), - 'divergent': _("do you want to use --divergent"), - 'divergent+unstable': _("do you want to use --divergent" - " or --unstable"), - 'unstable': _("do you want to use --unstable"), - 'any+bumped': _("do you want to use --any (or --rev) and --bumped"), - 'any+bumped+divergent': _("do you want to use --any (or --rev) and" - " --bumped or --divergent"), - 'any+bumped+unstable': _("do you want to use --any (or --rev) and" - "--bumped or --unstable"), - 'any+divergent': _("do you want to use --any (or --rev) and" - " --divergent"), - 'any+divergent+unstable': _("do you want to use --any (or --rev)" - " and --divergent or --unstable"), - 'any+unstable': _("do you want to use --any (or --rev)" - "and --unstable"), + 'bumped': _("do you want to use --bumped"), + 'bumped+divergent': _("do you want to use --bumped or --divergent"), + 'bumped+unstable': _("do you want to use --bumped or --unstable"), + 'divergent': _("do you want to use --divergent"), + 'divergent+unstable': _("do you want to use --divergent" + " or --unstable"), + 'unstable': _("do you want to use --unstable"), + 'any+bumped': _("do you want to use --any (or --rev) and --bumped"), + 'any+bumped+divergent': _("do you want to use --any (or --rev) and" + " --bumped or --divergent"), + 'any+bumped+unstable': _("do you want to use --any (or --rev) and" + "--bumped or --unstable"), + 'any+divergent': _("do you want to use --any (or --rev) and" + " --divergent"), + 'any+divergent+unstable': _("do you want to use --any (or --rev)" + " and --divergent or --unstable"), + 'any+unstable': _("do you want to use --any (or --rev)" + "and --unstable"), } if revopt: @@ -1305,21 +1302,21 @@ l = len(troubled[targetcat]) if l: hint = _("%d other %s in the repository, do you want --any " - "or --rev") % (l, targetcat) + "or --rev") % (l, targetcat) else: othertroubles = [] for cat in unselectedcategories: if troubled[cat]: othertroubles.append(cat) if othertroubles: - hint = hintmap['any+'+('+'.join(othertroubles))] + hint = hintmap['any+' + ('+'.join(othertroubles))] else: msg = _("no troubled changesets") assert msg is not None - ui.write_err(msg+"\n") + ui.write_err("%s\n" % msg) if hint: - ui.write_err("("+hint+")\n") + ui.write_err("(%s)\n" % hint) return 2 else: return 1 @@ -1409,7 +1406,7 @@ """select troubles in repo matching according to given options""" revs = set() if allopt or revopt: - revs = repo.revs(targetcat+'()') + revs = repo.revs("%s()" % targetcat) if revopt: revs = scmutil.revrange(repo, revopt) & revs elif not anyopt: @@ -1581,23 +1578,23 @@ fm.end() @command('^evolve|stabilize|solve', - [('n', 'dry-run', False, - _('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')), - ('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')), - ('c', 'continue', False, _('continue an interrupted evolution')), - ('l', 'list', False, 'provide details on troubled changesets in the repo'), - ] + mergetoolopts, - _('[OPTIONS]...')) + [('n', 'dry-run', False, + _('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')), + ('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')), + ('c', 'continue', False, _('continue an interrupted evolution')), + ('l', 'list', False, 'provide details on troubled changesets in the repo'), + ] + mergetoolopts, + _('[OPTIONS]...')) def evolve(ui, repo, **opts): """solve troubled changesets in your repository @@ -1702,7 +1699,6 @@ displayer.show(repo[n]) return 2 - ui.status(_('update:')) if not ui.quiet: displayer.show(ctx) @@ -1751,7 +1747,6 @@ lock.release() cmdutil.bailifchanged(repo) - if revopt and allopt: raise error.Abort('cannot specify both "--rev" and "--all"') if revopt and anyopt: @@ -1770,7 +1765,7 @@ for rev in revs: progresscb() _solveone(ui, repo, repo[rev], dryrunopt, confirmopt, - progresscb, targetcat) + progresscb, targetcat) seen += 1 progresscb() _cleanup(ui, repo, startnode, showprogress) @@ -1883,13 +1878,15 @@ displayer.show(target) if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y': raise error.Abort(_('evolve aborted by user')) - if progresscb: progresscb() + 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() + if progresscb: + progresscb() keepbranch = orig.p1().branch() != orig.branch() try: relocate(repo, orig, target, pctx, keepbranch) @@ -1934,7 +1931,8 @@ 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() + if progresscb: + progresscb() newid = tmpctx = None tmpctx = bumped # Basic check for common parent. Far too complicated and fragile @@ -1953,8 +1951,8 @@ except MergeFailure: repo.opener.write('graftstate', bumped.hex() + '\n') repo.ui.write_err(_('evolution failed!\n')) - repo.ui.write_err( - _("fix conflict and run 'hg evolve --continue'\n")) + msg = _("fix conflict and run 'hg evolve --continue'\n") + repo.ui.write_err(msg) raise # Create the new commit context repo.ui.status(_('computing new diff\n')) @@ -2019,15 +2017,15 @@ othersstr = "[%s]" % (','.join([str(i) for i in others])) 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 " - "such as:\n" - "| - hg touch -D\n" - "| - hg prune\n" - "| \n" - "| You should contact your local evolution Guru for help.\n" - ) % (divergent, othersstr) + "|[%s]\n" + "| This is not handled by automatic evolution yet\n" + "| You have to fallback to manual handling with commands " + "such as:\n" + "| - hg touch -D\n" + "| - hg prune\n" + "| \n" + "| You should contact your local evolution Guru for help.\n" + ) % (divergent, othersstr) ui.write_err(msg) return 2 other = others[0] @@ -2079,7 +2077,8 @@ repo.ui.status(_('updating to "local" conflict\n')) hg.update(repo, divergent.rev()) repo.ui.note(_('merging divergent changeset\n')) - if progresscb: progresscb() + if progresscb: + progresscb() stats = merge.update(repo, other.node(), branchmerge=True, @@ -2092,15 +2091,16 @@ "or 'hg update -C .' to abort\n")) if stats[3] > 0: raise error.Abort('merge conflict between several amendments ' - '(this is not automated yet)', - hint="""/!\ You can try: + '(this is not automated yet)', + hint="""/!\ You can try: /!\ * manual merge + resolve => new cset X /!\ * hg up to the parent of the amended changeset (which are named W and Z) /!\ * hg revert --all -r X /!\ * hg ci -m "same message as the amended changeset" => new cset Y /!\ * hg prune -n Y W Z """) - if progresscb: progresscb() + if progresscb: + progresscb() emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit') tr = repo.currenttransaction() assert tr is not None @@ -2136,9 +2136,7 @@ if newer: return base, tuple(ctx._repo[o] for o in newer[0]) raise error.Abort("base of divergent changeset %s not found" % ctx, - hint='this case is not yet handled') - - + hint='this case is not yet handled') shorttemplate = '[{rev}] {desc|firstline}\n' @@ -2220,7 +2218,7 @@ ('', 'no-topic', False, _('ignore topic and move topologically')), ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))], - '[OPTION]...') + '[OPTION]...') def cmdnext(ui, repo, **opts): """update to next child revision @@ -2310,7 +2308,7 @@ else: cmdutil.bailifchanged(repo) result = _solveone(ui, repo, repo[aspchildren[0]], dryrunopt, - False, lambda:None, category='unstable') + False, lambda: None, category='unstable') if not result: ui.status(_('working directory now at %s\n') % repo['.']) return result @@ -2326,7 +2324,7 @@ repomarks = repo._bookmarks if not bookmarks.issubset(repomarks): raise error.Abort(_("bookmark '%s' not found") % - ','.join(sorted(bookmarks - set(repomarks.keys())))) + ','.join(sorted(bookmarks - set(repomarks.keys())))) # If the requested bookmark is not the only one pointing to a # a revision we have to only delete the bookmark and not strip @@ -2336,10 +2334,10 @@ nodetobookmarks.setdefault(bnode, []).append(mark) for marks in nodetobookmarks.values(): if bookmarks.issuperset(marks): - rsrevs = repair.stripbmrevset(repo, marks[0]) - revs = set(revs) - revs.update(set(rsrevs)) - revs = sorted(revs) + rsrevs = repair.stripbmrevset(repo, marks[0]) + revs = set(revs) + revs.update(set(rsrevs)) + revs = sorted(revs) return repomarks, revs def _deletebookmark(repo, repomarks, bookmarks): @@ -2357,8 +2355,6 @@ finally: lockmod.release(tr, lock, wlock) - - def _getmetadata(**opts): metadata = {} date = opts.get('date') @@ -2369,21 +2365,20 @@ metadata['user'] = user return metadata - @command('^prune|obsolete', - [('n', 'new', [], _("successor changeset (DEPRECATED)")), - ('s', 'succ', [], _("successor changeset")), - ('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)")), - ('B', 'bookmark', [], _("remove revs only reachable from given" - " bookmark"))] + metadataopts, - _('[OPTION] [-r] REV...')) - # -U --noupdate option to prevent wc update and or bookmarks update ? + [('n', 'new', [], _("successor changeset (DEPRECATED)")), + ('s', 'succ', [], _("successor changeset")), + ('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)")), + ('B', 'bookmark', [], _("remove revs only reachable from given" + " bookmark"))] + metadataopts, + _('[OPTION] [-r] REV...')) +# XXX -U --noupdate option to prevent wc update and or bookmarks update ? def cmdprune(ui, repo, *revs, **opts): """hide changesets by marking them obsolete @@ -2442,14 +2437,14 @@ if not cp.mutable(): # note: createmarkers() would have raised something anyway raise error.Abort('cannot prune immutable changeset: %s' % cp, - hint="see 'hg help phases' for details") + hint="see 'hg help phases' for details") precs.append(cp) if not precs: raise error.Abort('nothing to prune') if _disallowednewunstable(repo, revs): raise error.Abort(_("cannot prune in the middle of a stack"), - hint = _("new unstable changesets are not allowed")) + hint=_("new unstable changesets are not allowed")) # defines successors changesets sucs = scmutil.revrange(repo, succs) @@ -2487,7 +2482,6 @@ while newnode in precs or newnode.obsolete(): newnode = newnode.parents()[0] - if newnode.node() != wdp.node(): if opts.get('keep', False): # This is largely the same as the implementation in @@ -2555,14 +2549,14 @@ lockmod.release(tr, lock, wlock) @command('amend|refresh', - [('A', 'addremove', None, - _('mark new/missing files as added/removed before committing')), - ('e', 'edit', False, _('invoke editor on commit messages')), - ('', 'close-branch', None, - _('mark a branch as closed, hiding it from the branch list')), - ('s', 'secret', None, _('use the secret phase for committing')), - ] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt, - _('[OPTION]... [FILE]...')) + [('A', 'addremove', None, + _('mark new/missing files as added/removed before committing')), + ('e', 'edit', False, _('invoke editor on commit messages')), + ('', 'close-branch', None, + _('mark a branch as closed, hiding it from the branch list')), + ('s', 'secret', None, _('use the secret phase for committing')), + ] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt, + _('[OPTION]... [FILE]...')) def amend(ui, repo, *pats, **opts): """combine a changeset with updates and replace it with a new one @@ -2624,6 +2618,7 @@ copied = copies.pathcopies(target, ctx) copied = dict((dst, src) for dst, src in copied.iteritems() if dst in files) + def filectxfn(repo, memctx, path, contentctx=ctx, redirect=newcontent): if path in redirect: return filectxfn(repo, memctx, path, contentctx=target, redirect=()) @@ -2694,10 +2689,10 @@ ds.copy(src, dst) @command('^uncommit', - [('a', 'all', None, _('uncommit all changes when no arguments given')), - ('r', 'rev', '', _('revert commit content to REV instead')), - ] + commands.walkopts, - _('[OPTION]... [NAME]')) + [('a', 'all', None, _('uncommit all changes when no arguments given')), + ('r', 'rev', '', _('revert commit content to REV instead')), + ] + commands.walkopts, + _('[OPTION]... [NAME]')) def uncommit(ui, repo, *pats, **opts): """move changes from parent revision to working directory @@ -2732,7 +2727,6 @@ raise error.Abort(_("cannot uncommit merge changeset")) oldphase = old.phase() - rev = None if opts.get('rev'): rev = scmutil.revsingle(repo, opts.get('rev')) @@ -2756,7 +2750,7 @@ newid = _commitfiltered(repo, old, match, target=rev) if newid is None: raise error.Abort(_('nothing to uncommit'), - hint=_("use --all to uncommit all files")) + hint=_("use --all to uncommit all files")) # Move local changes on filtered changeset obsolete.createmarkers(repo, [(old, (repo[newid],))]) phases.retractboundary(repo, tr, oldphase, [newid]) @@ -2809,9 +2803,9 @@ lockmod.release(tr, lock, wlock) @command('^split', - [('r', 'rev', [], _("revision to split")), - ] + commitopts + commitopts2, - _('hg split [OPTION]... [-r] REV')) + [('r', 'rev', [], _("revision to split")), + ] + commitopts + commitopts2, + _('hg split [OPTION]... [-r] REV')) def cmdsplit(ui, repo, *revs, **opts): """split a changeset into smaller changesets @@ -2855,6 +2849,7 @@ hg.update(repo, prev) commands.revert(ui, repo, rev=r, all=True) + def haschanges(): modified, added, removed, deleted = repo.status()[:4] return modified or added or removed or deleted @@ -2891,7 +2886,7 @@ @eh.wrapcommand('strip', extension='strip', opts=[ ('', 'bundle', None, _("delete the commit entirely and move it to a " - "backup bundle")), + "backup bundle")), ]) def stripwrapper(orig, ui, repo, *revs, **kwargs): if (not ui.configbool('experimental', 'prunestrip') or @@ -2915,14 +2910,14 @@ return cmdprune(ui, repo, *revs, **kwargs) @command('^touch', - [('r', 'rev', [], 'revision to update'), - ('D', 'duplicate', False, - 'do not mark the new revision as successor of the old one'), - ('A', 'allowdivergence', False, - 'mark the new revision as successor of the old one potentially creating ' - 'divergence')], - # allow to choose the seed ? - _('[-r] revs')) + [('r', 'rev', [], 'revision to update'), + ('D', 'duplicate', False, + 'do not mark the new revision as successor of the old one'), + ('A', 'allowdivergence', False, + 'mark the new revision as successor of the old one potentially creating ' + 'divergence')], + # 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 @@ -2963,20 +2958,20 @@ # The user hasn't yet decided what to do with the revived # cset, let's ask sset = obsolete.successorssets(repo, ctx.node()) - nodivergencerisk = len(sset) == 0 or ( - len(sset) == 1 and - len(sset[0]) == 1 and - repo[sset[0][0]].rev() == ctx.rev() - ) + nodivergencerisk = (len(sset) == 0 or + (len(sset) == 1 and + len(sset[0]) == 1 and + repo[sset[0][0]].rev() == ctx.rev() + )) if nodivergencerisk: duplicate = False else: displayer.show(ctx) index = ui.promptchoice( _("reviving this changeset will create divergence" - " unless you make a duplicate.\n(a)llow divergence or" - " (d)uplicate the changeset? $$ &Allowdivergence $$ " - "&Duplicate"), 0) + " unless you make a duplicate.\n(a)llow divergence or" + " (d)uplicate the changeset? $$ &Allowdivergence $$ " + "&Duplicate"), 0) choice = ['allowdivergence', 'duplicate'][index] if choice == 'allowdivergence': duplicate = False @@ -3001,11 +2996,11 @@ lockmod.release(tr, lock, wlock) @command('^fold|squash', - [('r', 'rev', [], _("revision to fold")), - ('', 'exact', None, _("only fold specified revisions")), - ('', 'from', None, _("fold revisions linearly to working copy parent")) - ] + commitopts + commitopts2, - _('hg fold [OPTION]... [-r] REV')) + [('r', 'rev', [], _("revision to fold")), + ('', 'exact', None, _("only fold specified revisions")), + ('', 'from', None, _("fold revisions linearly to working copy parent")) + ] + commitopts + commitopts2, + _('hg fold [OPTION]... [-r] REV')) def fold(ui, repo, *revs, **opts): """fold multiple revisions into a single one @@ -3057,9 +3052,10 @@ extrevs = repo.revs('(%ld::.) or (.::%ld)', revs, revs) discardedrevs = [r for r in revs if r not in extrevs] if discardedrevs: - raise error.Abort(_("cannot fold non-linear revisions"), - hint=_("given revisions are unrelated to parent " - "of working directory")) + msg = _("cannot fold non-linear revisions") + hint = _("given revisions are unrelated to parent of working" + " directory") + raise error.Abort(msg, hint=hint) revs = extrevs elif opts['exact']: # Nothing to do; "revs" is already set correctly @@ -3093,7 +3089,7 @@ msgs = ["HG: This is a fold of %d changesets." % len(allctx)] msgs += ["HG: Commit message of changeset %s.\n\n%s\n" % (c.rev(), c.description()) for c in allctx] - commitopts['message'] = "\n".join(msgs) + commitopts['message'] = "\n".join(msgs) commitopts['edit'] = True newid, unusedvariable = rewrite(repo, root, allctx, head, @@ -3102,7 +3098,7 @@ commitopts=commitopts) phases.retractboundary(repo, tr, targetphase, [newid]) obsolete.createmarkers(repo, [(ctx, (repo[newid],)) - for ctx in allctx]) + for ctx in allctx]) tr.close() finally: tr.release() @@ -3114,7 +3110,7 @@ @command('^metaedit', [('r', 'rev', [], _("revision to edit")), - ('', 'fold', None, _("also fold specified revisions into one")), + ('', 'fold', None, _("also fold specified revisions into one")), ] + commitopts + commitopts2, _('hg metaedit [OPTION]... [-r] [REV]')) def metaedit(ui, repo, *revs, **opts): @@ -3179,10 +3175,12 @@ 'revisions')) newunstable = _disallowednewunstable(repo, revs) if newunstable: - raise error.Abort( - _('cannot edit commit information in the middle of a '\ - 'stack'), hint=_('%s will become unstable and new unstable'\ - ' changes are not allowed') % repo[newunstable.first()]) + msg = _('cannot edit commit information in the middle' + ' of a stack') + hint = _('%s will become unstable and new unstable changes' + ' are not allowed') + hint %= repo[newunstable.first()] + raise error.Abort(msg, hint=hint) root = head = repo[revs.first()] wctx = repo[None] @@ -3203,7 +3201,7 @@ (c.rev(), c.description()) for c in allctx] else: msgs = [head.description()] - commitopts['message'] = "\n".join(msgs) + commitopts['message'] = "\n".join(msgs) commitopts['edit'] = True # TODO: if the author and message are the same, don't create a new @@ -3235,19 +3233,19 @@ roots = repo.revs('roots(%ld)', revs) if len(roots) > 1: raise error.Abort(_("cannot fold non-linear revisions " - "(multiple roots given)")) + "(multiple roots given)")) root = repo[roots.first()] if root.phase() <= phases.public: raise error.Abort(_("cannot fold public revisions")) heads = repo.revs('heads(%ld)', revs) if len(heads) > 1: raise error.Abort(_("cannot fold non-linear revisions " - "(multiple heads given)")) + "(multiple heads given)")) head = repo[heads.first()] if _disallowednewunstable(repo, revs): - raise error.Abort(_("cannot fold chain not ending with a head "\ - "or with branching"), hint = _("new unstable"\ - " changesets are not allowed")) + msg = _("cannot fold chain not ending with a head or with branching") + hint = _("new unstable changesets are not allowed") + raise error.Abort(msg, hint=hint) return root, head def _disallowednewunstable(repo, revs): @@ -3279,7 +3277,7 @@ raise error.Abort(_('cannot graft multiple revisions while ' 'obsoleting (for now).')) - return commitwrapper(orig, ui, repo,*revs, **kwargs) + return commitwrapper(orig, ui, repo, *revs, **kwargs) finally: lockmod.release(lock, wlock) @@ -3356,6 +3354,7 @@ @eh.extsetup def _installobsmarkersdiscovery(ui): olddisco = exchange.pushdiscoverymapping['obsmarker'] + def newdisco(pushop): _pushdiscoveryobsmarkers(olddisco, pushop) exchange.pushdiscoverymapping['obsmarker'] = newdisco @@ -3438,7 +3437,6 @@ undecided.difference_update(missing) undecided.difference_update(common) - ui.progress(_("comparing with other"), None) result = dag.headsetofconnecteds(common) ui.debug("%d total queries\n" % roundtrips) @@ -3619,8 +3617,8 @@ obsdata = pullop.remote.evoext_pullobsmarkers_0(**boundaries) obsdata = obsdata.read() if len(obsdata) > 5: - obsexcmsg(ui, "merging obsolescence markers (%i bytes)\n" - % len(obsdata)) + msg = "merging obsolescence markers (%i bytes)\n" % len(obsdata) + obsexcmsg(ui, msg) tr = pullop.gettransaction() old = len(pullop.repo.obsstore._all) pullop.repo.obsstore.mergemarkers(tr, obsdata) @@ -3663,8 +3661,8 @@ common=common) @command('debugobsrelsethashtree', - [('', 'v0', None, 'hash on marker format "0"'), - ('', 'v1', None, 'hash on marker format "1" (default)')] , _('')) + [('', 'v0', None, 'hash on marker format "0"'), + ('', '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 @@ -3695,9 +3693,9 @@ return for mark in markers: if node.nullid in mark[1]: - raise error.Abort(_('bad obsolescence marker detected: ' - 'invalid successors nullid'), - hint=_('You should run `hg debugobsconvert`')) + msg = _('bad obsolescence marker detected: invalid successors nullid') + hint = _('You should run `hg debugobsconvert`') + raise error.Abort(msg, hint=hint) @command( 'debugobsconvert', @@ -3738,7 +3736,7 @@ break else: help.helptable.append((["evolution"], _("Safely Rewriting History"), - _helploader)) + _helploader)) help.helptable.sort() def _relocatecommit(repo, orig, commitmsg): @@ -3785,7 +3783,7 @@ @eh.uisetup def setupevolveunfinished(ui): data = ('evolvestate', True, False, _('evolve in progress'), - _("use 'hg evolve --continue' or 'hg update -C .' to abort")) + _("use 'hg evolve --continue' or 'hg update -C .' to abort")) cmdutil.unfinishedstates.append(data) @eh.wrapfunction(hg, 'clean') @@ -3826,8 +3824,8 @@ return None version = _unpack('>I', versionblob)[0] if version != evolvestateversion: - raise error.Abort(_('unknown evolvestate version %i') - % version, hint=_('upgrade your evolve')) + msg = _('unknown evolvestate version %i') % version + raise error.Abort(msg, hint=_('upgrade your evolve')) records = [] data = f.read() off = 0 @@ -3867,10 +3865,10 @@ branchmerge=False, force=True) if repo._activebookmark: - repo.ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark) + repo.ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark) bookmarksmod.deactivate(repo) if keepbranch: - repo.dirstate.setbranch(orig.branch()) + repo.dirstate.setbranch(orig.branch()) if util.safehasattr(repo, 'currenttopic'): # uurrgs # there no other topic setter yet
--- a/hgext3rd/evolve/hack/directaccess.py Thu Mar 02 19:28:52 2017 +0100 +++ b/hgext3rd/evolve/hack/directaccess.py Thu Mar 02 19:29:37 2017 +0100 @@ -100,7 +100,7 @@ def uisetup(ui): """ Change ordering of extensions to ensure that directaccess extsetup comes after the one of the extensions in the loadsafter list """ - loadsafter = ui.configlist('directaccess','loadsafter') + loadsafter = ui.configlist('directaccess', 'loadsafter') order = list(extensions._order) directaccesidx = order.index('directaccess') @@ -188,7 +188,7 @@ if repo.filtername != 'visible-directaccess-nowarn': unhiddencommits = repo._explicitaccess - accessbefore repo.ui.warn(_("Warning: accessing hidden changesets %s " - "for write operation\n") % - (",".join([str(repo.unfiltered()[l]) - for l in unhiddencommits]))) + "for write operation\n") % + (",".join([str(repo.unfiltered()[l]) + for l in unhiddencommits]))) repo.invalidatevolatilesets()
--- a/hgext3rd/evolve/hack/drophack.py Thu Mar 02 19:28:52 2017 +0100 +++ b/hgext3rd/evolve/hack/drophack.py Thu Mar 02 19:29:37 2017 +0100 @@ -32,7 +32,7 @@ ostop = os.times() wall = cstop - cstart user = ostop[0] - ostart[0] - sys = ostop[1] - ostart[1] + sys = ostop[1] - ostart[1] comb = user + sys ui.write("%s: wall %f comb %f user %f sys %f\n" % (caption, wall, comb, user, sys))
--- a/hgext3rd/evolve/hack/inhibit.py Thu Mar 02 19:28:52 2017 +0100 +++ b/hgext3rd/evolve/hack/inhibit.py Thu Mar 02 19:29:37 2017 +0100 @@ -243,6 +243,7 @@ # lets wrap the computation of the obsolete set # We apply inhibition there obsfunc = obsolete.cachefuncs['obsolete'] + def _computeobsoleteset(repo): """remove any inhibited nodes from the obsolete set @@ -300,7 +301,7 @@ extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged) # Add bookmark -D option entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark) - entry[1].append(('D','prune',None, + entry[1].append(('D', 'prune', None, _('delete the bookmark and prune the commits underneath'))) @command('debugobsinhibit', [], '')
--- a/hgext3rd/evolve/legacy.py Thu Mar 02 19:28:52 2017 +0100 +++ b/hgext3rd/evolve/legacy.py Thu Mar 02 19:29:37 2017 +0100 @@ -97,9 +97,9 @@ subhex, objhex = line.split() suc = bin(subhex) prec = bin(objhex) - sucs = (suc==nullid) and [] or [suc] + sucs = (suc == nullid) and [] or [suc] meta = { - 'date': '%i %i' % util.makedate(), + 'date': '%i %i' % util.makedate(), 'user': ui.username(), } try: @@ -137,7 +137,7 @@ oldmark['date'] = '%i %i' % tuple(oldmark['date']) meta = dict((k.encode('utf-8'), v.encode('utf-8')) - for k, v in oldmark.iteritems()) + for k, v in oldmark.iteritems()) try: succs = [bin(n) for n in oldsubjects] succs = [n for n in succs if n != nullid] @@ -145,8 +145,9 @@ 0, metadata=meta) cnt += 1 except ValueError: - repo.ui.write_err("invalid marker %s -> %s\n" - % (oldobject, oldsubjects)) + msg = "invalid marker %s -> %s\n" + msg %= (oldobject, oldsubjects) + repo.ui.write_err(msg) err += 1 unlink.append(repo.sjoin('obsoletemarkers')) tr.close()
--- a/hgext3rd/evolve/serveronly.py Thu Mar 02 19:28:52 2017 +0100 +++ b/hgext3rd/evolve/serveronly.py Thu Mar 02 19:29:37 2017 +0100 @@ -55,7 +55,7 @@ def obsexcmsg(ui, message, important=False): verbose = ui.configbool('experimental', 'verbose-obsolescence-exchange', - False) + False) if verbose: message = 'OBSEXC: ' + message if important or verbose: @@ -166,7 +166,7 @@ if tmarkers: bmarkers = [] for m in tmarkers: - if not m in markercache: + if m not in markercache: markercache[m] = encodeonemarker(m) bmarkers.append(markercache[m]) bmarkers.sort() @@ -184,7 +184,7 @@ def _obshash(repo, nodes, version=0): if version == 0: hashs = _obsrelsethashtreefm0(repo) - elif version ==1: + elif version == 1: hashs = _obsrelsethashtreefm1(repo) else: assert False @@ -237,12 +237,14 @@ wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*') # wrap module content origfunc = exchange.getbundle2partsmapping['obsmarkers'] + def newfunc(*args, **kwargs): return _getbundleobsmarkerpart(origfunc, *args, **kwargs) exchange.getbundle2partsmapping['obsmarkers'] = newfunc extensions.wrapfunction(wireproto, 'capabilities', capabilities) # wrap command content oldcap, args = wireproto.commands['capabilities'] + def newcap(repo, proto): return capabilities(oldcap, repo, proto) wireproto.commands['capabilities'] = (newcap, args)