# HG changeset patch # User Sean Russell # Date 1264889419 18000 # Sat Jan 30 17:10:19 2010 -0500 # Node ID a2fa647a183e5befee43741d8e6ba4b0254c370f # Parent 9b28bb3a49614bbe8216abfe2b0921f6edd220ab Fixes the ticket status problem. Syncs the tickets again. diff --git a/.ditz/issue-3455abd67e78f997c74d72aff184585b74083415.yaml b/.ditz/issue-3455abd67e78f997c74d72aff184585b74083415.yaml --- a/.ditz/issue-3455abd67e78f997c74d72aff184585b74083415.yaml +++ b/.ditz/issue-3455abd67e78f997c74d72aff184585b74083415.yaml @@ -34,4 +34,12 @@ - Sean Russell - closed with disposition fixed - "" +- - 2010-01-30 22:03:53 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell +- - 2010-01-30 22:03:56 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 8 diff --git a/.ditz/issue-346223318c35bdac90b33437bc0d266e05475d9f.yaml b/.ditz/issue-346223318c35bdac90b33437bc0d266e05475d9f.yaml --- a/.ditz/issue-346223318c35bdac90b33437bc0d266e05475d9f.yaml +++ b/.ditz/issue-346223318c35bdac90b33437bc0d266e05475d9f.yaml @@ -24,4 +24,8 @@ - Sean Russell - closed with disposition fixed - "" +- - 2010-01-30 22:03:53 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 10 diff --git a/.ditz/issue-4d26d5a4a0a8500f1b24d28a954c3624be95097f.yaml b/.ditz/issue-4d26d5a4a0a8500f1b24d28a954c3624be95097f.yaml --- a/.ditz/issue-4d26d5a4a0a8500f1b24d28a954c3624be95097f.yaml +++ b/.ditz/issue-4d26d5a4a0a8500f1b24d28a954c3624be95097f.yaml @@ -28,4 +28,8 @@ - Sean Russell - closed with disposition fixed - "" +- - 2010-01-30 22:03:51 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 2 diff --git a/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml b/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml --- a/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml +++ b/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml @@ -28,4 +28,8 @@ - Sean Russell - closed with disposition fixed - "" +- - 2010-01-30 22:03:53 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 9 diff --git a/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml b/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml --- a/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml +++ b/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml @@ -26,4 +26,8 @@ - Sean Russell - assigned to release 2010.1 from unassigned - "" +- - 2010-01-30 22:03:54 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 13 diff --git a/.ditz/issue-8a82d727a91a667548b847a1e22d2ceb42f3709d.yaml b/.ditz/issue-8a82d727a91a667548b847a1e22d2ceb42f3709d.yaml --- a/.ditz/issue-8a82d727a91a667548b847a1e22d2ceb42f3709d.yaml +++ b/.ditz/issue-8a82d727a91a667548b847a1e22d2ceb42f3709d.yaml @@ -31,4 +31,8 @@ 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 trac_id: 11 diff --git a/.ditz/issue-8c9c852850fc96f084dcec9204b31431deca5abe.yaml b/.ditz/issue-8c9c852850fc96f084dcec9204b31431deca5abe.yaml --- a/.ditz/issue-8c9c852850fc96f084dcec9204b31431deca5abe.yaml +++ b/.ditz/issue-8c9c852850fc96f084dcec9204b31431deca5abe.yaml @@ -23,4 +23,8 @@ - Sean Russell - closed with disposition fixed - Fixed by r2c584fd394e +- - 2010-01-30 22:03:51 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 3 diff --git a/.ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml b/.ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml --- a/.ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml +++ b/.ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml @@ -18,4 +18,8 @@ - Sean Russell - created - "" +- - 2010-01-30 22:03:54 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 12 diff --git a/.ditz/issue-9618638bbe9059ffa431f5edc8d7b9c9a938dbab.yaml b/.ditz/issue-9618638bbe9059ffa431f5edc8d7b9c9a938dbab.yaml --- a/.ditz/issue-9618638bbe9059ffa431f5edc8d7b9c9a938dbab.yaml +++ b/.ditz/issue-9618638bbe9059ffa431f5edc8d7b9c9a938dbab.yaml @@ -24,4 +24,8 @@ - Sean Russell - assigned to release 2010.1 from unassigned - "" +- - 2010-01-30 22:03:51 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 1 diff --git a/.ditz/issue-9bfea1cdc188c9047e6d0b0b95eb931133997bd1.yaml b/.ditz/issue-9bfea1cdc188c9047e6d0b0b95eb931133997bd1.yaml --- a/.ditz/issue-9bfea1cdc188c9047e6d0b0b95eb931133997bd1.yaml +++ b/.ditz/issue-9bfea1cdc188c9047e6d0b0b95eb931133997bd1.yaml @@ -18,4 +18,8 @@ - Sean Russell - created - What's a creator comment for? +- - 2010-01-30 22:03:52 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 6 diff --git a/.ditz/issue-b6c0977924baa85b69eae1737c281ad03ce211af.yaml b/.ditz/issue-b6c0977924baa85b69eae1737c281ad03ce211af.yaml --- a/.ditz/issue-b6c0977924baa85b69eae1737c281ad03ce211af.yaml +++ b/.ditz/issue-b6c0977924baa85b69eae1737c281ad03ce211af.yaml @@ -16,4 +16,8 @@ - Sean Russell - created - "" +- - 2010-01-30 22:03:52 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 7 diff --git a/.ditz/issue-c293f6db629b1b62aa4ea6e4706525f5a045eb4f.yaml b/.ditz/issue-c293f6db629b1b62aa4ea6e4706525f5a045eb4f.yaml --- a/.ditz/issue-c293f6db629b1b62aa4ea6e4706525f5a045eb4f.yaml +++ b/.ditz/issue-c293f6db629b1b62aa4ea6e4706525f5a045eb4f.yaml @@ -22,4 +22,8 @@ - Sean Russell - closed with disposition fixed - Fixed by 69a95f48069e +- - 2010-01-30 22:03:52 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 5 diff --git a/.ditz/issue-e9972f258450d6aca85514f2a8d91b3240b66a41.yaml b/.ditz/issue-e9972f258450d6aca85514f2a8d91b3240b66a41.yaml --- a/.ditz/issue-e9972f258450d6aca85514f2a8d91b3240b66a41.yaml +++ b/.ditz/issue-e9972f258450d6aca85514f2a8d91b3240b66a41.yaml @@ -20,4 +20,12 @@ - Sean Russell - assigned to release 2010.2 from 2010.1 - "" +- - 2010-01-30 22:03:52 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell +- - 2010-01-30 22:03:55 Z + - ser + - commented + - Ticket synced from ditz by Sean Russell trac_id: 4 diff --git a/trac-sync.rb b/trac-sync.rb --- a/trac-sync.rb +++ b/trac-sync.rb @@ -152,9 +152,9 @@ 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 @@ 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 @@ # 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 @@ 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 @@ @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 @@ 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 @@ # 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 @@ # # 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