Fixes the ticket status problem.  Syncs the tickets again.
M .ditz/issue-3455abd67e78f997c74d72aff184585b74083415.yaml +8 -0
@@ 34,4 34,12 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - closed with disposition fixed
   - ""
+- - 2010-01-30 22:03:53 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
+- - 2010-01-30 22:03:56 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 8

          
M .ditz/issue-346223318c35bdac90b33437bc0d266e05475d9f.yaml +4 -0
@@ 24,4 24,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - closed with disposition fixed
   - ""
+- - 2010-01-30 22:03:53 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 10

          
M .ditz/issue-4d26d5a4a0a8500f1b24d28a954c3624be95097f.yaml +4 -0
@@ 28,4 28,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - closed with disposition fixed
   - ""
+- - 2010-01-30 22:03:51 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 2

          
M .ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml +4 -0
@@ 28,4 28,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - closed with disposition fixed
   - ""
+- - 2010-01-30 22:03:53 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 9

          
M .ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml +4 -0
@@ 26,4 26,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - assigned to release 2010.1 from unassigned
   - ""
+- - 2010-01-30 22:03:54 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 13

          
M .ditz/issue-8a82d727a91a667548b847a1e22d2ceb42f3709d.yaml +4 -0
@@ 31,4 31,8 @@ log_events:
     Until I get the ability to make change logs directly, they're not
     supported.  ditz-trac will copy comments, but it loses the event
     history when copying to Trac.  Trac to ditz history .is preserved.
+- - 2010-01-30 22:03:53 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 11

          
M .ditz/issue-8c9c852850fc96f084dcec9204b31431deca5abe.yaml +4 -0
@@ 23,4 23,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - closed with disposition fixed
   - Fixed by r2c584fd394e
+- - 2010-01-30 22:03:51 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 3

          
M .ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml +4 -0
@@ 18,4 18,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - created
   - ""
+- - 2010-01-30 22:03:54 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 12

          
M .ditz/issue-9618638bbe9059ffa431f5edc8d7b9c9a938dbab.yaml +4 -0
@@ 24,4 24,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - assigned to release 2010.1 from unassigned
   - ""
+- - 2010-01-30 22:03:51 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 1

          
M .ditz/issue-9bfea1cdc188c9047e6d0b0b95eb931133997bd1.yaml +4 -0
@@ 18,4 18,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - created
   - What's a creator comment for?
+- - 2010-01-30 22:03:52 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 6

          
M .ditz/issue-b6c0977924baa85b69eae1737c281ad03ce211af.yaml +4 -0
@@ 16,4 16,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - created
   - ""
+- - 2010-01-30 22:03:52 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 7

          
M .ditz/issue-c293f6db629b1b62aa4ea6e4706525f5a045eb4f.yaml +4 -0
@@ 22,4 22,8 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - closed with disposition fixed
   - Fixed by 69a95f48069e
+- - 2010-01-30 22:03:52 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 5

          
M .ditz/issue-e9972f258450d6aca85514f2a8d91b3240b66a41.yaml +8 -0
@@ 20,4 20,12 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - assigned to release 2010.2 from 2010.1
   - ""
+- - 2010-01-30 22:03:52 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
+- - 2010-01-30 22:03:55 Z
+  - ser
+  - commented
+  - Ticket synced from ditz by Sean Russell <ser@ser1.net>
 trac_id: 4

          
M trac-sync.rb +24 -11
@@ 152,9 152,9 @@ module Ditz
       maybe_create_components
       issues.each do |t,i| # t will always be nil
         attrs = { 
-          "created_at" => i.creation_time,
+          #"created_at" => i.creation_time,
           "type"       => DTYPE_TTYPE[ i.type ],
-          "reporter"   => i.reporter || "",
+          #"reporter"   => i.reporter || "",
           "milestone"  => i.release || "",
           "component"  => i.component || "",
           "status"     => DSTATUS_TSTATUS[ i.status ] || "",

          
@@ 164,14 164,16 @@ module Ditz
         try {
           tid = @trac.tickets.create( i.title, i.desc, attrs )
         }
-        @logger.debug("Created ticket #{tid} from #{i.id[0,4]} with #{attrs.inspect}")
         i.trac_id = tid
         try {
           rv[i] = @trac.tickets.get(tid)
         }
         raise "Got nil for a ticket we just created!" if rv[i].nil?
+        try {
+          @trac.query( "ticket.update", rv[i].id, "Ticket synced from ditz by #{@config.user}", attrs )
+        }
+        @logger.debug("Created ticket #{tid} from #{i.id[0,4]} with #{attrs.inspect}")
       end
-      @logger.info("Created #{rv.size} new tickets")
       rv
     end
 

          
@@ 218,14 220,17 @@ module Ditz
     # the only things we do here are (a) log comments, and (b) update the
     # ticket status if it differs 
     def update_tickets( pairs )
+      @logger.info("Updating tickets")
       pairs.each do |ticket, issue|
-        @logger.info("Working on #{ticket.id}/#{issue.id[0,4]}")
+        @logger.info("Updating ticket #{ticket.id} from #{issue.id[0,4]}")
         copy_comments( ticket, issue )
         issue_last_changed = if issue.log_events.size == 0
                                issue.creation_time
                              else
                                issue.log_events[-1][0]
                              end
+        @logger.debug( "Issue changed  #{issue_last_changed}" )
+        @logger.debug( "Ticket changed #{ticket.updated_at.to_time}" )
         if issue_last_changed > ticket.updated_at.to_time
           attrs = {}
           attrs["summary"] = issue.title if issue.title != ticket.summary

          
@@ 253,14 258,17 @@ module Ditz
 
 
     def update_issues( pairs )
+      @logger.info("Updating issues")
       pairs.each do |ticket, issue|
-        @logger.info( "Working on #{ticket.id}/#{issue.id[0,4]}" )
+        @logger.info( "Updating #{issue.id[0,4]} from #{ticket.id}" )
         copy_comments( issue, ticket )
         issue_last_changed = if issue.log_events.size == 0
                                issue.creation_time
                              else
                                issue.log_events[-1][0]
                              end
+        @logger.debug( "Issue changed  #{issue_last_changed}" )
+        @logger.debug( "Ticket changed #{ticket.updated_at.to_time}" )
         if issue_last_changed < ticket.updated_at.to_time
           attrs = {}
           attrs["summary"] = issue.title if issue.title != ticket.summary

          
@@ 297,6 305,7 @@ module Ditz
         @logger.warn(err.message) if tries == 0
         case err.message
         when /Wrong type NilClass/, /end of file reached/
+          sleep 0.5
           @logger.warn("Had to re-connect to Trac")
           @trac = Trac.new(@config.trac_sync_url, 
                            @config.trac_sync_user, 

          
@@ 522,8 531,8 @@ module Ditz
       trac = Trac.new(config.trac_sync_url, config.trac_sync_user, config.trac_sync_pass)
       util = Ditz::TracUtil.new( project, config, trac, logger )
 
-      tickets = trac.query("ticket.query", "status=new&max=1000000&order=id")
-      logger.info("Fetching #{tickets.size} tickets...")
+      tickets = trac.query("ticket.query", "max=1000000&order=id")
+      STDOUT.puts("Fetching #{tickets.size} tickets...")
       tickets.collect! {|id|
         STDOUT.print(".") ; STDOUT.flush
         trac.tickets.get(id)

          
@@ 542,12 551,16 @@ module Ditz
 
       # Create and update any missing issues.  new_pairs is {ticket=>new_issue} hash
       only_tickets = pairs.find_all {|m| m[1] == nil}
+      STDOUT.puts("Creating new issues from #{only_tickets.size} tickets")
       new_issues = util.create_issues( only_tickets )
+      STDOUT.puts("Created #{new_issues.size} new issues")
       pairs.each { |m| m[1] = new_issues[m[0]] unless m[1] }
 
       # Create and update any missing tickets. new_tickets is {issue=>new_ticket} hash
       only_issues = pairs.find_all {|m| m[0] == nil}
+      STDOUT.puts("Creating new tickets from #{only_issues.size} issues")
       new_tickets = util.create_tickets( only_issues )
+      STDOUT.puts("Created #{new_tickets.size} new tickets")
       pairs.each { |m| m[0] = new_tickets[m[1]] unless m[0] }
 
       # We can't create issues for releases that are already released (ditz

          
@@ 566,13 579,13 @@ module Ditz
       #
       # Don't update issues that just created a new ticket
       issues_to_update = pairs.reject {|t,i| new_tickets[i] }
-      logger.debug("Issues to update:")
+      STDOUT.puts("Updating #{issues_to_update.size} issues")
       logger.debug(issues_to_update.collect{|t,i| i.id[0,4] }.inspect)
-      #util.update_issues( issues_to_update )
+      util.update_issues( issues_to_update )
 
       # Don't update tickets that just created a new issue
       tickets_to_update = pairs.reject {|t,i| new_issues[t] }
-      logger.debug("Tickets to update:")
+      STDOUT.puts("Updating #{tickets_to_update.size} tickets")
       logger.debug(tickets_to_update.collect{|t,i| t.id }.inspect)
       util.update_tickets( tickets_to_update )
     end