Commits

Jason R. Coombs committed 57384be

SubprocessManager is now the default.

  • Participants
  • Parent commits 1c79015
  • Tags 2.0b1

Comments (0)

Files changed (4)

    the author recommends you do read that.
 
 
-Options
-*******
-
-Set the ``HGTOOLS_FORCE_CMD`` environment variable before running
-setup.py if you want to enforce the use of the hg command (though it
-will then fall back to the native libraries if the command is not
-available or fails to run).
-
 Changes
 *******
 
   - added `.get_parents` which returns the revision(s) of the specified
     revision.
 * Removed support for older versions of mercurial (LegacyLibraryManager).
+* The subprocess manager is now the default. The HGTOOLS_FORCE_CMD variable
+  no longer has any effect on hgtools.
 * Version detection now resolves multiple tags on the same revision by
   choosing the greatest version.
 

File hgtools/managers/base.py

 	def setup(self):
 		pass
 
-	@staticmethod
-	def get_valid_managers(location):
+	@classmethod
+	def get_valid_managers(cls, location):
 		"""
 		Get the valid HGRepoManagers for this location.
 		"""
-		force_cmd = os.environ.get('HGTOOLS_FORCE_CMD', False)
-		# until we have importlib, use __import__
+		# until we have importlib (python 2.7), use __import__
 		__import__('hgtools.managers.subprocess')
 		__import__('hgtools.managers.library')
-		class_order = (
-			(
-				hgtools.managers.subprocess.SubprocessManager,
-				hgtools.managers.library.LibraryManager,
-			)
-			if force_cmd else
-			(
-				hgtools.managers.library.LibraryManager,
-				hgtools.managers.subprocess.SubprocessManager,
-			)
-		)
-		all_managers = (cls(location) for cls in class_order)
+		by_priority_attr = lambda c: getattr(c, 'priority', 0)
+		classes = sorted(cls.__subclasses__(), key = by_priority_attr,
+			reverse = True)
+		all_managers = (c(location) for c in classes)
 		return (mgr for mgr in all_managers if mgr.is_valid())
 
 	@staticmethod

File hgtools/managers/subprocess.py

 	An HGRepoManager implemented by calling into the 'hg' command-line
 	as a subprocess.
 	"""
+	priority = 1
 	exe = 'hg'
 
 	def is_valid(self):

File hgtools/plugins.py

 	else:
 		# We don't have a version stored in tag_build, so calculate
 		#  the version using an HGRepoManager.
-		# for now, force the CMD version, because the library version
+		# use the SubrepoManager because the library version
 		#  is not implemented.
-		os.environ['HGTOOLS_FORCE_CMD'] = 'True'
-		mgr = managers.HGRepoManager.get_first_valid_manager()
+		mgr = managers.SubprocessManager('.')
 		version_handler = options.get('version_handler', _calculate_version)
 		version = version_handler(mgr, options)
 	return version