[PATCH] devel/mercurial --authormapsuffix

Glen Barber gjb at FreeBSD.org
Sun Jun 22 20:21:30 UTC 2014


On Sun, Jun 22, 2014 at 03:56:11PM -0400, Glen Barber wrote:
> On Sun, Jun 22, 2014 at 12:43:08PM -0700, Lawrence Stewart wrote:
> > Hi Python team,
> > 
> > As part of the set up and ongoing running of hg-beta.freebsd.org, I make
> > use of a patch against devel/mercurial which allows me to append a
> > suffix to author names during the svn -> hg incremental conversion process.
> > 
> > clusteradm@ are working to streamline the package management on cluster
> > hosts and it would simplify things for them if the hg-beta.freebsd.org
> > jail did not make use of any custom compiled software.
> > 
> > The patch in question is at [1]. and after discussion with upstream
> > [2,3] it was decided not to fold it into the official Mercurial
> > distribution.
> > 
> > I'm hoping you would be happy to carry the patch in our mercurial/devel
> > port as an off-by-default option which clusteradm@ can then enable for
> > cluster package builds via poudriere.
> > 
> 
> Something like what devel/bugzilla44 does would be perfect.  What that
> port does is includes an off-by-default FREEBSD option, which we can
> enable in the cluster, adding the patch in question as EXTRA_PATCHES.
> 
>   % make -C devel/bugzilla44 -V FREEBSD_DESC
>   Patch used internally by the FreeBSD project
> 

The attached diff against the devel/mercurial port seems to do what we
need.

Glen

-------------- next part --------------
Index: Makefile
===================================================================
--- Makefile	(revision 358572)
+++ Makefile	(working copy)
@@ -14,10 +14,11 @@
 USE_PYTHON=	2
 USE_PYDISTUTILS=yes
 
-OPTIONS_DEFINE=	CA_BUNDLE DATA DOCS EXAMPLES NLS
+OPTIONS_DEFINE=	CA_BUNDLE DATA DOCS EXAMPLES NLS FREEBSD
 OPTIONS_DEFAULT=DATA
 OPTIONS_SUB=	yes
 CA_BUNDLE_DESC=	Install CA Certificates
+FREEBSD_DESC=	Patches used internally by the FreeBSD Project
 
 CONTRIB_FILES=	bash_completion \
 		casesmash.py \
@@ -66,6 +67,10 @@
 EXTRA_PATCHES+=	${FILESDIR}/extra-patch-setup.py
 .endif
 
+.if ${PORT_OPTIONS:MFREEBSD}
+EXTRA_PATCHES+=	${FILESDIR}/extra-patch-authormapsuffix
+.endif
+
 post-install:
 	${INSTALL_MAN} ${WRKSRC}/doc/*.1 ${STAGEDIR}${PREFIX}/man/man1/
 	${INSTALL_MAN} ${WRKSRC}/doc/*.5 ${STAGEDIR}${PREFIX}/man/man5/
Index: files/extra-patch-authormapsuffix
===================================================================
--- files/extra-patch-authormapsuffix	(revision 0)
+++ files/extra-patch-authormapsuffix	(working copy)
@@ -0,0 +1,166 @@
+--- hgext/convert/__init__.py.orig	2014-06-01 17:15:14.000000000 -0400
++++ hgext/convert/__init__.py	2014-06-22 16:11:35.609199105 -0400
+@@ -85,6 +85,9 @@
+ 
+     Empty lines and lines starting with a ``#`` are ignored.
+ 
++    The authormapsuffix can be used to append set text to each
++    post-authormap-translated author name.
++
+     The filemap is a file that allows filtering and remapping of files
+     and directories. Each line can contain one of the following
+     directives::
+@@ -314,6 +317,8 @@
+            _('import up to source revision REV'), _('REV')),
+           ('A', 'authormap', '',
+            _('remap usernames using this file'), _('FILE')),
++          ('', 'authormapsuffix', '',
++           _('append this suffix to remapped author names'), _('SUFFIX')),
+           ('', 'filemap', '',
+            _('remap file names using contents of file'), _('FILE')),
+           ('', 'splicemap', '',
+--- hgext/convert/convcmd.py.orig	2014-06-01 17:15:14.000000000 -0400
++++ hgext/convert/convcmd.py	2014-06-22 16:11:35.610199033 -0400
+@@ -103,12 +103,15 @@
+         self.commitcache = {}
+         self.authors = {}
+         self.authorfile = None
++        self.authormapsuffix = ''
+ 
+         # Record converted revisions persistently: maps source revision
+         # ID to target revision ID (both strings).  (This is how
+         # incremental conversions work.)
+         self.map = mapfile(ui, revmapfile)
+ 
++        if opts.get('authormapsuffix'):
++            self.authormapsuffix = opts.get('authormapsuffix')
+         # Read first the dst author map if any
+         authorfile = self.dest.authorfile()
+         if authorfile and os.path.exists(authorfile):
+@@ -356,7 +359,7 @@
+                 continue
+ 
+             srcauthor = srcauthor.strip()
+-            dstauthor = dstauthor.strip()
++            dstauthor = dstauthor.strip() + self.authormapsuffix
+             if self.authors.get(srcauthor) in (None, dstauthor):
+                 msg = _('mapping author %s to %s\n')
+                 self.ui.debug(msg % (srcauthor, dstauthor))
+@@ -370,7 +373,8 @@
+ 
+     def cachecommit(self, rev):
+         commit = self.source.getcommit(rev)
+-        commit.author = self.authors.get(commit.author, commit.author)
++        commit.author = self.authors.get(commit.author,
++                                         commit.author + self.authormapsuffix)
+         # If commit.branch is None, this commit is coming from the source
+         # repository's default branch and destined for the default branch in the
+         # destination repository. For such commits, passing a literal "None"
+--- tests/test-convert-authormap.t.orig	2014-06-01 17:15:14.000000000 -0400
++++ tests/test-convert-authormap.t	2014-06-22 16:11:35.610199033 -0400
+@@ -10,6 +10,8 @@
+   $ cd orig
+   $ echo foo > foo
+   $ HGUSER='user name' hg ci -qAm 'foo'
++  $ echo bar > bar
++  $ HGUSER='user name 2' hg ci -qAm 'bar'
+   $ cd ..
+ 
+ Explicit --authors
+@@ -26,13 +28,19 @@
+   scanning source...
+   sorting...
+   converting...
+-  0 foo
++  1 foo
++  0 bar
+   writing author map file $TESTTMP/new/.hg/authormap (glob)
+   $ cat new/.hg/authormap
+   user name=Long User Name
+   $ hg -Rnew log
+-  changeset:   0:d89716e88087
++  changeset:   1:263e7765e4b7
+   tag:         tip
++  user:        user name 2
++  date:        Thu Jan 01 00:00:00 1970 +0000
++  summary:     bar
++  
++  changeset:   0:d89716e88087
+   user:        Long User Name
+   date:        Thu Jan 01 00:00:00 1970 +0000
+   summary:     foo
+@@ -48,11 +56,72 @@
+   scanning source...
+   sorting...
+   converting...
+-  0 foo
++  1 foo
++  0 bar
+   $ hg -Rnew log
+-  changeset:   0:d89716e88087
++  changeset:   1:263e7765e4b7
+   tag:         tip
++  user:        user name 2
++  date:        Thu Jan 01 00:00:00 1970 +0000
++  summary:     bar
++  
++  changeset:   0:d89716e88087
+   user:        Long User Name
+   date:        Thu Jan 01 00:00:00 1970 +0000
+   summary:     foo
+   
++  $ rm -rf new
++
++Use authormapsuffix together with authormap
++
++  $ cat > authormap.txt <<EOF
++  > user name = username
++  > user name 2 = username2
++  > EOF
++  $ hg convert --authormap authormap.txt --authormapsuffix '@test.org' orig new
++  initializing destination new repository
++  scanning source...
++  sorting...
++  converting...
++  1 foo
++  0 bar
++  writing author map file $TESTTMP/new/.hg/authormap
++  $ cat new/.hg/authormap
++  user name 2=username2 at test.org
++  user name=username at test.org
++  $ hg -Rnew log
++  changeset:   1:aeeaab422b32
++  tag:         tip
++  user:        username2 at test.org
++  date:        Thu Jan 01 00:00:00 1970 +0000
++  summary:     bar
++  
++  changeset:   0:51317d63da9e
++  user:        username at test.org
++  date:        Thu Jan 01 00:00:00 1970 +0000
++  summary:     foo
++  
++  $ rm -rf new
++
++Use authormapsuffix stand alone
++
++  $ hg convert --authormapsuffix '@test.org' orig new
++  initializing destination new repository
++  scanning source...
++  sorting...
++  converting...
++  1 foo
++  0 bar
++  $ hg -Rnew log
++  changeset:   1:94e0dcfe3b0d
++  tag:         tip
++  user:        user name 2 at test.org
++  date:        Thu Jan 01 00:00:00 1970 +0000
++  summary:     bar
++  
++  changeset:   0:e2ff155c86b8
++  user:        user name at test.org
++  date:        Thu Jan 01 00:00:00 1970 +0000
++  summary:     foo
++  
++

Property changes on: files/extra-patch-authormapsuffix
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-python/attachments/20140622/4d0ed949/attachment.sig>


More information about the freebsd-python mailing list