显示标签为“SVN”的博文。显示所有博文
显示标签为“SVN”的博文。显示所有博文

2007年9月13日星期四

SVN::Notify

SVN::Notify Module Version: 2.66 Source

Name ^

SVN::Notify - Subversion activity notification

Synopsis ^

Use svnnotify in post-commit:

  svnnotify --repos-path "$1" --revision "$2" \
--to developers@example.com [options]

svnnotify --repos-path "$1" --revision "$2" \
--to-cx-regex i10n@example.com=I10N [options]

Use the class in a custom script:

  use SVN::Notify;

my $notifier = SVN::Notify->new(%params);
$notifier->prepare;
$notifier->execute;

Description ^

This class may be used for sending email messages for Subversion repository activity. There are a number of different modes supported, and SVN::Notify is fully subclassable to easily add new functionality. By default, A list of all the files affected by the commit will be assembled and listed in a single message. An additional option allows diffs to be calculated for the changes and either appended to the message or added as an attachment. See the with_diff and attach_diff options below.

Usage ^

To use SVN::Notify, simply add a call to svnnotify to your Subversion repository's post-commit script. This script lives at the root of the repository directory; consult the documentation in post-commit.tmpl for details. Make sure that you specify the complete path to svnnotify, as well as to svnlook and sendmail in the options passed to svnnotify so that everything executes properly.

Windows Usage

To get SVN::Notify to work properly in a post-commit script, you must set the following environment variables, as they will likley not be present inside Apache:

PATH=C:\perl\bin
OS=Windows_NT
SystemRoot=C:\WINDOWS

See http://svn.haxx.se/users/archive-2006-05/0593.shtml for more detailed information on getting SVN::Notify running on Windows. If you have issues with asynchronous execution, try using HookStart.exe (http://www.koders.com/csharp/fidE2724F44EF2D47F1C0FE76C538006435FA20051D.aspx) to run svnnotify.

Class Interface ^

Constructor

new

  my $notifier = SVN::Notify->new(%params);

Constructs and returns a new SVN::Notify object. This object is a handle on the whole process of collecting metadata and content for the commit email and then sending it. As such, it takes a number of parameters to affect that process.

Each of these parameters has a corresponding command-line option that can be passed to svnnotify. The options have the same names as these parameters, but any underscores you see here should be replaced with dashes when passed to svnnotify. Each also has a corresponding single-character option. All of these are documented here.

Supported parameters:

repos_path
  svnnotify --repos-path "$PATH"
svnnotify -p "$PATH"

The path to the Subversion repository. The path is passed as the first argument when Subversion executes post-commit. So you can simply pass $1 to this parameter if you like. See the documentation in post-commit for details. Required.

revision
  svnnotify --revision "$REV"
svnnotify -r "$REV"

The revision number for the current commit. The revision number is passed as the second argument when Subversion executes post-commit. So you can simply pass $2 to this parameter if you like. See the documentation in post-commit for details. Required.

to
  svnnotify --to commiters@example.com
svnnotify -t commiters@example.com --to managers@example.com

The address or addresses to which to send the notification email. Can be used multiple times to specify multiple addresses. This parameter is required unless either to_regex_map or to_email_map is specified.

to_regex_map
  svnnotify --to-regex-map translate@example.com=L18N \
-x legal@example.com=License

This parameter specifies a hash reference of email addresses to regular expression strings. SVN::Notify will compile the regular expression strings into regular expression objects, and then send notification messages if and only if the name of one or more of the directories affected by a commit matches the regular expression. This is a good way to have a notification email sent to a particular mail address (or comma-delimited list of addresses) only for certain parts of the subversion tree. This parameter is required unless to or to_email_map is specified.

The command-line options, --to-regex_map and -x, can be specified any number of times, once for each entry in the hash to be passed to new(). The value passed to the option must be in the form of the key and the value separated by an equal sign. Consult the Getopt::Long documentation for more information.

Here's an example complements of Matt Doar of how to use to_regex_map to do per-branch matching:

  author=`svnlook author $REPOS -r $REV`

# The mail regexes should match all the top-level directories
/usr/bin/svnnotify --repos-path "$REPOS" --revision "$REV" \
-x eng-bar@example.com,${EXTRAS}="^Bar" \
-x eng-foo@example.com,${EXTRAS}="^trunk/Foo|^branches/Foo|^tags/Foo" \
-x $author@example.com="^users" --subject-cx
to_email_map
  svnnotify --to-email-map L18N=translate@example.com \
--to-email-map License=legal@example.com

The inverse of to_regex_map: The regular expression is the hash key and the email address or addresses are the value.

from
  svnnotify --from somewhere@example.com
svnnotify -f elsewhere@example.com

The email address to use in the "From" line of the email. If not specified, SVN::Notify will use the username from the commit, as returned by svnlook info.

user_domain
  svnnotify --user-domain example.com
svnnotify -D example.net

A domain name to append to the username for the "From" header of the email. During a Subversion commit, the username returned by svnlook info is usually something like a Unix login name. SVN::Notify will use this username in the email "From" header unless the from parameter is specified. If you wish to have the username take the form of a real email address, specify a domain name and SVN::Notify will append \@$domain_name to the username in order to create a real email address. This can be useful if all of your committers have an email address that corresponds to their username at the domain specified by the user_domain parameter.

svnlook
  svnnotify --svnlook /path/to/svnlook
svnnotify -l /path/to/svnlook

The location of the svnlook executable. If not specified, SVN::Notify will search through the directories in the $PATH environment variable, plus in /usr/local/bin and /usr/sbin, for an svnlook executable. Specify a full path to svnlook via this option or by setting the $SVNLOOK environment variable if svnlook isn't in your path or to avoid loading File::Spec.

It's important to provide a complete path to svnlook because the environment during the execution of post-commit is anemic, with nary a $PATH environment variable to be found. So if svnnotify appears not to be working at all (and Subversion seems loathe to log when it dies!), make sure that you have specified the complete path to a working svnlook executable.

sendmail
  svnnotify --sendmail /path/to/sendmail
svnnotify -s /path/to/sendmail

The location of the sendmail executable. If neither the sendmail nor the smtp parameter is specified, SVN::Notify will search through the directories in the $PATH environment variable, plus in /usr/local/bin and /usr/sbin, for an sendmail executable. Specify a full path to sendmail via this option or by setting the $SENDMAIL environment variable if sendmail isn't in your path or to avoid loading File::Spec. The same caveats as applied to the location of the svnlook executable apply here.

set_sender
  svnnotify --set-sender
svnnotify -E

Uses the -f option to sendmail to set the envelope sender address of the email to the same address as is used for the "From" header. If you're also using the from option, be sure to make it only an email address. Don't include any other junk in it, like a sender's name. Ignored when using smtp.

smtp
  svnnotify --smtp smtp.example.com

The address for an SMTP server through which to send the notification email. If unspecified, SVN::Notify will use sendmail to send the message. If sendmail is not installed locally (such as on Windows boxes!), you must specify an SMTP server.

smtp_user
  svnnotify --smtp-user myuser

The user name for SMTP authentication. If this option is specified, SVN::Notify will use Net::SMTP_auth to send the notification message, and will of course authenticate to the SMTP server.

smtp_pass
  svnnotify --smtp-pass mypassword

The password for SMTP authentication. Use in parallel with smtp_user.

smtp_authtype
  svnnotify --smtp-authtype authtype

The authentication method to use for authenticating to the SMTP server. The available authentication types include "PLAIN", "NTLM", "CRAM_MD5", and others. Consult the Authen::SASL documentation for a complete list. Defaults to "PLAIN".

charset
  svnnotify --charset UTF-8
svnnotify -c Big5

The character set typically used on the repository for log messages, file names, and file contents. Used to specify the character set in the email Content-Type headers and, when the language paremeter is specified, the $LANG environment variable when launching sendmail. Defaults to "UTF-8".

io_layer
  svnnotify --io-layer raw
svnnotify -o bytes

The Perl IO layer to use for inputting and outputting data. See perlio for details. Defaults to "encoding($charset)". If your repository uses different character encodings, charset should be set to whatever is the most common character encoding, and io_layer is best set to raw, e.g., --io-layer raw --charset cp850. In that case, some characters might not look right in the commit messaage (because an email can manage only one character encoding at a time), but then svnnotify won't get stuck issuing a slew of warnings.

language
  svnnotify --language fr
svnnotify -g i-klingon

The language typically used on the repository for log messages, file names, and file contents. Used to specify the email Content-Language header and to set the $LANG environment variable to $notify->language . '.' . $notify->charset before executing sendmail. Undefined by default, meaning that no Content-Language header is output and the $LANG environment variable will not be set.

with_diff
  svnnotify --with-diff
svnnotify -d

A boolean value specifying whether or not to include the output of svnlook diff in the notification email. The diff will be inline at the end of the email unless the attach_diff parameter specifies a true value.

attach_diff
  svnnotify --attach-diff
svnnotify -a

A boolean value specifying whether or not to attach the output of svnlook diff to the notification email. Rather than being inline in the body of the email, this parameter causes SVN::Notify to attach the diff as a separate file, named for the user who triggered the commit and the date and time UTC at which the commit took place. Specifying this parameter to a true value implicitly sets the with_diff parameter to a true value.

diff_switches
  svnnotify --diff-switches '--no-diff-added'
svnnotify -w '--no-diff-deleted'

Switches to pass to svnlook diff, such as --no-diff-deleted and --no-diff-added. And who knows, maybe someday it will support the same options as svn diff, such as --diff-cmd and --extensions. Only relevant when used with with_diff or attach_diff.

reply_to
  svnnotify --reply-to devlist@example.com
svnnotify -R developers@example.net

The email address to use in the "Reply-To" header of the notification email. No "Reply-To" header will be added to the email if no value is specified for the reply_to parameter.

add_headers
  svnnotify --add-header X-Approve=letMeIn

Add a header to the notification email message. The header name and its value must be separated by an equals sign. Specify the option multiple times in order to add multiple headers. Headers with the same names are allowed. Not to be confused with the --header option, which adds introductory text to the beginning of the email body.

subject_prefix
  svnnotify --subject-prefix [Devlist]
svnnotify -P [%d (Our-Developers)]

An optional string to prepend to the beginning of the subject line of the notification email. If it contains '%d', it will be used to place the revision number; otherwise it will simply be prepended to the subject, which will contain the revision number in brackets.

subject_cx
  svnnotify --subject-cx
svnnotify -C

A boolean value indicating whether or not to include a the context of the commit in the subject line of the email. In a commit that affects multiple files, the context will be the name of the shortest directory affected by the commit. This should indicate up to how high up the Subversion repository tree the commit had an effect. If the commit affects a single file, then the context will simply be the name of that file.

strip_cx_regex
  svnnotify --strip-cx-regex '^trunk/'
svnnotify --strip-cx-regex '^trunk/' --strip-cx-regex '^branches/'
svnnotify -X '^trunk'
svnnotify -X '^trunk' -X '^branches'

One or more regular expressions to be used to strip out parts of the subject context. This can be useful for very deep Subversion trees, where the commits you're sending will always be sent from a particular subtree, so you'd like to remove part of the tree. Used only if subject_cx is set to a true value. Pass an array reference if calling new() directly.

no_first_line
  svnnotify --no-first-line
svnnotify -O

Omits the first line of the log message from the subject. This is most useful when used in combination with the subject_cx parameter, so that just the commit context is displayed in the subject and no part of the log message.

header
  svnnotify --header 'SVN::Notify is brought to you by Kineticode.

Adds a specified text to each message as a header at the beginning of the body of the message. Not to be confused with the --add-header option, which adds a header to the headers section of the email.

footer
  svnnotify --footer 'Copyright (R) by Kineticode, Inc.'

Adds a specified text to each message as a footer at the end of the body of the message.

max_sub_length
  svnnotify --max-sub-length 72
svnnotify -i 76

The maximum length of the notification email subject line. SVN::Notify includes the first line of the commit log message, or the first sentence of the message (defined as any text up to the string ". "), whichever is shorter. This could potentially be quite long. To prevent the subject from being over a certain number of characters, specify a maximum length here, and SVN::Notify will truncate the subject to the last word under that length.

max_diff_length
  svnnotify --max-diff-length 1024

The maximum length of the diff (attached or in the body). The diff output is truncated at the last line under the maximum character count specified and then outputs an additional line indicating that the maximum diff size was reached and output truncated. This is helpful when a large diff output could cause a message to bounce due to message size.

handler
  svnnotify --handler HTML
svnnotify -H HTML

Specify the subclass of SVN::Notify to be constructed and returned, and therefore to handle the notification. Of course you can just use a subclass directly, but this parameter is designed to make it easy to just use SVN::Notify->new without worrying about loading subclasses, such as in svnnotify. Be sure to read the documentation for your subclass of choice, as there may be additional parameters and existing parameters may behave differently.

author_url
  svnnotify --author-url 'http://svn.example.com/changelog/~author=%s/repos'
svnnotify --A 'mailto:%s@example.com'

If a URL is specified for this parameter, then it will be used to create a link for the current author. The URL can have the "%s" format where the author's username should be put into the URL.

revision_url
  svnnotify --revision-url 'http://svn.example.com/changelog/?cs=%s'
svnnotify -U 'http://svn.example.com/changelog/?cs=%s'

If a URL is specified for this parameter, then it will be used to create a link to the Subversion browser URL corresponding to the current revision number. It will also be used to create links to any other revision numbers mentioned in the commit message. The URL must have the "%s" format where the Subversion revision number should be put into the URL.

svnweb_url
  svnnotify --svnweb-url 'http://svn.example.com/index.cgi/revision/?rev=%s'
svnnotify -S 'http://svn.example.net/index.cgi/revision/?rev=%s'

Deprecated. Use revision_url instead.

viewcvs_url
  svnnotify --viewcvs-url 'http://svn.example.com/viewcvs/?rev=%s&view=rev'

Deprecated. Use revision_url instead.

ticket_map
  svnnotify --ticket-map '\[?#\s*(\d+)\s*\]?=http://example.com/ticket?id=%s' \
--ticket-map 'rt=http://rt.cpan.org/NoAuth/Bugs.html?id=%s' \
--ticket-map '\b([A-Z]+-\d+)\b=http://jira/browse/%s'

Specifies a mapping between a regular expression and a URL. The regular expression should return a single match to be interpolated into the URL, which should be a sprintf format using "%s" to place the match (usually the ticket identifier) from the regex. The command-line option may be specified any number of times for different ticketing systems. To the API, it must be passed as a hash reference.

The first example matches "[#1234]" or "#1234" or "[# 1234]". This regex should be as specific as possible, preferably wrapped in "\b" to match word boundaries. If you're using SVN::Notify::HTML, be sure to read its documentation for a different regular expression requirement!

Optionally, the key value can be a placeholder for a regular expession used internally by SVN::Notify to match strings typically used for well-known ticketing systems. Those keys are:

rt

Matches Request Tracker (RT) ticket references of the form "Ticket # 12", "ticket 6", "RT # 52", "rt 52", "RT-Ticket # 213" or even "Ticket#1066".

bugzilla

Matches Bugzilla bug references of the form "Bug # 12" or "bug 6" or even "Bug#1066".

jira

Matches JIRA references of the form "JRA-1234".

gnats

Matches GnatsWeb references of the form "PR 1234".

rt_url
  svnnotify --rt-url 'http://rt.cpan.org/NoAuth/Bugs.html?id=%s'
svnnotify -T 'http://rt.perl.org/NoAuth/Bugs.html?id=%s'

A shortcut for --ticket-map 'rt=$url' provided for backwards compatibility.

bugzilla_url
  svnnotify --bugzilla-url 'http://bugzilla.mozilla.org/show_bug.cgi?id=%s'
svnnotify -B 'http://bugs.bricolage.cc/show_bug.cgi?id=%s'

A shortcut for --ticket-map 'bugzilla=$url' provided for backwards compatibility.

jira_url
  svnnotify --jira-url 'http://jira.atlassian.com/secure/ViewIssue.jspa?key=%s'
svnnotify -J 'http://nagoya.apache.org/jira/secure/ViewIssue.jspa?key=%s'

A shortcut for --ticket-map 'jira=$url' provided for backwards compatibility.

gnats_url
  svnnotify --gnats-url 'http://gnatsweb.example.com/cgi-bin/gnatsweb.pl?cmd=view&pr=%s'
svnnotify -G 'http://gnatsweb.example.com/cgi-bin/gnatsweb.pl?cmd=view&pr=%s'

A shortcut for --ticket-map 'gnats=$url' provided for backwards compatibility.

ticket_url
  svnnotify --ticket-url 'http://ticket.example.com/showticket.html?id=%s'

Deprecated. Use ticket_map, instead.

ticket_regex
  svnnotify --ticket-regex '\[?#\s*(\d+)\s*\]?'

Deprecated. Use ticket_map, instead.

verbose
  svnnotify --verbose -V

A value between 0 and 3 specifying how verbose SVN::Notify should be. The default is 0, meaning that SVN::Notify will be silent. A value of 1 causes SVN::Notify to output some information about what it's doing, while 2 and 3 each cause greater verbosity. To set the verbosity on the command line, simply pass the --verbose or -V option once for each level of verbosity, up to three times. Output from SVN::Notify is sent to STDOUT.

boundary

The boundary to use between email body text and attachments. This is normally generated by SVN::Notify.

subject

The subject of the email to be sent. This attribute is normally generated by prepare_subject().

Class Methods

content_type

  my $content_type = SVN::Notify->content_type;

Returns the content type of the notification message, "text/plain". Used to set the Content-Type header for the message.

register_attributes

  SVN::Notify::Subclass->register_attributes(
foo_attr => 'foo-attr=s',
bar => 'bar',
bat => undef,
);

This class method is used by subclasses to register new attributes. Pass in a list of key/value pairs, where the keys are the attribute names and the values are option specifications in the format required by Getopt::Long. SVN::Notify will create accessors for each attribute, and if the corresponding value is defined, it will be used by the get_options() class method to get a command-line option value.

See for an example usage of register_attributes().

get_options

  my $options = SVN::Notify->get_options;

Parses the command-line options in @ARGV to a hash reference suitable for passing as the parameters to new(). See "new" for a complete list of the supported parameters and their corresponding command-line options.

This method use Getopt::Long to parse @ARGV. It then looks for a handler option and, if it finds one, loads the appropriate subclass and parsed any options it requires from @ARGV. Subclasses should use register_attributes() to register any attributes and options they require.

file_label_map

  my $map = SVN::Notify->file_label_map;

Returns a hash reference of the labels to be used for the lists of files. A hash reference of file lists is stored in the files attribute after prepare_files() has been called. The hash keys in that list correspond to Subversion status codes, and these are mapped to their appropriate labels by the hash reference returned by this method:

  { U => 'Modified Paths',
A => 'Added Paths',
D => 'Removed Paths',
_ => 'Property Changed'
}

find_exe

  my $exe = SVN::Notify->find_exe($exe_name);

This method searches through the system path, as well as the extra directories /usr/local/bin and /usr/sbin (because they're common paths for svnlook and sendmail for an executable file with the name $exe_name. The first one it finds is returned with its full path. If none is found, find_exe() returns undef.

Instance Interface ^

Instance Methods

prepare

  $notifier->prepare;

Prepares the SVN::Notify object, collecting all the data it needs in preparation for sending the notification email. Really it's just a shortcut for:

  $notifier->prepare_recipients;
$notifier->prepare_contents;
$notifier->prepare_files;
$notifier->prepare_subject;

Only it returns after the call to prepare_recipients() if there are no recipients (that is, as when recipients are specified solely by the to_regex_map or to_email_map parameter and none of the regular expressions match any of the affected directories).

prepare_recipients

  $notifier->prepare_recipients;

Collects and prepares a list of the notification recipients. The recipients are a combination of the value passed to the to parameter as well as any email addresses specified as keys in the hash reference passed to_regex_map parameter or values passed to the to_email_map parameter, where the corresponding regular expressions stored in the hash matches one or more of the names of the directories affected by the commit.

If the subject_cx parameter to new() has a true value, prepare_recipients() also determines the directory name to use for the context.

prepare_contents

  $notifier->prepare_contents;

Prepares the contents of the commit message, including the name of the user who triggered the commit (and therefore the contents of the "From" header to be used in the email) and the log message.

prepare_files

  $notifier->prepare_files;

Prepares the lists of files affected by the commit, sorting them into their categories: modified files, added files, and deleted files. It also compiles a list of files wherein a property was set, which might have some overlap with the list of modified files (if a single commit both modified a file and set a property on it).

If the subject_cx parameter was specified and a single file was affected by the commit, then prepare_files() will also specify that file name as the context to be used in the subject line of the commit email.

prepare_subject

  $notifier->prepare_subject;

Prepares the subject line for the notification email. This method must be called after prepare_recipients() and prepare_files(), since each of those methods potentially sets up the context for use in the the subject line. The subject may have a prefix defined by the subject_prefix parameter to new(), it has the revision number, it might have the context if the subject_cx specified a true value, and it will have the first sentence or line of the commit, whichever is shorter. The subject may then be truncated to the maximum length specified by the max_sub_length parameter.

execute

  $notifier->execute;

Sends the notification message. This involves opening a file handle to sendmail or a tied file handle connected to an SMTP server and passing it to output(). This is the main method used to send notifications or execute any other actions in response to Subversion activity.

output

  $notifier->output($file_handle);
$notifier->output($file_handle, $no_headers);

Called internally by execute() to output a complete email message. The file a file handle, so that output() and its related methods can print directly to the email message. The optional second argument, if true, will suppress the output of the email headers.

Really output() is a simple wrapper around a number of other method calls. It is thus essentially a shortcut for:

    $notifier->output_headers($out) unless $no_headers;
$notifier->output_content_type($out);
$notifier->start_body($out);
$notifier->output_metadata($out);
$notifier->output_log_message($out);
$notifier->output_file_lists($out);
if ($notifier->with_diff) {
my $diff_handle = $self->diff_handle;
if ($notifier->attach_diff) {
$notifier->end_body($out);
$notifier->output_attached_diff($out, $diff_handle);
} else {
$notifier->output_diff($out, $diff_handle);
$notifier->end_body($out);
}
} else {
$notifier->end_body($out);
}
$notifier->end_message($out);

output_headers

  $notifier->output_headers($file_handle);

Outputs the headers for the notification message headers. Should be called only once for a single email message.

output_content_type

  $notifier->output_content_type($file_handle);

Outputs the content type and transfer encoding headers. These demarcate the body of the message. If the attach_diff parameter was set to true, then a boundary string will be generated and the Content-Type set to "multipart/mixed" and stored as the boundary attribute.

Arter that, this method outputs the content type returned by content_type(), the character set specified by the charset attribute, and a Content-Transfer-Encoding of "8bit". Subclasses can either rely on this functionality or override this method to provide their own content type headers.

start_body

  $notifier->start_body($file_handle);

This method starts the body of the notification message, which means that it outputs the contents of the header attribute, if there are any. Otherwise it outputs nothing, but see subclasses for other behaviors.

output_metadata

  $notifier->output_metadata($file_handle);

This method outputs the metadata of the commit, including the revision number, author (user), and date of the revision. If the author_url or revision_url attributes have been set, then the appropriate URL(s) for the revision will also be output.

output_log_message

  $notifier->output_log_message($file_handle);

Outputs the commit log message, as well as the label "Log Message".

run_ticket_map

  $notifier->run_ticket_map( \&callback, @params );

Loops over the ticket systems you have defined, calling the $callback function for each one, pasing to it the regex, url and @params specified as its parameters.

output_file_lists

  $notifier->output_file_lists($file_handle);

Outputs the lists of modified, added, and deleted files, as well as the list of files for which properties were changed. The labels used for each group are pulled in from the file_label_map() class method.

end_body

  $notifier->end_body($file_handle);

Closes out the body of the email by outtputing the contents of the footer attribute, if any, and then a couple of newlines. Designed to be called when the body of the message is complete, and before any call to output_attached_diff().

output_diff

  $notifier->output_diff($out_file_handle, $diff_file_handle);

Reads diff data from $diff_file_handle and outputs it to to $out_file_handle.

output_attached_diff

  $notifier->output_attached_diff($out_file_handle, $diff_file_handle);

Reads diff data from $diff_file_handle and outputs it to to $out_file_handle as an attachment.

end_message

  $notifier->end_message($file_handle);

Outputs the final part of the message,. In this case, that means only a boundary if the attach_diff parameter is true. Designed to be called after any call to output_attached_diff().

diff_handle

  my $diff = $notifier->diff_handle;
while (<$diff>) { print }

Returns a file handle reference providing access to the the commit diff. It will usually be passed as the second argument to output_diff() or output_attached_diff().

Accessors

repos_path

  my $repos_path = $notifier->repos_path;
$notifier = $notifier->repos_path($repos_path);

Gets or sets the value of the repos_path attribute.

revision

  my $revision = $notifier->revision;
$notifier = $notifier->revision($revision);

Gets or sets the value of the revision attribute.

to

  my $to = $notifier->to;
$notifier = $notifier->to($to);
my @tos = $notifier->to;
$notifier = $notifier->to(@tos);

Gets or sets the list of values stored in the to attribute. In a scalar context, it returns only the first value in the list, for backards compatibility with older versions of SVN::Notify. In list context, it of course returns the entire list. Pass in one or more values to set all of the values for the to attribute.

to_regex_map

  my $to_regex_map = $notifier->to_regex_map;
$notifier = $notifier->to_regex_map($to_regex_map);

Gets or sets the value of the to_regex_map attribute, which is a hash reference of email addresses mapped to regular expressions.

to_email_map

  my $to_email_map = $notifier->to_email_map;
$notifier = $notifier->to_email_map($to_email_map);

Gets or sets the value of the to_email_map attribute, which is a hash reference of regular expressions mapped to email addresses.

from

  my $from = $notifier->from;
$notifier = $notifier->from($from);

Gets or sets the value of the from attribute.

user_domain

  my $user_domain = $notifier->user_domain;
$notifier = $notifier->user_domain($user_domain);

Gets or sets the value of the user_domain attribute.

svnlook

  my $svnlook = $notifier->svnlook;
$notifier = $notifier->svnlook($svnlook);

Gets or sets the value of the svnlook attribute.

sendmail

  my $sendmail = $notifier->sendmail;
$notifier = $notifier->sendmail($sendmail);

Gets or sets the value of the sendmail attribute.

set_sender

  my $set_sender = $notifier->set_sender;
$notifier = $notifier->set_sender($set_sender);

Gets or sets the value of the set_sender attribute.

smtp

  my $smtp = $notifier->smtp;
$notifier = $notifier->smtp($smtp);

Gets or sets the value of the smtp attribute.

charset

  my $charset = $notifier->charset;
$notifier = $notifier->charset($charset);

Gets or sets the value of the charset attribute.

io_layer

  my $io_layer = $notifier->io_layer;
$notifier = $notifier->io_layer($io_layer);

Gets or sets the value of the io_layer attribute.

language

  my $language = $notifier->language;
$notifier = $notifier->language($language);

Gets or sets the value of the language attribute.

with_diff

  my $with_diff = $notifier->with_diff;
$notifier = $notifier->with_diff($with_diff);

Gets or sets the value of the with_diff attribute.

attach_diff

  my $attach_diff = $notifier->attach_diff;
$notifier = $notifier->attach_diff($attach_diff);

Gets or sets the value of the attach_diff attribute.

diff_switches

  my $diff_switches = $notifier->diff_switches;
$notifier = $notifier->diff_switches($diff_switches);

Gets or sets the value of the diff_switches attribute.

reply_to

  my $reply_to = $notifier->reply_to;
$notifier = $notifier->reply_to($reply_to);

Gets or sets the value of the reply_to attribute.

add_headers

  my $add_headers = $notifier->add_headers;
$notifier = $notifier->add_headers({
'X-Accept' => [qw(This That)],
'X-Reject' => 'Me!',
});

Gets or sets the value of the add_headers attribute, which is a hash reference of the headers to be added to the email message. If one header needs to appear multiple times, simply pass the corresponding hash value as an array reference of each value for the header. Not to be confused with the header accessor, which gets and sets text to be included at the beginning of the body of the email message.

subject_prefix

  my $subject_prefix = $notifier->subject_prefix;
$notifier = $notifier->subject_prefix($subject_prefix);

Gets or sets the value of the subject_prefix attribute.

subject_cx

  my $subject_cx = $notifier->subject_cx;
$notifier = $notifier->subject_cx($subject_cx);

Gets or sets the value of the subject_cx attribute.

strip_cx_regex

  my $strip_cx_regex = $notifier->strip_cx_regex;
$notifier = $notifier->strip_cx_regex($strip_cx_regex);
my @strip_cx_regexs = $notifier->strip_cx_regex;
$notifier = $notifier->strip_cx_regex(@strip_cx_regexs);

Gets or sets the list of values stored in the strip_cx_regex attribute. In a scalar context, it returns only the first value in the list; in list context, it of course returns the entire list. Pass in one or more values to set all of the values for the strip_cx_regex attribute.

max_sub_length

  my $max_sub_length = $notifier->max_sub_length;
$notifier = $notifier->max_sub_length($max_sub_length);

Gets or sets the value of the max_sub_length attribute.

max_diff_length

  my $max_diff_length = $notifier->max_diff_length;
$notifier = $notifier->max_diff_length($max_diff_length);

Gets or set the value of the max_diff_length attribute.

author_url

  my $author_url = $notifier->author_url;
$notifier = $notifier->author_url($author_url);

Gets or sets the value of the author_url attribute.

revision_url

  my $revision_url = $notifier->revision_url;
$notifier = $notifier->revision_url($revision_url);

Gets or sets the value of the revision_url attribute.

svnweb_url

Deprecated. Pleas use revision_url(), instead.

viewcvs_url

Deprecated. Pleas use revision_url(), instead.

verbose

  my $verbose = $notifier->verbose;
$notifier = $notifier->verbose($verbose);

Gets or sets the value of the verbose attribute.

bondary

  my $bondary = $notifier->bondary;
$notifier = $notifier->bondary($bondary);

Gets or sets the value of the bondary attribute. This string is normally set by a call to output_headers(), but may be set ahead of time.

user

  my $user = $notifier->user;
$notifier = $notifier->user($user);

Gets or sets the value of the user attribute, which is set to the value pulled in from svnlook by the call to prepare_contents().

date

  my $date = $notifier->date;
$notifier = $notifier->date($date);

Gets or sets the value of the date attribute, which is set to the value pulled in from svnlook by the call to prepare_contents().

message

  my $message = $notifier->message;
$notifier = $notifier->message($message);

Gets or sets the value of the message attribute, which is set to an array reference of strings by the call to prepare_contents().

message_size

  my $message_size = $notifier->message_size;
$notifier = $notifier->message_size($message_size);

Gets or sets the value of the message_size attribute, which is set to the value pulled in from svnlook by the call to prepare_contents().

subject

  my $subject = $notifier->subject;
$notifier = $notifier->subject($subject);

Gets or sets the value of the subject attribute, which is normally set by a call to prepare_subject(), but may be set explicitly.

files

  my $files = $notifier->files;
$notifier = $notifier->files($files);

Gets or sets the value of the files attribute, which is set to a hash reference of change type mapped to arrays of strings by the call to prepare_files().

header

  my $header = $notifier->header;
$notifier = $notifier->header($header);

Gets or set the value of the header attribute. Not to be confused with the add_headers attribute, which manages headers to be inserted into the notification email message headers.

footer

  my $footer = $notifier->footer;
$notifier = $notifier->footer($footer);

Gets or set the value of the footer attribute.

See Also ^

SVN::Notify::HTML
SVN::Notify::HTML::ColorDiff

Subclasses SVN::Notify.

https://sourceforge.net/docs/E09#svn_notify

SourceForge.net support for SVN::Notify.

http://svn.haxx.se/users/archive-2006-05/0593.shtml

Tutorial for installing Apache, Subversion, and SVN::Notify on Windows.

Bugs ^

Please send bug reports to .

Author ^

David Wheeler

Copyright and License ^

Copyright (c) 2004-2007 Kineticode, Inc. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2007年9月12日星期三

从CVS迁移到SVN

从CVS迁移到SVN

前篇文章介绍使用CVS2SVN软件进行转换,转换效果不是特别理想,今天看了下面一篇文章,使用SVN-Importer这种方法.感觉不错,先试用一下.
最近想把公司原来用CVS管理的代码迁移到SVN中去。主要是因为SVN是整个版本库共享一个版本历史,比较方便完整的Checkout某个工程。而且SVN还有一些CVS所不具有的良好特性,比如支持对目录版本进行管理,支持重命名和移动等。
  
   上网查了下,大部分人用cvs2svn来将CVS版本库迁移到SVN中。但是cvs2svn似乎要用Python来运行,我向来对这个日本人发明的脚本 不感兴趣,所以希望能找到其它方案。最后发现SVN Importer。SVN Importer不仅可以进行CVS版本库到SVN版本库的迁移,而且还可以迁移PVCS、VSS、ClearCase、MKS、StarTeam等 VCS(Version Control System,版本管理系统)的版本库到SVN。
  大家去Subversion主页的时候,通常都是直接去的www.subversion.org(subversion.tigris.org)。其实Subversion还有另一个主页www.subversion.com。. COM站我去得少,却没想到一进去最明显的那个位置就是SVN Importer。这个工具是用Java实现的,需要JRE来运行。而且,由于SVN Importer几乎都是使用源VCS自带的命令行工具来导出数据,所以需要安装源VCS。另外,SVN Importer向SVN导入数据的时候,用的是Subversion的svnadmin,所以还需要安装Subversion。
  SVN Importer有两种方案来迁移CVS的版本库。
  1. 使用SVN Importer内置的Java CVS通过pserver协议来导出数据;
  2. 使用RCS直接从CVS版本库文件系统中导出数据。
  数据迁移过程分三步。和其它工具类似,都是读数据、生成DUMP、导入DUMP。整个过程及参数配置都在文档里写得比较详细。文档目前只有英文的,不过目前Subversion中文站(www.subversion.org.cn)正在翻译SVN Importer的文档,相信中文文档不久就会面世。顺便打个广告——请有兴趣翻译的朋友与subversion.org.cn站长联系(http://www.subversion.org.cn/index.php?option=com_contact&Itemid=3),申请加入翻译队伍。
  中文文档出台之前,总不能就不用SVN Importer吧,所以我就根据个人经验简单的介绍下吧。
   SVN Importer的安装和运行很简单。下载之后解压到某个目录即完成安装。安装目录下有一个run.bat文件。运行run.bat的时候要带2-3个参 数。第一个参数是操作模式;第二个参数是配置文件;第三个参数指定一个日期,表示仅迁移这个日期之后的数据。
  SVN Importer有3种操作模式:完整、增量和列表。完整模式用于将源VCS的版本库数据全部导出;增量模式则用在第一次的完整模式之后,导出新增加的数据;列表模式只将要导出的数据显示出来,不实际导出。
  至于配置文件,在安装目录下已经有一个config.properties作为示例。使用SVN Importer的时候只需要复制一份这个文件,再稍做修改即可。
  配置文件中主要分四个部分:
  第一部分,常规配置,这里选择源版本库,设置临时目录,以及中间文件的位置等。重要的一些设置如下:
  srcprovider=源VCS,可以是cvs、cvsrcs、pvcs、vss、cc、mks等
  import_dump_into_svn=yes或no,是否在生成DUMP文件之后立即导入SVN中(选否则不导入)
  full.dump.file=完整模式时生成的DUMP文件路径
  incr.dump.file=增量模式时生成的DUMP文件路径
  incr.history.file=历史文件路径,这个文件在第一次完整模式时生成,以后使用增量模式时需要读取其内容。
  第二部分是SVN相关的设置,主要包括svnadmin的位置和版本库中的一些设置。关键设置如下:
  trunk_path=/trunk,主分支所在目录
  branches_path=/branches,分支目录
  tags_path=/tags,标签保存目录
  svnimporter_user_name=SvnImporter,创建版本库的用户名
  svnadmin.executable=svnadmin的路径
  svnadmin.repository_path=产生的SVN版本库路径
  svnadmin.parent_dir=将数据导入版本库里的哪们目录。想设置为根目录,将这个值设置为.(点号)即可;或者可以设置成工程名。trunk、branches和tags都会产生在这个目录之下。
第三部分是对所选择的源VCS进行配置,用于导出数据。因为工作中只是为了迁移CVS的数据,所以只用到了导出CVS的两种配置。稍后说明。
  第四部分是对日志文件的一些配置。
   第一次是直接使用的srcprovider=cvs,通过pserver来导出数据。想对于cvsrcs来说,这个速度要稍慢一些,但是它不需要安装第 三方的工具,只需要使用内置的Java CVS就行,所以用来导出小项目还是比较好的。而且配置也比较简单,主要就是CVSROOT中的一些配置。
  cvs.class=org.polarion.svnimporter.cvsprovider.CvsProvider
  cvs.username=访问CVS版本库的用户名
  cvs.password=上面用户名登录CVS版本库时的密码
  cvs.hostname=主机地址
  cvs.repository=CVSROOT目录
  cvs.modulename=要导出的工程(或目录)
  cvs.tempdir=存放临时文件的目录
  后来考虑到CVS里面的工程都比较大,而且可能需要直接从版本库文件导出数据(不是通过客户端去访问CVS版本库,而直接访问版库的文件),所以又尝试了使用srcprovider=cvsrcs。这个情况下要用GNU RCS来导出CVS数据,所以需要安装RCS(http://www.gnu.org/software/rcs/rcs.html)。
   RCS目前最新是5.7版,分3个包下载,分别是rcs57pc1、rcs57pc2和rcs57pc3。这3个文件包分别是编译好的二进制文件、文档 和源码。其实只需要下载第一个包就行了,需要用到的也只是bin目录下的rlog和co两个命令而已。相关配置大概有:
  cvsrcs.class=org.polarion.svnimporter.cvsprovider.CvsRcsProvider
  cvsrcs.repository_path=CVS版库文件目录
  cvsrcs.rlog_command=rlog命令的路径
  cvsrcs.co_command=co命令的路径
  cvsrcs.tempdir=保存临时文件的目录
  配置好之后,一开始每次运行都失败,看日志也不知所云。大概是说某个文件没找到。于是决定手工运行rlog.exe来试试看。
  rlog.exe cvsroot\common\common.sln,v
  结果报错
  rlog: cvsroot\common\RCS/common.sln,v: No such file or directory
  很奇怪,为什么rlog非要塞一个RCS/目录进去呢?后来在论坛上查到,使用cvsrcs的时候,需要设置环境变量RCSINIT=-x,v/,虽然看不明白是啥意思,不过设置了这个环境变量之后SVN Importer跑成功了。
   为了搞明白这个设置,所以只好去下载了RCS的文档来查看。在文档里搜索-x,v/,发现原来是配置RCS处理的文件后缀。未设置的情况下会去RCS子 目录中查找文件。-x是设置后缀的参数,v是CVS版本库文件的后缀,而/是分隔符,其后没有东西表示为空。所以这个设置是兼顾,v文件和RCS/两种情 况。
  最后,由于CVS不能记录目录的更改历史,最后导入到SVN后,从HEAD里取出来的数据中有许多原来删除掉的目录和文件。感觉多冒出来 的那些都应该是些空目录才对,搞不明白为什么还有一些删除掉的文件也冒出来了,还不太好找规律。所以,只好先对照从CVS里Checkout出来的最新 版,删除掉多余的目录和文件之后,再Checkin到SVN中,这才算完成迁移过程。

Tags: svn

Subversion备份

Subversion备份

如有转发请注明出处:http://www.subversion.org.cn/index.php?option=com_content&task=view&id=85&Itemid=9

版本控制最关键的一件事是保证数据的安全性,不能因为磁盘损坏,程序故障造成版本库无可挽回的错误,为此必须制定较完备的备份策略。在Subversion中,我们有三种备份方式:完全备份,增量备份和同步版本库。

1, 完全备份
最 常见和简单的备份就是直接使用拷贝命令,将版本库目录拷贝到备份目录上,就可以了。但是这样不是很安全的方式,因为如果在拷贝时版本库发生变化,将会造成 备份的结果不够准确,失去备份的作用,为此Subversion提供了“svnadmin hotcopy”命令,可以防止这种问题。
还记得我们的版本库目录吗?

D:\SVNROOT
├─project1
│ ├─conf
│ ├─dav
│ ├─db
│ │ ├─revprops
│ │ ├─revs
│ │ └─transactions
│ ├─hooks
│ └─locks
└─project2
├─conf
├─dav
├─db
│ ├─revprops
│ ├─revs
│ └─transactions
├─hooks
└─locks


如果要把project1备份到d:\svnrootbak目录下,只需要运行:
svnadmin hotcopy d:\svnroot\project1 d:\svnrootbak\project1
但是我们作为配置管理员,必须想办法优化这个过程,如果我们这个目录下有许多版本库,需要为每个版本库写这样一条语句备份,为此我写了下面的脚本,实现备份一个目录下的所有版本库。我们在D:\SVNROOT下创建了两个文件,simpleBackup.bat:
@echo 正在备份版本库%1......
@%SVN_HOME%\bin\svnadmin hotcopy %1 %BACKUP_DIRECTORY%\%2
@echo 版本库%1成功备份到了%2!
这个文件仅仅是对“svnadmin hotcopy”的包装,然后是backup.bat:
echo off
rem Subversion的安装目录
set SVN_HOME="D:\Subversion"
rem 所有版本库的父目录
set SVN_ROOT=D:\svnroot
rem 备份的目录
set BACKUP_SVN_ROOT=D:\svnrootbak
set BACKUP_DIRECTORY=%BACKUP_SVN_ROOT%\%date:~0,10%
if exist %BACKUP_DIRECTORY% goto checkBack
echo 建立备份目录%BACKUP_DIRECTORY%>>%SVN_ROOT%/backup.log
mkdir %BACKUP_DIRECTORY%
rem 验证目录是否为版本库,如果是则取出名称备份
for /r %SVN_ROOT% %%I in (.) do @if exist "%%I\conf\svnserve.conf" %SVN_ROOT%\simpleBackup.bat "%%~fI" %%~nI
goto end
:checkBack
echo 备份目录%BACKUP_DIRECTORY%已经存在,请清空。
goto end
:end
你 在使用的时候,只需要修改backup.bat开头的三个路径,将两个脚本拷贝到“SVN_ROOT”下就可以了。根据以上的配置,你只需要运行 backup.bat,就可以把“SVN_ROOT”下的版本库都备份到“BACKUP_SVN_ROOT”里,并且存放在备份所在日的目录里,例如 “D:\svnrootbak\2006-10-22”。
虽然这部分工作很简单,可是必须有人定时地去执行这个操作(例如每周一凌晨),为了避免发生遗忘的情况,我们可以将这个操作加入到系统的at任务当中去,例如还是上面的环境,为了安装at任务,我们运行:
[pre]at 1:00 /every:M D:\svnroot\backup.bat[/pre]
这样在每周一凌晨1:00都会执行这个备份过程。当然备份在本机也是不安全的,你也许需要上传到别的机器,这个就要靠你自己去实现了。

2, 增量备份尽管完全备份非常简单,但是也是有代价的,当版本库非常巨大时,经常进行完全备份是不现实的,也并不必要,但是一旦版本库在备份之间发生问题,该如何呢,这里我们就用到了增量备份。
增量备份通常要与完全备份结合使用,就像oracle数据库的归档日志,记录着每次Subversion提交的变化,然后在需要恢复时能够回到最新的可用状态。在我们这个例子中我们使用的是,svnadmin dump命令进行增量的备份,使用方法是:
svnadmin dump project1 --revision 15 --incremental > dumpfile2
上面的命令实现了对修订版本15进行增量的备份,其中的输出文件dumpfile2只保存了修订版本15更改的内容。
为了记录每次提交的结果,我们需要使用一项Subversion的特性--钩子(hook),看看我们的project1目录:
├─project1
│ ├─conf
│ ├─dav
│ ├─db
│ │ ├─revprops
│ │ ├─revs
│ │ └─transactions
│ ├─hooks
│ └─locks
其中的hooks目录里存放的就是钩子脚本,我们在此处只使用post-commit钩子,这个钩子会在每次提交之后执行,为了实现我们的备份功能,我们在hooks下建立一个文件post-commit.bat,内容如下:
echo off
set SVN_HOME="C:\Program Files\Subversion"
set SVN_ROOT=D:\svnroot
set UNIX_SVN_ROOT=D:/svnroot
set DELTA_BACKUP_SVN_ROOT=D:\svnrootbak\deltaset LOG_FILE=%1\backup.log
echo backup revision %2 >> %LOG_FILE%for /r %SVN_ROOT% %%I in (.) do if D:/svnroot/%%~nI == %1 %SVN_ROOT%\%%~nI\hooks\deltaBackup.bat %%~nI %2
goto end:end
通过这个脚本,可以实现D:\svnroot下的版本库提交时自动增量备份到D:\svnrootbak\delta(确定这个目录存在),其中使用的deltaBackup.bat其实可以放在任何地方,只是对脚本的svnadmin dump的包装,内容如下:
@echo 正在备份版本库%2......
%SVN_HOME%\bin\svnadmin dump %SVN_ROOT%\%1 --incremental --revision %2 >> %DELTA_BACKUP_SVN_ROOT%\%1.dump
@echo 版本库%2成功备份到了%3!
以上两个脚本可以直接拷贝到project2的hooks目录下,不需要修改就可以实现project2的自动备份。
以上的操作已经OK了,现在需要做的是将完全备份和增量备份结合起来,也就是在完全备份后清理增量备份的结果,使之只保存完全备份后的结果。
当果真出现版本库的故障,就要求我们实现版本库的恢复操作了,这是用要使用svnadmin load命令,同时也需要上次的完全备份例如要把上次完全备份backuprepo,和之后的增量备份dumpfile:
svnadmin load backuprepo < dumpfile
最后的结果,可以下载svnroot.rar,将之解压缩到d:\下,然后修改几个bat文件的SVN_HOME就可以使用了。
3, 版本库同步
Subversion 1.4增加了同步机制,可以实现一个版本库同另一个版本库的同步(但好像只是单向的),我们可以用来实现版本库的备份或镜像。
3.1. 对目标库初始化
[pre]svnsync init svn://localhost/project2 svn://localhost/project1 [/pre]
其中project2是目标的版本库,而project1是源版本库。其中的目标版本库必须为空,而且必须允许修订版本属性的修改,也就是在目标的版本库的hooks目录里添加一个文件pre-revprop-change.bat,内容为空即可。
3.2. 同步project2到project1
[pre]svnsync sync svn://localhost/project2 [/pre]
这 时候你update一下你的project2的一个工作拷贝,就会发现有了project1的所有内容。如果project1又有提交,这时候 project2的版本库无法看到最新的变化,还需要再运行一遍sync操作,这样才能将最新的变化同步。需要注意的是,目标版本库只能做成只读的,如果 目标版本库发生了变更,则无法继续同步了。
3.3. 同步历史属性的修改
因为同步不会更新对历史属性的修改,所以svnsync还有子命令copy-revprops,可以同步某个版本的属性。
3.4. 钩子自动同步
希望在每次提交时同步,则需要在源版本库增加post-commit脚本,内容如下:
[pre]echo offset SVN_HOME="D:\Subversion"%SVN_HOME%\bin\svnsync sync --non-interactive svn://localhost/project2 [/pre]
把以上内容存放为post-commit.bat,然后放到版本库project1下的hooks目录下,这样project1每次提交,都会引起project2的同步。
Tags: SVN 备份

2007年9月11日星期二

[翻译]压缩Subversion备份【English Version】

[翻译]压缩Subversion备份English Version

原文来自Compact Subversion Backups

如果你有一个较大的Subsersion版本库而你又想用最少的空间来将它备份下来,用这个命令(请将/repo替换成你的版本库路径)吧:

svnadmin dump --deltas /repo |bzip2 |tee dump.bz2 | md5sum >dump.md5

分步解释:

  1. 最重要的一步是 -deltas,将消耗更多的CPU资源,但拥有更有效的差异存储办法。
  2. bzip2压缩方案比gzip慢,但换来的更好的压缩率。
  3. 更有趣的是,tee方法将压缩的数据流转向到文件dump.bz2,同时将其输出到标准输出,后者有转向给了MD5摘要计算工具。

要恢复这个版本库,检查校验值(md5sum创建的),创建一个空的版本库,恢复备份:

md5sum -c dump.md5 <dump.bz2
svnadmin create newrepo
bzcat dump.bz2 | svnadmin load newrepo
请享受压缩后用MD5校验的备份吧,最后别忘记将dump.md5和dump.bz2存储到真正安全的地方!

2007年9月10日星期一

[浩南艰辛原创]Apache 2.2 + SVN 1.44 + Trac 0.10.4 安装全过程

  早就对从网页上访问SVN垂涎已久,更对bug追踪想入非非好多年~~~
  今天,终于告一个段落了,能够较好的工作和高亮语法显示。如同大多数网上文章所言,安装正确版本的软件,就是成功的一半。
  这里需要以下软件:
  SVN
  svn-1.4.4-setup.exe
  TortoiseSVN-1.4.4.9706-win32-svn-1.4.4.msi
  LanguagePack-1.4.4.9706-win32-zh_CN.exe
  SVNService.exe
  
  Apache
  apache_2.2.4-win32-x86-no_ssl.msi
  
  Trac
  trac-0.10.4.win32.exe
  
  但是这些软件仅仅是冰山一角。。。需要依赖的软件太多了。。。
  
  Python 系列
  python-2.4.msi
  clearsilver-0.9.14.win32-py2.4.exe
  SilverCity-0.9.7.win32-py2.4.exe 语法高亮显示必备!!
  pywin32-210.win32-py2.4.exe
  svn-python-1.4.3.win32-py2.4.exe
  pysqlite-2.3.2.win32-py2.4.exe
  mod_python-3.3.0b.win32-py2.4-Apache2.2.exe
  
  神啊,光看着就很头痛了。为了语法高亮,还要安装:
  enscript-1.6.3-9-bin.zip
  libintl-0.14.4-bin.zip
  libiconv-1.9.2-1-bin.zip
  
  一个极为严重的问题是,SVN使用的APR版本与Apache2.2使用的APR版本不一致,SVN的mod_authz_svn和mod_dav_svn 在apache中加载失败。感谢网络上大牛提供自己编译的两个so动态库文件,详细信息见Subversion 1.3 mod_dav_svn for Apache 2.2。这里就需要相关的如下文件:
  mod_authz_svn.zip
  mod_dav_svn.zip
  libapr.zip
  libhttpd.zip
  
  把这些对应的文件覆盖掉原来的文件即可。
  
  其他的东西基本就遵循网上的了 :)

apache svn+trac 配置

贡丸 @ 2007-02-17 02:33

1. 软件:
a) silvercity: SilverCity-0.9.7.win32-py2.4.exe
b) enscript: enscript-1.6.3-9-bin.exe
c) clearsilver: clearsilver-0.9.14.win32-py2.4.exe
d) pysqlite: pysqlite-2.3.3.win32-py2.4.exe

2. 配置:
a) cmd到Reposity/svn目录,
svnadmin create projectname
创建一个repository. 或者直接用TortoiseSVN之类的东西创建也可以. 然后就可以import代码上去了, 按照先前的配置, 代码位置在: http://localhost/svn/projectname
b) 把上面四个东西先装完, cmd到Reposity/trac目录下,
python trac-admin D:\WebServer\Repository\trac\projectname initenv
创建一个repository, 按如下输入:
Project Name [My Project]> New Project (reposity 名字)
Database connection string [sqlite:db/trac.db]> (回车使用默认值)
Repository type [svn]> (回车, 用的就是这个)
Path to repository [/path/to/repos]> D:\Repository\svn\projectname (svn repository目录, 注意是svn的)
Templates directory [D:\Appserv\python\share\trac\templates]> (回车使用默认值)
c) cmd到$python\Scripts目录,
python trac-admin D:\WebServer\Repository\trac\projectname permission add admin TRAC_ADMIN
把之前的admin设置成管理员.
d) 装了silvercity应该就能显示语法了, 但是很多还是不行, 调用enscript, $projectname$\conf\trac.ini, 找到:
enscript_path = enscript
改成完整路径即可.
e) plugins设置:
打开$projectname$\conf\trac.ini文件, 加入如下内容到最下面:
[account-manager]
password_file = D:\WebServer\Repository\project-users.db
password_store = HtPasswdStore
[components]
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.accountmanager = enabled
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.web_ui.accountmodule = enabled
acct_mgr.web_ui.loginmodule = enabled
acct_mgr.web_ui.registrationmodule = enabled
trac.web.auth.loginmodule = enabled
iniadmin.iniadmin.iniadminplugin = enabled
webadmin.* = enabled
这样就能使用admin所有的功能了.

本文参考了这篇文章.

apache svn+trac 配置

贡丸 @ 2007-02-17 02:33

1. 软件:
a) silvercity: SilverCity-0.9.7.win32-py2.4.exe
b) enscript: enscript-1.6.3-9-bin.exe
c) clearsilver: clearsilver-0.9.14.win32-py2.4.exe
d) pysqlite: pysqlite-2.3.3.win32-py2.4.exe

2. 配置:
a) cmd到Reposity/svn目录,
svnadmin create projectname
创建一个repository. 或者直接用TortoiseSVN之类的东西创建也可以. 然后就可以import代码上去了, 按照先前的配置, 代码位置在: http://localhost/svn/projectname
b) 把上面四个东西先装完, cmd到Reposity/trac目录下,
python trac-admin D:\WebServer\Repository\trac\projectname initenv
创建一个repository, 按如下输入:
Project Name [My Project]> New Project (reposity 名字)
Database connection string [sqlite:db/trac.db]> (回车使用默认值)
Repository type [svn]> (回车, 用的就是这个)
Path to repository [/path/to/repos]> D:\Repository\svn\projectname (svn repository目录, 注意是svn的)
Templates directory [D:\Appserv\python\share\trac\templates]> (回车使用默认值)
c) cmd到$python\Scripts目录,
python trac-admin D:\WebServer\Repository\trac\projectname permission add admin TRAC_ADMIN
把之前的admin设置成管理员.
d) 装了silvercity应该就能显示语法了, 但是很多还是不行, 调用enscript, $projectname$\conf\trac.ini, 找到:
enscript_path = enscript
改成完整路径即可.
e) plugins设置:
打开$projectname$\conf\trac.ini文件, 加入如下内容到最下面:
[account-manager]
password_file = D:\WebServer\Repository\project-users.db
password_store = HtPasswdStore
[components]
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.accountmanager = enabled
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.web_ui.accountmodule = enabled
acct_mgr.web_ui.loginmodule = enabled
acct_mgr.web_ui.registrationmodule = enabled
trac.web.auth.loginmodule = enabled
iniadmin.iniadmin.iniadminplugin = enabled
webadmin.* = enabled
这样就能使用admin所有的功能了.

本文参考了这篇文章.

SVN Web Client中文修订版下载

SVN Web Client中文修订版下载

  SVN Web Client是Subversion(当前最流行的版本控件软件之一)的Web客户端软件。虽然Subversion已有很好的桌面客户端软件TortoiseSVN,但是,为了适应不同项目参与者的需求,Web客户端还是有它“不用安装”和“网络共享”的优点。而且SVN Web Client也是一个很容易上手的Web客户端。

  最初,我是看了Evan的一篇文章“两款好用的SVN Web Client”,才对SVN Web Client感兴趣的。在使用的过程中,几次遇到“中文问题”。幸亏得到Evan帮助,才得以解决。在此,我要特别感谢他!

  其实Evan的解决方案,在更早的时候,就已经在他的Blog上发布了。只可惜我一直没有时去实践它。前几天有空,按他的方案实际操作了一把,效果立杆见影。到此为止,我在SVN Web Client上遇到的中文问题,也已得到全部解决。

  为了方便大家,我将修订后的SVN Web Client 2.5.1重新打包,以供有中文需求的朋友使用。修改的具体内容如下:

  1. $svnwebclient\WEB-INF\web.xml文件126行,将DefaultEncoding属性修改为GB2312,以支持中文URL的访问。

  2. $svnwebclient\WEB-INF\lib目录,添加commons-io-1.2.jar和commons-fileupload-1.1.1.jar文件包,并删除原有的commons-fileupload-1.0.jar文件包。

  3. $svnwebclient\WEB-INF\classes\org\polarion\svnwebclient\util目录,用Evan提供的Uploader.class文件替换原有文件。

注意还有一个中文设置,虽然svnwebclient的readme里讲了,但我还是想再 说明一下。那就是,要在独立运行的Tomca中,修改server.xml文件,将文件中8080端口(自行对应)的标签设置成URIEncoding="UTF-8",以支持中文路径。如果Tomcat集成到了Apache,则可参照“Apache+Tomcat中支持“UTF-8”编码的中文地址”文章。

下载地址svnwebclient-2.5.1.zip

关于用SVNWebClient提交中文文件名出错的问题

五一节回了老家一趟,于是就有了借口不更新自己的日志了,前几天上来看到传说一梦给 我留了2条留言说用SVNWebClient上传中文文件名的文件时,会出现乱码。说老实话,当初推荐SVNWebClient和sventon时,也只 当它们是纯粹的基于Web的SVN浏览工具,所以也就没有去测试这个中文上传和中文注释的问题。还好当初虽然不怎样看好SVNWebClient,但也没 有将其卸载,于是就试了一把。好险,差一点就没有测出来。传说一梦也不说说清楚,是当文件名中出现奇数个中文的时候会出现乱码,而偶数个时就OK,当然, 我一开始试的就刚好是类似于"中文名.txt"子类的。于是杀到SVNWebClient的网站,在其论坛上看到已经有人提了问题了,只是没人问津,这不 明摆着欺负中国人嘛!NND,只有发扬开源精神,自己动手了,尽管我是不会用SVNWebClient做SVN客户端工具的,放着那么好的TortoiseSVN不用,不是自己找难受嘛。

大体关于中文乱码的问题,其实就是个编码的问题,打开SVNWebClient的源码,找到处理上传的servlet:org.polarion.svnwebclient.util.Uploader.java,不是好好的嘛,用的是Jarkata的FileUpload, 也做了utf8的转码,不应该有错啊。在其转换前后加了点调试代码,发现没有什么特别的东西。不过,联想到以前用过的其它文件上传组件,往往对中文的处理 没有考虑周全,正准备将其代码也下载下来研究一把,突然发现其最新的版本是1.1,而SVNWebClient使用的是1.0,心想不要其已经自动纠正 了。下载新的版本,不过新版本还需要Jarkata的IO库, 一并下载,然后按照其文档,改用最新的ServletFileUpload,重新编译部署。这次乱得可比较彻底了,不管偶数个还是奇数个中文都是乱码,不 过,好在在转换前后加了点调试,发现文件名在没有转换前竟然是正常的,于是几次尝试后,终于将其搞定。Uploader.java最新代码如下:


import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;


public class Uploader {

public static Map doPost(HttpServletRequest request, HttpServletResponse responce, String destinationDirectory, String tempDirectory) {
Map parameters
= new HashMap();

File tempDir
= new File(tempDirectory);
if ( ! tempDir.exists()) {
tempDir.mkdirs();
}

File destDir
= new File(destinationDirectory);
if ( ! destDir.exists()) {
destDir.mkdirs();
}

ServletFileUpload fu
= new ServletFileUpload( new DiskFileItemFactory( 4096 , new java.io.File(tempDirectory)));
List fileItems
= null ;
try {
fileItems
= fu.parseRequest(request);
}
catch (FileUploadException e) {
Logger.getInstance(Uploader.
class ).error(e, e);
}

for (Iterator i = fileItems.iterator(); i.hasNext();) {
FileItem fi
= (FileItem) i.next();
if (fi.isFormField()) {
try {
parameters.put(fi.getFieldName(), fi.getString(
" UTF8 " ));
}
catch (UnsupportedEncodingException e) {
Logger.getInstance(Uploader.
class ).error(e, e);
}
}
else {
// filename on the client
String fileName = fi.getName();
// write the file
try {
File uploadFile
= new File(destinationDirectory + " / " + FileUtil.getLastPathElement(fileName));
fi.write(uploadFile);
// fi.delete();
} catch (Exception e) {
Logger.getInstance(Uploader.
class ).error(e, e);
}
parameters.put(FormParameters.FILE_NAME, FileUtil.getLastPathElement(fileName));
}
}

return parameters;
}
}

另外,不懂或者不愿意去学Java的人就不要用SVNWebClient和sventon了,世界上有那么多的各种各样语言编写的开源工具,干嘛不选一个自己熟悉的呢^_^。

Uploader.java下载
Uploader.class下载