diff -r 970a4c13ebc3 -r 6c922448ccec hgext/evolve.py --- a/hgext/evolve.py Sun Oct 16 09:52:53 2016 -0700 +++ b/hgext/evolve.py Fri Oct 28 15:44:15 2016 +0200 @@ -21,7 +21,7 @@ __version__ = '5.4.1' testedwith = '3.4.3 3.5.2 3.6.2 3.7.3 3.8.1 3.9' -buglink = 'http://bz.selenic.com/' +buglink = 'https://bz.mercurial-scm.org/' evolutionhelptext = """ @@ -665,17 +665,11 @@ @eh.templatekw('obsolete') def obsoletekw(repo, ctx, templ, **args): - """:obsolete: String. The obsolescence level of the node, could be - ``stable``, ``unstable``, ``suspended`` or ``extinct``. + """:obsolete: String. Whether the changeset is ``obsolete``. """ if ctx.obsolete(): - if ctx.extinct(): - return 'extinct' - else: - return 'suspended' - elif ctx.unstable(): - return 'unstable' - return 'stable' + return 'obsolete' + return '' @eh.templatekw('troubles') def showtroubles(repo, ctx, **args): @@ -964,28 +958,25 @@ tr = repo.currenttransaction() assert tr is not None try: - try: - r = _evolvemerge(repo, orig, dest, pctx, keepbranch) - 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() - repo.setparents(repo['.'].node(), nullid) - writedirstate(repo.dirstate, tr) - # 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 - tr.close() # to keep changes in this transaction (e.g. dirstate) - raise - oldbookmarks = repo.nodebookmarks(nodesrc) - _finalizerelocate(repo, orig, dest, nodenew, tr) - finally: - pass # TODO: remove this redundant try/finally block + r = _evolvemerge(repo, orig, dest, pctx, keepbranch) + 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() + repo.setparents(repo['.'].node(), nullid) + writedirstate(repo.dirstate, tr) + # 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 + tr.close() # to keep changes in this transaction (e.g. dirstate) + raise + oldbookmarks = repo.nodebookmarks(nodesrc) + _finalizerelocate(repo, orig, dest, nodenew, tr) return nodenew def _bookmarksupdater(repo, oldid, tr): @@ -1024,7 +1015,7 @@ ### dirstate compatibility layer < hg 3.6 def writedirstate(dirstate, tr): - if dirstate.write.func_defaults is not None: # mercurial 3.6 and above + if dirstate.write.func_code.co_argcount != 1: # mercurial 3.6 and above return dirstate.write(tr) return dirstate.write() @@ -1794,14 +1785,18 @@ raise error.Abort('no evolve to continue') orig = repo[state['current']] # XXX This is a terrible terrible hack, please get rid of it. - repo.opener.write('graftstate', orig.hex() + '\n') + lock = repo.wlock() try: - graftcmd = commands.table['graft'][0] - ret = graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) - _evolvestatedelete(repo) - return ret + repo.opener.write('graftstate', orig.hex() + '\n') + try: + graftcmd = commands.table['graft'][0] + ret = graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) + _evolvestatedelete(repo) + return ret + finally: + util.unlinkpath(repo.join('graftstate'), ignoremissing=True) finally: - util.unlinkpath(repo.join('graftstate'), ignoremissing=True) + lock.release() cmdutil.bailifchanged(repo) @@ -1994,73 +1989,70 @@ tr = repo.currenttransaction() assert tr is not None bmupdate = _bookmarksupdater(repo, bumped.node(), tr) - try: - if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)): - # Need to rebase the changeset at the right place - repo.ui.status( - _('rebasing to destination parent: %s\n') % prec.p1()) - try: - tmpid = relocate(repo, bumped, prec.p1()) - if tmpid is not None: - tmpctx = repo[tmpid] - obsolete.createmarkers(repo, [(bumped, (tmpctx,))]) - 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')) - raise - # Create the new commit context - repo.ui.status(_('computing new diff\n')) - files = set() - copied = copies.pathcopies(prec, bumped) - precmanifest = prec.manifest().copy() - # 3.3.2 needs a list. - # future 3.4 don't detect the size change during iteration - # this is fishy - for key, val in list(bumped.manifest().iteritems()): - precvalue = precmanifest.get(key, None) - if precvalue is not None: - del precmanifest[key] - if precvalue != val: - files.add(key) - files.update(precmanifest) # add missing files - # commit it - if files: # something to commit! - def filectxfn(repo, ctx, path): - if path in bumped: - fctx = bumped[path] - flags = fctx.flags() - mctx = memfilectx(repo, fctx.path(), fctx.data(), - islink='l' in flags, - isexec='x' in flags, - copied=copied.get(path)) - return mctx - return None - text = 'bumped update to %s:\n\n' % prec - text += bumped.description() - - new = context.memctx(repo, - parents=[prec.node(), node.nullid], - text=text, - files=files, - filectxfn=filectxfn, - user=bumped.user(), - date=bumped.date(), - extra=bumped.extra()) - - newid = repo.commitctx(new) - if newid is None: - obsolete.createmarkers(repo, [(tmpctx, ())]) - newid = prec.node() - else: - phases.retractboundary(repo, tr, bumped.phase(), [newid]) - obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))], - flag=obsolete.bumpedfix) - bmupdate(newid) - repo.ui.status(_('committed as %s\n') % node.short(newid)) - finally: - pass # TODO: remove this redundant try/finally block + if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)): + # Need to rebase the changeset at the right place + repo.ui.status( + _('rebasing to destination parent: %s\n') % prec.p1()) + try: + tmpid = relocate(repo, bumped, prec.p1()) + if tmpid is not None: + tmpctx = repo[tmpid] + obsolete.createmarkers(repo, [(bumped, (tmpctx,))]) + 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')) + raise + # Create the new commit context + repo.ui.status(_('computing new diff\n')) + files = set() + copied = copies.pathcopies(prec, bumped) + precmanifest = prec.manifest().copy() + # 3.3.2 needs a list. + # future 3.4 don't detect the size change during iteration + # this is fishy + for key, val in list(bumped.manifest().iteritems()): + precvalue = precmanifest.get(key, None) + if precvalue is not None: + del precmanifest[key] + if precvalue != val: + files.add(key) + files.update(precmanifest) # add missing files + # commit it + if files: # something to commit! + def filectxfn(repo, ctx, path): + if path in bumped: + fctx = bumped[path] + flags = fctx.flags() + mctx = memfilectx(repo, fctx.path(), fctx.data(), + islink='l' in flags, + isexec='x' in flags, + copied=copied.get(path)) + return mctx + return None + text = 'bumped update to %s:\n\n' % prec + text += bumped.description() + + new = context.memctx(repo, + parents=[prec.node(), node.nullid], + text=text, + files=files, + filectxfn=filectxfn, + user=bumped.user(), + date=bumped.date(), + extra=bumped.extra()) + + newid = repo.commitctx(new) + if newid is None: + obsolete.createmarkers(repo, [(tmpctx, ())]) + newid = prec.node() + else: + phases.retractboundary(repo, tr, bumped.phase(), [newid]) + obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))], + flag=obsolete.bumpedfix) + bmupdate(newid) + repo.ui.status(_('committed as %s\n') % node.short(newid)) # reroute the working copy parent to the new changeset repo.dirstate.beginparentchange() repo.dirstate.setparents(newid, node.nullid)