|
Boost-Commit : |
From: john_at_[hidden]
Date: 2007-10-22 07:16:15
Author: johnmaddock
Date: 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
New Revision: 40281
URL: http://svn.boost.org/trac/boost/changeset/40281
Log:
Added Bjorn Roald's patches to enable scans of svn.
Updated docs accordingly.
Text files modified:
trunk/tools/bcp/add_path.cpp | 4 +
trunk/tools/bcp/bcp.hpp | 1
trunk/tools/bcp/bcp.html | 20 +++---
trunk/tools/bcp/bcp_imp.cpp | 12 ++++
trunk/tools/bcp/bcp_imp.hpp | 3 +
trunk/tools/bcp/file_types.cpp | 2
trunk/tools/bcp/main.cpp | 4 +
trunk/tools/bcp/scan_cvs_path.cpp | 107 +++++++++++++++++++++++++++++++++++++++
8 files changed, 139 insertions(+), 14 deletions(-)
Modified: trunk/tools/bcp/add_path.cpp
==============================================================================
--- trunk/tools/bcp/add_path.cpp (original)
+++ trunk/tools/bcp/add_path.cpp 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -49,6 +49,8 @@
//
if(m_cvs_mode && !fs::exists(m_boost_path / p / "CVS/Entries"))
return;
+ if(m_svn_mode && !fs::exists(m_boost_path / p / ".svn/entries"))
+ return;
//
// enermerate files and directories:
//
@@ -75,7 +77,7 @@
//
// if the file does not exist in cvs then don't do anything with it:
//
- if(m_cvs_mode && (m_cvs_paths.find(p) == m_cvs_paths.end()))
+ if((m_cvs_mode || m_svn_mode) && (m_cvs_paths.find(p) == m_cvs_paths.end()))
return;
//
// if we've already seen the file return:
Modified: trunk/tools/bcp/bcp.hpp
==============================================================================
--- trunk/tools/bcp/bcp.hpp (original)
+++ trunk/tools/bcp/bcp.hpp 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -20,6 +20,7 @@
virtual void enable_list_mode() = 0;
virtual void enable_summary_list_mode() = 0;
virtual void enable_cvs_mode() = 0;
+ virtual void enable_svn_mode() = 0;
virtual void enable_unix_lines() = 0;
virtual void enable_scan_mode() = 0;
virtual void enable_license_mode() = 0;
Modified: trunk/tools/bcp/bcp.html
==============================================================================
--- trunk/tools/bcp/bcp.html (original)
+++ trunk/tools/bcp/bcp.html 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -3,7 +3,7 @@
<head>
<title>bcp</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" type="text/css" href="../../boost.css">
+ <link rel="stylesheet" type="text/css" href="../../doc/html/boostbook.css">
</head>
<body>
<P>
@@ -16,7 +16,7 @@
<H1 align="center">The bcp utility</H1>
</TD>
<td width="50">
- <h3><a href="../../index.htm"><img height="45" width="43" alt="Boost.Regex Index" src="../../libs/regex/doc/uarrow.gif"
+ <h3><a href="../../index.htm"><img alt="Boost.Regex Index" src="../../doc/html/images/up.png"
border="0"></a></h3>
</td>
</TR>
@@ -81,8 +81,8 @@
<P>Treats the module list as a list of (probably non-boost) files to scan for
boost dependencies, the files listed in the module list are not copied (or
listed), only the boost files upon which they depend.</P>
- <PRE>--cvs</PRE>
- <P>Only copy files under cvs version control.</P>
+ <PRE>--svn</PRE>
+ <P>Only copy files under svn version control.</P>
<PRE>--unix-lines</PRE>
<P>Make sure that all copied files use Unix style line endings.</P>
<H4>module-list: </H4>
@@ -179,15 +179,15 @@
<HR>
<P></P>
<P></P>
- <p>Revised
- <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
- 28 June 2004
- <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
- </p>
- <P><I>© Copyright <a href="mailto:jm_at_[hidden]">John Maddock</a> 2003-4</I></P>
+ <p>Last revised $Date$</p>
+ <P><I>© Copyright John Maddock 2003-7</I></P>
<P align="left"><I>Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
</I></P>
</body>
</html>
+
+
+
+
Modified: trunk/tools/bcp/bcp_imp.cpp
==============================================================================
--- trunk/tools/bcp/bcp_imp.cpp (original)
+++ trunk/tools/bcp/bcp_imp.cpp 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -18,7 +18,7 @@
#include <string>
bcp_implementation::bcp_implementation()
- : m_list_mode(false), m_list_summary_mode(false), m_license_mode(false), m_cvs_mode(false), m_unix_lines(false), m_scan_mode(false), m_bsl_convert_mode(false), m_bsl_summary_mode(false)
+ : m_list_mode(false), m_list_summary_mode(false), m_license_mode(false), m_cvs_mode(false), m_svn_mode(false), m_unix_lines(false), m_scan_mode(false), m_bsl_convert_mode(false), m_bsl_summary_mode(false)
{
}
@@ -46,6 +46,11 @@
m_cvs_mode = true;
}
+void bcp_implementation::enable_svn_mode()
+{
+ m_svn_mode = true;
+}
+
void bcp_implementation::enable_scan_mode()
{
m_scan_mode = true;
@@ -124,8 +129,13 @@
// if m_cvs_mode is true:
if(m_cvs_mode)
{
+ std::cerr << "CAUTION: Boost is no longer in CVS, cvs mode may not work anymore!!!" << std::endl;
scan_cvs_path(fs::path());
}
+ if(m_svn_mode)
+ {
+ scan_svn_path(fs::path());
+ }
//
// if in license mode, try to load more/blanket_permission.txt
//
Modified: trunk/tools/bcp/bcp_imp.hpp
==============================================================================
--- trunk/tools/bcp/bcp_imp.hpp (original)
+++ trunk/tools/bcp/bcp_imp.hpp 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -51,6 +51,7 @@
void enable_list_mode();
void enable_summary_list_mode();
void enable_cvs_mode();
+ void enable_svn_mode();
void enable_unix_lines();
void enable_scan_mode();
void enable_license_mode();
@@ -64,6 +65,7 @@
private:
// internal helper functions:
void scan_cvs_path(const fs::path& p);
+ void scan_svn_path(const fs::path& p);
void add_path(const fs::path& p);
void add_directory(const fs::path& p);
void add_file(const fs::path& p);
@@ -83,6 +85,7 @@
bool m_list_summary_mode; // list file summary only
bool m_license_mode; // generate license information for files listed
bool m_cvs_mode; // check cvs for files
+ bool m_svn_mode; // check svn for files
bool m_unix_lines; // fix line endings
bool m_scan_mode; // scan non-boost files.
bool m_bsl_convert_mode; // try to convert to the BSL
Modified: trunk/tools/bcp/file_types.cpp
==============================================================================
--- trunk/tools/bcp/file_types.cpp (original)
+++ trunk/tools/bcp/file_types.cpp 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -39,7 +39,7 @@
bool bcp_implementation::is_binary_file(const fs::path& p)
{
- if(m_cvs_mode)
+ if(m_cvs_mode || m_svn_mode)
{
std::map<fs::path, bool, path_less>::iterator pos = m_cvs_paths.find(p);
if(pos != m_cvs_paths.end()) return pos->second;
Modified: trunk/tools/bcp/main.cpp
==============================================================================
--- trunk/tools/bcp/main.cpp (original)
+++ trunk/tools/bcp/main.cpp 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -107,6 +107,10 @@
{
papp->enable_cvs_mode();
}
+ else if(0 == std::strcmp("--svn", argv[i]))
+ {
+ papp->enable_svn_mode();
+ }
else if(0 == std::strcmp("--scan", argv[i]))
{
papp->enable_scan_mode();
Modified: trunk/tools/bcp/scan_cvs_path.cpp
==============================================================================
--- trunk/tools/bcp/scan_cvs_path.cpp (original)
+++ trunk/tools/bcp/scan_cvs_path.cpp 2007-10-22 07:16:15 EDT (Mon, 22 Oct 2007)
@@ -1,6 +1,7 @@
/*
*
- * Copyright (c) 2003 Dr John Maddock
+ * Copyright (c) 2003-7 John Maddock
+ * Copyright (c) 2007 Bjorn Roald
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -16,6 +17,7 @@
#include <boost/regex.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/detail/workaround.hpp>
+#include <iostream>
void bcp_implementation::scan_cvs_path(const fs::path& p)
{
@@ -61,3 +63,106 @@
}
}
}
+
+void bcp_implementation::scan_svn_path(const fs::path& p)
+{
+ //
+ // scan through the svn entries files to build a list
+ // of all the files under svn version control
+ // and whether they are text or binary:
+ //
+ static const boost::regex entry_expression("^\\f([^\\f]*)");
+ static const boost::regex entry_line_expression("\\n[[:blank:]]*([^\\n]*)");
+ // static const boost::regex
+ // mime_type_expression("\\nsvn:mime-type\\nV [[digit]]*\\n([^/]*)[^\\n]*");
+
+ fs::path entries(m_boost_path / p / ".svn" / "entries");
+ if(fs::exists(entries))
+ {
+ fileview view(entries);
+ boost::cregex_token_iterator
+ i(view.begin(), view.end(), entry_expression, 1), j;
+
+ while(i != j) // entries
+ {
+ std::string entr = i->str();
+ boost::sregex_token_iterator
+ atr_it(entr.begin(), entr.end(), entry_line_expression, 1), atr_j;
+
+ if(atr_it != atr_j)
+ {
+ std::string name = atr_it->str(); // name of file or directory
+ fs::path fpath = p / name;
+ if(++atr_it != atr_j)
+ {
+ std::string kind = atr_it->str();
+ if(kind == "file")
+ {
+ // find if binary, we asume text unless mime type is
+ // set in property file
+ bool binary = false; //
+
+ // skip some lines type | example
+ if( ++atr_it != atr_j && // revnum |
+ ++atr_it != atr_j && // url |
+ ++atr_it != atr_j && // repos |
+ ++atr_it != atr_j && // scedule attr |
+ ++atr_it != atr_j && // text timestamp | 2007-09-02T...
+ ++atr_it != atr_j && // checksum | 58f4bfa7860...
+ ++atr_it != atr_j && // cmt_date | 2007-05-09T...
+ ++atr_it != atr_j && // cmt_rev | 37654
+ ++atr_it != atr_j && // cmt_author | dgregor
+ ++atr_it != atr_j ) // has_props | has-props
+ {
+ if(atr_it->str() == "has-props")
+ {
+ // we need to check properties file for mime-type
+ // that does not start with "text/", if found file is binary
+ fs::path properties(m_boost_path / p / ".svn" / "prop-base"
+ / (name + ".svn-base") );
+ if(fs::exists(properties))
+ {
+ fileview prop(properties);
+ boost::regex_token_iterator<const char*>
+ mime_it(prop.begin(), prop.end(), entry_line_expression, 1);
+
+ bool have_mime = false;
+
+ while(mime_it != j)
+ {
+ std::string prop = mime_it->str();
+ if(prop == "svn:mime-type")
+ {
+ have_mime = true;
+ if(++mime_it != j && ++mime_it != j &&
+ mime_it->str().find("text/") != 0)
+ {
+ binary = true;
+ }
+ }
+ ++mime_it;
+ }
+ /*
+ if(!have_mime)
+ {
+ std::cerr << "CAUTION: file " << fpath << " does not have a mime type set." << std::endl;
+ }
+ */
+ }
+ }
+ }
+ m_cvs_paths[fpath] = binary;
+ } // kind == "file"
+ else if(kind == "dir")
+ {
+ scan_svn_path(fpath); // recursion for directory entries
+ }
+ // else
+ // std::cerr << "WARNING: unknown entry kind for entry " << name
+ // << "in " << entries << std::endl;
+ }
+ }
+ ++i;
+ } // while
+ }
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk