Fossil SCM

Added better error message when trying to remove a directory.

jeremy_c 2010-02-08 14:20 UTC dead-end
Commit 1761fee0556d5e1b554e29a67462d18dceb5db83
1 file changed +10 -5
+10 -5
--- src/add.c
+++ src/add.c
@@ -7,11 +7,11 @@
77
**
88
** This program is distributed in the hope that it will be useful,
99
** but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1111
** General Public License for more details.
12
-**
12
+**
1313
** You should have received a copy of the GNU General Public
1414
** License along with this library; if not, write to the
1515
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1616
** Boston, MA 02111-1307, USA.
1717
**
@@ -32,18 +32,18 @@
3232
/*
3333
** Set to true if files whose names begin with "." should be
3434
** included when processing a recursive "add" command.
3535
*/
3636
static int includeDotFiles = 0;
37
-
37
+
3838
/*
3939
** Add a single file
4040
*/
4141
static void add_one_file(const char *zName, int vid, Blob *pOmit){
4242
Blob pathname;
4343
const char *zPath;
44
-
44
+
4545
file_tree_name(zName, &pathname, 1);
4646
zPath = blob_str(&pathname);
4747
if( strcmp(zPath, "manifest")==0
4848
|| strcmp(zPath, "_FOSSIL_")==0
4949
|| strcmp(zPath, "manifest.uuid")==0
@@ -126,11 +126,11 @@
126126
/*
127127
** COMMAND: add
128128
**
129129
** Usage: %fossil add FILE...
130130
**
131
-** Make arrangements to add one or more files to the current checkout
131
+** Make arrangements to add one or more files to the current checkout
132132
** at the next commit.
133133
**
134134
** When adding files recursively, filenames that begin with "." are
135135
** excluded by default. To include such files, add the "--dotfiles"
136136
** option to the command-line.
@@ -201,13 +201,18 @@
201201
}
202202
db_begin_transaction();
203203
for(i=2; i<g.argc; i++){
204204
char *zName;
205205
char *zPath;
206
+ int isDir;
206207
Blob pathname;
207208
208209
zName = mprintf("%/", g.argv[i]);
210
+ isDir = file_isdir(zName);
211
+ if( isDir==1 ){
212
+ fossil_fatal("cannot remove directories. Please remove individual files instead.");
213
+ }
209214
file_tree_name(zName, &pathname, 1);
210215
zPath = blob_str(&pathname);
211216
if( !db_exists(
212217
"SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
213218
fossil_fatal("not in the repository: %s", zName);
@@ -221,11 +226,11 @@
221226
db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0");
222227
db_end_transaction(0);
223228
}
224229
225230
/*
226
-** Rename a single file.
231
+** Rename a single file.
227232
**
228233
** The original name of the file is zOrig. The new filename is zNew.
229234
*/
230235
static void mv_one_file(int vid, const char *zOrig, const char *zNew){
231236
printf("RENAME %s %s\n", zOrig, zNew);
232237
--- src/add.c
+++ src/add.c
@@ -7,11 +7,11 @@
7 **
8 ** This program is distributed in the hope that it will be useful,
9 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ** General Public License for more details.
12 **
13 ** You should have received a copy of the GNU General Public
14 ** License along with this library; if not, write to the
15 ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 ** Boston, MA 02111-1307, USA.
17 **
@@ -32,18 +32,18 @@
32 /*
33 ** Set to true if files whose names begin with "." should be
34 ** included when processing a recursive "add" command.
35 */
36 static int includeDotFiles = 0;
37
38 /*
39 ** Add a single file
40 */
41 static void add_one_file(const char *zName, int vid, Blob *pOmit){
42 Blob pathname;
43 const char *zPath;
44
45 file_tree_name(zName, &pathname, 1);
46 zPath = blob_str(&pathname);
47 if( strcmp(zPath, "manifest")==0
48 || strcmp(zPath, "_FOSSIL_")==0
49 || strcmp(zPath, "manifest.uuid")==0
@@ -126,11 +126,11 @@
126 /*
127 ** COMMAND: add
128 **
129 ** Usage: %fossil add FILE...
130 **
131 ** Make arrangements to add one or more files to the current checkout
132 ** at the next commit.
133 **
134 ** When adding files recursively, filenames that begin with "." are
135 ** excluded by default. To include such files, add the "--dotfiles"
136 ** option to the command-line.
@@ -201,13 +201,18 @@
201 }
202 db_begin_transaction();
203 for(i=2; i<g.argc; i++){
204 char *zName;
205 char *zPath;
 
206 Blob pathname;
207
208 zName = mprintf("%/", g.argv[i]);
 
 
 
 
209 file_tree_name(zName, &pathname, 1);
210 zPath = blob_str(&pathname);
211 if( !db_exists(
212 "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
213 fossil_fatal("not in the repository: %s", zName);
@@ -221,11 +226,11 @@
221 db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0");
222 db_end_transaction(0);
223 }
224
225 /*
226 ** Rename a single file.
227 **
228 ** The original name of the file is zOrig. The new filename is zNew.
229 */
230 static void mv_one_file(int vid, const char *zOrig, const char *zNew){
231 printf("RENAME %s %s\n", zOrig, zNew);
232
--- src/add.c
+++ src/add.c
@@ -7,11 +7,11 @@
7 **
8 ** This program is distributed in the hope that it will be useful,
9 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ** General Public License for more details.
12 **
13 ** You should have received a copy of the GNU General Public
14 ** License along with this library; if not, write to the
15 ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 ** Boston, MA 02111-1307, USA.
17 **
@@ -32,18 +32,18 @@
32 /*
33 ** Set to true if files whose names begin with "." should be
34 ** included when processing a recursive "add" command.
35 */
36 static int includeDotFiles = 0;
37
38 /*
39 ** Add a single file
40 */
41 static void add_one_file(const char *zName, int vid, Blob *pOmit){
42 Blob pathname;
43 const char *zPath;
44
45 file_tree_name(zName, &pathname, 1);
46 zPath = blob_str(&pathname);
47 if( strcmp(zPath, "manifest")==0
48 || strcmp(zPath, "_FOSSIL_")==0
49 || strcmp(zPath, "manifest.uuid")==0
@@ -126,11 +126,11 @@
126 /*
127 ** COMMAND: add
128 **
129 ** Usage: %fossil add FILE...
130 **
131 ** Make arrangements to add one or more files to the current checkout
132 ** at the next commit.
133 **
134 ** When adding files recursively, filenames that begin with "." are
135 ** excluded by default. To include such files, add the "--dotfiles"
136 ** option to the command-line.
@@ -201,13 +201,18 @@
201 }
202 db_begin_transaction();
203 for(i=2; i<g.argc; i++){
204 char *zName;
205 char *zPath;
206 int isDir;
207 Blob pathname;
208
209 zName = mprintf("%/", g.argv[i]);
210 isDir = file_isdir(zName);
211 if( isDir==1 ){
212 fossil_fatal("cannot remove directories. Please remove individual files instead.");
213 }
214 file_tree_name(zName, &pathname, 1);
215 zPath = blob_str(&pathname);
216 if( !db_exists(
217 "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
218 fossil_fatal("not in the repository: %s", zName);
@@ -221,11 +226,11 @@
226 db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0");
227 db_end_transaction(0);
228 }
229
230 /*
231 ** Rename a single file.
232 **
233 ** The original name of the file is zOrig. The new filename is zNew.
234 */
235 static void mv_one_file(int vid, const char *zOrig, const char *zNew){
236 printf("RENAME %s %s\n", zOrig, zNew);
237

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button