@@ -32,12 +32,20 @@
** Generate text describing all changes. Prepend zPrefix to each line
** of output.
**
** We assume that vfile_check_signature has been run.
+**
+** If missingIsFatal is true, then any files that are missing or which
+** are not true files results in a fatal error.
*/
-static void status_report(Blob *report, const char *zPrefix){
+static void status_report(
+ Blob *report, /* Append the status report here */
+ const char *zPrefix, /* Prefix on each line of the report */
+ int missingIsFatal /* MISSING and NOT_A_FILE are fatal errors */
+){
Stmt q;
int nPrefix = strlen(zPrefix);
+ int nErr = 0;
db_prepare(&q,
"SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
" FROM vfile "
" WHERE file_is_selected(id)"
@@ -51,23 +59,35 @@
int isRenamed = db_column_int(&q,4);
char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname);
blob_append(report, zPrefix, nPrefix);
if( isDeleted ){
- blob_appendf(report, "DELETED %s\n", zPathname);
- }else if( access(zFullName, 0) ){
- blob_appendf(report, "MISSING %s\n", zPathname);
+ blob_appendf(report, "DELETED %s\n", zPathname);
+ }else if( !file_isfile(zFullName) ){
+ if( access(zFullName, 0)==0 ){
+ blob_appendf(report, "NOT_A_FILE %s\n", zPathname);
+ if( missingIsFatal ){
+ fossil_warning("not a file: %s", zPathname);
+ nErr++;
+ }
+ }else{
+ blob_appendf(report, "MISSING %s\n", zPathname);
+ if( missingIsFatal ){
+ fossil_warning("missing file: %s", zPathname);
+ nErr++;
+ }
+ }
}else if( isNew ){
- blob_appendf(report, "ADDED %s\n", zPathname);
+ blob_appendf(report, "ADDED %s\n", zPathname);
}else if( isDeleted ){
- blob_appendf(report, "DELETED %s\n", zPathname);
+ blob_appendf(report, "DELETED %s\n", zPathname);
}else if( isChnged==2 ){
blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname);
}else if( isChnged==3 ){
blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname);
}else if( isChnged==1 ){
- blob_appendf(report, "EDITED %s\n", zPathname);
+ blob_appendf(report, "EDITED %s\n", zPathname);
}else if( isRenamed ){
- blob_appendf(report, "RENAMED %s\n", zPathname);
+ blob_appendf(report, "RENAMED %s\n", zPathname);
}
free(zFullName);
}
db_finalize(&q);
@@ -77,8 +97,11 @@
blob_append(report, zPrefix, nPrefix);
blob_appendf(report, "MERGED_WITH %s\n", db_column_text(&q, 0));
}
db_finalize(&q);
+ if( nErr ){
+ fossil_fatal("aborting due to prior errors");
+ }
}
/*
** COMMAND: changes
@@ -93,10 +116,10 @@
int vid;
db_must_be_within_tree();
blob_zero(&report);
vid = db_lget_int("checkout", 0);
- vfile_check_signature(vid);
- status_report(&report, "");
+ vfile_check_signature(vid, 0);
+ status_report(&report, "", 0);
blob_write_to_file(&report, "-");
}
/*
@@ -122,19 +145,22 @@
/*
** COMMAND: ls
**
-** Usage: %fossil ls
-**
-** Show the names of all files in the current checkout
+** Usage: %fossil ls [-l]
+**
+** Show the names of all files in the current checkout. The -l provides
+** extra information about each file.
*/
void ls_cmd(void){
int vid;
Stmt q;
-
+ int isBrief;
+
+ isBrief = find_option("l","l", 0)==0;
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
- vfile_check_signature(vid);
+ vfile_check_signature(vid, 0);
db_prepare(&q,
"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
" FROM vfile"
" ORDER BY 1"
@@ -145,20 +171,26 @@
int isNew = db_column_int(&q,2)==0;
int chnged = db_column_int(&q,3);
int renamed = db_column_int(&q,4);
char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname);
- if( isNew ){
- printf("ADDED %s\n", zPathname);
- }else if( access(zFullName, 0) ){
- printf("MISSING %s\n", zPathname);
+ if( isBrief ){
+ printf("%s\n", zPathname);
+ }else if( isNew ){
+ printf("ADDED %s\n", zPathname);
+ }else if( !file_isfile(zFullName) ){
+ if( access(zFullName, 0)==0 ){
+ printf("NOT_A_FILE %s\n", zPathname);
+ }else{
+ printf("MISSING %s\n", zPathname);
+ }
}else if( isDeleted ){
- printf("DELETED %s\n", zPathname);
+ printf("DELETED %s\n", zPathname);
}else if( chnged ){
- printf("EDITED %s\n", zPathname);
+ printf("EDITED %s\n", zPathname);
}else if( renamed ){
- printf("RENAMED %s\n", zPathname);
+ printf("RENAMED %s\n", zPathname);
}else{
- printf("UNCHANGED %s\n", zPathname);
+ printf("UNCHANGED %s\n", zPathname);
}
free(zFullName);
}
db_finalize(&q);
@@ -257,10 +289,24 @@
** the VISUAL or EDITOR environment variable.
**
** Store the final commit comment in pComment. pComment is assumed
** to be uninitialized - any prior content is overwritten.
+**
+** zInit is the text of the most recent failed attempt to check in
+** this same change. Use zInit to reinitialize the check-in comment
+** so that the user does not have to retype.
+**
+** zBranch is the name of a new branch that this check-in is forced into.
+** zBranch might be NULL or an empty string if no forcing occurs.
+**
+** parent_rid is the recordid of the parent check-in.
*/
-static void prepare_commit_comment(Blob *pComment, char *zInit){
+static void prepare_commit_comment(
+ Blob *pComment,
+ char *zInit,
+ const char *zBranch,
+ int parent_rid
+){
const char *zEditor;
char *zCmd;
char *zFile;
Blob text, line;
@@ -272,16 +318,22 @@
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
"# The check-in comment follows wiki formatting rules.\n"
"#\n", -1
);
+ if( zBranch && zBranch[0] ){
+ blob_appendf(&text, "# tags: %s\n#\n", zBranch);
+ }else{
+ char *zTags = info_tags_of_checkin(parent_rid);
+ if( zTags ) blob_appendf(&text, "# tags: %z\n#\n", zTags);
+ }
if( g.markPrivate ){
blob_append(&text,
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
"# repositories.\n"
"#\n", -1
);
}
- status_report(&text, "# ");
+ status_report(&text, "# ", 1);
zEditor = db_get("editor", 0);
if( zEditor==0 ){
zEditor = getenv("VISUAL");
}
@@ -554,9 +606,9 @@
blob_zero(&comment);
blob_read_from_file(&comment, zCommentFile);
}else{
char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
- prepare_commit_comment(&comment, zInit);
+ prepare_commit_comment(&comment, zInit, zBranch, vid);
free(zInit);
}
if( blob_size(&comment)==0 ){
Blob ans;