diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-12-04 06:22:16 -0800 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-12-04 06:22:16 -0800 |
commit | dc23257f5fd02474bd425ce5e44dffe0bd29508a (patch) | |
tree | c5c0af33093087f10f0caf5ce021aa4cb0b4a879 | |
parent | f35c38e87eafffb497338b9273fe84f284a41dcf (diff) | |
parent | 09a45d745269a419b0c5da0664912e061dc8e5d3 (diff) | |
download | bcfg2-dc23257f5fd02474bd425ce5e44dffe0bd29508a.tar.gz bcfg2-dc23257f5fd02474bd425ce5e44dffe0bd29508a.tar.bz2 bcfg2-dc23257f5fd02474bd425ce5e44dffe0bd29508a.zip |
Merge pull request #54 from kincl/jasons-hacking
Adding a default conflict resolver of theirs-full to Svn Plugin
-rw-r--r-- | doc/server/plugins/version/svn.txt | 33 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Svn.py | 31 |
2 files changed, 62 insertions, 2 deletions
diff --git a/doc/server/plugins/version/svn.txt b/doc/server/plugins/version/svn.txt index 7166ee89d..f7739bd51 100644 --- a/doc/server/plugins/version/svn.txt +++ b/doc/server/plugins/version/svn.txt @@ -32,3 +32,36 @@ Simply add Svn to your plugins line in ``/etc/bcfg2.conf``:: [server] plugins = Bundler,Cfg,Metadata,..,Svn + +Resolving conflicts +======================= + +By default, the Svn plugin does not attempt to resolve conflicts +when trying to commit or update the repository. This can be changed by +adding to ``/etc/bcfg2.conf``:: + + [Svn] + conflict_resolution = + ++-----------------+ +| Actions | ++=================+ +| base | ++-----------------+ +| postpone | ++-----------------+ +| mine-conflict | ++-----------------+ +| theirs-conflict | ++-----------------+ +| mine-full | ++-----------------+ +| theirs-full | ++-----------------+ + +Descriptions of each action can be found in the `Version Control with +Subversion`_ book. + +.. _Version Control with Subversion: +http://svnbook.red-bean.com/en/1.7/svn.ref.svn.html#svn.ref.svn.sw.accept + diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py index 57689cf33..26443f103 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 @@ -20,6 +21,20 @@ class Svn(Bcfg2.Server.Plugin.Version): __vcs_metadata_path__ = ".svn" if HAS_SVN: __rmi__ = Bcfg2.Server.Plugin.Version.__rmi__ + ['Update', 'Commit'] + else: + __vcs_metadata_path__ = ".svn" + + def callback_conflict_resolver(self, conflict_description): + """PySvn callback function to resolve conflicts""" + 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) @@ -32,8 +47,20 @@ class Svn(Bcfg2.Server.Plugin.Version): self.client = None else: self.client = pysvn.Client() + try: + 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" + self.logger.warning(msg) + except ConfigParser.NoOptionError: + msg = "Svn: Option not found in bcfg2.conf: %s" % \ + 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): @@ -89,7 +116,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 |