Fossil SCM

By default, the changes and status commands list all changed files relative to the current working directory, unless the --non-relative option is used.

ben 2011-07-10 15:01 ben-changes-report
Commit a05bbff46acb84964af5aaae53b11f6939030a38
1 file changed +15 -40
+15 -40
--- src/checkin.c
+++ src/checkin.c
@@ -33,61 +33,38 @@
3333
*/
3434
static void status_report(
3535
Blob *report, /* Append the status report here */
3636
const char *zPrefix, /* Prefix on each line of the report */
3737
int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */
38
- int reportSubdirOnly /* Only report for the current sub-dir */
38
+ int cwdRelative /* Report relative to the current working dir */
3939
){
4040
Stmt q;
4141
int nPrefix = strlen(zPrefix);
4242
int nErr = 0;
43
- Blob currentDir, rootDir;
44
- const char *zShowSubDir = 0;
45
- int showSubDirLen = 0;
46
- int otherChanges = 0;
43
+ Blob rewrittenPathname;
4744
db_prepare(&q,
4845
"SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
4946
" FROM vfile "
5047
" WHERE file_is_selected(id)"
5148
" AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
5249
);
53
- /* If sub-directory only reports are acceptable, check to see if we're
54
- ** in a sub-directory of the checkout. */
55
- if( reportSubdirOnly ){
56
- blob_zero(&currentDir);
57
- file_canonical_name(".", &currentDir);
58
- blob_zero(&rootDir);
59
- file_canonical_name(g.zLocalRoot, &rootDir);
60
- if( blob_compare(&currentDir, &rootDir)!=0
61
- && blob_size(&currentDir)>blob_size(&rootDir) ){
62
- /* Current directory is not the root of the repository */
63
- blob_appendf(report, "%sIn sub-directory %s:\n", zPrefix,
64
- blob_str(&currentDir) + blob_size(&rootDir) + 1);
65
- blob_append(&currentDir,"/",1);
66
- zShowSubDir = blob_str(&currentDir) + blob_size(&rootDir) + 1;
67
- showSubDirLen = blob_size(&currentDir) - blob_size(&rootDir) - 1;
68
- }
69
- }
70
- /* Show the changes */
50
+ blob_zero(&rewrittenPathname);
7151
while( db_step(&q)==SQLITE_ROW ){
7252
const char *zPathname = db_column_text(&q,0);
7353
const char *zDisplayName = zPathname;
74
- if( zShowSubDir!=0 ){
75
- if( strncmp(zPathname,zShowSubDir,showSubDirLen)!=0 ){
76
- /* Not in sub-directory, don't display this file */
77
- otherChanges++;
78
- continue;
79
- }else{
80
- /* In sub directory, so hide the prefix */
81
- zDisplayName += showSubDirLen;
82
- }
83
- }
8454
int isDeleted = db_column_int(&q, 1);
8555
int isChnged = db_column_int(&q,2);
8656
int isNew = db_column_int(&q,3)==0;
8757
int isRenamed = db_column_int(&q,4);
8858
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
59
+ if( cwdRelative ){
60
+ file_relative_name(zFullName, &rewrittenPathname);
61
+ zDisplayName = blob_str(&rewrittenPathname);
62
+ if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
63
+ zDisplayName += 2; /* no unnecessary ./ prefix */
64
+ }
65
+ }
8966
blob_append(report, zPrefix, nPrefix);
9067
if( isDeleted ){
9168
blob_appendf(report, "DELETED %s\n", zDisplayName);
9269
}else if( !file_isfile(zFullName) ){
9370
if( file_access(zFullName, 0)==0 ){
@@ -116,21 +93,19 @@
11693
}else if( isRenamed ){
11794
blob_appendf(report, "RENAMED %s\n", zDisplayName);
11895
}
11996
free(zFullName);
12097
}
98
+ blob_reset(&rewrittenPathname);
12199
db_finalize(&q);
122100
db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid"
123101
" WHERE id=0");
124102
while( db_step(&q)==SQLITE_ROW ){
125103
blob_append(report, zPrefix, nPrefix);
126104
blob_appendf(report, "MERGED_WITH %s\n", db_column_text(&q, 0));
127105
}
128106
db_finalize(&q);
129
- if( otherChanges!=0 ){
130
- blob_appendf(report, "%d other changes. Use --show-all option to list all changes.\n");
131
- }
132107
if( nErr ){
133108
fossil_fatal("aborting due to prior errors");
134109
}
135110
}
136111
@@ -145,23 +120,23 @@
145120
** Options:
146121
**
147122
** --sha1sum Verify file status using SHA1 hashing rather
148123
** than relying on file mtimes.
149124
**
150
-** --show-all When invoked from a sub-directory, show changes
151
-** even if they're outside the current directory.
125
+** --non-relative Don't display filenames relative to the current
126
+** working directory.
152127
*/
153128
void changes_cmd(void){
154129
Blob report;
155130
int vid;
156131
int useSha1sum = find_option("sha1sum", 0, 0)!=0;
157
- int showAllFlag = find_option("show-all","S",0)!=0;
132
+ int nonRelative = find_option("non-relative", 0, 0)!=0;
158133
db_must_be_within_tree();
159134
blob_zero(&report);
160135
vid = db_lget_int("checkout", 0);
161136
vfile_check_signature(vid, 0, useSha1sum);
162
- status_report(&report, "", 0, !showAllFlag);
137
+ status_report(&report, "", 0, !nonRelative);
163138
blob_write_to_file(&report, "-");
164139
}
165140
166141
/*
167142
** COMMAND: status
168143
--- src/checkin.c
+++ src/checkin.c
@@ -33,61 +33,38 @@
33 */
34 static void status_report(
35 Blob *report, /* Append the status report here */
36 const char *zPrefix, /* Prefix on each line of the report */
37 int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */
38 int reportSubdirOnly /* Only report for the current sub-dir */
39 ){
40 Stmt q;
41 int nPrefix = strlen(zPrefix);
42 int nErr = 0;
43 Blob currentDir, rootDir;
44 const char *zShowSubDir = 0;
45 int showSubDirLen = 0;
46 int otherChanges = 0;
47 db_prepare(&q,
48 "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
49 " FROM vfile "
50 " WHERE file_is_selected(id)"
51 " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
52 );
53 /* If sub-directory only reports are acceptable, check to see if we're
54 ** in a sub-directory of the checkout. */
55 if( reportSubdirOnly ){
56 blob_zero(&currentDir);
57 file_canonical_name(".", &currentDir);
58 blob_zero(&rootDir);
59 file_canonical_name(g.zLocalRoot, &rootDir);
60 if( blob_compare(&currentDir, &rootDir)!=0
61 && blob_size(&currentDir)>blob_size(&rootDir) ){
62 /* Current directory is not the root of the repository */
63 blob_appendf(report, "%sIn sub-directory %s:\n", zPrefix,
64 blob_str(&currentDir) + blob_size(&rootDir) + 1);
65 blob_append(&currentDir,"/",1);
66 zShowSubDir = blob_str(&currentDir) + blob_size(&rootDir) + 1;
67 showSubDirLen = blob_size(&currentDir) - blob_size(&rootDir) - 1;
68 }
69 }
70 /* Show the changes */
71 while( db_step(&q)==SQLITE_ROW ){
72 const char *zPathname = db_column_text(&q,0);
73 const char *zDisplayName = zPathname;
74 if( zShowSubDir!=0 ){
75 if( strncmp(zPathname,zShowSubDir,showSubDirLen)!=0 ){
76 /* Not in sub-directory, don't display this file */
77 otherChanges++;
78 continue;
79 }else{
80 /* In sub directory, so hide the prefix */
81 zDisplayName += showSubDirLen;
82 }
83 }
84 int isDeleted = db_column_int(&q, 1);
85 int isChnged = db_column_int(&q,2);
86 int isNew = db_column_int(&q,3)==0;
87 int isRenamed = db_column_int(&q,4);
88 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
 
 
 
 
 
 
 
89 blob_append(report, zPrefix, nPrefix);
90 if( isDeleted ){
91 blob_appendf(report, "DELETED %s\n", zDisplayName);
92 }else if( !file_isfile(zFullName) ){
93 if( file_access(zFullName, 0)==0 ){
@@ -116,21 +93,19 @@
116 }else if( isRenamed ){
117 blob_appendf(report, "RENAMED %s\n", zDisplayName);
118 }
119 free(zFullName);
120 }
 
121 db_finalize(&q);
122 db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid"
123 " WHERE id=0");
124 while( db_step(&q)==SQLITE_ROW ){
125 blob_append(report, zPrefix, nPrefix);
126 blob_appendf(report, "MERGED_WITH %s\n", db_column_text(&q, 0));
127 }
128 db_finalize(&q);
129 if( otherChanges!=0 ){
130 blob_appendf(report, "%d other changes. Use --show-all option to list all changes.\n");
131 }
132 if( nErr ){
133 fossil_fatal("aborting due to prior errors");
134 }
135 }
136
@@ -145,23 +120,23 @@
145 ** Options:
146 **
147 ** --sha1sum Verify file status using SHA1 hashing rather
148 ** than relying on file mtimes.
149 **
150 ** --show-all When invoked from a sub-directory, show changes
151 ** even if they're outside the current directory.
152 */
153 void changes_cmd(void){
154 Blob report;
155 int vid;
156 int useSha1sum = find_option("sha1sum", 0, 0)!=0;
157 int showAllFlag = find_option("show-all","S",0)!=0;
158 db_must_be_within_tree();
159 blob_zero(&report);
160 vid = db_lget_int("checkout", 0);
161 vfile_check_signature(vid, 0, useSha1sum);
162 status_report(&report, "", 0, !showAllFlag);
163 blob_write_to_file(&report, "-");
164 }
165
166 /*
167 ** COMMAND: status
168
--- src/checkin.c
+++ src/checkin.c
@@ -33,61 +33,38 @@
33 */
34 static void status_report(
35 Blob *report, /* Append the status report here */
36 const char *zPrefix, /* Prefix on each line of the report */
37 int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */
38 int cwdRelative /* Report relative to the current working dir */
39 ){
40 Stmt q;
41 int nPrefix = strlen(zPrefix);
42 int nErr = 0;
43 Blob rewrittenPathname;
 
 
 
44 db_prepare(&q,
45 "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
46 " FROM vfile "
47 " WHERE file_is_selected(id)"
48 " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
49 );
50 blob_zero(&rewrittenPathname);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51 while( db_step(&q)==SQLITE_ROW ){
52 const char *zPathname = db_column_text(&q,0);
53 const char *zDisplayName = zPathname;
 
 
 
 
 
 
 
 
 
 
54 int isDeleted = db_column_int(&q, 1);
55 int isChnged = db_column_int(&q,2);
56 int isNew = db_column_int(&q,3)==0;
57 int isRenamed = db_column_int(&q,4);
58 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
59 if( cwdRelative ){
60 file_relative_name(zFullName, &rewrittenPathname);
61 zDisplayName = blob_str(&rewrittenPathname);
62 if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
63 zDisplayName += 2; /* no unnecessary ./ prefix */
64 }
65 }
66 blob_append(report, zPrefix, nPrefix);
67 if( isDeleted ){
68 blob_appendf(report, "DELETED %s\n", zDisplayName);
69 }else if( !file_isfile(zFullName) ){
70 if( file_access(zFullName, 0)==0 ){
@@ -116,21 +93,19 @@
93 }else if( isRenamed ){
94 blob_appendf(report, "RENAMED %s\n", zDisplayName);
95 }
96 free(zFullName);
97 }
98 blob_reset(&rewrittenPathname);
99 db_finalize(&q);
100 db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid"
101 " WHERE id=0");
102 while( db_step(&q)==SQLITE_ROW ){
103 blob_append(report, zPrefix, nPrefix);
104 blob_appendf(report, "MERGED_WITH %s\n", db_column_text(&q, 0));
105 }
106 db_finalize(&q);
 
 
 
107 if( nErr ){
108 fossil_fatal("aborting due to prior errors");
109 }
110 }
111
@@ -145,23 +120,23 @@
120 ** Options:
121 **
122 ** --sha1sum Verify file status using SHA1 hashing rather
123 ** than relying on file mtimes.
124 **
125 ** --non-relative Don't display filenames relative to the current
126 ** working directory.
127 */
128 void changes_cmd(void){
129 Blob report;
130 int vid;
131 int useSha1sum = find_option("sha1sum", 0, 0)!=0;
132 int nonRelative = find_option("non-relative", 0, 0)!=0;
133 db_must_be_within_tree();
134 blob_zero(&report);
135 vid = db_lget_int("checkout", 0);
136 vfile_check_signature(vid, 0, useSha1sum);
137 status_report(&report, "", 0, !nonRelative);
138 blob_write_to_file(&report, "-");
139 }
140
141 /*
142 ** COMMAND: status
143

Keyboard Shortcuts

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