Support #3939

Ticket to commit id references still show old SVN commit id's

Added by Tim Sutton over 10 years ago. Updated over 10 years ago.

Status:ClosedStart date:2011-06-05
Priority:NormalDue date:
Assignee:Pirmin Kalberer% Done:

0%

Category:-
Target version:-
Pull Request or Patch supplied: Tag:

Description

This is a known issue that we are working to resolve. We will run a batch update on the or r1232 style refences. New references can be added using the syntax:

commit:03EC23

revlist2.txt Magnifier (2.02 MB) Tim Sutton, 2011-06-10 01:48 PM

revlist.txt Magnifier (528 KB) Tim Sutton, 2011-06-11 02:26 PM

History

#1 Updated by Pirmin Kalberer over 10 years ago

  • Assignee changed from Tim Sutton to Pirmin Kalberer

#2 Updated by Pirmin Kalberer over 10 years ago

  • Status changed from Open to In Progress
  • Assignee changed from Pirmin Kalberer to Tim Sutton

I've replaced all SVN revisions with GIT hashes. But it seems that the translation table (/tmp/quantum-gis/lookupTable.txt) generated with https://github.com/poseidix/TRAC-SVN-to-GIT-migration/blob/master/createLookupTable.sh is wrong. See e.g. #3782
Tim: Could you rollback the tickets (Table journals) and try to generate a working translation table?

lib/tasks/migrate_svn.rake:

desc 'Migrate SVN commit messages'
task :migrate_svn => :environment do
  pathLookupTable = "/tmp/quantum-gis/lookupTable.txt" 
  nrHashCharacters = 8

  # run https://github.com/poseidix/TRAC-SVN-to-GIT-migration/blob/master/createLookupTable.sh first
  lookupTable = {}
  File.open(pathLookupTable, "r") do |infile|
    while (line = infile.gets)
      next if line.empty?
      svnID, gitID = line.strip.split("\\t")
      svnID.sub!(/git-svn-id:http:[email protected](\\d+)c8812cc2-4d05-0410-92ff-de0c093fc19c/, '\\1')
      lookupTable[svnID] = gitID[0, nrHashCharacters] unless gitID.nil?
    end
  end

  ActiveRecord::Base.partial_updates = false
  Journal.find(:all).each do |journal|
    if journal.notes
      txt = journal.notes.gsub!(/\\br([1-9][0-9]+)\\b/) do |m|
      svnID = $1
      gitID = lookupTable[svnID]
      if gitID.nil?
        puts "Warning: unknown GIT hash for SVN revision #{svnID}" 
        next
      end
      m.sub("r#{svnID}", "commit:#{gitID} (SVN r#{svnID})")
      end
      journal.save! if txt
    end
  end
end

#3 Updated by Tim Sutton over 10 years ago

Attached is the hash table I generated. As you can see there are often multiple GIT commits per svn commit. I am not really sure how we can deal with that.

Regards

Tim

#4 Updated by Pirmin Kalberer over 10 years ago

I checked two changesets and they didn't match. The additional git hashes seem to come from other branches.

See e.g.
http://trac.osgeo.org/qgis/changeset/10012
https://issues.qgis.org/projects/quantum-gis/repository/revisions/3200e3e500262a4819b61c44b9fff9ba437d1fa9

Could you try again with master branch only?

#5 Updated by Tim Sutton over 10 years ago

Ok try the attached file generated using:

git rev-list master  --pretty=medium | grep git-svn-id -A 2 > revlist.txt

Then processed using vim with the following keystroke macro (register a from ~/.viminfo):

"[email protected]»CHAR» 0
» [email protected]<80>kd<80>kdx<80>kd^[dd<80>kh

#6 Updated by Tim Sutton over 10 years ago

Ooops forgot attachment....added now...

#7 Updated by Pirmin Kalberer over 10 years ago

  • Assignee changed from Tim Sutton to Pirmin Kalberer
  • Status changed from In Progress to Closed

Reapplied rake script (including SVN offset 1 translation):

desc 'Migrate SVN commit messages'
task :migrate_svn => :environment do
  pathLookupTable = "/tmp/revlist.txt" 
  nrHashCharacters = 8

  # run https://github.com/poseidix/TRAC-SVN-to-GIT-migration/blob/master/createLookupTable.sh first
  lookupTable = {}
  File.open(pathLookupTable, "r") do |infile|
    while (line = infile.gets)
      next if line.empty?
      svnID, gitID = line.strip.split
      lookupTable[svnID] = gitID[0, nrHashCharacters] unless gitID.nil?
    end
  end

  ActiveRecord::Base.partial_updates = false
  Journal.find(:all).each do |journal|
    if journal.notes
      #txt = journal.notes.gsub!(/\\br([1-9][0-9]+)\\b/) do |m|
      txt = journal.notes.gsub!(/commit:........ \\(SVN r([1-9][0-9]+)\\)/) do |m|
      svnID = ($1.to_i+1).to_s
      gitID = lookupTable[svnID]
      if gitID.nil?
        puts "Warning: unknown GIT hash for SVN revision #{svnID}" 
        next
      end
      #m.sub("r#{svnID}", "commit:#{gitID} (SVN r#{svnID})")
      "commit:#{gitID} (SVN r#{svnID})" 
      end
      journal.save! if txt
    end
  end
end

Also available in: Atom PDF