[PATCH] translations: Make "GIT Committish:" lines obsolete

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] translations: Make "GIT Committish:" lines obsolete

Johannes Schindelin

Use git to determine when the translation last changed instead of
relying on the "GIT Committish" line.

The downside of this patch is that a simple typo fix in the original
documentation still requires an update of the translation; otherwise
"make check-translation" will continue to complain about that fix not
being reflected in the translation.

Signed-off-by: Johannes Schindelin <[hidden email]>

---

        By reading my Python code, you can tell I detest that language. If
        you know better methods to achieve the same, please don't let me
        die dumb.

        Of course, this patch also requires maintainers to make sure they
        are actually committing up-to-date translations.

        If you don't like the patch, just drop it (I do not insist this is
        a better way than the "GIT Committish" lines, but found it an
        interesting exercise.)

 buildscripts/check_translation.py |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/buildscripts/check_translation.py b/buildscripts/check_translation.py
index 35ab59e..3acd1db 100644
--- a/buildscripts/check_translation.py
+++ b/buildscripts/check_translation.py
@@ -16,15 +16,16 @@ def dir_lang (file, lang):
     return os.path.join (*path_components)
 
 ##     Translation of GIT Commit: <hash>
-REVISION_RE = re.compile ('.*GIT [Cc]ommittish: ([a-f0-9]+)', re.DOTALL)
 CVS_DIFF = 'git diff %(revision)s HEAD -- %(original)s | cat'
 
 def check_file (original, translated):
-    s = open (translated).read ()
-    m = REVISION_RE.match (s)
+    cmd = 'git rev-list --max-count=1 --no-merges HEAD ' + translated
+    l = os.popen (cmd)
+    m = l.read ()
+    l.close ()
     if not m:
-        raise translated + ': no GIT committish: <hash> found'
-    revision = m.group (1)
+        raise translated + ': not in any commit: ' + translated
+    revision = m.replace("\n", "")
 
     c = CVS_DIFF % vars ()
     if verbose:


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

Jan Nieuwenhuizen-2
Johannes Schindelin <[hidden email]> writes:

> Use git to determine when the translation last changed instead of
> relying on the "GIT Committish" line.

Thanks for helping to solve this silly Git issue.  However, I do not
understand, how can Git know what original version was translated?

It is perfectly possible that the translater copies the entire site
(currently identifying and freezing the original copy by adding Git
Committish: <> in those files), translates all files, and commits 2
weeks later.  In the mean time, the original site has seen several
updates.

Using this patch, will the correct diff be shown to the translator to
help her incorporating the changes made in the mean time?

Greetings,
Jan.

--
Jan Nieuwenhuizen <[hidden email]> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

Till
A bit off-topic:
Well, I don't know anything about python, but have to say that the current script doesnt't work for me or I didn't understand it so far. That is, I just did the check-translation and it showed fatal error about some git comment numbers. So I changed *all* commitishes that were in my de-tree. And then the script run without any comment. But I know that there were changes in the files -- so I had to go through them all by Hand, comparing English and German versions. Shouldn't the script just say that: here were some changes? And how can it do this if it doesn't accept my commitish numbers -- I understand that when I insert the last available commitish the script doesn't find any differences, because it obviously searches for commitish numbers to say: in the last commitish this file was changed, and your commitish is older... and so on. And I just inserted the last commitish.
But then, why did it not accept my commitish numbers in the first case?

Greetings
Till

Jan Nieuwenhuizen wrote:
Johannes Schindelin [hidden email] writes:

  
Use git to determine when the translation last changed instead of
relying on the "GIT Committish" line.
    

Thanks for helping to solve this silly Git issue.  However, I do not
understand, how can Git know what original version was translated?

It is perfectly possible that the translater copies the entire site
(currently identifying and freezing the original copy by adding Git
Committish: <> in those files), translates all files, and commits 2
weeks later.  In the mean time, the original site has seen several
updates.

Using this patch, will the correct diff be shown to the translator to
help her incorporating the changes made in the mean time?

Greetings,
Jan.

  

_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

John Mandereau
In reply to this post by Jan Nieuwenhuizen-2
Le samedi 13 janvier 2007 à 14:56 +0100, Jan Nieuwenhuizen a écrit :
> Johannes Schindelin <[hidden email]> writes:
>
> > Use git to determine when the translation last changed instead of
> > relying on the "GIT Committish" line.
>
> Thanks for helping to solve this silly Git issue.  However, I do not
> understand, how can Git know what original version was translated?

That's not always possible.  If a translator polishes translation of a
page and commit without running check-translation first, he will miss
changes in English pages.  It is worth trying to make translators' life
easier, but this patch isn't a good solution.  I'd prefer a script that
update the committishes in translated pages automatically when a
translator has made sure the translation is synced with the last fetched
remote head. I'll have a look at Werner's old and ignored
check-translation patch, too ;-)


> It is perfectly possible that the translater copies the entire site
> (currently identifying and freezing the original copy by adding Git
> Committish: <> in those files), translates all files, and commits 2
> weeks later.  In the mean time, the original site has seen several
> updates.

Agreed.  This is even very probable, as Git newbies may pull several
times before they understand they should add and commit newly translated
files.

> Using this patch, will the correct diff be shown to the translator to
> help her incorporating the changes made in the mean time?

After a quick test, I say "yes", but only if you do things right from
the beginning with Git, which is seldom true.  Current check-translation
system is slightly more tolerant and reliable IMHO.


--
John Mandereau <[hidden email]>



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

John Mandereau
In reply to this post by Till
Le samedi 13 janvier 2007 à 16:45 +0200, Till Rettig a écrit :
> A bit off-topic:
> Well, I don't know anything about python, but have to say that the
> current script doesnt't work for me or I didn't understand it so far.

If you find something unclear or missing in the README, please let me
know.  See also Jean-Charles's gitrux, that he recently sent on this
list.

>  That is, I just did the check-translation and it showed fatal error
> about some git comment numbers. So I changed *all* commitishes that
> were in my de-tree. And then the script run without any comment. But I
> know that there were changes in the files -- so I had to go through
> them all by Hand, comparing English and German versions. Shouldn't the
> script just say that: here were some changes? And how can it do this
> if it doesn't accept my commitish numbers -- I understand that when I
> insert the last available commitish the script doesn't find any
> differences, because it obviously searches for commitish numbers to
> say: in the last commitish this file was changed, and your commitish
> is older... and so on. And I just inserted the last commitish.
> But then, why did it not accept my commitish numbers in the first
> case?

This is strange you encounter bad committishes errors, as (I suppose)
_you_ have written this committishes in translated files, so even if
they are not valid committishes in git.sv.gnu.org, they should be valid
committishes in your local repository copy.


You must have done something wrong with the committishes.  There are two
ways to fix them and make sure the translation is up to date (in every
case, don't pull during this process, like during any
check-translation/update process):

- either you write the latest committish to all pages and you check
every translated page against the English one.

- either you write an old enough committish to all pages, then you check
and update the translation as usual, except that check-translation will
show you a lot of changes being already in translated pages.

After that, you will be able to safely follow README instructions for
future translation updates.


Good luck!
--
John Mandereau <[hidden email]>



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

Johannes Schindelin
In reply to this post by Jan Nieuwenhuizen-2
Hi,

On Sat, 13 Jan 2007, Jan Nieuwenhuizen wrote:

> Johannes Schindelin <[hidden email]> writes:
>
> > Use git to determine when the translation last changed instead of
> > relying on the "GIT Committish" line.
>
> Thanks for helping to solve this silly Git issue.  However, I do not
> understand, how can Git know what original version was translated?

Well, it can't. As I mentioned in my email, the committer has to make sure
that he is committing an up-to-date translation, i.e. that it corresponds
to the English documentation in the _same_ revision.

> It is perfectly possible that the translater copies the entire site
> (currently identifying and freezing the original copy by adding Git
> Committish: <> in those files), translates all files, and commits 2
> weeks later.  In the mean time, the original site has seen several
> updates.
>
> Using this patch, will the correct diff be shown to the translator to
> help her incorporating the changes made in the mean time?

It _can_ be done, but is a little more involved. The basic idea is to
introduce a side branch starting at the revision this translation is based
on. Then, just commit the translation (which means that the translated
text corresponds exactly to the English text in that revision). Merge the
result back into the main branch. In git commands:

# replace myweb~20 by whatever revision this is based on
$ git checkout -b sidebranch myweb~20

# apply the patch (assuming you got it as a mail with an inlined patch)
$ git am themailboxfilewiththepatch

# go back to main branch
$ git checkout myweb

# merge the sidebranch
$ git pull . sidebranch

(# with git 1.5.0 this will be instead
 $ git merge sidebranch)

The commit ancestry now looks like this:

myweb~21 - myweb~20 - ... - myweb
         \                /
             sidebranch

Note that what was myweb~20 before is now myweb~21, becasuse we added a
commit to that branch.

This will _only_ work, however, if myweb~20 .. myweb~1 do _not_ touch
files of that particular translation (otherwise _they_ would be found,
instead of the changes in sidebranch).

Having said that, I doubt that it will happen all that often: Once we have
reasonably up-to-date translations, the updates will be small, and
probably applied very fast.

And for new translations, the contributors can use "make
check-translation" themselves, to find the spots they have to update
before submission.

Ciao,
Dscho



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

Johannes Schindelin
In reply to this post by John Mandereau
Hi,

On Sat, 13 Jan 2007, John Mandereau wrote:

> If a translator polishes translation of a page and commit without
> running check-translation first, he will miss changes in English pages.

If the translator does not commit halfway through _and_ pull _and_
continues polishing _and_ commits without checking translation first, it
still works.

My patch works like this: for every file to check, find the most recent
commit which changed that file. Compare the version of the corresponding
_English_ file in the working tree with the version in that commit.

So something like

1. translate
2. hack hack hack
3. polish translation
4. pull upstream
5. check

still works as expected.

> I'd prefer a script that update the committishes in translated pages
> automatically when a translator has made sure the translation is synced
> with the last fetched remote head.

That is reasonably easy, too, but will add one commit. Of course, the
commit then says "I checked the translation at this stage and am confident
it is up-to-date", which might be a desired thing.

> > It is perfectly possible that the translater copies the entire site
> > (currently identifying and freezing the original copy by adding Git
> > Committish: <> in those files), translates all files, and commits 2
> > weeks later.  In the mean time, the original site has seen several
> > updates.
>
> Agreed.  This is even very probable, as Git newbies may pull several
> times before they understand they should add and commit newly translated
> files.

Yes, this is a problem.

> > Using this patch, will the correct diff be shown to the translator to
> > help her incorporating the changes made in the mean time?
>
> After a quick test, I say "yes", but only if you do things right from
> the beginning with Git, which is seldom true.  Current check-translation
> system is slightly more tolerant and reliable IMHO.

As I said, it was a fun exercise.

Ciao,
Dscho



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

Johannes Schindelin
In reply to this post by Till
Hi,

On Sat, 13 Jan 2007, Till Rettig wrote:

> I just did the check-translation and it showed fatal error about some
> git comment numbers.

What error did it show? And what commit (or _did_ you mean "comment"?)
numbers were they?

If in doubt, you can always create a throwaway branch from that revision:
Say "git log" to find which commit you changed the numbers (say "git log
-p" to see the diffs interspersed), and then say

$ git checkout -b temp <commit>

Ciao,
Dscho



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

Johannes Schindelin
In reply to this post by John Mandereau
Hi,

On Sat, 13 Jan 2007, John Mandereau wrote:

> See also Jean-Charles's gitrux, that he recently sent on this list.

I missed that. I also cannot find it in the archives. What does it do?

Ciao,
Dscho



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

John Mandereau
Le dimanche 14 janvier 2007 à 13:18 +0100, Johannes Schindelin a écrit :
> On Sat, 13 Jan 2007, John Mandereau wrote:
> > See also Jean-Charles's gitrux, that he recently sent on this list.
>
> I missed that. I also cannot find it in the archives. What does it do?

See the "Translators git-tips" thread.  Jean-Charles, a French
translator, has wrote a tutorial on updating lilypond.org translations
using Git and Emacs, and has called it "gitrux".  I don't know why...
ask him if you are curious :)

Cheers
--
John Mandereau <[hidden email]>



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] translations: Make "GIT Committish:" lines obsolete

Till
In reply to this post by John Mandereau


John Mandereau wrote:
Le samedi 13 janvier 2007 à 16:45 +0200, Till Rettig a écrit :
  
A bit off-topic:
Well, I don't know anything about python, but have to say that the
current script doesnt't work for me or I didn't understand it so far.
    

If you find something unclear or missing in the README, please let me
know.  See also Jean-Charles's gitrux, that he recently sent on this
list.
  
Yes, I guess it just really takes some time to understand git and all that it implies. I surely
thought I was following the README stricktly, but might well be that I did some mistakes
like omitted some steps or something.
But then, why did it not accept my commitish numbers in the first
case?
  

This is strange you encounter bad committishes errors, as (I suppose)
_you_ have written this committishes in translated files, so even if
they are not valid committishes in git.sv.gnu.org, they should be valid
committishes in your local repository copy.
  
I guess I found the reason: I started a new git repository at some point when everything was goin a bit weired. So
I guess the first commitishes that I had were not in the history of this newer one. But as I understand
it is better to use the internet commitish and not the local one, so the patches will apply cleanly (at
least in theory).
Hope then my next patches will be ok. ;-)

Till

_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel