# HG changeset patch # User Kevin Bullock # Date 1517600502 21600 # Node ID c4703246f350e2321e1c9d3fe8ccd7785881a796 # Parent d75d704772d1dfbceef32f3da7fece4afc4eda14 compat: mark all compat-checking locations outside hggit.compat with "COMPAT:" The format is: # COMPAT: hg X.Y - description of change that affects this block diff -r d75d704772d1 -r c4703246f350 hggit/__init__.py --- a/hggit/__init__.py Tue Sep 18 21:52:09 2018 +0200 +++ b/hggit/__init__.py Fri Feb 02 13:41:42 2018 -0600 @@ -51,6 +51,7 @@ templatekw, ) +# COMPAT: hg 3.2 - exchange module was introduced try: from mercurial import exchange exchange.push # existed in first iteration of this file @@ -58,19 +59,19 @@ # We only *use* the exchange module in hg 3.2+, so this is safe pass +# COMPAT: hg 3.5 - ignore module was removed try: from mercurial import ignore ignore.readpats ignoremod = True except (AttributeError, ImportError): - # The ignore module disappeared in Mercurial 3.5 ignoremod = False +# COMPAT: hg 3.0 - revset.baseset was added baseset = set try: baseset = revset.baseset except AttributeError: - # baseset was added in hg 3.0 pass try: @@ -105,6 +106,7 @@ # support for `hg clone localgitrepo` _oldlocal = hg.schemes['file'] +# COMPAT: hg 1.9 - url.url class moved into util module try: urlcls = hgutil.url except AttributeError: @@ -215,6 +217,7 @@ return revs, co +# COMPAT: hg 1.4 - this is no longer needed if getattr(hg, 'addbranchrevs', False): extensions.wrapfunction(hg, 'addbranchrevs', safebranchrevs) @@ -226,7 +229,8 @@ }) helpdir = os.path.join(os.path.dirname(__file__), 'help') entry = (['git'], _("Working with Git Repositories"), - # Mercurial >= 3.6: doc(ui) + # COMPAT: hg 3.6 - help table expects a delayed loader (see + # help.loaddoc()) lambda *args: open(os.path.join(helpdir, 'git.rst')).read()) insort(help.helptable, entry) diff -r d75d704772d1 -r c4703246f350 hggit/git_handler.py --- a/hggit/git_handler.py Tue Sep 18 21:52:09 2018 +0200 +++ b/hggit/git_handler.py Fri Feb 02 13:41:42 2018 -0600 @@ -324,10 +324,10 @@ bms = [rhead + suffix] if bms: + # COMPAT: hg 3.5 - bookmarks.setcurrent renamed to activate try: bookmarks.activate(self.repo, bms[0]) except AttributeError: - # hg < 3.5 bookmarks.setcurrent(self.repo, bms[0]) self.save_map(self.map_file) @@ -342,11 +342,11 @@ lock = self.repo.lock() try: tr = self.repo.transaction("phase") + # COMPAT: hg 3.2 - advanceboundary uses transaction try: phases.advanceboundary(self.repo, tr, phases.public, blist) except TypeError: - # hg < 3.2 phases.advanceboundary(self.repo, phases.public, blist) tr.close() @@ -970,6 +970,8 @@ # it's a file reported as modified from Git delete, mode, sha = info if delete: + # COMPAT: hg 3.2 - expects this function to return + # None for missing files if getattr(memctx, '_returnnoneformissingfiles', False): return None else: # Mercurial < 3.2 @@ -1152,16 +1154,17 @@ if 'capabilities^{}' in new_refs: del new_refs['capabilities^{}'] tip = hex(tip) + # COMPAT: hg 1.8 - bookmarks extension moved to core try: commands.bookmark(self.ui, self.repo, 'master', rev=tip, force=True) except NameError: bookmarks.bookmark(self.ui, self.repo, 'master', rev=tip, force=True) + # COMPAT: hg 3.5 - bookmarks.setcurrent renamed to activate try: bookmarks.activate(self.repo, 'master') except AttributeError: - # hg < 3.5 bookmarks.setcurrent(self.repo, 'master') new_refs['refs/heads/master'] = self.map_git_get(tip) diff -r d75d704772d1 -r c4703246f350 hggit/gitdirstate.py --- a/hggit/gitdirstate.py Tue Sep 18 21:52:09 2018 +0200 +++ b/hggit/gitdirstate.py Fri Feb 02 13:41:42 2018 -0600 @@ -11,14 +11,15 @@ util, ) +# COMPAT: hg 3.5 - ignore module was removed try: from mercurial import ignore ignore.readpats ignoremod = True except (AttributeError, ImportError): - # ignore module was removed in Mercurial 3.5 ignoremod = False -# pathauditor moved to pathutil in 2.9 + +# COMPAT: hg 2.9 - pathauditor moved to pathutil try: from mercurial import pathutil pathutil.pathauditor @@ -163,7 +164,7 @@ matchalways = match.always() matchtdir = match.traversedir dmap = self._map - # osutil moved in hg 4.3, but util re-exports listdir + # COMPAT: hg 4.3 - osutil moved, but util re-exports listdir try: listdir = util.listdir except AttributeError: @@ -192,8 +193,8 @@ results, work, dirsnotfound = self._walkexplicit(match, subrepos) skipstep3 = skipstep3 and not (work or dirsnotfound) + # COMPAT: hg 3.3.3 - work is now a list of tuples if work and isinstance(work[0], tuple): - # Mercurial >= 3.3.3 work = [nd for nd, d in work if not dirignore(d)] else: work = [d for d in work if not dirignore(d)]