[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [RFC] IMPORTANT: Cleaning l10n-sync damage from D-I SVN repository



On Thursday 04 June 2009, Bastian Blank wrote:
> > A tag is a copy, but the files are not actually copied. So if I
> > change the file in trunk in a revision before the tag, the tagged
> > version of the file will automatically change as well.
>
> You can change the file along with the copy operation.

Right, I see what you mean now. I've extended my awk script to do that:
- when a da.po file for a package is removed, it's also saved to a tmp
  dir, so I always have the latest version for each package available
- when I encounter a revision that creates a tag for the package, I read
  the last saved file back in (modifying the path to match the tag dir)

The cleaned dump file it creates looks good; next is testing if it loads 
and checking resulting revisions.

New version of script attached (for posterity and the curious :-)

> Another problem: does anyone use dumps with deltas? The hotbackup
> script bundled with subversion does this.

No idea, though the subversion-tools package description says it's for bdb 
based repos. If someone does I hope they speak up.

Cheers,
FJP

Output of the awk script
------------------------
Tag r55973 found for cdebconf
   282 lines restored
Tag r56032 found for partman-efi
   96 lines restored
Tag r56062 found for nobootloader
   227 lines restored
Tag r56074 found for partman-target
   264 lines restored
Tag r56090 found for flash-kernel
   92 lines restored
Tag r56092 found for silo-installer
   224 lines restored
Tag r56094 found for partman-ext2r0
   267 lines restored
Tag r56119 found for partman-palo
   80 lines restored
Tag r56157 found for sibyl-installer
   101 lines restored
Tag r56160 found for arcboot-installer
   168 lines restored
Tag r56399 found for quik-installer
   454 lines restored
Tag r56402 found for prep-installer
   133 lines restored
Tag r56404 found for yaboot-installer
   355 lines restored
Tag r56406 found for partman-prep
   81 lines restored
Tag r56408 found for partman-newworld
   106 lines restored
Tag r56411 found for cdebconf
   282 lines restored
Tag r56825 found for cdebconf
   282 lines restored

BEGIN {
	start = 1
	clean = 0
	infile = 0
	save_trans = 0
	restore_trans = 0
}

# Set limits of cleaning operation
/^Revision-number: 55934/ {
	clean = 1
}
/^Revision-number: 57134/ {
	clean = 0
}

# New revision; close previous one
/^Revision-number:/ {
	rev = substr($0, 18)
	infile = 0
	if (save_trans == 1) {
		close(pfile)
		save_trans=0
	}

	# Restore last version of corrupted file for taged version
	if  (restore_trans == 1) {
		cnt = 0
		# Skip first (blank) line
		getline line <pfile
		while (getline line <pfile) {
			cnt = cnt + 1
			if (line !~ /^Node-path:/) {
				print line
			} else {
				print npath "/debian/po/da.po"
			}
		}
		print "   " cnt " lines restored" >"/dev/stderr"
		close(pfile)
		restore_trans = 0
	}
}
# New file in current revision
/^Node-path:/ {
	infile = 0
	npath = $0
	if (save_trans == 1) {
		close(pfile)
		save_trans = 0
	}
}

# These are the files we want
/^Node-path: trunk.*\/(po\/sublevel4|cdebconf|nobootloader|flash-kernel|partman-(prep|newworld|target|ext2r0|efi|palo)|(silo|prep|quik|yaboot|sibyl|arcboot|vmelilo)-installer)\/.*da\.po/ {
	# Save a copy of the last version we encounter
	if ($0 !~ /\/sublevel4\//) {
		s = match($0, "[^/]+/debian")
		package = substr($0, s, RLENGTH - 7)
		pfile = "tmp/" package ".sv"
		save_trans = 1
	}
	infile = 1
}

# We're tagging a cleaned package => restore the da.po file to the
# uploaded version (last saved "cleaned" instance from trunk)
/^Node-copyfrom-path: trunk.*\/(cdebconf|nobootloader|flash-kernel|partman-(prep|newworld|target|ext2r0|efi|palo)|(silo|prep|quik|yaboot|sibyl|arcboot|vmelilo)-installer)$/ {
	if (clean == 1) {
		s = match($0, "[^/]+$")
		package = substr($0, s)
		pfile = "tmp/" package ".sv"
		print "Tag r" rev " found for " package >"/dev/stderr"
		restore_trans = 1
	}
}

# The prevline construction is needed because if we restore a translation
# that needs to be done before the extra newline that starts a new revision
/.*/ {
	if (clean == 0 || infile == 0) {
		if (start != 1) {
			print prevline
		}
	} else if (save_trans == 1) {
		print prevline >pfile
	}
	start = 0
	prevline = $0
}

END {
	print prevline
}

Reply to: