]> andersk Git - svn-all-fast-export.git/blobdiff - src/svn.cpp
Don't crash on empty author
[svn-all-fast-export.git] / src / svn.cpp
index 9cb0b989cdd680b4f0c494a9a1d246162d3f97ed..dcbd40c66ab787ff999afde7bb6ddbb5d47b2e5c 100644 (file)
@@ -250,6 +250,20 @@ static int recursiveDumpDir(Repository::Transaction *txn, svn_fs_root_t *fs_root
     }
 }
 
+static bool wasDir(svn_fs_t *fs, int revnum, const char *pathname, apr_pool_t *pool)
+{
+    AprAutoPool subpool(pool);
+    svn_fs_root_t *fs_root;
+    if (svn_fs_revision_root(&fs_root, fs, revnum, subpool) != SVN_NO_ERROR)
+        return false;
+
+    svn_boolean_t is_dir;
+    if (svn_fs_is_dir(&is_dir, fs_root, pathname, subpool) != SVN_NO_ERROR)
+        return false;
+
+    return is_dir;
+}
+
 time_t get_epoch(char *svn_date)
 {
     struct tm tm;
@@ -309,6 +323,13 @@ int SvnPrivate::exportRevision(int revnum)
                 continue;
             if (rule.rx.exactMatch(current)) {
                 foundMatch = true;
+                if (rule.repository.isEmpty()) {
+                    // ignore rule
+                    qDebug() << "..." << qPrintable(current) << "rev" << revnum
+                             << "-> ignored";
+                    break;
+                }
+
                 QString repository = current;
                 QString branch = current;
                 QString path = current;
@@ -325,7 +346,7 @@ int SvnPrivate::exportRevision(int revnum)
                 if (!txn) {
                     Repository *repo = repositories.value(repository, 0);
                     if (!repo) {
-                        qCritical() << "Rule" << rule.rx.pattern()
+                        qCritical() << "Rule" << rule.rx.pattern() << "line" << rule.lineNumber
                                     << "references unknown repository" << repository;
                         return EXIT_FAILURE;
                     }
@@ -354,8 +375,14 @@ int SvnPrivate::exportRevision(int revnum)
         }
 
         if (!foundMatch) {
-            qCritical() << current << "did not match any rules; cannot continue";
-            return EXIT_FAILURE;
+            if (is_dir) {
+                qDebug() << current << "is a directory; ignoring";
+            } else if (wasDir(fs, revnum - 1, key, pool)) {
+                qDebug() << current << "was a directory; ignoring";
+            } else {
+                qCritical() << current << "did not match any rules; cannot continue";
+                return EXIT_FAILURE;
+            }
         }
     }
     revpool.clear();
@@ -371,7 +398,7 @@ int SvnPrivate::exportRevision(int revnum)
     svn_string_t *svnlog = (svn_string_t*)apr_hash_get(revprops, "svn:log", APR_HASH_KEY_STRING);
 
     QByteArray log = (char *)svnlog->data;
-    QByteArray authorident = identities.value((char *)svnauthor->data);
+    QByteArray authorident = svnauthor ? identities.value((char *)svnauthor->data) : QByteArray();
     time_t epoch = get_epoch((char*)svndate->data);
     if (authorident.isEmpty()) {
         if (!svnauthor || svn_string_isempty(svnauthor))
This page took 0.0546180000000001 seconds and 4 git commands to generate.