Mercurial > hg > easyhg
comparison mainwindow.cpp @ 348:076c2b3de51b bug_92
Reject only non-empty directories as clone targets: we're happy if the directory exists but is empty
author | Chris Cannam |
---|---|
date | Wed, 16 Mar 2011 12:10:56 +0000 |
parents | 987a094047c9 |
children | 383223b1dd34 |
comparison
equal
deleted
inserted
replaced
347:987a094047c9 | 348:076c2b3de51b |
---|---|
1241 return false; | 1241 return false; |
1242 } | 1242 } |
1243 | 1243 |
1244 QString MainWindow::complainAboutCloneToExistingFolder(QString arg, QString remote) | 1244 QString MainWindow::complainAboutCloneToExistingFolder(QString arg, QString remote) |
1245 { | 1245 { |
1246 // If the directory "arg" exists but "arg" plus the last path | 1246 // If the directory "arg" exists but is empty, then we accept it. |
1247 // component of "remote" does not, then offer the latter as an | 1247 |
1248 // alternative path | 1248 // If the directory "arg" exists and is non-empty, but "arg" plus |
1249 // the last path component of "remote" does not exist, then offer | |
1250 // the latter as an alternative path. | |
1249 | 1251 |
1250 QString offer; | 1252 QString offer; |
1251 | 1253 |
1252 QDir d(arg); | 1254 QDir d(arg); |
1255 | |
1253 if (d.exists()) { | 1256 if (d.exists()) { |
1257 | |
1258 if (d.entryList(QDir::Dirs | QDir::Files | | |
1259 QDir::NoDotAndDotDot | | |
1260 QDir::Hidden | QDir::System).empty()) { | |
1261 // directory is empty; accept it | |
1262 return arg; | |
1263 } | |
1264 | |
1254 if (QRegExp("^\\w+://").indexIn(remote) >= 0) { | 1265 if (QRegExp("^\\w+://").indexIn(remote) >= 0) { |
1255 QString rpath = QUrl(remote).path(); | 1266 QString rpath = QUrl(remote).path(); |
1256 if (rpath != "") { | 1267 if (rpath != "") { |
1257 rpath = QDir(rpath).dirName(); | 1268 rpath = QDir(rpath).dirName(); |
1258 if (rpath != "" && !d.exists(rpath)) { | 1269 if (rpath != "" && !d.exists(rpath)) { |