From b97fbb64ae7e79e96ddf150b577954149a0240c6 Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Mon, 3 Dec 2012 15:25:39 -0500 Subject: Future-proofed conflict option selection * moved from a map table to a getattr() lookup --- src/lib/Bcfg2/Server/Plugins/Svn.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins/Svn.py') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index a33948526..26443f103 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -21,24 +21,20 @@ class Svn(Bcfg2.Server.Plugin.Version): __vcs_metadata_path__ = ".svn" if HAS_SVN: __rmi__ = Bcfg2.Server.Plugin.Version.__rmi__ + ['Update', 'Commit'] - - conflict_resolution_map = { - "base": pysvn.wc_conflict_choice.base, - "mine-conflict": pysvn.wc_conflict_choice.mine_conflict, - "theirs-conflict": pysvn.wc_conflict_choice.theirs_conflict, - "mine-full": pysvn.wc_conflict_choice.mine_full, - "theirs-full": pysvn.wc_conflict_choice.theirs_full, - "none": None - } else: __vcs_metadata_path__ = ".svn" def callback_conflict_resolver(self, conflict_description): """PySvn callback function to resolve conflicts""" - self.logger.info("Svn: Resolving conflict for %s with %s" % \ - (conflict_description['path'], - self.svn_resolution)) - return self.conflict_resolution_map[self.svn_resolution], None, False + try: + choice = getattr(pysvn.wc_conflict_choice, + self.svn_resolution.replace('-','_')) + self.logger.info("Svn: Resolving conflict for %s with %s" % \ + (conflict_description['path'], + self.svn_resolution)) + return choice, None, False + except AttributeError: + return pysvn.wc_conflict_choice.postpone def __init__(self, core, datastore): Bcfg2.Server.Plugin.Version.__init__(self, core, datastore) -- cgit v1.2.3-1-g7c22