Transition to libbe.LOG for logging
[be.git] / libbe / storage / vcs / base.py
index 5f13c012821d58b4864f938b71efcc211a402d02..671df43330dbef33b99eb1b29a9211709a37def2 100644 (file)
@@ -3,7 +3,7 @@
 #                         Ben Finney <benf@cybersource.com.au>
 #                         Chris Ball <cjb@laptop.org>
 #                         Gianluca Montecchi <gian@grys.it>
-#                         W. Trevor King <wking@drexel.edu>
+#                         W. Trevor King <wking@tremily.us>
 #
 # This file is part of Bugs Everywhere.
 #
@@ -20,7 +20,7 @@
 # You should have received a copy of the GNU General Public License along with
 # Bugs Everywhere.  If not, see <http://www.gnu.org/licenses/>.
 
-"""Define the base :class:`VCS` (Version Control System) class, which
+"""Define the base :py:class:`VCS` (Version Control System) class, which
 should be subclassed by other Version Control System backends.  The
 base class implements a "do not version" VCS.
 """
@@ -57,7 +57,7 @@ Don't list this module, it is implicitly last.
 """
 
 def set_preferred_vcs(name):
-    """Manipulate :data:`VCS_ORDER` to place `name` first.
+    """Manipulate :py:data:`VCS_ORDER` to place `name` first.
 
     This is primarily indended for testing purposes.
     """
@@ -70,7 +70,7 @@ def set_preferred_vcs(name):
 def _get_matching_vcs(matchfn):
     """Return the first module for which matchfn(VCS_instance) is True.
 
-    Searches in :data:`VCS_ORDER`.
+    Searches in :py:data:`VCS_ORDER`.
     """
     for submodname in VCS_ORDER:
         module = import_by_name('libbe.storage.vcs.%s' % submodname)
@@ -82,7 +82,7 @@ def _get_matching_vcs(matchfn):
 def vcs_by_name(vcs_name):
     """Return the module for the VCS with the given name.
 
-    Searches in :data:`VCS_ORDER`.
+    Searches in :py:data:`VCS_ORDER`.
     """
     if vcs_name == VCS.name:
         return new()
@@ -91,14 +91,14 @@ def vcs_by_name(vcs_name):
 def detect_vcs(dir):
     """Return an VCS instance for the vcs being used in this directory.
 
-    Searches in :data:`VCS_ORDER`.
+    Searches in :py:data:`VCS_ORDER`.
     """
     return _get_matching_vcs(lambda vcs: vcs._detect(dir))
 
 def installed_vcs():
     """Return an instance of an installed VCS.
 
-    Searches in :data:`VCS_ORDER`.
+    Searches in :py:data:`VCS_ORDER`.
     """
     return _get_matching_vcs(lambda vcs: vcs.installed())
 
@@ -143,7 +143,7 @@ class CachedPathID (object):
        .../.be/BUGDIR/bugs/BUG/comments/COMMENT
           ^-- root path
 
-    See :mod:`libbe.util.id` for a discussion of ID formats.
+    See :py:mod:`libbe.util.id` for a discussion of ID formats.
 
     Examples
     --------
@@ -207,7 +207,7 @@ class CachedPathID (object):
         self._cache_path = os.path.join(
             self._root, self._spacer_dirs[0], 'id-cache')
 
-    def init(self, verbose=True, cache=None):
+    def init(self, cache=None):
         """Create cache file for an existing .be directory.
 
         The file contains multiple lines of the form::
@@ -219,15 +219,18 @@ class CachedPathID (object):
         else:
             self._cache = cache
         spaced_root = os.path.join(self._root, self._spacer_dirs[0])
-        for dirpath, dirnames, filenames in os.walk(spaced_root):
+        for dirpath, dirnames, filenames in os.walk(spaced_root,
+                                                    followlinks=True):
             if dirpath == spaced_root:
                 continue
             try:
                 id = self.id(dirpath)
                 relpath = dirpath[len(self._root + os.path.sep):]
                 if id.count('/') == 0:
-                    if verbose == True and id in self._cache:
-                        print >> sys.stderr, 'Multiple paths for %s: \n  %s\n  %s' % (id, self._cache[id], relpath)
+                    if id in self._cache:
+                        libbe.LOG.warning(
+                            'multiple paths for {0}:\n  {1}\n  {2}'.format(
+                                id, self._cache[id], relpath))
                     self._cache[id] = relpath
             except InvalidPath:
                 pass
@@ -270,7 +273,7 @@ class CachedPathID (object):
         else:
             extra = fields[1:]
         if uuid not in self._cache:
-            self.init(verbose=False, cache=self._cache)
+            self.init(cache=self._cache)
             if uuid not in self._cache:
                 raise InvalidID(uuid)
         if relpath == True:
@@ -354,7 +357,6 @@ class VCS (libbe.storage.base.VersionedStorage):
         libbe.storage.base.VersionedStorage.__init__(self, *args, **kwargs)
         self.versioned = False
         self.interspersed_vcs_files = False
-        self.verbose_invoke = False
         self._cached_path_id = CachedPathID()
         self._rooted = False
 
@@ -922,8 +924,6 @@ class VCS (libbe.storage.base.VersionedStorage):
     def _u_invoke(self, *args, **kwargs):
         if 'cwd' not in kwargs:
             kwargs['cwd'] = self.repo
-        if 'verbose' not in kwargs:
-            kwargs['verbose'] = self.verbose_invoke
         if 'encoding' not in kwargs:
             kwargs['encoding'] = self.encoding
         return invoke(*args, **kwargs)
@@ -1031,7 +1031,7 @@ class VCS (libbe.storage.base.VersionedStorage):
         return relpath
 
     def _u_abspath(self, path, root=None):
-        """Return the absolute path from a path realtive to root.
+        """Return the absolute path from a path relative to root.
 
         Examples
         --------
@@ -1068,7 +1068,7 @@ class VCS (libbe.storage.base.VersionedStorage):
 
         See Also
         --------
-        :mod:`libbe.storage.util.upgrade`
+        libbe.storage.util.upgrade
         """
         if path == None:
             path = os.path.join(self.repo, '.be', 'version')
@@ -1168,7 +1168,7 @@ if libbe.TESTING == True:
     class VCS_get_user_id_TestCase(VCSTestCase):
         """Test cases for VCS.get_user_id method."""
 
-        def test_gets_existing_user_id(self):
+        def test_get_existing_user_id(self):
             """Should get the existing user ID."""
             if self.s.installed():
                 user_id = self.s.get_user_id()