Mercurial > evolve
changeset 1835:93d4661a6ee7
compat: drop bookmark compatibility layer
All the version we now supports have the 'new' API.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 28 Feb 2017 14:31:18 +0100 |
parents | f23a97d14895 |
children | 9e87ac06be90 |
files | hgext3rd/evolve/__init__.py |
diffstat | 1 files changed, 16 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py Tue Feb 28 14:29:36 2017 +0100 +++ b/hgext3rd/evolve/__init__.py Tue Feb 28 14:31:18 2017 +0100 @@ -950,7 +950,7 @@ except error.Abort as exc: repo.dirstate.beginparentchange() repo.setparents(repo['.'].node(), nullid) - writedirstate(repo.dirstate, tr) + repo.dirstate.write(tr) # fix up dirstate for copies and renames copies.duplicatecopies(repo, dest.rev(), orig.p1().rev()) repo.dirstate.endparentchange() @@ -978,33 +978,6 @@ repo._bookmarks.recordchange(tr) return updatebookmarks -### bookmarks api compatibility layer ### -def bmdeactivate(repo): - try: - return bookmarksmod.deactivate(repo) - except AttributeError: - return bookmarksmod.unsetcurrent(repo) -def bmactivate(repo, book): - try: - return bookmarksmod.activate(repo, book) - except AttributeError: - return bookmarksmod.setcurrent(repo, book) - -def bmactive(repo): - try: - return repo._activebookmark - except AttributeError: - return repo._bookmarkcurrent - -### dirstate compatibility layer < hg 3.6 - -def writedirstate(dirstate, tr): - if dirstate.write.func_code.co_argcount != 1: # mercurial 3.6 and above - return dirstate.write(tr) - return dirstate.write() - - - ### new command ############################# metadataopts = [ @@ -2208,7 +2181,7 @@ ui.warn(_('(do you want --no-topic)\n')) elif len(parents) == 1: p = parents[0] - bm = bmactive(repo) + bm = repo._activebookmark shouldmove = opts.get('move_bookmark') and bm is not None if dryrunopt: ui.write(('hg update %s;\n' % p.rev())) @@ -2225,7 +2198,7 @@ repo._bookmarks[bm] = p.node() repo._bookmarks.recordchange(tr) else: - bmdeactivate(repo) + bookmarksmod.deactivate(repo) tr.close() finally: lockmod.release(tr, lock) @@ -2282,7 +2255,7 @@ displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) if len(children) == 1: c = children[0] - bm = bmactive(repo) + bm = repo._activebookmark shouldmove = opts.get('move_bookmark') and bm is not None if dryrunopt: ui.write(('hg update %s;\n' % c.rev())) @@ -2299,7 +2272,7 @@ repo._bookmarks[bm] = c.node() repo._bookmarks.recordchange(tr) else: - bmdeactivate(repo) + bookmarksmod.deactivate(repo) tr.close() finally: lockmod.release(tr, lock) @@ -2537,21 +2510,21 @@ changedfiles.extend(dirchanges) repo.dirstate.rebuild(newnode.node(), newnode.manifest(), changedfiles) - writedirstate(dirstate, tr) + dirstate.write(tr) else: - bookactive = bmactive(repo) + bookactive = repo._activebookmark # Active bookmark that we don't want to delete (with -B option) # we deactivate and move it before the update and reactivate it # after movebookmark = bookactive and not bookmarks if movebookmark: - bmdeactivate(repo) + bookmarksmod.deactivate(repo) repo._bookmarks[bookactive] = newnode.node() repo._bookmarks.recordchange(tr) commands.update(ui, repo, newnode.rev()) ui.status(_('working directory now at %s\n') % newnode) if movebookmark: - bmactivate(repo, bookactive) + bookmarksmod.activate(repo, bookactive) # update bookmarks if bookmarks: @@ -2876,10 +2849,10 @@ raise error.Abort(_("cannot split merge commits")) prev = ctx.p1() bmupdate = _bookmarksupdater(repo, ctx.node(), tr) - bookactive = bmactive(repo) + bookactive = repo._activebookmark if bookactive is not None: - repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo)) - bmdeactivate(repo) + repo.ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark) + bookmarksmod.deactivate(repo) hg.update(repo, prev) commands.revert(ui, repo, rev=r, all=True) @@ -2910,7 +2883,7 @@ tip = repo[newcommits[-1]] bmupdate(tip.node()) if bookactive is not None: - bmactivate(repo, bookactive) + bookmarksmod.activate(repo, bookactive) obsolete.createmarkers(repo, [(repo[r], newcommits)]) tr.close() finally: @@ -4107,9 +4080,9 @@ dest, branchmerge=False, force=True) - if bmactive(repo): - repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo)) - bmdeactivate(repo) + if repo._activebookmark: + repo.ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark) + bookmarksmod.deactivate(repo) if keepbranch: repo.dirstate.setbranch(orig.branch()) if util.safehasattr(repo, 'currenttopic'):