Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jul 2007 12:17:21 GMT
From:      Vaclav Haisman <v.haisman@sh.cvut.cz>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/114353: Fix to bug in devel/monotone with boost 1.34.0
Message-ID:  <200707061217.l66CHLm6008892@www.freebsd.org>
Resent-Message-ID: <200707061220.l66CK4LP093091@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         114353
>Category:       ports
>Synopsis:       Fix to bug in devel/monotone with boost 1.34.0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 06 12:20:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Vaclav Haisman
>Release:        6.2
>Organization:
SU SH
>Environment:
FreeBSD shell.sh.cvut.cz 6.2-STABLE FreeBSD 6.2-STABLE #0: Fri Jun 22 22:24:46 CEST 2007     root@shell.sh.cvut.cz:/usr/obj/usr/src/sys/SHELL  i386
>Description:
This patch fixes <http://article.gmane.org/gmane.comp.version-control.monotone.devel/11444>.

>How-To-Repeat:

>Fix:
The attached patch.


Patch attached with submission follows:

#
#
# patch "paths.cc"
#  from [0b81dfd4a65442de417c635cd8f003994af44ee1]
#    to [1013ba10017d49914ab3dfb0c894c4aafcbcedc2]
#
============================================================
--- paths.cc	0b81dfd4a65442de417c635cd8f003994af44ee1
+++ paths.cc	1013ba10017d49914ab3dfb0c894c4aafcbcedc2
@@ -10,6 +10,7 @@
 #include <string>
 #include <sstream>
 
+#include <boost/version.hpp>
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/convenience.hpp>
 
@@ -249,6 +250,41 @@ internal_string_to_split_path(string con
   I(fully_normalized_path_split(path, true, sp));
 }
 
+// path::normalize() is deprecated in Boost 1.34, and also
+// doesn't remove leading or trailing dots any more.
+static fs::path
+normalize_path(fs::path const & in)
+{
+#if BOOST_VERSION < 103400
+  return in.normalize();
+#else
+  fs::path out;
+  vector<string> stack;
+  for (fs::path::iterator i = in.begin(); i != in.end(); ++i)
+    {
+      // remove . elements
+      if (*i == ".")
+        continue;
+      // remove foo/.. element pairs
+      if (*i == "..")
+        {
+          if (!stack.empty())
+            {
+              stack.pop_back();
+              continue;
+            }
+        }
+      stack.push_back(*i);
+    }
+  for (vector<string>::const_iterator i = stack.begin();
+       i != stack.end(); ++i)
+    {
+      out /= *i;
+    }
+  return out;
+#endif
+}
+
 static void
 normalize_external_path(string const & path, string & normalized)
 {
@@ -272,7 +308,7 @@ normalize_external_path(string const & p
           base = initial_rel_path.get();
           // the fs::native is needed to get it to accept paths like ".foo".
           relative = fs::path(path, fs::native);
-          out = (base / relative).normalize();
+          out = normalize_path(base / relative);
         }
       catch (exception &)
         {
@@ -539,9 +575,9 @@ normalize_out_dots(string const & path)
 normalize_out_dots(string const & path)
 {
 #ifdef WIN32
-  return fs::path(path, fs::native).normalize().string();
+  return normalize_path(fs::path(path, fs::native)).string();
 #else
-  return fs::path(path, fs::native).normalize().native_file_string();
+  return normalize_path(fs::path(path, fs::native)).native_file_string();
 #endif
 }
 
@@ -679,9 +715,17 @@ find_bookdir(fs::path const & root, fs::
     }
 
   // check for _MTN/. and _MTN/.. to see if mt dir is readable
-  if (!fs::exists(check / ".") || !fs::exists(check / ".."))
+  try
     {
-      L(FL("problems with '%s' (missing '.' or '..')") % check.string());
+      if (!fs::exists(check / ".") || !fs::exists(check / ".."))
+        {
+          L(FL("problems with '%s' (missing '.' or '..')") % check.string());
+          return false;
+        }
+    }
+  catch(exception &)
+    {
+      L(FL("problems with '%s' (cannot check for '.' or '..')") % check.string());
       return false;
     }
   return true;


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707061217.l66CHLm6008892>