User:Oz Linden/Tools

From Second Life Wiki
Jump to navigation Jump to search

These are some tools I've built and make available under the following warranty:

These tools work:
  • for me
  • as well as I need them to
  • right now

... that having been said, suggestions and requests for help are welcome.

All of these tools are available from the mercurial repository:

https://bitbucket.org/oz_linden/tools


Chat Logs

Together, the two scripts below can be used to prepare wiki archives of in-world meeting text chat.

The first extracts text from a chat log as produced by the viewer, and that output can be piped to the second to convert to wiki formatting:

chat-extract --begin '[2011/02/09 13:02]' --end '[2011/02/09 14:08]' ~/SecondLife/Logs/oz_linden/chat \
| sllog2wiki > ~/tmp/post.wiki

For an example of the output of the current version resulting from the above, see my user group archive for 9 Feb

chat-extract

Extracts text from a log file; the viewer must have the timestamp option enabled.

 chat-extract
    --begin begin-timestamp
    --end   end-timestamp
    [ --ignore ignore-pattern-file ]
    [--help]
    chat-log

Searches the specified chat-log file for lines bounded by the begin and end timestamps, and writes them to standard output. The '.txt' suffix may be left off the file name, and the command will automatically also try the same name with a datestamp added if the file is not found without it.

The ignore-pattern-file, if specified, contains patterns (perl regular expressions) which cause any line they match to be omitted from the output.

The ignore option default can be set by putting an assignment in the file

$HOME/.chat-extract.rc 

whose contents look like:

ignore = ignore-pattern-file


sllog2wiki

Converts chat log input to a nice wiki presentation

 sllog2wiki
    [ --bots bot-names-file ]
    [--help]
    [ chat-log ]

Reads chat-log (or standard input if no file is specified) and writes wiki markup to standard output. The name column of the output contains the display name of the agent, linked to the profile for the user.

The bot-names-file, is a list of names (one per line) for which no links to profiles should be generated.

The bots option default can be set by putting an assignment in the file

$HOME/.sllog2wiki.rc 

whose contents look like:

bots = bot-names-file

Python Help Message Wiki Formatter

Usage:

      pyhelp2wiki [--title <section-title>] [--level <section-level>]
      pyhelp2wiki [--help]


Options:

optional arguments:
--title SECTION_TITLE Adds this title as a section header
--level SECTION_LEVEL The number of '=' characters

Reads the output of a conventional python command --help options (as produced by the python argparse package) from standard input, and writes a wiki markup by the python argparse package) from standard input, and writes a wiki markup version of it to standard output. version of it to standard output.

Integration Tools

These tools are used to manage collections of related repositories, and to pull changes from one to another in a uniform way.

Repository Collection Updater

Usage:

   mm-updates [ <configuration> ]

Updates and checks local repositories based on a configuration file. It is useful in maintaining a set of local mirrors of remote repositories.

If the configuration file name is not specified on the command line:

  • The environment variable MM_UPDATES_CONFIG is checked
  • If that is not set, then the default file is $HOME/.mm_updates_config

Each line of the configuration file contains either 2 or 3 repositories:

<local-path> <parent-repo> [ <downstream-repo> ]
local-path
Specifies the full path to a local hg repository. This is the only repository that is ever modified by this command.
parent-repo
Is either a remote repository URL or a local repository path. Any changesets from the parent not found in the local repo are pulled to it; if this would require a merge, the mm-updates command fails with an error.
downstream-repo
Is either a remote repository URL or a local repository path. If specified, this command checks to see if the local repo contains any changesets not in the downstream repo and displays the number found.

Note that the ~/.hgrc file may be used to define path aliases for the parent or downstream repositories, but that the local must be a directory path.

Blank lines are allowed in the configuration file, and the '#' character starts comments, which are ignored.

BUG: paths must be fully specified - specifically the usual '~' for $HOME does not work

Example Configuration file:

  1. local-repo parent-repo downstream-repo

/Users/oz/Work/viewer-release http://hg.secondlife.com/viewer-release /Users/oz/Work/viewer-beta http://hg.secondlife.com/viewer-beta /Users/oz/Work/viewer-release /Users/oz/Work/viewer-betaR /Users/oz/Work/viewer-beta-review

/Users/oz/Work/viewer-development http://hg.secondlife.com/viewer-development /Users/oz/Work/viewer-beta-review /Users/oz/Work/viewer-dev-review /Users/oz/Work/viewer-dev-review

Change Merge

This is a wrapper for the mercurial hg fetch command that helps with constructing merge changeset comments based on the pattern of naming repositories using the jira issue key as the last element of the repository path.

Usage:

  mm-getfix <repository> [<changeset>]
or
  mm-getfix <repository> [-r <changeset>]
  mm-getfix <repository> [--rev <changeset>]

Prompts for an issue number to be included in the merge change comment (a default is extracted from the last element of the repository path).

Displays all non-merge changesets that would be merged by this operation, then prompts for a merge comment (with default made from issue number).

Entering return for either prompt accepts default and proceeds. After comment prompt, an 'hg fetch' command is executed. It is safe to abort the command at either prompt.

License Header Splicing

This tool splices the contents of one file into another, replacing any lines found between a start and and marker in the target file. In the process, it preserves the content syntax, if any, found in the original file. It is useful for replacing the license header in a file, and especially so when you have many files to modify

Usage:

splice -b <begin-marker> -e <end-marker> [-f <fail-log>] [--keep] <file-to-insert-between-markers> <file-to-edit>

Specifically, in the Second Life Viewer code, the following is usually correct:

splice --keep --begin '$LicenseInfo:' --end '$/LicenseInfo' new-license source-file

DOS Line End Checker

Usage:

   check-lineends [ -t | --trace ] 

Detects use of carriage return for line endings. Prints the paths of files that contain carriage returns that should not.

With the --trace option, detects the mercurial changeset that introduced them, and prints the log message for that changeset.


Open Source Contribution Statistics

Generates statistics on Open Source contributions from a viewer repository.

open-contributions <tag-list-file>

Where the tag-list-file contains a sequence of mercurial tag values, one per line.