2
0

ListTheTree 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #! /usr/local/bin/perl
  2. eval "exec /usr/local/bin/perl -S $0 $*"
  3. if $running_under_some_shell;
  4. ################################################################################
  5. #
  6. # File: ListTheTree <source tree>
  7. # RCS: $XConsortium: ListTheTree /main/3 1995/10/30 13:43:24 rswiston $
  8. # Author: Jim Andreas Hewlett-Packard, OSSD-CV
  9. # Created: 1/15/92
  10. # Modified by: Marc Ayotte Hewlett-Packard, OSSD-CV (perlizer)
  11. # Language: N/A
  12. # Package: N/A
  13. # Status: CDE distributed
  14. #
  15. # (c) Copyright 1993, Hewlett-Packard Company, all rights reserved.
  16. #
  17. # Description: This file does 2 things:
  18. # 1) List the source tree's structure.
  19. # This structure is placed into the source tree's
  20. # directory as :TreeListing.
  21. # 2) Creates a listing of all of the files locked in the
  22. # source tree and places it in :TreeListing.locks.
  23. ################################################################################
  24. if ($ARGV[0]) {
  25. $TREE = $ARGV[0];
  26. #
  27. # if not / relative get pwd path
  28. #
  29. if ($TREE !~ m%^\/%) {
  30. print STDERR " Must be a / related path e.g -> /foo. Sorry!\n";
  31. exit 1;
  32. }
  33. }
  34. else {
  35. die " USAGE ListTheTree <source directory>\n";
  36. }
  37. # put /usr/local/bin in the path for Rcslocks
  38. $ENV{'PATH'} = "/x/cdesrc/admin/bin:/usr/local/bin:$ENV{'PATH'}";
  39. if (! chdir("$TREE")) {
  40. die " ERROR -> Couldn't change directory to $TREE.\n";
  41. }
  42. ######################
  43. # get the tree listing
  44. ######################
  45. system ("find . -print > :TreeListing.new");
  46. unlink(":TreeListing");
  47. if (! rename(":TreeListing.new",":TreeListing")) {
  48. print " WARNING -> couldn't mv :TreeListing.new to :TreeListing.\n";
  49. }
  50. ###################################
  51. # find the locked files in the tree
  52. ###################################
  53. unlink(":TreeListing.locks.new");
  54. open(NLOCK,">>$TREE/:TreeListing.locks.new");
  55. print NLOCK "List of locked files in $TREE\n\n";
  56. @dirs=(`find . -type d -print`);
  57. foreach $dir (@dirs) {
  58. undef(@rcsLocks);
  59. chop($dir);
  60. if (chdir("$dir")) {
  61. @rcsLocks = (`Rcslocks -v`);
  62. # only list directory if there are locks
  63. if (@rcsLocks) {
  64. print NLOCK "$dir\n";
  65. while (@rcsLocks) {
  66. $lock = shift(@rcsLocks);
  67. print NLOCK " $lock";
  68. }
  69. print NLOCK "\n";
  70. }
  71. }
  72. else {
  73. print " WARNING -> could not cd to ${TREE}/${dir}\n";
  74. print " $!\n";
  75. }
  76. chdir("$TREE");
  77. }
  78. unlink("$TREE/:TreeListing.locks");
  79. rename("$TREE/:TreeListing.locks.new","$TREE/:TreeListing.locks");
  80. #
  81. # get changes from last listing
  82. # check file $TREE/changestamp
  83. #
  84. $cstamp = "${TREE}/changestamp";
  85. if ( -f "${TREE}/changestamp" ) {
  86. $laststamp = `cat $cstamp`;
  87. chop $laststamp;
  88. }
  89. else {
  90. $date = `date +%y%m%d`;
  91. chop $date;
  92. $laststamp = "${date}0001";
  93. $dip = `echo "$laststamp" >$cstamp`;
  94. $date = `date +%m%d0001`;
  95. chop $date;
  96. system "touch $date $cstamp";
  97. }
  98. $curstamp = `date +%y%m%d%H%M`;
  99. chop $curstamp;
  100. unlink("$TREE/:TreeListing.changes.new");
  101. open(NCHANGE,">>$TREE/:TreeListing.changes.new");
  102. print NCHANGE "List of changed files in $TREE\n\n";
  103. @allfiles=(`find . -follow -name "*,v" -newer $cstamp -print`);
  104. foreach $file (@allfiles) {
  105. chop $file;
  106. if (open($RCSFILE,"$file")) {
  107. NEXTLINE:
  108. while ($line = <$RCSFILE>) {
  109. chop $line;
  110. if ($line !~ m%^date%) {
  111. next NEXTLINE;
  112. }
  113. else {
  114. $lastdate = $line;
  115. $author = $line;
  116. $lastdate =~ s%^.* (\d+\.\d+\.\d+\.\d+\.\d+).*$%\1%;
  117. $lastdate =~ s%\.%%g;
  118. if ($lastdate > $laststamp) {
  119. $author =~ s%^.*author (.*); .*;$%\1%;
  120. print NCHANGE "$file <-> $author\n";
  121. }
  122. }
  123. }
  124. close($RCSFILE);
  125. }
  126. }
  127. $dip = `echo "$curstamp" >$cstamp`;
  128. unlink("$TREE/:TreeListing.changes");
  129. rename("$TREE/:TreeListing.changes.new","$TREE/:TreeListing.changes");