Fossil SCM

The "fossil changes --scp REMOTE" command causes all local changes to be copied over to REMOTE.

drh 2021-02-05 20:54 trunk
Commit 90ae5bbf9466e29725446ec5a9255e9f820666832e7cfb45ca70484472878d86
1 file changed +45 -3
+45 -3
--- src/checkin.c
+++ src/checkin.c
@@ -410,10 +410,17 @@
410410
** If both --merge and --no-merge are used, --no-merge has priority. The
411411
** same is true of --classify and --no-classify.
412412
**
413413
** The "fossil changes --extra" command is equivalent to "fossil extras".
414414
**
415
+** The "fossil changes --scp REMOTE" invokes the "scp" command repeatedly
416
+** to move all changed files to a directory on another machine identified
417
+** by REMOTE. If REMOTE begins with "dryrun:" then the scp commands that
418
+** would have been issued are printed, but no copying is actually done.
419
+** The --scp command causes most other options to be ignored, with the
420
+** notable exception of --extra.
421
+**
415422
** General options:
416423
** --abs-paths Display absolute pathnames.
417424
** --rel-paths Display pathnames relative to the current working
418425
** directory.
419426
** --hash Verify file status using hashing rather than
@@ -421,14 +428,15 @@
421428
** --case-sensitive BOOL Override case-sensitive setting.
422429
** --dotfiles Include unmanaged files beginning with a dot.
423430
** --ignore <CSG> Ignore unmanaged files matching CSG glob patterns.
424431
**
425432
** Options specific to the changes command:
426
-** --header Identify the repository if report is non-empty.
427
-** -v|--verbose Say "(none)" if the change report is empty.
428433
** --classify Start each line with the file's change type.
434
+** --header Identify the repository if report is non-empty.
429435
** --no-classify Do not print file change types.
436
+** --scp REMOTE Used scp to move changed files to REMOTE
437
+** -v|--verbose Say "(none)" if the change report is empty.
430438
**
431439
** Filter options:
432440
** --edited Display edited, merged, and conflicted files.
433441
** --updated Display files updated by merge/integrate.
434442
** --changed Combination of the above two options.
@@ -470,10 +478,11 @@
470478
/* --sha1sum is an undocumented alias for --hash for backwards compatiblity */
471479
int useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0;
472480
int showHdr = command==CHANGES && find_option("header", 0, 0);
473481
int verboseFlag = command==CHANGES && find_option("verbose", "v", 0);
474482
const char *zIgnoreFlag = find_option("ignore", 0, 1);
483
+ const char *zScpRemote = find_option("scp",0,1);
475484
unsigned scanFlags = 0;
476485
unsigned flags = 0;
477486
int vid, i;
478487
479488
fossil_pledge("stdio rpath wpath cpath fattr id flock tty chown");
@@ -553,15 +562,48 @@
553562
if( vid ){
554563
show_common_info(vid, "checkout:", 1, 1);
555564
}
556565
db_record_repository_filename(0);
557566
}
567
+
568
+ /* If the --scp command is present override other options so that
569
+ ** we get only changes with --no-classify */
570
+ if( zScpRemote ){
571
+ flags &= ~(C_CLASSIFY|C_MISSING|C_DELETED|C_RENAMED|C_RELPATH|
572
+ C_MERGE|C_MTIME|C_SIZE|C_COMMENT);
573
+ }
558574
559575
/* Find and print all requested changes. */
560576
blob_zero(&report);
561577
status_report(&report, flags);
562
- if( blob_size(&report) ){
578
+ if( zScpRemote ){
579
+ Blob line;
580
+ int n = (int)strlen(zScpRemote);
581
+ while( n && zScpRemote[n-1]=='/' ){ n--; }
582
+ while( blob_line(&report, &line) ){
583
+ Blob cmd;
584
+ char *zArg;
585
+ const char *zFile;
586
+ blob_trim(&line);
587
+ zFile = blob_str(&line);
588
+ blob_init(&cmd, 0, 0);
589
+ blob_append(&cmd, "scp ", 4);
590
+ zArg = mprintf("%s%s", g.zLocalRoot, zFile);
591
+ blob_append_escaped_arg(&cmd, zArg);
592
+ fossil_free(zArg);
593
+ blob_append_char(&cmd, ' ');
594
+ zArg = mprintf("%.*s/%s", n, zScpRemote, zFile);
595
+ blob_append_escaped_arg(&cmd, zArg);
596
+ fossil_free(zArg);
597
+ fossil_print("%s\n", blob_str(&cmd));
598
+ if( strncmp(zScpRemote, "dryrun:", 7) ){
599
+ /* Run the command if it does NOT begin with "dryrun:" */
600
+ fossil_system(blob_str(&cmd));
601
+ }
602
+ blob_reset(&cmd);
603
+ }
604
+ }else if( blob_size(&report) ){
563605
if( showHdr ){
564606
fossil_print(
565607
"Changes for %s at %s:\n", db_get("project-name", "<unnamed>"),
566608
g.zLocalRoot);
567609
}
568610
--- src/checkin.c
+++ src/checkin.c
@@ -410,10 +410,17 @@
410 ** If both --merge and --no-merge are used, --no-merge has priority. The
411 ** same is true of --classify and --no-classify.
412 **
413 ** The "fossil changes --extra" command is equivalent to "fossil extras".
414 **
 
 
 
 
 
 
 
415 ** General options:
416 ** --abs-paths Display absolute pathnames.
417 ** --rel-paths Display pathnames relative to the current working
418 ** directory.
419 ** --hash Verify file status using hashing rather than
@@ -421,14 +428,15 @@
421 ** --case-sensitive BOOL Override case-sensitive setting.
422 ** --dotfiles Include unmanaged files beginning with a dot.
423 ** --ignore <CSG> Ignore unmanaged files matching CSG glob patterns.
424 **
425 ** Options specific to the changes command:
426 ** --header Identify the repository if report is non-empty.
427 ** -v|--verbose Say "(none)" if the change report is empty.
428 ** --classify Start each line with the file's change type.
 
429 ** --no-classify Do not print file change types.
 
 
430 **
431 ** Filter options:
432 ** --edited Display edited, merged, and conflicted files.
433 ** --updated Display files updated by merge/integrate.
434 ** --changed Combination of the above two options.
@@ -470,10 +478,11 @@
470 /* --sha1sum is an undocumented alias for --hash for backwards compatiblity */
471 int useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0;
472 int showHdr = command==CHANGES && find_option("header", 0, 0);
473 int verboseFlag = command==CHANGES && find_option("verbose", "v", 0);
474 const char *zIgnoreFlag = find_option("ignore", 0, 1);
 
475 unsigned scanFlags = 0;
476 unsigned flags = 0;
477 int vid, i;
478
479 fossil_pledge("stdio rpath wpath cpath fattr id flock tty chown");
@@ -553,15 +562,48 @@
553 if( vid ){
554 show_common_info(vid, "checkout:", 1, 1);
555 }
556 db_record_repository_filename(0);
557 }
 
 
 
 
 
 
 
558
559 /* Find and print all requested changes. */
560 blob_zero(&report);
561 status_report(&report, flags);
562 if( blob_size(&report) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563 if( showHdr ){
564 fossil_print(
565 "Changes for %s at %s:\n", db_get("project-name", "<unnamed>"),
566 g.zLocalRoot);
567 }
568
--- src/checkin.c
+++ src/checkin.c
@@ -410,10 +410,17 @@
410 ** If both --merge and --no-merge are used, --no-merge has priority. The
411 ** same is true of --classify and --no-classify.
412 **
413 ** The "fossil changes --extra" command is equivalent to "fossil extras".
414 **
415 ** The "fossil changes --scp REMOTE" invokes the "scp" command repeatedly
416 ** to move all changed files to a directory on another machine identified
417 ** by REMOTE. If REMOTE begins with "dryrun:" then the scp commands that
418 ** would have been issued are printed, but no copying is actually done.
419 ** The --scp command causes most other options to be ignored, with the
420 ** notable exception of --extra.
421 **
422 ** General options:
423 ** --abs-paths Display absolute pathnames.
424 ** --rel-paths Display pathnames relative to the current working
425 ** directory.
426 ** --hash Verify file status using hashing rather than
@@ -421,14 +428,15 @@
428 ** --case-sensitive BOOL Override case-sensitive setting.
429 ** --dotfiles Include unmanaged files beginning with a dot.
430 ** --ignore <CSG> Ignore unmanaged files matching CSG glob patterns.
431 **
432 ** Options specific to the changes command:
 
 
433 ** --classify Start each line with the file's change type.
434 ** --header Identify the repository if report is non-empty.
435 ** --no-classify Do not print file change types.
436 ** --scp REMOTE Used scp to move changed files to REMOTE
437 ** -v|--verbose Say "(none)" if the change report is empty.
438 **
439 ** Filter options:
440 ** --edited Display edited, merged, and conflicted files.
441 ** --updated Display files updated by merge/integrate.
442 ** --changed Combination of the above two options.
@@ -470,10 +478,11 @@
478 /* --sha1sum is an undocumented alias for --hash for backwards compatiblity */
479 int useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0;
480 int showHdr = command==CHANGES && find_option("header", 0, 0);
481 int verboseFlag = command==CHANGES && find_option("verbose", "v", 0);
482 const char *zIgnoreFlag = find_option("ignore", 0, 1);
483 const char *zScpRemote = find_option("scp",0,1);
484 unsigned scanFlags = 0;
485 unsigned flags = 0;
486 int vid, i;
487
488 fossil_pledge("stdio rpath wpath cpath fattr id flock tty chown");
@@ -553,15 +562,48 @@
562 if( vid ){
563 show_common_info(vid, "checkout:", 1, 1);
564 }
565 db_record_repository_filename(0);
566 }
567
568 /* If the --scp command is present override other options so that
569 ** we get only changes with --no-classify */
570 if( zScpRemote ){
571 flags &= ~(C_CLASSIFY|C_MISSING|C_DELETED|C_RENAMED|C_RELPATH|
572 C_MERGE|C_MTIME|C_SIZE|C_COMMENT);
573 }
574
575 /* Find and print all requested changes. */
576 blob_zero(&report);
577 status_report(&report, flags);
578 if( zScpRemote ){
579 Blob line;
580 int n = (int)strlen(zScpRemote);
581 while( n && zScpRemote[n-1]=='/' ){ n--; }
582 while( blob_line(&report, &line) ){
583 Blob cmd;
584 char *zArg;
585 const char *zFile;
586 blob_trim(&line);
587 zFile = blob_str(&line);
588 blob_init(&cmd, 0, 0);
589 blob_append(&cmd, "scp ", 4);
590 zArg = mprintf("%s%s", g.zLocalRoot, zFile);
591 blob_append_escaped_arg(&cmd, zArg);
592 fossil_free(zArg);
593 blob_append_char(&cmd, ' ');
594 zArg = mprintf("%.*s/%s", n, zScpRemote, zFile);
595 blob_append_escaped_arg(&cmd, zArg);
596 fossil_free(zArg);
597 fossil_print("%s\n", blob_str(&cmd));
598 if( strncmp(zScpRemote, "dryrun:", 7) ){
599 /* Run the command if it does NOT begin with "dryrun:" */
600 fossil_system(blob_str(&cmd));
601 }
602 blob_reset(&cmd);
603 }
604 }else if( blob_size(&report) ){
605 if( showHdr ){
606 fossil_print(
607 "Changes for %s at %s:\n", db_get("project-name", "<unnamed>"),
608 g.zLocalRoot);
609 }
610

Keyboard Shortcuts

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