Print $Rev$ property on file docx and xlsx

19 views
Skip to first unread message

Valentina Marziali

unread,
Jan 5, 2023, 9:33:02 AM1/5/23
to TortoiseSVN
I would like to print the value of the Revision property into a docx and xlsx file. 
I added the property form windows context menu properties --> subversion --> properties --> new --> keyword --> revision .
I wrote into the file/cell  $Rev$
but, after a commit,  I can't see the value of the revision.
This process is fine for txt file.

Could you help me?
Thank you

Daniel Sahlberg

unread,
Jan 5, 2023, 9:47:43 AM1/5/23
to TortoiseSVN
docx and xlsx are binary file formats (zipped XML files to be more precise). Subversion is looking for "$Rev$" within the file but it is very unlikely you will find it in clear in the file. And in either case if Subversion would replace it, chances are that the ZIP file will be corrupt afterwards. Don't set the svn:keywords property on binary files! 

I can't see an easy way to add the revision number within a document.

One way would be to add a pre-commit script using the COM interfaces of Word and Excel to open the file and Search/replace the $Rev$ identifier. But that will only add the latest known revision to the document, which is not the same as the revision you will get after commit. (It is not even assured you will get "latest known + 1" since another commit might be going on in the background and the one finishing first will get the next rev number).

Another way would be to do a post-update and/or post-commit script that does the same (this is similar to what Subversion is doing with the automatic keyword expansion), but you will end up with locally modified files which might be a showstopper in case someone else modifies the file in the repository. (Subversion handles this on text files since it translates/detranslates the $Rev$ keyword before talking to the repository).

Kind regards,
Daniel

Valentina Marziali

unread,
Jan 5, 2023, 11:04:31 AM1/5/23
to TortoiseSVN
Thank you Daniel for your fast and exaustive reply.
Regards
Valentina

--
You received this message because you are subscribed to the Google Groups "TortoiseSVN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tortoisesvn...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tortoisesvn/2815657c-d0dd-40a3-bd91-7a02daa4ee23n%40googlegroups.com.

Stefan

unread,
Jan 5, 2023, 11:06:51 AM1/5/23
to TortoiseSVN
you could use the COM object of SubWCRev to get the revision in your office documents:

lorenz

unread,
Jan 9, 2023, 3:21:13 AM1/9/23
to torto...@googlegroups.com
Valentina Marziali tramite TortoiseSVN wrote:

>I would like to print the value of the Revision property into a docx and
>xlsx file.
>[...]

as Daniel points out othertread, docx and xlsx are zip-archives.

But using the uncompressed formats doc/xls and fixed-lenght keyword
expansion works for me ...

... sort off 8-)
Cell formulars in excel (for example string manipulation) needs
(explicit) recalculation to update the derived cells.

After that the file shows up as modified.
Don't save it when there are no other changes.
--

Lorenz

lorenz

unread,
Jan 9, 2023, 4:18:32 AM1/9/23
to torto...@googlegroups.com
TortoiseSVN on behalf of lorenznl wrote:
>[...]
>Cell formulars in excel (for example string manipulation) need
>(explicit) recalculation to update the derived cells.
>[...]

dang, forgot to mention that formulars base on the cells with the
keywords need something like "&TEXT(NOW();"")" to force updating on
recalculation.
--

Lorenz

Valentina Marziali

unread,
Jan 11, 2023, 10:41:08 AM1/11/23
to TortoiseSVN on behalf of lorenznl
Thanks a lot

--
You received this message because you are subscribed to the Google Groups "TortoiseSVN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tortoisesvn...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages