Fossil

Check-in [c8253f40]
Login

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

Overview
Comment:Allow the "fossil commit" command to accept directories as command-line arguments and commit all files contained underneath those directories.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c8253f4066cbc562b835419ba6b1b0928d88373a
User & Date: drh 2013-06-21 15:19:56
References
2013-06-24
08:27
Use file_tree_name(), not file_canonical_name(), as in Richard's example [c8253f4066] for "fossil ls|changes|status" too. Advantage: 1) a panic when an out-of-tree filename is given on the command line 2) shortcut when any command line argument is "." (or resolves to the top of the tree in any other way) check-in: ae012443 user: jan.nijtmans tags: trunk
Context
2013-06-22
01:44
Work around a networking problem on WinXP when transferring large files. check-in: 74eec78b user: drh tags: trunk
2013-06-21
15:19
Allow the "fossil commit" command to accept directories as command-line arguments and commit all files contained underneath those directories. check-in: c8253f40 user: drh tags: trunk
14:46
Oops, forgot to zero the blob. check-in: d09e3738 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

43
44
45
46
47
48
49

50
51
52
53
54
55
56
...
110
111
112
113
114
115
116


117
118
119
120
121
122
123
...
732
733
734
735
736
737
738

739
740
741
742
743



744



745
746
747











748
749
750












751
752
753
754
755
756
757




758

759
760
761
762
763
764
765
  Blob rewrittenPathname;
  Blob where;
  const char *zTreeName;
  int i, nRoot;

  blob_zero(&where);
  nRoot = (int)strlen(g.zLocalRoot);

  for(i=2; i<g.argc; i++) {
    Blob fname;
    file_canonical_name(g.argv[i], &fname, 0);
    zTreeName = blob_str(&fname)+nRoot;
    blob_appendf(&where, " %s (pathname=%Q %s) "
                 "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
                 (blob_size(&where)>0) ? "OR" : "AND", zTreeName,
................................................................................
      if( file_contains_merge_marker(zFullName) ){
        blob_appendf(report, "CONFLICT   %s\n", zDisplayName);
      }else{
        blob_appendf(report, "EDITED     %s\n", zDisplayName);
      }
    }else if( isRenamed ){
      blob_appendf(report, "RENAMED    %s\n", zDisplayName);


    }
    free(zFullName);
  }
  blob_reset(&rewrittenPathname);
  db_finalize(&q);
  db_prepare(&q, "SELECT uuid, id FROM vmerge JOIN blob ON merge=rid"
                 " WHERE id<=0");
................................................................................
** allocated and remains NULL. Other parts of the code interpret this
** to mean "all files".
**
** Returns 1 if there was a warning, 0 otherwise.
*/
int select_commit_files(void){
  int result = 0;

  if( g.argc>2 ){
    int ii, jj=0;
    Blob b;
    blob_zero(&b);
    g.aCommitFile = fossil_malloc(sizeof(int)*(g.argc-1));







    for(ii=2; ii<g.argc; ii++){
      int iId;
      file_tree_name(g.argv[ii], &b, 1);











      iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q %s",
                   blob_str(&b), filename_collation() );
      if( iId<0 ){












        fossil_warning("fossil knows nothing about: %s", g.argv[ii]);
        result = 1;
      }else{
        g.aCommitFile[jj++] = iId;
      }
      blob_reset(&b);
    }




    g.aCommitFile[jj] = 0;

  }
  return result;
}

/*
** Make sure the current check-in with timestamp zDate is younger than its
** ancestor identified rid and zUuid.  Throw a fatal error if not.







>







 







>
>







 







>


|
<
|
>
>
>

>
>
>

|
|
>
>
>
>
>
>
>
>
>
>
>
|
<
<
>
>
>
>
>
>
>
>
>
>
>
>


<
<

|

>
>
>
>

>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
735
736
737
738
739
740
741
742
743
744
745

746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768


769
770
771
772
773
774
775
776
777
778
779
780
781
782


783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
  Blob rewrittenPathname;
  Blob where;
  const char *zTreeName;
  int i, nRoot;

  blob_zero(&where);
  nRoot = (int)strlen(g.zLocalRoot);
  blob_zero(&where);
  for(i=2; i<g.argc; i++) {
    Blob fname;
    file_canonical_name(g.argv[i], &fname, 0);
    zTreeName = blob_str(&fname)+nRoot;
    blob_appendf(&where, " %s (pathname=%Q %s) "
                 "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
                 (blob_size(&where)>0) ? "OR" : "AND", zTreeName,
................................................................................
      if( file_contains_merge_marker(zFullName) ){
        blob_appendf(report, "CONFLICT   %s\n", zDisplayName);
      }else{
        blob_appendf(report, "EDITED     %s\n", zDisplayName);
      }
    }else if( isRenamed ){
      blob_appendf(report, "RENAMED    %s\n", zDisplayName);
    }else{
      report->nUsed -= nPrefix;
    }
    free(zFullName);
  }
  blob_reset(&rewrittenPathname);
  db_finalize(&q);
  db_prepare(&q, "SELECT uuid, id FROM vmerge JOIN blob ON merge=rid"
                 " WHERE id<=0");
................................................................................
** allocated and remains NULL. Other parts of the code interpret this
** to mean "all files".
**
** Returns 1 if there was a warning, 0 otherwise.
*/
int select_commit_files(void){
  int result = 0;
  assert( g.aCommitFile==0 );
  if( g.argc>2 ){
    int ii, jj=0;
    Blob fname;

    int isDir;
    Stmt q;
    const char *zCollate;
    Bag toCommit;

    zCollate = filename_collation();
    blob_zero(&fname);
    bag_init(&toCommit);
    for(ii=2; ii<g.argc; ii++){
      int cnt = 0;
      file_tree_name(g.argv[ii], &fname, 1);
      if( fossil_strcmp(blob_str(&fname),".")==0 ){
        bag_clear(&toCommit);
        return result;
      }
      isDir = file_isdir(g.argv[ii]);
      if( isDir==1 ){
        db_prepare(&q,
          "SELECT id FROM vfile WHERE pathname>'%q/' %s AND pathname<'%q0'",
          blob_str(&fname), zCollate, blob_str(&fname), zCollate);
      }else if( isDir==2 ){
        db_prepare(&q,
          "SELECT id FROM vfile WHERE pathname=%Q",


          blob_str(&fname), zCollate);
      }else{
        fossil_warning("not found: %s", g.argv[ii]);
        result = 1;
        continue;
      }
      while( db_step(&q)==SQLITE_ROW ){
        cnt++;
        bag_insert(&toCommit, db_column_int(&q, 0));
      }
      db_finalize(&q);
      if( cnt==0 ){
        fossil_warning("fossil knows nothing about: %s", g.argv[ii]);
        result = 1;


      }
      blob_reset(&fname);
    }
    g.aCommitFile = fossil_malloc( (bag_count(&toCommit)+1) * sizeof(g.aCommitFile[0]) );
    for(ii=bag_first(&toCommit); ii>0; ii=bag_next(&toCommit, ii)){
      g.aCommitFile[jj++] = ii;
    }
    g.aCommitFile[jj] = 0;
    bag_clear(&toCommit);
  }
  return result;
}

/*
** Make sure the current check-in with timestamp zDate is younger than its
** ancestor identified rid and zUuid.  Throw a fatal error if not.