⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svn_load_dirs.pl.in

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 IN
📖 第 1 页 / 共 5 页
字号:
          unless ($seen_dir{$d})            {              $seen_dir{$d} = 1;              if (safe_read_from_pipe($svn, 'log', '-r', 'HEAD',                                      @svn_use_repos_cmd_opts, $url) != 0)                {                  push(@dirs_to_create, $d);                  push(@urls_to_create, $url);                }            }        }    }  if (@dirs_to_create)    {      print "The following directories do not exist and need to exist:\n";      foreach my $dir (@dirs_to_create)        {          print "  $dir\n";        }      exit 0 unless &get_answer("You must add them now to load the " .                                "directories.  Continue (Y/n)? ", 'ny', 1);      my $message = "Create directories to load project into.\n\n";      foreach my $dir (@dirs_to_create)        {          if (length $repos_base_path_segment)            {              $message .= "* $repos_base_path_segment/$dir: New directory.\n";            }          else            {              $message .= "* $dir: New directory.\n";            }        }      $message = wrap('', '  ', $message);      read_from_process($svn, 'mkdir', @svn_use_repos_cmd_opts,                        '-m', $message, @urls_to_create);    }  else    {      print "No directories need to be created to prepare repository.\n";    }}# Either checkout a new working copy from the repository or use an# existing working copy.if (defined $opt_existing_wc_dir)  {    # Update an already existing working copy.    print "Not checking out anything; using existing working directory at\n";    print "$opt_existing_wc_dir\n";    chdir($opt_existing_wc_dir)      or die "$0: cannot chdir '$opt_existing_wc_dir': $!\n";    read_from_process($svn, 'update', @svn_use_repos_cmd_opts);  }else  {    # Check out the svn repository starting at the svn URL into a    # fixed directory name.    my $checkout_dir_name = 'my_import_wc';    # Check out only the directory being imported to, otherwise the    # checkout of the entire base URL can be very huge, if it contains    # a large number of tags.    my $checkout_url;    if ($repos_load_rel_path eq '.')      {        $checkout_url = $repos_base_url;      }    else      {        $checkout_url = "$repos_base_url/$repos_load_rel_path";      }    print "Checking out $checkout_url into $temp_dir/$checkout_dir_name\n";    chdir($temp_dir)      or die "$0: cannot chdir '$temp_dir': $!\n";    read_from_process($svn, 'checkout',                      @svn_use_repos_cmd_opts,                      $checkout_url, $checkout_dir_name);    chdir($checkout_dir_name)      or die "$0: cannot chdir '$checkout_dir_name': $!\n";  }# At this point, the current working directory is the top level# directory of the working copy.  Record the absolute path to this# location because the script will chdir back here later on.my $wc_import_dir_cwd = cwd;# Set up the names for the path to the import and tag directories.my $repos_load_abs_path;if ($repos_load_rel_path eq '.')  {    $repos_load_abs_path = length($repos_base_path_segment) ?                           $repos_base_path_segment : "/";  }else  {    $repos_load_abs_path = length($repos_base_path_segment) ?                           "$repos_base_path_segment/$repos_load_rel_path" :                           $repos_load_rel_path;  }# Now go through each source directory and copy each file from the# source directory to the target directory.  For new target files, add# them to svn.  For files that no longer exist, delete them.my $print_rename_message = 1;my @load_dirs            = @ARGV;while (defined (my $load_dir = &get_next_load_dir))  {    my $load_tag = $load_tags{$load_dir};    if (defined $load_tag)      {        print "\nLoading $load_dir and will save in tag $load_tag.\n";      }    else      {        print "\nLoading $load_dir.\n";      }    # The first hash is keyed by the old name in a rename and the    # second by the new name.  The last variable contains a list of    # old and new filenames in a rename.    my %rename_from_files;    my %rename_to_files;    my @renamed_filenames;    unless ($opt_no_user_input)      {        my $repeat_loop;        do          {            $repeat_loop = 0;            my %add_files;            my %del_files;            # Get the list of files and directories in the repository            # working copy.  This hash is called %del_files because            # each file or directory will be deleted from the hash            # using the list of files and directories in the source            # directory, leaving the files and directories that need            # to be deleted.            %del_files = &recursive_ls_and_hash($wc_import_dir_cwd);            # This anonymous subroutine finds all the files and            # directories in the directory to load.  It notes the file            # type and for each file found, it deletes it from            # %del_files.            my $wanted = sub              {                s#^\./##;                return if $_ eq '.';                my $source_path = $_;                my $dest_path   = "$wc_import_dir_cwd/$_";                my ($source_type) = &file_info($source_path);                my ($dest_type)   = &file_info($dest_path);                # Fail if the destination type exists but is of a                # different type of file than the source type.                if ($dest_type ne '0' and $source_type ne $dest_type)                  {                    die "$0: does not handle changing source and destination ",                        "type for '$source_path'.\n";                  }                if ($source_type ne 'd' and                    $source_type ne 'f' and                    $source_type ne 'l')                  {                    warn "$0: skipping loading file '$source_path' of type ",                         "'$source_type'.\n";                    unless ($opt_no_user_input)                      {                        print STDERR "Press return to continue: ";                        <STDIN>;                      }                    return;                  }                unless (defined delete $del_files{$source_path})                  {                    $add_files{$source_path}{type} = $source_type;                  }              };            # Now change into the directory containing the files to            # load.  First change to the original directory where this            # script was run so that if the specified directory is a            # relative directory path, then the script can change into            # it.            chdir($orig_cwd)              or die "$0: cannot chdir '$orig_cwd': $!\n";            chdir($load_dir)              or die "$0: cannot chdir '$load_dir': $!\n";            find({no_chdir   => 1,                  preprocess => sub { sort { $b cmp $a }                                      grep { $_ !~ /^[._]svn$/ } @_ },                  wanted     => $wanted                 }, '.');            # At this point %add_files contains the list of new files            # and directories to be created in the working copy tree            # and %del_files contains the files and directories that            # need to be deleted.  Because there may be renames that            # have taken place, give the user the opportunity to            # rename any deleted files and directories to ones being            # added.            my @add_files = sort keys %add_files;            my @del_files = sort keys %del_files;            # Because the source code management system may keep the            # original renamed file or directory in the working copy            # until a commit, remove them from the list of deleted            # files or directories.            &filter_renamed_files(\@del_files, \%rename_from_files);            # Now change into the working copy directory in case any            # renames need to be performed.            chdir($wc_import_dir_cwd)              or die "$0: cannot chdir '$wc_import_dir_cwd': $!\n";            # Only do renames if there are both added and deleted            # files and directories.            if (@add_files and @del_files)              {                my $max = @add_files > @del_files ? @add_files : @del_files;                # Print the files that have been added and deleted.                # Find the deleted file with the longest name and use                # that for the width of the filename column.  Add one                # to the filename width to let the directory /                # character be appended to a directory name.                my $line_number_width = 4;                my $filename_width    = 0;                foreach my $f (@del_files)                  {                    my $l = length($f);                    $filename_width = $l if $l > $filename_width;                  }                ++$filename_width;                my $printf_format = "%${line_number_width}d";                if ($print_rename_message)                  {                    $print_rename_message = 0;                    print "\n",                      "The following table lists files and directories that\n",                      "exist in either the Subversion repository or the\n",                      "directory to be imported but not both.  You now have\n",                      "the opportunity to match them up as renames instead\n",                      "of deletes and adds.  This is a Good Thing as it'll\n",                      "make the repository take less space.\n\n",                      "The left column lists files and directories that\n",                      "exist in the Subversion repository and do not exist\n",                      "in the directory being imported.  The right column\n",                      "lists files and directories that exist in the\n",                      "directory being imported.  Match up a deleted item\n",                      "from the left column with an added item from the\n",                      "right column.  Note the line numbers on the left\n",                      "which you type into this script to have a rename\n",                      "performed.\n";                  }                # Sort the added and deleted files and directories by                # the lowercase versions of their basenames instead of                # their complete path, which makes finding files that                # were moved into different directories easier to                # match up.                @add_files = map { $_->[0] }                             sort { $a->[1] cmp $b->[1] }                             map { [$_->[0], lc($_->[1])] }                             map { [$_, m#([^/]+)$#] }                             @add_files;                @del_files = map { $_->[0] }                             sort { $a->[1] cmp $b->[1] }                             map { [$_->[0], lc($_->[1])] }                             map { [$_, m#([^/]+)$#] }                             @del_files;              RELIST:                for (my $i=0; $i<$max; ++$i)                  {                    my $add_filename = '';                    my $del_filename = '';                    if ($i < @add_files)                      {                        $add_filename = $add_files[$i];                        if ($add_files{$add_filename}{type} eq 'd')                          {                            $add_filename .= '/';                          }                      }                    if ($i < @del_files)                      {                        $del_filename = $del_files[$i];                        if ($del_files{$del_filename}{type} eq 'd')                          {                            $del_filename .= '/';                          }                      }                    if ($i % 22 == 0)                      {                        print                          "\n",                          " " x $line_number_width,                          " ",                          "Deleted", " " x ($filename_width-length("Deleted")),                          " ",                          "Added\n";                      }                    printf $printf_format, $i;                    print  " ", $del_filename,                           "_" x ($filename_width - length($del_filename)),                           " ", $add_filename, "\n";                    if (($i+1) % 22 == 0)                      {                        unless (&get_answer("Continue printing (Y/n)? ",                                            'ny', 1))                          {                            last;                          }                      }                  }                # Get the feedback from the user.                my $line;                my $add_filename;                my $add_index;                my $del_filename;                my $del_index;                my $got_line = 0;                do {                  print "Enter two indexes for each column to rename, ",                        "(R)elist, or (F)inish: ";                  $line = <STDIN>;                  $line = '' unless defined $line;                  if ($line =~ /^R$/i )                    {                      goto RELIST;                    }                                    if ($line =~ /^F$/i)                    {                      $got_line = 1;                    }                  elsif ($line =~ /^(\d+)\s+(\d+)$/)                    {                      print "\n";                      $del_index = $1;                      $add_index = $2;                      if ($del_index >= @del_files)                        {                          print "Delete index $del_index is larger than ",                                "maximum index of ", scalar @del_files - 1,                                ".\n";                          $del_index = undef;                        }                      if ($add_index > @add_files)                        {                          print "Add index $add_index is larger than maximum ",                                "index of ", scalar @add_files - 1, ".\n";                          $add_index = undef;                        }                      $got_line = defined $del_index && defined $add_index;                      # Check that the file or directory to be renamed                      # has the same file type.                      if ($got_line)                        {                          $add_filename = $add_files[$add_index];                          $del_filename = $del_files[$del_index];                          if ($add_files{$add_filename}{type} ne                              $del_files{$del_filename}{type})                            {                              print "File types for $del_filename and ",                                    "$add_filename differ.\n";                              $got_line = undef;                            }                        }                    }                } until ($got_line);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -