This is an archive of the discontinued Mercurial Phabricator instance.

convert: option to set date and time for svn commits
ClosedPublic

Authored by nslsrv on Jan 11 2021, 5:55 PM.

Details

Summary

Converting to subversion repository is not preserving original commit dates as
it may break some subversion functionality if commit dates are not monotonically
increasing.

This patch adds convert.svn.dangerous-set-commit-dates configuration option
to change this behaviour and enable commit dates convertion for those who want
to take risks.

Subversion always uses commit dates with UTC timezone, so only timestamps
are used.

Test test-convert-svn-sink.t uses svnxml.py script to dump history of svn
repositories. Atm the script is not printing date field from svn log. This
patch changes this to allow checks on correctness of date and time convertion.

Documentation is updated. Additional test case is added to test commit dates
convertion.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

nslsrv created this revision.Jan 11 2021, 5:55 PM
nslsrv planned changes to this revision.Jan 11 2021, 6:33 PM

Just noticed that incremental conversion is not covered by the patch.

hgext/convert/subversion.py
1505

I guess it's wrong for incremental conversion: it must be initialized with the last svn commit date, if destination svn repository is not empty.

durin42 added inline comments.
hgext/convert/__init__.py
501

I'd rather this had a scarier name, like allow-setting-dates-i-understand-this-can-break-some-svn-behavior-and-read-the-docs. Also, modern convention these days is to separate words with dashes in config knobs to make them easier to read. :)

504

Extra caveats are required here, notably that per http://svnbook.red-bean.com/en/1.7/svn.ref.reposhooks.pre-revprop-change.html if the pre-revprop-change hook is absent (the default) on the server then this option must remain disabled.

nslsrv added inline comments.Jan 11 2021, 8:07 PM
hgext/convert/__init__.py
504

If there's no pre-revprop-change hook than propsetting would fail completely, not only for svn:date, but also for hg:convert-rev and hg:convert-branch. It would work as a natural barrier, since propset retcodes are not checked.

The setting being proposed here is not for enabling propsetting itself, but rather for controlling its behavior making it "safe" or "non-safe".

By now I assume that monotonically increasing dates is a good default if propsetting itself is allowed on the server. Do you think that it's better to have propsetting disabled by default?

I'm preparing the patch that checks the last revision date, which makes the code even more complex. Maybe it's time to shift back to simplier solution and make an option to just enable/disable date propsetting itself.

durin42 added inline comments.Jan 12 2021, 10:37 AM
hgext/convert/__init__.py
504

I don't know that I'd bother with the more complicated version. I do think it makes sense to have the date-propsetting off by default (the hg:whatever ones are fine - they're harmless).

Good catch on this failing-working if propsets fail. I guess that's by design. Probably still should document the svn-date-editing thing requiring the hook because otherwise that's a mysterious bug report in 3y waiting to happen IMO.

nslsrv retitled this revision from convert: set date and time for svn commits to convert: option to set date and time for svn commits.Jan 12 2021, 4:20 PM
nslsrv edited the summary of this revision. (Show Details)
nslsrv updated this revision to Diff 24722.
nslsrv marked 3 inline comments as done.Jan 12 2021, 4:24 PM

I decided to simplify things and made an option to enable/disable date setting altogether. I've addressed the comments about option naming, documented the need for pre-revprop-change hook modification and made the hook generation more flexible for local repo case.

@durin42 Should I ask you or anybody else to review? No problem with waiting, just not sure.

Ping someone else please - I'm busy with other things this week. :(

pulkit accepted this revision.Jan 27 2021, 5:31 AM
This revision is now accepted and ready to land.Jan 27 2021, 5:31 AM
This revision was automatically updated to reflect the committed changes.