[PATCH] hgconvert: preserve revision timestamps from hg to svn

Christian Ebert blacktrash at gmx.net
Fri Jul 12 13:36:47 CDT 2013


* Florent Angebault on Friday, July 12, 2013 at 17:52:54 +0200
> # HG changeset patch
> # User Florent Angebault <florent.angebault at free.fr>
> # Date 1373641599 -7200
> #      Fri Jul 12 17:06:39 2013 +0200
> # Node ID 5834870243cb49bb1c31554bced1fd5b09b4850c
> # Parent  41c4bdd1d585a9196bd6c668fd9fce5e67a1028a
> hgconvert: preserve revision timestamps from hg to svn
> 
> diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
> --- a/hgext/convert/subversion.py
> +++ b/hgext/convert/subversion.py
> @@ -2,7 +2,7 @@
> #
> # Copyright(C) 2007 Daniel Holth et al
> 
> -import os, re, sys, tempfile, urllib, urllib2, xml.dom.minidom
> +import os, re, sys, tempfile, urllib, urllib2, xml.dom.minidom, dateutil.parser

dateutil.parser is not a standard module, I don't think. Why not
use hg's util.parsedate()?

> import cPickle as pickle
> 
> from mercurial import strutil, scmutil, util, encoding
> @@ -992,6 +992,7 @@
> ACTION="$5"
> 
> if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
> +if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:date" ]; then exit 0; fi
> if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-branch" ]; then exit 0; fi
> if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-rev" ]; then exit 0; fi
> 
> @@ -1242,6 +1243,11 @@
>             if commit.branch and commit.branch != 'default':
>                 self.run('propset', 'hg:convert-branch', commit.branch,
>                          revprop=True, revision=rev)
> +            if commit.date:
> +                date = dateutil.parser.parse(commit.date)

I think this should be    date = util.parsedate(commit.date)[0]

> +                self.run('propset', 'svn:date',
> +                         date.strftime('%Y-%m-%dT%H:%M:%S.%fZ'),

probably:                   util.datestr((date, 0), '%Y-%m-%dT%H:%M:%S.%fZ)

Not 100% sure about omitting TZ and the float though.

-- 
theatre - books - texts - movies
Black Trash Productions at home: http://www.blacktrash.org
Black Trash Productions on Facebook:
http://www.facebook.com/blacktrashproductions


More information about the Mercurial-devel mailing list