From 16359ae0f40b80c5ddc5bf495d3c1081bf5b81b3 Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Wed, 7 Nov 2012 14:42:10 -0500 Subject: Adding a default conflict resolver of theirs-full to Svn Plugin --- src/lib/Bcfg2/Server/Plugins/Svn.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index fda6b57b5..ac1c73160 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -22,6 +22,9 @@ class Svn(Bcfg2.Server.Plugin.Version): else: __vcs_metadata_path__ = ".svn" + def callback_conflict_resolver(self): + return pysvn.wc_conflict_choice.theirs_full, None, False + def __init__(self, core, datastore): Bcfg2.Server.Plugin.Version.__init__(self, core, datastore) @@ -33,6 +36,7 @@ class Svn(Bcfg2.Server.Plugin.Version): self.client = None else: self.client = pysvn.Client() + self.client.callback_conflict_resolver = self.callback_conflict_resolver self.logger.debug("Initialized svn plugin with SVN directory %s" % self.vcs_path) -- cgit v1.2.3-1-g7c22 From de0ae51b6dc635a3acd2491d4ca3fd021aa55873 Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Mon, 19 Nov 2012 10:36:21 -0500 Subject: minor typo and function documentation --- src/lib/Bcfg2/Server/Plugins/Svn.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index ac1c73160..17a275340 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -23,7 +23,8 @@ class Svn(Bcfg2.Server.Plugin.Version): __vcs_metadata_path__ = ".svn" def callback_conflict_resolver(self): - return pysvn.wc_conflict_choice.theirs_full, None, False + """PySvn callback function to resolve conflicts""" + return pysvn.wc_conflict_choice.theirs_full, None, False def __init__(self, core, datastore): Bcfg2.Server.Plugin.Version.__init__(self, core, datastore) @@ -94,7 +95,7 @@ class Svn(Bcfg2.Server.Plugin.Version): self.logger.info("Updated %s from revision %s to %s" % \ (self.vcs_root, old_revision, self.revision.number)) return True - + def Commit(self): """Svn.Commit() => True|False\nCommit svn repository\n""" # First try to update -- cgit v1.2.3-1-g7c22 From bf98d0d2c56c00ef5b5eb71aeb03e76b41475e2b Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Tue, 27 Nov 2012 14:30:45 -0500 Subject: adding svn merge resolution map --- src/lib/Bcfg2/Server/Plugins/Svn.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index bc585570d..a79cc3c0e 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -5,6 +5,7 @@ updating the repository. """ import sys import Bcfg2.Server.Plugin +from Bcfg2.Compat import ConfigParser try: import pysvn HAS_SVN = True @@ -21,9 +22,21 @@ class Svn(Bcfg2.Server.Plugin.Version): if HAS_SVN: __rmi__ = Bcfg2.Server.Plugin.Version.__rmi__ + ['Update', 'Commit'] - def callback_conflict_resolver(self): + conflict_resolution_map = { + "base": pysvn.wc_conflict_choice.base, + "working": pysvn.wc_conflict_choice.working, + "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""" - return pysvn.wc_conflict_choice.theirs_full, None, False + return self.conflict_resolution_map[svn_resolution], None, False def __init__(self, core, datastore): Bcfg2.Server.Plugin.Version.__init__(self, core, datastore) @@ -36,7 +49,18 @@ class Svn(Bcfg2.Server.Plugin.Version): self.client = None else: self.client = pysvn.Client() - self.client.callback_conflict_resolver = self.callback_conflict_resolver + try: + if self.setup.cfg.has_option("svn", "conflict_resolution"): + svn_resolution = self.setup.cfp.get("svn", + "conflict_resolution") + self.client.callback_conflict_resolver = self.callback_conflict_resolver + except ConfigParser.NoSectionError: + msg = "Svn: No [svn] section found in bcfg2.conf" + LOGGER.warning(msg) + except ConfigParser.NoOptionError: + msg = "Svn: Option not found in bcfg2.conf: %s" % \ + sys.exc_info()[1] + LOGGER.warning(msg) self.logger.debug("Initialized svn plugin with SVN directory %s" % self.vcs_path) -- cgit v1.2.3-1-g7c22 From 9060ce87415dd930cf9306bf61bffcb7d8e702ed Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Tue, 27 Nov 2012 14:32:41 -0500 Subject: adding svn_resolution to global namespace --- src/lib/Bcfg2/Server/Plugins/Svn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index a79cc3c0e..04083a970 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -36,7 +36,7 @@ class Svn(Bcfg2.Server.Plugin.Version): def callback_conflict_resolver(self, conflict_description): """PySvn callback function to resolve conflicts""" - return self.conflict_resolution_map[svn_resolution], None, False + return self.conflict_resolution_map[self.svn_resolution], None, False def __init__(self, core, datastore): Bcfg2.Server.Plugin.Version.__init__(self, core, datastore) @@ -51,7 +51,7 @@ class Svn(Bcfg2.Server.Plugin.Version): self.client = pysvn.Client() try: if self.setup.cfg.has_option("svn", "conflict_resolution"): - svn_resolution = self.setup.cfp.get("svn", + self.svn_resolution = self.setup.cfp.get("svn", "conflict_resolution") self.client.callback_conflict_resolver = self.callback_conflict_resolver except ConfigParser.NoSectionError: -- cgit v1.2.3-1-g7c22 From 93bd9dd8354264b7a96b5061cf51588b687ba24e Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Tue, 27 Nov 2012 21:18:23 -0500 Subject: fixing bugs --- src/lib/Bcfg2/Server/Plugins/Svn.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index 04083a970..9fe3fd398 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -50,17 +50,18 @@ class Svn(Bcfg2.Server.Plugin.Version): else: self.client = pysvn.Client() try: - if self.setup.cfg.has_option("svn", "conflict_resolution"): - self.svn_resolution = self.setup.cfp.get("svn", + if self.core.setup.cfg.has_option("svn", "conflict_resolution"): + self.svn_resolution = self.core.setup.cfp.get("svn", "conflict_resolution") - self.client.callback_conflict_resolver = self.callback_conflict_resolver + self.client.callback_conflict_resolver = \ + self.callback_conflict_resolver except ConfigParser.NoSectionError: msg = "Svn: No [svn] section found in bcfg2.conf" - LOGGER.warning(msg) + self.logger.warning(msg) except ConfigParser.NoOptionError: msg = "Svn: Option not found in bcfg2.conf: %s" % \ sys.exc_info()[1] - LOGGER.warning(msg) + self.logger.warning(msg) self.logger.debug("Initialized svn plugin with SVN directory %s" % self.vcs_path) -- cgit v1.2.3-1-g7c22 From eefa08eaac8e45963321bd55291a81a579db2cb1 Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Tue, 27 Nov 2012 21:24:31 -0500 Subject: fixing line lengths --- src/lib/Bcfg2/Server/Plugins/Svn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index 9fe3fd398..a3a149b1f 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -50,7 +50,8 @@ class Svn(Bcfg2.Server.Plugin.Version): else: self.client = pysvn.Client() try: - if self.core.setup.cfg.has_option("svn", "conflict_resolution"): + if self.core.setup.cfg.has_option("svn", + "conflict_resolution"): self.svn_resolution = self.core.setup.cfp.get("svn", "conflict_resolution") self.client.callback_conflict_resolver = \ -- cgit v1.2.3-1-g7c22 From 6d0ac6ce0deab13e5cc395b4655a2cd94cef9d9f Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Tue, 27 Nov 2012 21:40:26 -0500 Subject: log actions better --- src/lib/Bcfg2/Server/Plugins/Svn.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index a3a149b1f..d444b6a0c 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -36,6 +36,9 @@ class Svn(Bcfg2.Server.Plugin.Version): 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 def __init__(self, core, datastore): -- cgit v1.2.3-1-g7c22 From 10105b311788549bbc6136884bb3e6133d86b1b3 Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Tue, 27 Nov 2012 21:45:09 -0500 Subject: fixing syntax --- src/lib/Bcfg2/Server/Plugins/Svn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index d444b6a0c..9ec334dd0 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -38,7 +38,7 @@ class Svn(Bcfg2.Server.Plugin.Version): """PySvn callback function to resolve conflicts""" self.logger.info("Svn: Resolving conflict for %s with %s" % \ (conflict_description['path'], - self.svn_resolution) + self.svn_resolution)) return self.conflict_resolution_map[self.svn_resolution], None, False def __init__(self, core, datastore): -- cgit v1.2.3-1-g7c22 From 2928afaa547dd8861f0ba9ca2c48c1579c19b48e Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Tue, 27 Nov 2012 22:23:49 -0500 Subject: adding doc, changing variable names --- src/lib/Bcfg2/Server/Plugins/Svn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index 9ec334dd0..b1f8ef388 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -53,14 +53,14 @@ class Svn(Bcfg2.Server.Plugin.Version): else: self.client = pysvn.Client() try: - if self.core.setup.cfg.has_option("svn", + if self.core.setup.cfg.has_option("Svn", "conflict_resolution"): - self.svn_resolution = self.core.setup.cfp.get("svn", + self.svn_resolution = self.core.setup.cfp.get("Svn", "conflict_resolution") self.client.callback_conflict_resolver = \ self.callback_conflict_resolver except ConfigParser.NoSectionError: - msg = "Svn: No [svn] section found in bcfg2.conf" + msg = "Svn: No [Svn] section found in bcfg2.conf" self.logger.warning(msg) except ConfigParser.NoOptionError: msg = "Svn: Option not found in bcfg2.conf: %s" % \ -- cgit v1.2.3-1-g7c22 From e63eea186a953a53afbcddfae89ec49d602a1353 Mon Sep 17 00:00:00 2001 From: Jason Kincl Date: Wed, 28 Nov 2012 08:50:26 -0500 Subject: fixing logic so try..except works correctly, bugs --- src/lib/Bcfg2/Server/Plugins/Svn.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index b1f8ef388..a33948526 100644 --- a/src/lib/Bcfg2/Server/Plugins/Svn.py +++ b/src/lib/Bcfg2/Server/Plugins/Svn.py @@ -24,7 +24,6 @@ class Svn(Bcfg2.Server.Plugin.Version): conflict_resolution_map = { "base": pysvn.wc_conflict_choice.base, - "working": pysvn.wc_conflict_choice.working, "mine-conflict": pysvn.wc_conflict_choice.mine_conflict, "theirs-conflict": pysvn.wc_conflict_choice.theirs_conflict, "mine-full": pysvn.wc_conflict_choice.mine_full, @@ -53,11 +52,9 @@ class Svn(Bcfg2.Server.Plugin.Version): else: self.client = pysvn.Client() try: - if self.core.setup.cfg.has_option("Svn", - "conflict_resolution"): - self.svn_resolution = self.core.setup.cfp.get("Svn", - "conflict_resolution") - self.client.callback_conflict_resolver = \ + self.svn_resolution = self.core.setup.cfp.get("Svn", + "conflict_resolution") + self.client.callback_conflict_resolver = \ self.callback_conflict_resolver except ConfigParser.NoSectionError: msg = "Svn: No [Svn] section found in bcfg2.conf" @@ -67,7 +64,7 @@ class Svn(Bcfg2.Server.Plugin.Version): sys.exc_info()[1] self.logger.warning(msg) - self.logger.debug("Initialized svn plugin with SVN directory %s" % + self.logger.debug("Svn: Initialized svn plugin with SVN directory %s" % self.vcs_path) def get_revision(self): -- cgit v1.2.3-1-g7c22 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') 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