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

I have an LSL script that can be used to record the timestamps and email the owner a chat-extract command line, but it is not quite polished enough for me to post here; ask if you are interested.

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

Jira Issue Finder

Feed any stream of input to this script and it will extract the Jira issue keys from the stream and format them as a list. Issues that have been moved will be listed using the most current key:

Usage:

findjiras [options]

Formatting options

These options control the output format, and are mutually exclusive. With none of these specified, only the issue numbers are printed, separated by newline.

-s separator, --separator separator
separate the results with this string (such as ", ")

To format a list including the summary line from the issue, use one of:

-t, --text
format as plain text
-m, --html
format as an html descriptive list
-w, --wiki
format as a wiki descriptive list

Filtering options

These options filter the issues by project name; the default without these options is to find all valid Jira ids. Each may be specified more than once to specify multiple projects. Note that for issues that have been moved, this applies to the final issue id.
-p included-project, --project included-project
find issues only for the project named
-x excluded-project, --exclude excluded-project
specific projects not to include

Other options

-h, --help
show this help message and exit
-c, --count
print a summary of counts of the different jira types after the list
-u USERNAME, --user USERNAME
specify the user account in Jira (defaults to the FINDJIRAS_USER environment variable). If not specified, the script will prompt you for it.

Examples

To find all issues since a the release-2-1 tag, and display in wiki form:

hg log --follow --prune release-2-1 -rtip:0 --template '{desc}\n' | findjiras -w

To list just the issue ids for all issues in your local repository that are not in the canonical viewer-release repository:

hg out --template '{desc}\n' https://bitbucket.org/lindenlab/viewer-release | findjiras

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.

Mercurial Tools

Repository Collection Updater

mm-updates [<verbosity-option>] [-n|--dry-run] [-c|--config <configuration>] [  <repository> ... ]

Checks and updates local repositories based on a configuration file. It is useful in maintaining a set of local mirrors of remote repositories, and displaying the relationships between them.

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

  1. The environment variable MM_UPDATES_CONFIG is checked
  2. If that is not set, then the default file is $\{HOME\}/.mm_updates_config

Each line of the configuration file contains 2 or more repositories:

local-path remote-repo downstream-repo...
local-path
Specifies a local hg repository (may be an hg alias, but that alias must resolve to a full local path name). This is the only repository that is ever modified by this command.
remote-repo
Is either a remote repository URL or a local repository path. Any changesets from the remote 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 a list of zero or more repositories: each may be a remote repository URL or a local repository path.
If specified, each repository is checked to see if the local repo contains any changesets not in the downstream repo and displays the number found.

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

If repositories are specified on the command line, then only those are updated and checked.

The verbosity options are: -d|--debug -v|--verbose -q|--quiet

The -n|--dry-run option causes the command to display what would have been fetched, but the local repository is not actually modified.

If a repository specified on the command line is not found in the configuration file, then remote-repo is assumed to be its 'default' repository, and downstream-repo is assumed to be its 'default-push' repository (if any).

Example Configuration file:

#      local-repo                  parent-repo                                   downstream-repo
/Users/oz/Work/viewer-release      ssh://hg.secondlife.com/viewer-release
/Users/oz/Work/viewer-beta         ssh://hg.secondlife.com/viewer-beta        /Users/oz/Work/viewer-release
/Users/oz/Work/viewer-betareview   /Users/oz/Work/viewer-beta
/Users/oz/Work/viewer-development  ssh://hg.secondlife.com/viewer-development /Users/oz/Work/viewer-beta
/Users/oz/Work/viewer-devreview    /Users/oz/Work/viewer-development

Merge Request

mm-merge <options> issue-id [<repository> [<changeset>]]

Executes a merge into the current repository after doing some checks.

The local repository is checked for uncommitted changes; if any are found, they are displayed and the command aborts.

This assumes that you are working in a clone of a repository on which any changes to be merged have been based (see --base option, below).

Displays all changesets that would be merged from the specified repository into the base repository, and then the changesets that will be merged into the current repository. If those are the same, it says so and continues; if not, the difference is displayed and you are prompted for whether or not to continue with the merge into the local repository.

Prompts for a merge comment (with default made from issue number). When a comment is entered (it is safe to abort with control-c at this point), the changes are pulled and merged.

The pulled changes are archived in a Mercurial bundle file named "<issue-id>.hg" See the --archive option below.

Arguments:

issue-id
Used in the default merge comment, and is the name of the archived Mercurial bundle file. If specified as just a number, the value of $MM_MERGE_PROJECT is prepended with a dash. Always converted to all upper case.
repository
The repository from which changes are pulled.
If no repository is specified, the contents of the system clipboard are used.
The repository may be local or remote, and may be a Mercurial alias.
If the repository url domain is either bitbucket.org or hg.secondlife.com, it is converted to the equivalent ssh url.
changeset
The changeset to pull (may be any Mercurial revision specifier).
If no changeset is specified, 'tip' is used (see also --rev below).

Options:

{-v|--verbose}
Displays more information about changesets
{-n|--dry-run}
Shows what changesets would be merged, but does nothing.
{-a|--archive} <archive-directory>
Directory where a Mercurial bundle of the merged changes will be saved as "<issue-id>.hg".
Defaults to $MM_MERGE_ARCHIVE
{-b|--base} base-repo
Specify a local base repository against which merges should be compared.
Defaults to $HG_BASE_REPO, and may be specified using a Mercurial alias.
{-r|--rev} <changeset>
Specify the revision to pull from <repository>.
This may also be specified by either:
  • the optional final <changeset> argument
  • a trailing url path /changeset/<changeset>
  • a url fragment identifier #<changeset>
{-h|--help}
Print this help
{-d|--debug}
Print verbose tracing info and keep temporary files


Change Merge

This is a wrapper 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.

Push Wrapper

This provides some simple safety checks before pushing changes.

   mm-push [ <target-repo> ]


  • Checks for any uncommitted local changes
    • if there are local uncommitted changes, asks for confirmation to proceed
  • Translates any alias used for target-repo.
  • Checks to see if there are unmerged changes in the target-repo.
    • if there are remote changes, displays them in 'compact' format and aborts.
  • Checks to see if there any local changes to be pushed.
    • if there are local changes, displays them in 'compact' format and requests confirmation before pushing them.

Hooks

Well Formed XML Checker

migrated into the general mercurial coding policy hook

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.