Fossil

Check-in [1761fee0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added better error message when trying to remove a directory.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | dead-end
Files: files | file ages | folders
SHA1:1761fee0556d5e1b554e29a67462d18dceb5db83
User & Date: jeremy_c 2010-02-08 14:20:24
Context
2010-02-08
14:20
Added better error message when trying to remove a directory. Closed-Leaf check-in: 1761fee0 user: jeremy_c tags: dead-end
2010-02-06
20:20
fixed [9ff56ae8a6] - "fossil sha" crash check-in: 4027ad4b user: ron tags: dead-end
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/add.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
...
199
200
201
202
203
204
205

206
207
208




209
210
211
212
213
214
215
...
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
** modify it under the terms of the GNU General Public
** License version 2 as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** General Public License for more details.
** 
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA  02111-1307, USA.
**
** Author contact information:
**   drh@hwaci.com
................................................................................
#include <dirent.h>

/*
** Set to true if files whose names begin with "." should be
** included when processing a recursive "add" command.
*/
static int includeDotFiles = 0;
    
/*
** Add a single file
*/
static void add_one_file(const char *zName, int vid, Blob *pOmit){
  Blob pathname;
  const char *zPath;
      
  file_tree_name(zName, &pathname, 1);
  zPath = blob_str(&pathname);
  if( strcmp(zPath, "manifest")==0
   || strcmp(zPath, "_FOSSIL_")==0
   || strcmp(zPath, "manifest.uuid")==0
   || blob_compare(&pathname, pOmit)==0
  ){
................................................................................
}

/*
** COMMAND: add
**
** Usage: %fossil add FILE...
**
** Make arrangements to add one or more files to the current checkout 
** at the next commit.
**
** When adding files recursively, filenames that begin with "." are
** excluded by default.  To include such files, add the "--dotfiles"
** option to the command-line.
*/
void add_cmd(void){
................................................................................
  if( vid==0 ){
    fossil_panic("no checkout to remove from");
  }
  db_begin_transaction();
  for(i=2; i<g.argc; i++){
    char *zName;
    char *zPath;

    Blob pathname;

    zName = mprintf("%/", g.argv[i]);




    file_tree_name(zName, &pathname, 1);
    zPath = blob_str(&pathname);
    if( !db_exists(
             "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
      fossil_fatal("not in the repository: %s", zName);
    }else{
      db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
................................................................................
    free(zName);
  }
  db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0");
  db_end_transaction(0);
}

/*
** Rename a single file.  
**
** The original name of the file is zOrig.  The new filename is zNew.
*/
static void mv_one_file(int vid, const char *zOrig, const char *zNew){
  printf("RENAME %s %s\n", zOrig, zNew);
  db_multi_exec(
    "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d",







|







 







|






|







 







|







 







>



>
>
>
>







 







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
** modify it under the terms of the GNU General Public
** License version 2 as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA  02111-1307, USA.
**
** Author contact information:
**   drh@hwaci.com
................................................................................
#include <dirent.h>

/*
** Set to true if files whose names begin with "." should be
** included when processing a recursive "add" command.
*/
static int includeDotFiles = 0;

/*
** Add a single file
*/
static void add_one_file(const char *zName, int vid, Blob *pOmit){
  Blob pathname;
  const char *zPath;

  file_tree_name(zName, &pathname, 1);
  zPath = blob_str(&pathname);
  if( strcmp(zPath, "manifest")==0
   || strcmp(zPath, "_FOSSIL_")==0
   || strcmp(zPath, "manifest.uuid")==0
   || blob_compare(&pathname, pOmit)==0
  ){
................................................................................
}

/*
** COMMAND: add
**
** Usage: %fossil add FILE...
**
** Make arrangements to add one or more files to the current checkout
** at the next commit.
**
** When adding files recursively, filenames that begin with "." are
** excluded by default.  To include such files, add the "--dotfiles"
** option to the command-line.
*/
void add_cmd(void){
................................................................................
  if( vid==0 ){
    fossil_panic("no checkout to remove from");
  }
  db_begin_transaction();
  for(i=2; i<g.argc; i++){
    char *zName;
    char *zPath;
    int isDir;
    Blob pathname;

    zName = mprintf("%/", g.argv[i]);
    isDir = file_isdir(zName);
    if( isDir==1 ){
      fossil_fatal("cannot remove directories. Please remove individual files instead.");
	}
    file_tree_name(zName, &pathname, 1);
    zPath = blob_str(&pathname);
    if( !db_exists(
             "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
      fossil_fatal("not in the repository: %s", zName);
    }else{
      db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
................................................................................
    free(zName);
  }
  db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0");
  db_end_transaction(0);
}

/*
** Rename a single file.
**
** The original name of the file is zOrig.  The new filename is zNew.
*/
static void mv_one_file(int vid, const char *zOrig, const char *zNew){
  printf("RENAME %s %s\n", zOrig, zNew);
  db_multi_exec(
    "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d",