[meld] Add logging for VC modules
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Add logging for VC modules
- Date: Fri, 30 Nov 2012 19:29:42 +0000 (UTC)
commit ecfbdb1afcf525e6872673b82fb465be9964bc24
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Oct 27 11:55:43 2012 +1000
Add logging for VC modules
This commit refactors all of the existiny print-style logging to actual
logging usage, with some small changes in what is actually dumped.
meld/vc/cvs.py | 6 ++++--
meld/vc/fossil.py | 12 ++++++------
meld/vc/monotone.py | 22 ++++++++++++++++------
meld/vc/rcs.py | 2 --
4 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/meld/vc/cvs.py b/meld/vc/cvs.py
index c1deb55..326d52c 100644
--- a/meld/vc/cvs.py
+++ b/meld/vc/cvs.py
@@ -21,6 +21,7 @@
### (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
### THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import logging
import os
from gettext import gettext as _
import re
@@ -63,6 +64,7 @@ class Vc(_vc.Vc):
return True
def _get_dirsandfiles(self, directory, dirs, files):
+ log = logging.getLogger(__name__)
try:
entries = open(os.path.join(directory, self.VC_DIR, "Entries")).read()
@@ -89,7 +91,7 @@ class Vc(_vc.Vc):
except ValueError:
pass
else:
- print "Unknown Entries.Log line '%s'" % match[0]
+ log.warning("Unknown Entries.Log line '%s'", match[0])
entries += "\n".join(toadd)
retfiles = []
@@ -117,7 +119,7 @@ class Vc(_vc.Vc):
if rev[0] == "0":
state = _vc.STATE_NEW
else:
- print "Revision '%s' not understood" % rev
+ state = _vc.STATE_ERROR
elif date=="dummy timestamp from new-entry":
state = _vc.STATE_MODIFIED
else:
diff --git a/meld/vc/fossil.py b/meld/vc/fossil.py
index 680fc68..b99fd8a 100644
--- a/meld/vc/fossil.py
+++ b/meld/vc/fossil.py
@@ -24,6 +24,7 @@
### THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import errno
+import logging
import os
from . import _vc
@@ -80,6 +81,8 @@ class Vc(_vc.CachedVc):
return self.root
def _lookup_tree_cache(self, rootdir):
+ log = logging.getLogger(__name__)
+
while 1:
try:
entries = _vc.popen([self.CMD, "ls", "-l"],
@@ -103,19 +106,16 @@ class Vc(_vc.CachedVc):
os.sep + fname):
state = _vc.STATE_MISSING
- if state == _vc.STATE_ERROR:
- print "WARNING: unknown state ('%s') reported by " \
- "'ls -l'" % mstate
else:
state = _vc.STATE_ERROR
- print "WARNING: unknown state ('%s') reported by 'ls -l' " \
- "(version skew?)" % mstate
+ log.warning("Unknown state '%s'", mstate)
tree_state[os.path.join(self.root, fname)] = state
return tree_state
def _get_dirsandfiles(self, directory, dirs, files):
+ log = logging.getLogger(__name__)
tree = self._get_tree_cache(directory)
@@ -162,7 +162,7 @@ class Vc(_vc.CachedVc):
'manifest.uuid']
if f not in ignorelist:
- print("WARNING: '%s' was not listed by 'ls -l'" % f)
+ log.warning("'%s' was not listed", f)
# If it ain't listed by the inventory it's not under version
# control
diff --git a/meld/vc/monotone.py b/meld/vc/monotone.py
index bc29827..34c3aea 100644
--- a/meld/vc/monotone.py
+++ b/meld/vc/monotone.py
@@ -23,6 +23,7 @@
### THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import errno
+import logging
import os
from . import _vc
@@ -117,13 +118,16 @@ class Vc(_vc.CachedVc):
super(Vc, self).__init__(os.path.normpath(location))
def choose_monotone_version(self):
+ log = logging.getLogger(__name__)
+
try:
# for monotone >= 0.26
self.VC_DIR = "_MTN"
self.CMD = "mtn"
self.interface_version = float(_vc.popen([self.CMD, "automate", "interface_version"]).read())
if self.interface_version > 9.0:
- print "WARNING: Unsupported interface version (please report any problems to the meld mailing list)"
+ log.error("Unsupported monotone interface version; please "
+ "report any problems to the Meld mailing list.")
except (ValueError, OSError):
# for monotone <= 0.25
self.VC_DIR = "MT"
@@ -152,6 +156,8 @@ class Vc(_vc.CachedVc):
return self.root
def _lookup_tree_cache(self, rootdir):
+ log = logging.getLogger(__name__)
+
while 1:
try:
entries = _vc.popen([self.CMD, "automate", "inventory"],
@@ -196,10 +202,12 @@ class Vc(_vc.CachedVc):
else:
state = self.state_map_6[mstate]
if state == _vc.STATE_ERROR:
- print "WARNING: invalid state ('%s') reported by 'automate inventory' for %s" % (mstate, fname)
+ log.warning("Invalid state '%s' reported for "
+ "%s", mstate, fname)
else:
state = _vc.STATE_ERROR
- print "WARNING: impossible state ('%s') reported by 'automate inventory' for %s (version skew?)" % (mstate, fname)
+ log.warning("Invalid state '%s' reported for %s "
+ "(version skew?)", mstate, fname)
# insert the file into the summarized inventory
tree_state[os.path.join(self.root, fname)] = state
@@ -217,16 +225,18 @@ class Vc(_vc.CachedVc):
if mstate in self.state_map_old:
state = self.state_map_old[mstate]
if state == _vc.STATE_ERROR:
- print "WARNING: invalid state ('%s') reported by 'automate inventory'" % mstate
+ log.warning("Invalid state '%s' reported", mstate)
else:
state = _vc.STATE_ERROR
- print "WARNING: impossible state ('%s') reported by 'automate inventory' (version skew?)" % mstate
+ log.warning("Invalid state '%s' reported (version skew?)",
+ mstate)
tree_state[os.path.join(self.root, fname)] = state
return tree_state
def _get_dirsandfiles(self, directory, dirs, files):
+ log = logging.getLogger(__name__)
tree = self._get_tree_cache(directory)
@@ -251,7 +261,7 @@ class Vc(_vc.CachedVc):
ignorelist = [ 'format', 'log', 'options', 'revision', 'work', 'debug', 'inodeprints' ]
if f not in ignorelist:
- print "WARNING: '%s' was not listed by 'automate inventory'" % f
+ log.warning("'%s' was not listed", f)
# if it ain't listed by the inventory it's not under version
# control
diff --git a/meld/vc/rcs.py b/meld/vc/rcs.py
index 3ac155d..4d1a494 100644
--- a/meld/vc/rcs.py
+++ b/meld/vc/rcs.py
@@ -62,14 +62,12 @@ class Vc(_vc.Vc):
sysresult = (result & 0x00FF)
cmdresult = (result & 0xFF00) >> 8
if sysresult != 0:
- print "Error getting state of file %s (exec error %d)" % (path, sysresult)
state = _vc.STATE_ERROR
elif cmdresult == 0:
state = _vc.STATE_NORMAL
elif cmdresult == 1:
state = _vc.STATE_MODIFIED
else:
- print "Error getting state of file %s: %d" % (path, result)
state = _vc.STATE_ERROR
retfiles.append(_vc.File(path, name, state))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]