Fossil

Check-in [5015043b]
Login

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

Overview
Comment:Retain original finfo behavior by introducing a new "mode" for artifact-id.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5015043b2d3e06fbbd274e103968ec6c5fac9ef3936b1af5d5aecae112f17412
User & Date: andybradford 2021-04-13 13:53:42
Context
2021-04-15
03:11
Assorted improvements to the "Setting Up A Server" section in the quickstart guide, primarily clarity and linking to other sources of related info. ... (check-in: f17ab298 user: wyoung tags: trunk)
2021-04-13
13:53
Retain original finfo behavior by introducing a new "mode" for artifact-id. ... (check-in: 5015043b user: andybradford tags: trunk)
2021-04-09
07:17
/chat internal doc correction and cleanup. No visible changes. ... (check-in: 243be3ef user: stephan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/finfo.c.

29
30
31
32
33
34
35



36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
116
117
118
119
120
121
122

123
124
125
126
127
128
129
...
134
135
136
137
138
139
140
141
142

143
144
145

146
147
148
149
150
151
152
** in time.  The default mode is -l.
**
** For the -l|--log mode: If "-b|--brief" is specified one line per revision
** is printed, otherwise the full comment is printed.  The "-n|--limit N"
** and "--offset P" options limits the output to the first N changes
** after skipping P changes.
**



** In the -s mode prints the status as <status> <revision>.  This is
** a quick status and does not check for up-to-date-ness of the file.
**
** In the -p mode, there's an optional flag "-r|--revision REVISION".
** The specified version (or the latest checked out version) is printed
** to stdout.  The -p mode is another form of the "cat" command.
**
** Options:
**   -b|--brief           Display a brief (one line / revision) summary
**   --case-sensitive B   Enable or disable case-sensitive filenames.  B is a
**                        boolean: "yes", "no", "true", "false", etc.

**   -l|--log             Select log mode (the default)
**   -n|--limit N         Display the first N changes (default unlimited).
**                        N less than 0 means no limit.
**   --offset P           Skip P changes
**   -p|--print           Select print mode
**   -r|--revision R      Print the given revision (or ckout, if none is given)
**                        to stdout (only in print mode)
................................................................................
**   -s|--status          Select status mode (print a status indicator for FILE)
**   -W|--width N         Width of lines (default is to auto-detect). Must be
**                        more than 22 or else 0 to indicate no limit.
**
** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
*/
void finfo_cmd(void){
  const char *zRevision = find_option("revision", "r", 1);

  db_must_be_within_tree();
  if( find_option("status","s",0) ){
    Stmt q;
    Blob line;
    Blob fname;
    int vid;

................................................................................
    db_finalize(&q);
    fossil_print("%s\n", blob_str(&line));
    blob_reset(&fname);
    blob_reset(&line);
  }else if( find_option("print","p",0) ){
    Blob record;
    Blob fname;


    /* We should be done with options.. */
    verify_all_options();

    file_tree_name(g.argv[2], &fname, 0, 1);
    if( zRevision ){
      historical_blob(zRevision, blob_str(&fname), &record, 1);
................................................................................
        fossil_fatal("no history for file: %b", &fname);
      }
      content_get(rid, &record);
    }
    blob_write_to_file(&record, "-");
    blob_reset(&record);
    blob_reset(&fname);
  }else if( zRevision && zRevision[0] ){
    Blob fname;


    verify_all_options();


    if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
    file_tree_name(g.argv[2], &fname, 0, 1);
    int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
                         "  (SELECT uuid FROM files_of_checkin(%Q)"
                         "   WHERE filename=%B %s)",
                     zRevision, &fname, filename_collation());
    if( rid==0 ) {







>
>
>











>







 







<
<







 







>







 







|

>



>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
..
58
59
60
61
62
63
64


65
66
67
68
69
70
71
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
** in time.  The default mode is -l.
**
** For the -l|--log mode: If "-b|--brief" is specified one line per revision
** is printed, otherwise the full comment is printed.  The "-n|--limit N"
** and "--offset P" options limits the output to the first N changes
** after skipping P changes.
**
** The -i mode will print the artifact ID of FILENAME given the REVISION
** provided by the -r flag (which is required).

** In the -s mode prints the status as <status> <revision>.  This is
** a quick status and does not check for up-to-date-ness of the file.
**
** In the -p mode, there's an optional flag "-r|--revision REVISION".
** The specified version (or the latest checked out version) is printed
** to stdout.  The -p mode is another form of the "cat" command.
**
** Options:
**   -b|--brief           Display a brief (one line / revision) summary
**   --case-sensitive B   Enable or disable case-sensitive filenames.  B is a
**                        boolean: "yes", "no", "true", "false", etc.
**   -i|--id              Print the artifact ID (requires -r)
**   -l|--log             Select log mode (the default)
**   -n|--limit N         Display the first N changes (default unlimited).
**                        N less than 0 means no limit.
**   --offset P           Skip P changes
**   -p|--print           Select print mode
**   -r|--revision R      Print the given revision (or ckout, if none is given)
**                        to stdout (only in print mode)
................................................................................
**   -s|--status          Select status mode (print a status indicator for FILE)
**   -W|--width N         Width of lines (default is to auto-detect). Must be
**                        more than 22 or else 0 to indicate no limit.
**
** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
*/
void finfo_cmd(void){


  db_must_be_within_tree();
  if( find_option("status","s",0) ){
    Stmt q;
    Blob line;
    Blob fname;
    int vid;

................................................................................
    db_finalize(&q);
    fossil_print("%s\n", blob_str(&line));
    blob_reset(&fname);
    blob_reset(&line);
  }else if( find_option("print","p",0) ){
    Blob record;
    Blob fname;
    const char *zRevision = find_option("revision", "r", 1);

    /* We should be done with options.. */
    verify_all_options();

    file_tree_name(g.argv[2], &fname, 0, 1);
    if( zRevision ){
      historical_blob(zRevision, blob_str(&fname), &record, 1);
................................................................................
        fossil_fatal("no history for file: %b", &fname);
      }
      content_get(rid, &record);
    }
    blob_write_to_file(&record, "-");
    blob_reset(&record);
    blob_reset(&fname);
  }else if( find_option("id","i",0) ){
    Blob fname;
    const char *zRevision = find_option("revision", "r", 1);

    verify_all_options();

    if( zRevision==0 ) usage("-i|--id also requires -r|--revision");
    if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
    file_tree_name(g.argv[2], &fname, 0, 1);
    int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
                         "  (SELECT uuid FROM files_of_checkin(%Q)"
                         "   WHERE filename=%B %s)",
                     zRevision, &fname, filename_collation());
    if( rid==0 ) {