Re: [viewvc-users] viewvc-1.1.19 issue ...

"C. Michael Pilato" <[email protected]> Tue, 23 Apr 2013 14:15:45 -0400
Newsgroups gmane.comp.version-control.cvs.viewcvs.user
Organization CollabNet, Inc.
Message-ID <[email protected]>
On 04/23/2013 02:06 PM, olli hauer wrote:
> On 2013-04-23 19:48, C. Michael Pilato wrote:
>> On 04/23/2013 01:12 PM, olli hauer wrote:
>>> All tests are done with the same viewvc.conf only [general] changed
>>>
>>> Not working:
>>> ============
>>> [general]
>>> svn_root = FreeBSD: /repos/svn/svnroot/testrepo
>>
>> This won't work because the option name is "svn_roots" (with an 's'), not
>> "svn_root".
> 
> Grrr, thanks for finding the typo!
> Indeed, correct typing (svn_roots) solves the mistake.

Great.

>> So having two 'svn' root_parents works; but having one 'svn' and one 'cvs'
>> does not.  Okay.
> 
> Yes, having root_parents with 'svn' and 'cvs' does not work.

So you are, in fact, seeing exactly the same problem as Michael Theys.
Unfortunately, I cannot for the life of me reproduce this problem!

In Michael's case, it seems that the root listing works fine, but that when
you try to view a Subversion root, it 404's.  He dropped some debugging code
into ViewVC for me and it looked like what was happening was that ViewVC was
claiming to have found his Subversion root inside his CVS root parent!

If you are able to do so, can you apply the *reverse* of the attached patch
to your 1.1.19 instance and see if the problem goes away?  You might need to
clear your browser cache to get clean results.

$ cd /path/to/viewvc
$ patch -p0 -R < /path/to/viewvc-1.1.19-root-handling.patch.txt

-- Mike

PS:  Just by way of a heads-up, note that there's another buglet in 1.1.19,
too.  In the function lib/viewvc.py:markup_stream(), the code refers to a
variable "lin".  It should be "line".  Once again, the lack of an automated
test suite for this product has shot me in the foot.

-- 
C. Michael Pilato <[email protected]>
CollabNet   <>   www.collab.net   <>   Enterprise Cloud Development

------------------------------------------------------
http://viewvc.tigris.org/ds/viewMessage.do?dsForumId=4255&dsMessageId=3054072

To unsubscribe from this discussion, e-mail: [[email protected]].
viewvc-1.1.19-root-handling.patch.txt (text/plain, 2.8 KB)
Index: lib/viewvc.py
===================================================================
--- lib/viewvc.py	(.../tags/1.1.18)	(revision 2883)
+++ lib/viewvc.py	(.../branches/1.1.x)	(revision 2883)
@@ -4570,14 +4721,14 @@
       continue
     pp = os.path.normpath(string.strip(pp[:pos]))
     
+    rootpath = None
     if roottype == 'cvs':
-      roots = vclib.ccvs.expand_root_parent(pp)
+      rootpath = vclib.ccvs.find_root_in_parent(pp, rootname)
     elif roottype == 'svn':
-      roots = vclib.svn.expand_root_parent(pp)
-    else:
-      roots = {}
-    if roots.has_key(rootname):
-      return roots[rootname]
+      rootpath = vclib.svn.find_root_in_parent(pp, rootname)
+
+    if rootpath is not None:
+      return rootpath
   return None
 
 def locate_root(cfg, rootname):
Index: lib/vclib/svn/__init__.py
===================================================================
--- lib/vclib/svn/__init__.py	(.../tags/1.1.18)	(revision 2883)
+++ lib/vclib/svn/__init__.py	(.../branches/1.1.x)	(revision 2883)
@@ -77,6 +77,20 @@
   return roots
 
 
+def find_root_in_parent(parent_path, rootname):
+  """Search PARENT_PATH for a root named ROOTNAME, returning the
+  canonicalized ROOTPATH of the root if found; return None if no such
+  root is found."""
+  
+  if not re.search(_re_url, parent_path):
+    assert os.path.isabs(parent_path)
+    rootpath = os.path.join(parent_path, rootname)
+    format_path = os.path.join(rootpath, "format")
+    if os.path.exists(format_path):
+      return canonicalize_rootpath(rootpath)
+  return None
+
+
 def SubversionRepository(name, rootpath, authorizer, utilities, config_dir):
   rootpath = canonicalize_rootpath(rootpath)
   if re.search(_re_url, rootpath):
Index: lib/vclib/ccvs/__init__.py
===================================================================
--- lib/vclib/ccvs/__init__.py	(.../tags/1.1.18)	(revision 2883)
+++ lib/vclib/ccvs/__init__.py	(.../branches/1.1.x)	(revision 2883)
@@ -35,6 +35,23 @@
   return roots
 
 
+def find_root_in_parent(parent_path, rootname):
+  """Search PARENT_PATH for a root named ROOTNAME, returning the
+  canonicalized ROOTPATH of the root if found; return None if no such
+  root is found."""
+
+  assert os.path.isabs(parent_path)
+  # Is PARENT_PATH itself a CVS repository?  If so, we allow ROOTNAME
+  # to be any subdir within it.  Otherwise, we expect
+  # PARENT_PATH/ROOTNAME to be a CVS repository.
+  rootpath = os.path.join(parent_path, rootname)
+  if os.path.exists(os.path.join(parent_path, "CVSROOT", "config")):
+    return canonicalize_rootpath(rootpath)
+  if os.path.exists(os.path.join(rootpath, "CVSROOT", "config")):
+    return canonicalize_rootpath(rootpath)
+  return None
+
+
 def CVSRepository(name, rootpath, authorizer, utilities, use_rcsparse):
   rootpath = canonicalize_rootpath(rootpath)
   if use_rcsparse:
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJRds/RAAoJEPXg8AH+aBMzKjQP/RtbXvnoPWwi+bbLxupuFkHF
QW3mxyjHs5tztW3qOrW3EYJ3EH6oZhl5M6JDBGbCF9VWlzwFwC9UcRsmzzj+Jxxl
12Q1uWkpFNZ5WeLfSbY+sldp/2CHUeo29zPN2YAJRLYtUMjVRv71lWC+dSsva8Kg
7pFtvXTMLGo87VYY+JR4M6f8imm4MaX6HPfFM7ZSARkCzYg/FqhcJCVZnthMRU7O
1KWdgzrg56rsI8s8t8aRjcQoQAqsJHF4yspdcOn4Ddf6/Mutqu+8JE6q4Z4N/Y3T
cltG6pMK5lRk1sllikBxpihCi/XDyHlVUKjB8kqz1ayCogwr/u3v7dIWiD3BYjtM
tItozEf0gl5gUHKrm3Ue2d6LFyRkkFXKX5bNO2naPBVANCKdjyHXFD8UpAmUPriz
DNjLXO7Qyx61IltzYKFt2Fo01RmaJb5Tt2CTe7pnN1CAZsYtyAhJEcWNR4IeCpUE
OQLLvGwhyopzT3mZGno6cCFpuAJKW1MduperqZqZiEnKzRnEgV2zz3gPSrIJgHkO
/CqynQRJrziS5EFX+tMA6VslHQqulDvoP91vGL/i6vAKoH4s6vNBAn3TXxDYM7oW
thQaf/kMQP6VM35XTHkNCPV4aEv3RasXN+G4+X0s8o7MHqimI9kjRrFzzv2sT/ei
laEaCnbIayaD1KupgLSn
=uAT8
-----END PGP SIGNATURE-----