Abstract away the details of where svn revs are stored in a commit
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Bryan O'Sullivan <b... @serpentine.com>
Date: Mon, 30 Apr 2012 16:08:44 -0700
Local: Mon, Apr 30 2012 7:08 pm
Subject: [PATCH] Abstract away the details of where svn revs are stored in a commit
# HG changeset patch
# User Bryan O'Sullivan <bry... @fb.com>
# Date 1335827282 25200
# Node ID 5a50e44302286194b9d2aec9594b4d32d22ed3f7
# Parent 8de09a3b8ffdd2a0123694c4004e9e98de13d7b0
Abstract away the details of where svn revs are stored in a commit
diff -r 8de09a3b8ffd -r 5a50e4430228 hgsubversion/svncommands.py
--- a/hgsubversion/svncommands.py Mon Apr 30 16:07:41 2012 -0700
+++ b/hgsubversion/svncommands.py Mon Apr 30 16:08:02 2012 -0700
@@ -3,6 +3,7 @@
import cPickle as pickle
import sys
import traceback
+import urlparse
from mercurial import commands
from mercurial import hg
@@ -79,7 +80,6 @@
return result
-
def rebuildmeta(ui, repo, args, **opts):
"""rebuild hgsubversion metadata using values stored in revisions
"""
@@ -132,19 +132,18 @@
for rev in repo:
util.progress(ui, 'prepare', rev, total=numrevs)
ctx = repo[rev]
- extra = ctx.extra()
- convinfo = extra.get('convert_revision', None)
+ convinfo = util.getsvnrev(ctx, None)
if not convinfo:
continue
svnrevnum = int(convinfo.rsplit('@', 1)[1])
youngest = max(youngest, svnrevnum)
- if extra.get('close', None) is None:
+ if ctx.extra().get('close', None) is None:
continue
droprev = lambda x: x.rsplit('@', 1)[0]
parentctx = ctx.parents()[0]
- parentinfo = parentctx.extra().get('convert_revision', '@')
+ parentinfo = util.getsvnrev(parentctx, '@')
if droprev(parentinfo) == droprev(convinfo):
closed.add(parentctx.rev())
@@ -155,7 +154,7 @@
for rev in repo:
util.progress(ui, 'rebuild', rev, total=numrevs)
ctx = repo[rev]
- convinfo = ctx.extra().get('convert_revision', None)
+ convinfo = util.getsvnrev(ctx, None)
if not convinfo:
continue
if '.hgtags' in ctx.files():
@@ -166,7 +165,7 @@
newdata = ctx.filectx('.hgtags').data()
for newtag in newdata[len(parentdata):-1].split('\n'):
ha, tag = newtag.split(' ', 1)
- tagged = repo[ha].extra().get('convert_revision', None)
+ tagged = util.getsvnrev(repo[ha], None)
if tagged is None:
tagged = -1
else:
@@ -244,7 +243,7 @@
parent = ctx
while parent.node() != node.nullid:
parentextra = parent.extra()
- parentinfo = parentextra.get('convert_revision')
+ parentinfo = util.getsvnrev(parent)
assert parentinfo
parent = parent.parents()[0]
@@ -400,7 +399,7 @@
ui.status('Not a child of an svn revision.\n')
return 0
r, br = hashes[pn]
- subdir = parent.extra()['convert_revision'][40:].split('@')[0]
+ subdir = util.getsvnrev(parent)[40:].split('@')[0]
if meta.layout == 'single':
branchpath = ''
elif br == None:
diff -r 8de09a3b8ffd -r 5a50e4430228 hgsubversion/util.py
--- a/hgsubversion/util.py Mon Apr 30 16:07:41 2012 -0700
+++ b/hgsubversion/util.py Mon Apr 30 16:08:02 2012 -0700
@@ -232,11 +232,15 @@
# parentctx is not an ancestor of childctx, files are unrelated
return False
+def getsvnrev(ctx, defval=None):
+ '''Extract SVN revision from commit metadata'''
+ return ctx.extra().get('convert_revision', defval)
+
def _templatehelper(ctx, kw):
'''
Helper function for displaying information about converted changesets.
'''
- convertinfo = ctx.extra().get('convert_revision', '')
+ convertinfo = getsvnrev(ctx, '')
if not convertinfo or not convertinfo.startswith('svn:'):
return ''
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Augie Fackler <r... @durin42.com>
Date: Fri, 4 May 2012 19:40:23 -0500
Local: Fri, May 4 2012 8:40 pm
Subject: Re: [PATCH] Abstract away the details of where svn revs are stored in a commit
queued, with the one nit I listed below fixed
On Apr 30, 2012, at 6:08 PM, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bry
... @fb.com>
> # Date 1335827282 25200
> # Node ID 5a50e44302286194b9d2aec9594b4d32d22ed3f7
> # Parent 8de09a3b8ffdd2a0123694c4004e9e98de13d7b0
> Abstract away the details of where svn revs are stored in a commit
> diff -r 8de09a3b8ffd -r 5a50e4430228 hgsubversion/svncommands.py
> --- a/hgsubversion/svncommands.py Mon Apr 30 16:07:41 2012 -0700
> +++ b/hgsubversion/svncommands.py Mon Apr 30 16:08:02 2012 -0700
> @@ -3,6 +3,7 @@
> import cPickle as pickle
> import sys
> import traceback
> +import urlparse
> from mercurial import commands
> from mercurial import hg
> @@ -79,7 +80,6 @@
> return result
> -
Don't sweat it for this patch (I'll fix up), but in hgsubversion we've generally preserved the pep8 two blank lines before a top level name.
> def rebuildmeta(ui, repo, args, **opts):
> """rebuild hgsubversion metadata using values stored in revisions
> """
> @@ -132,19 +132,18 @@
> for rev in repo:
> util.progress(ui, 'prepare', rev, total=numrevs)
> ctx = repo[rev]
> - extra = ctx.extra()
> - convinfo = extra.get('convert_revision', None)
> + convinfo = util.getsvnrev(ctx, None)
> if not convinfo:
> continue
> svnrevnum = int(convinfo.rsplit('@', 1)[1])
> youngest = max(youngest, svnrevnum)
> - if extra.get('close', None) is None:
> + if ctx.extra().get('close', None) is None:
> continue
> droprev = lambda x: x.rsplit('@', 1)[0]
> parentctx = ctx.parents()[0]
> - parentinfo = parentctx.extra().get('convert_revision', '@')
> + parentinfo = util.getsvnrev(parentctx, '@')
> if droprev(parentinfo) == droprev(convinfo):
> closed.add(parentctx.rev())
> @@ -155,7 +154,7 @@
> for rev in repo:
> util.progress(ui, 'rebuild', rev, total=numrevs)
> ctx = repo[rev]
> - convinfo = ctx.extra().get('convert_revision', None)
> + convinfo = util.getsvnrev(ctx, None)
> if not convinfo:
> continue
> if '.hgtags' in ctx.files():
> @@ -166,7 +165,7 @@
> newdata = ctx.filectx('.hgtags').data()
> for newtag in newdata[len(parentdata):-1].split('\n'):
> ha, tag = newtag.split(' ', 1)
> - tagged = repo[ha].extra().get('convert_revision', None)
> + tagged = util.getsvnrev(repo[ha], None)
> if tagged is None:
> tagged = -1
> else:
> @@ -244,7 +243,7 @@
> parent = ctx
> while parent.node() != node.nullid:
> parentextra = parent.extra()
> - parentinfo = parentextra.get('convert_revision')
> + parentinfo = util.getsvnrev(parent)
> assert parentinfo
> parent = parent.parents()[0]
> @@ -400,7 +399,7 @@
> ui.status('Not a child of an svn revision.\n')
> return 0
> r, br = hashes[pn]
> - subdir = parent.extra()['convert_revision'][40:].split('@')[0]
> + subdir = util.getsvnrev(parent)[40:].split('@')[0]
> if meta.layout == 'single':
> branchpath = ''
> elif br == None:
> diff -r 8de09a3b8ffd -r 5a50e4430228 hgsubversion/util.py
> --- a/hgsubversion/util.py Mon Apr 30 16:07:41 2012 -0700
> +++ b/hgsubversion/util.py Mon Apr 30 16:08:02 2012 -0700
> @@ -232,11 +232,15 @@
> # parentctx is not an ancestor of childctx, files are unrelated
> return False
> +def getsvnrev(ctx, defval=None):
> + '''Extract SVN revision from commit metadata'''
> + return ctx.extra().get('convert_revision', defval)
> +
> def _templatehelper(ctx, kw):
> '''
> Helper function for displaying information about converted changesets.
> '''
> - convertinfo = ctx.extra().get('convert_revision', '')
> + convertinfo = getsvnrev(ctx, '')
> if not convertinfo or not convertinfo.startswith('svn:'):
> return ''
You must
Sign in before you can post messages.
You do not have the permission required to post.