summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2012-07-27 18:12:31 +0200
committerJan Holesovsky <kendy@suse.cz>2012-07-27 20:47:03 +0200
commitf206149e641e9b50df8bbbc02b2179ec4380018e (patch)
tree1be3f021ff2d63e50b3301d390cad313320bb247
parenteb4f3d997be901ab471a2405b2179490c85cb397 (diff)
Add an option to delete everything before starting import.
-rw-r--r--repository.cxx18
-rw-r--r--repository.hxx6
2 files changed, 20 insertions, 4 deletions
diff --git a/repository.cxx b/repository.cxx
index ea602e7..e79b0f9 100644
--- a/repository.cxx
+++ b/repository.cxx
@@ -205,13 +205,14 @@ Tag::Tag( const Committer& committer_, const std::string& name_, Time time_, con
Error::report( "Cannot guess the branch name for '" + name_ + "'" );
}
-Repository::Repository( const std::string& reponame_, const string& regex_, unsigned int max_revs_ )
+Repository::Repository( const std::string& reponame_, const string& regex_, unsigned int max_revs_, bool cleanup_first_ )
: mark( 1 ),
out( ( reponame_ + ".dump" ).c_str() ),
commits( new BranchId[max_revs_ + 10] ),
parents( new string[max_revs_ + 10] ),
max_revs( max_revs_ ),
- name( reponame_ )
+ name( reponame_ ),
+ cleanup_first( cleanup_first_ )
{
int status = regcomp( &regex_rule, regex_.c_str(), REG_EXTENDED | REG_NOSUB );
if ( status != 0 )
@@ -283,6 +284,12 @@ void Repository::commit( const Committer& committer_, const std::string& name_,
}
}
+ if ( cleanup_first )
+ {
+ out << "deleteall" << endl;
+ cleanup_first = false;
+ }
+
out << file_changes
<< endl;
@@ -382,6 +389,7 @@ bool Repositories::load( const char* fname_, unsigned int max_revs_, int& min_re
ifstream input( fname_, ifstream::in );
string line;
bool sets_min_rev = false;
+ bool cleanup_first = false;
bool result = false;
while ( !input.eof() )
@@ -425,6 +433,10 @@ bool Repositories::load( const char* fname_, unsigned int max_revs_, int& min_re
string tmp = line.substr( equals + 1 );
Filter::setExclusions(line.substr( equals + 1 ).c_str() );
}
+ else if ( line.substr( arg, equals - arg ) == "cleanup_first" )
+ {
+ cleanup_first = true;
+ }
else if ( line.substr( arg, equals - arg ) == "convert_commit_messages" )
{
commit_messages.convert = true;
@@ -562,7 +574,7 @@ bool Repositories::load( const char* fname_, unsigned int max_revs_, int& min_re
continue;
}
- Repository* rep = new Repository( line.substr( 0, min( equal, colon ) ), line.substr( equal + 1 ), max_revs_ );
+ Repository* rep = new Repository( line.substr( 0, min( equal, colon ) ), line.substr( equal + 1 ), max_revs_, cleanup_first );
if ( sets_min_rev )
rep->mapCommit( min_rev_, line.substr( colon + 1, equal - colon - 1 ) );
diff --git a/repository.hxx b/repository.hxx
index 99a08b6..b8684ca 100644
--- a/repository.hxx
+++ b/repository.hxx
@@ -88,9 +88,13 @@ class Repository
/// Name of the repository.
std::string name;
+ /// When committing for the first time, should we remove everything else?
+ /// Makes sense for repository that is an incomplete continuation of another one.
+ bool cleanup_first;
+
public:
/// The regex_ is here to decide if the file belongs to this repository.
- Repository( const std::string& reponame_, const std::string& regex_, unsigned int max_revs_ );
+ Repository( const std::string& reponame_, const std::string& regex_, unsigned int max_revs_, bool cleanup_first_ );
~Repository();