Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Stolen from Pete

  • Loading branch information...
commit c412ac8b6654520cfd8c72cfc952686773e29812 1 parent 35ff3e7
Andy Lester authored January 28, 2010

Showing 1 changed file with 29 additions and 0 deletions. Show diff stats Hide diff stats

  1. 29  bin/hwd-renumber
29  bin/hwd-renumber
... ...
@@ -0,0 +1,29 @@
  1
+#!/usr/bin/perl
  2
+
  3
+# If it already has a number on it, or it does NOT have a number but it
  4
+# has an estimate, it will get assigned a number.  If you have done work
  5
+# in the HWD, it will translate the numbers on the work, too.
  6
+
  7
+my $newtaskid = 101;
  8
+
  9
+my %translation;
  10
+while (my $line = <>) {
  11
+    next if /^#/;
  12
+    if ($line =~ /^-.*\((?:[^()],)*\s*#(\d+)(?:,[^()]*)*\s*\)\s*(?:#.*)?$/) {
  13
+        my $task = $1;
  14
+        do { print $line; next } if $task > 9000;
  15
+        die "Bad task number" unless $task;
  16
+        $translation{$task} = $newtaskid;
  17
+        $line =~ s/#$task/#$newtaskid/;
  18
+        $newtaskid++;
  19
+    } elsif ($line =~ /^-.*\((\s*\d*(?:\.\d*)?h\s*)\)/) {
  20
+        my $match = $1;
  21
+        $line =~ s/\($match/\(#$newtaskid, $match/;
  22
+        $newtaskid++;
  23
+    } elsif ($line =~ /^\w/) {
  24
+        if ($line !~ /-\d\d\s*\^/) {
  25
+            $line =~ s/(-\d\d\s*)(\d+)/$1.$translation{$2}/e || die "Translation not found: $line";
  26
+        }
  27
+    }
  28
+    print $line;
  29
+}

0 notes on commit c412ac8

Please sign in to comment.
Something went wrong with that request. Please try again.