Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stripped out the submodularization support

  • Loading branch information...
commit ecd102f6a667aa0dc4cca96efcd55c91ead2977c 1 parent 79339e3
@jwiegley authored
View
4 Makefile.am
@@ -30,8 +30,7 @@ git_monitor_CXXFLAGS += -Weverything -Wno-padded -Wno-weak-vtables \
-fno-limit-debug-info
subconvert_SOURCES = src/authors.cpp src/branches.cpp src/converter.cpp \
- src/gitutil.cpp src/main.cpp src/submodule.cpp \
- src/svndump.cpp
+ src/gitutil.cpp src/main.cpp src/svndump.cpp
git_monitor_SOURCES = src/gitutil.cpp src/git-monitor.cpp
@@ -40,7 +39,6 @@ pkginclude_HEADERS = src/svndump.h \
src/authors.h \
src/branches.h \
src/converter.h \
- src/submodule.h \
src/status.h
nodist_subconvert_SOURCES = system.hpp
View
141 src/converter.cpp
@@ -154,11 +154,6 @@ void ConvertRepository::establish_commit_info()
<< '\n';
buf << "SVN-Revision: " << rev;
-#if 0
- // jww (2012-04-18): We also need a "super repository" that contains a
- // .gitmodules file which is updated every time a submodule is updated.
- buf << "\nHistory-Commit: " << rev;
-#endif
commit_log = buf.str();
}
@@ -169,63 +164,33 @@ void ConvertRepository::set_commit_info(Git::CommitPtr commit)
commit->set_message(commit_log);
}
-std::pair<filesystem::path, Submodule *>
-ConvertRepository::find_submodule(const filesystem::path& pathname)
-{
- submodules_map_t::iterator i = submodules_map.find(pathname);
- if (i != submodules_map.end())
- return (*i).second;
-
- for (filesystem::path dirname(pathname);
- ! dirname.empty();
- dirname = dirname.parent_path()) {
- submodules_map_t::iterator j = submodules_map.find(dirname);
- if (j != submodules_map.end()) {
- std::string suffix(pathname.string(), dirname.string().length() + 1);
- return std::make_pair((*j).second.first / filesystem::path(suffix),
- (*j).second.second);
- }
- }
-
- return std::make_pair(filesystem::path(), nullptr);
-}
-
Git::BranchPtr
ConvertRepository::find_branch(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch)
+ const filesystem::path& pathname)
{
- return (related_branch ?
- repo->find_branch_by_name(related_branch->name) :
- repo->find_branch_by_path(pathname));
+ return repo->find_branch_by_path(pathname);
}
void ConvertRepository::update_object(Git::Repository * repo,
const filesystem::path& pathname,
Git::ObjectPtr obj,
Git::BranchPtr from_branch,
- Git::BranchPtr related_branch,
std::string debug_text)
{
// First, add the change to the flat-history branch (which will become
// a tag when the process is completed).
-
- if (! related_branch) {
- // from_branch is never needed here, since 'obj' has already been
- // copied from the source location.
- Git::CommitPtr history_commit(history_branch->get_commit());
- if (obj)
- history_commit->update(pathname, obj);
- else
- history_commit->remove(pathname);
- }
+ Git::CommitPtr history_commit(history_branch->get_commit());
+ if (obj)
+ history_commit->update(pathname, obj);
+ else
+ history_commit->remove(pathname);
//assert(history_commit->is_modified());
// Second, add the change to the related branch, according to
// branches.txt
- Git::BranchPtr branch(find_branch(repo, pathname, related_branch));
+ Git::BranchPtr branch(find_branch(repo, pathname));
Git::CommitPtr branch_commit(branch->get_commit(from_branch));
status.info(debug_text + " <" + branch->name + ">" +
@@ -233,37 +198,14 @@ void ConvertRepository::update_object(Git::Repository * repo,
std::string(" {") + repo->repo_name + "}"));
std::string::size_type path_len(pathname.string().length());
- std::string::size_type subpath_len(related_branch ? 0 :
- branch->prefix.string().length());
- filesystem::path subpath(related_branch ? pathname :
- (path_len == subpath_len ?
- pathname : std::string(pathname.string(),
- subpath_len + 1)));
+ std::string::size_type subpath_len(branch->prefix.string().length());
+ filesystem::path subpath(path_len == subpath_len ?
+ pathname : std::string(pathname.string(),
+ subpath_len + 1));
if (obj)
branch_commit->update(subpath, obj);
else
branch_commit->remove(subpath);
-
- if (! submodules_map.empty() && ! related_branch) {
- // Add the change to any related submodule, according to
- // manifest.txt. We actually add this to a branch in the current
- // repository for efficiency's sake, allowing it to be sifted out
- // using git-filter-branch afterward.
- Submodule * submodule;
- filesystem::path submodule_path;
-
-#if defined(_LIBCPP_VERSION)
- std::tie(submodule_path, submodule) = find_submodule(subpath);
-#else
- std::tr1::tie(submodule_path, submodule) = find_submodule(subpath);
-#endif
-
- if (submodule) {
- std::cerr << " ==> matched to submodule " << submodule->pathname
- << " -> " << submodule_path << std::endl;
- process_change(submodule->repository, submodule_path, branch);
- }
- }
}
std::string
@@ -290,8 +232,7 @@ ConvertRepository::describe_change(SvnDump::File::Node::Kind kind,
}
bool ConvertRepository::add_file(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch)
+ const filesystem::path& pathname)
{
std::string debug_text;
if (opts.verbose || opts.debug)
@@ -316,12 +257,10 @@ bool ConvertRepository::add_file(Git::Repository * repo,
assert(obj);
assert(obj->is_blob());
- obj = obj->copy_to_name(pathname.filename().string(),
- related_branch != nullptr);
+ obj = obj->copy_to_name(pathname.filename().string());
update_object(repo, pathname, obj,
- find_branch(repo, from_path, related_branch),
- related_branch, debug_text);
+ find_branch(repo, from_path), debug_text);
return true;
}
else if (! (node->get_action() == SvnDump::File::Node::ACTION_CHANGE &&
@@ -330,15 +269,14 @@ bool ConvertRepository::add_file(Git::Repository * repo,
node->has_text() ? node->get_text() : "",
node->has_text() ? node->get_text_length() : 0);
- update_object(repo, pathname, obj, nullptr, related_branch, debug_text);
+ update_object(repo, pathname, obj, nullptr, debug_text);
return true;
}
return false;
}
bool ConvertRepository::add_directory(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch)
+ const filesystem::path& pathname)
{
assert(node->has_copy_from());
@@ -357,20 +295,17 @@ bool ConvertRepository::add_directory(Git::Repository * repo,
if (Git::ObjectPtr obj = get_past_tree()->lookup(from_path)) {
assert(obj->is_tree());
update_object(repo, pathname,
- obj->copy_to_name(pathname.filename().string(),
- related_branch != nullptr),
- find_branch(repo, from_path, related_branch),
- related_branch, debug_text);
+ obj->copy_to_name(pathname.filename().string()),
+ find_branch(repo, from_path), debug_text);
return true;
}
return false;
}
bool ConvertRepository::delete_item(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch)
+ const filesystem::path& pathname)
{
- update_object(repo, pathname, nullptr, nullptr, related_branch,
+ update_object(repo, pathname, nullptr, nullptr,
std::string("?D: ") + pathname.string());
return true;
}
@@ -441,8 +376,7 @@ int ConvertRepository::prescan(SvnDump::File::Node& _node)
}
void ConvertRepository::process_change(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch)
+ const filesystem::path& pathname)
{
SvnDump::File::Node::Kind kind = node->get_kind();
SvnDump::File::Node::Action action = node->get_action();
@@ -451,15 +385,15 @@ void ConvertRepository::process_change(Git::Repository * repo,
if (kind == SvnDump::File::Node::KIND_FILE &&
(action == SvnDump::File::Node::ACTION_ADD ||
action == SvnDump::File::Node::ACTION_CHANGE)) {
- changed = add_file(repo, pathname, related_branch);
+ changed = add_file(repo, pathname);
}
else if (action == SvnDump::File::Node::ACTION_DELETE) {
- changed = delete_item(repo, pathname, related_branch);
+ changed = delete_item(repo, pathname);
}
else if (node->has_copy_from() &&
kind == SvnDump::File::Node::KIND_DIR &&
action == SvnDump::File::Node::ACTION_ADD) {
- changed = add_directory(repo, pathname, related_branch);
+ changed = add_directory(repo, pathname);
}
if (! changed)
@@ -497,16 +431,6 @@ void ConvertRepository::operator()(SvnDump::File::Node& _node)
}
}
- for (submodule_list_t::iterator i = submodules_list.begin();
- i != submodules_list.end();
- ++i)
- if ((*i)->repository->write(last_rev)) {
- if (opts.collect && rev % opts.collect == 0) {
- (*i)->repository->write_branches();
- (*i)->repository->garbage_collect();
- }
- }
-
free_past_trees();
status.update(rev);
@@ -524,22 +448,9 @@ void ConvertRepository::finish()
repository->write(last_rev);
repository->write_branches();
- for (submodule_list_t::iterator i = submodules_list.begin();
- i != submodules_list.end();
- ++i) {
- (*i)->repository->write(last_rev);
- (*i)->repository->write_branches();
- }
-
- if (opts.collect) {
+ if (opts.collect)
repository->garbage_collect();
- for (submodule_list_t::iterator i = submodules_list.begin();
- i != submodules_list.end();
- ++i)
- (*i)->repository->garbage_collect();
- }
-
if (history_branch->commit) {
repository->create_tag(history_branch->commit, history_branch->name);
status.info(std::string("Wrote tag ") + history_branch->name);
View
31 src/converter.h
@@ -37,7 +37,6 @@
#include "gitutil.h"
#include "status.h"
#include "authors.h"
-#include "submodule.h"
struct ConvertRepository
{
@@ -47,11 +46,6 @@ struct ConvertRepository
typedef std::pair<int, int> copy_from_value;
typedef std::list<copy_from_value> copy_from_list;
- typedef std::vector<Submodule *> submodules_list_t;
- typedef std::map<filesystem::path,
- std::pair<filesystem::path,
- Submodule *> > submodules_map_t;
-
SvnDump::File::Node * node;
StatusDisplay& status;
Options opts;
@@ -62,8 +56,6 @@ struct ConvertRepository
copy_from_list copy_from;
Git::Repository * repository; // let it leak!
Git::BranchPtr history_branch;
- submodules_list_t submodules_list;
- submodules_map_t submodules_map;
std::string commit_log;
shared_ptr<git_signature> signature;
@@ -80,10 +72,6 @@ struct ConvertRepository
#ifdef ASSERTS
checked_delete(repository);
#endif
- for (submodules_list_t::iterator i = submodules_list.begin();
- i != submodules_list.end();
- ++i)
- checked_delete(*i);
}
void free_past_trees();
@@ -92,38 +80,29 @@ struct ConvertRepository
void establish_commit_info();
void set_commit_info(Git::CommitPtr commit);
- std::pair<filesystem::path, Submodule *>
- find_submodule(const filesystem::path& pathname);
-
Git::BranchPtr find_branch(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch = nullptr);
+ const filesystem::path& pathname);
void update_object(Git::Repository * repo,
const filesystem::path& pathname,
Git::ObjectPtr obj = nullptr,
Git::BranchPtr from_branch = nullptr,
- Git::BranchPtr related_branch = nullptr,
std::string debug_text = "");
void process_change(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch = nullptr);
+ const filesystem::path& pathname);
std::string describe_change(SvnDump::File::Node::Kind kind,
SvnDump::File::Node::Action action);
bool add_file(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch = nullptr);
+ const filesystem::path& pathname);
bool add_directory(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch = nullptr);
+ const filesystem::path& pathname);
bool delete_item(Git::Repository * repo,
- const filesystem::path& pathname,
- Git::BranchPtr related_branch = nullptr);
+ const filesystem::path& pathname);
int prescan(SvnDump::File::Node& node);
void operator()(SvnDump::File::Node& node);
View
4 src/main.cpp
@@ -275,10 +275,6 @@ int main(int argc, char *argv[])
filesystem::is_regular_file(branches_file))
errors += Branches::load_branches(branches_file, converter, status);
- if (! modules_file.empty() &&
- filesystem::is_regular_file(modules_file))
- errors += Submodule::load_modules(modules_file, converter);
-
// Validate this information as much as possible before possibly
// wasting the user's time with useless work.
View
131 src/submodule.cpp
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2011, BoostPro Computing. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * - Neither the name of BoostPro Computing nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "submodule.h"
-#include "converter.h"
-
-Submodule::Submodule(std::string _pathname, ConvertRepository& _parent)
- : pathname(_pathname), parent(_parent)
-{
- filesystem::create_directories(pathname);
-
- // Initialize a Git repository for this submodule in the subdirectory
- std::system((std::string("git --git-dir=\"") +
- pathname + "/.git\" init").c_str());
-
- repository =
- new Git::Repository(filesystem::system_complete(pathname),
- parent.status, function<void(Git::CommitPtr)>
- (bind(&ConvertRepository::set_commit_info, &parent, _1)));
- repository->repo_name = pathname;
-
- // Copy all of the main repository's branches into the submodule,
- // which acts like a mirror for a targeted subset of that main
- // repository, we just won't know for which branches until the end.
- for (Git::Repository::branches_name_map::iterator
- i = parent.repository->branches_by_name.begin();
- i != parent.repository->branches_by_name.end();
- ++i) {
- Git::BranchPtr branch(new Git::Branch(repository));
-
- branch->name = (*i).second->name;
- branch->prefix = (*i).second->prefix;
-
- repository->find_branch_by_name(branch->name, branch);
- }
-}
-
-int Submodule::load_modules(const filesystem::path& modules_file,
- ConvertRepository& parent)
-{
- int errors = 0;
-
- parent.submodules_map.clear();
- parent.submodules_list.clear();
-
- static const int MAX_LINE = 8192;
- char linebuf[MAX_LINE + 1];
-
- filesystem::ifstream in(modules_file);
-
- Submodule * curr_module = nullptr;
-
- while (in.good() && ! in.eof()) {
- in.getline(linebuf, MAX_LINE);
-
- if (linebuf[0] == '#') {
- continue;
- }
- else if (linebuf[0] == '[') {
- std::string module_name(linebuf, 1, std::strlen(linebuf) - 2);
- if (module_name != "<ignore>") {
- curr_module = new Submodule(module_name, parent);
- parent.submodules_list.push_back(curr_module);
- }
- }
- else if (const char * p = std::strchr(linebuf, ':')) {
- if (curr_module) {
- std::string source_path =
- std::string(linebuf, 0,
- static_cast<std::string::size_type>(p - linebuf));
-
- ++p;
- while (std::isspace(*p))
- ++p;
-
- std::string target_path = std::string(p);
- if (target_path == ".")
- target_path = "";
-
- if (source_path != "<ignore>") {
- if (source_path[source_path.length() - 1] == '/')
- source_path = std::string(source_path, 0, source_path.length() - 1);
-
- if (target_path[target_path.length() - 1] == '/')
- target_path = std::string(target_path, 0, target_path.length() - 1);
-
- std::pair<ConvertRepository::submodules_map_t::iterator,
- bool> result = parent.submodules_map.insert
- (ConvertRepository::submodules_map_t::value_type
- (source_path, std::make_pair(target_path, curr_module)));
-
- if (! result.second)
- std::cerr << "Failed to load from "
- << modules_file.string() << ": "
- << std::string("[") << curr_module->pathname << "]: "
- << source_path << " -> " << target_path;
- }
- }
- }
- }
- return errors;
-}
View
55 src/submodule.h
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2011, BoostPro Computing. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * - Neither the name of BoostPro Computing nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SUBMODULE_H
-#define _SUBMODULE_H
-
-#include "gitutil.h"
-
-struct ConvertRepository;
-
-struct Submodule;
-typedef std::vector<Submodule *> submodule_list_t;
-
-struct Submodule : public noncopyable
-{
- std::string pathname;
- ConvertRepository& parent;
- Git::Repository * repository;
-
- Submodule(std::string _pathname, ConvertRepository& _parent);
-
- static int load_modules(const filesystem::path& modules_file,
- ConvertRepository& parent);
-};
-
-#endif // _SUBMODULE_H

2 comments on commit ecd102f

@dabrahams
Collaborator

I guess I want to revert this commit now?

@jwiegley
Owner

Yes.

Please sign in to comment.
Something went wrong with that request. Please try again.