# HG changeset patch # User Frank Kingswood # Date 2009-12-15 10:37:23 # Node ID 69ce7a10e593d28006790b8e264e2a89b8ad41f9 # Parent a43ae5777221e02b5910677c1e6f150bc0613a39 convert: implement two hooks in builtin cvsps diff --git a/hgext/convert/__init__.py b/hgext/convert/__init__.py --- a/hgext/convert/__init__.py +++ b/hgext/convert/__init__.py @@ -165,6 +165,15 @@ def convert(ui, src, dest=None, revmapfi matched. If a match occurs, then the conversion process will add the most recent revision on the branch indicated in the regex as the second parent of the changeset. + --config hook.cvslog + Specify a Python function to be called at the end of gathering + the CVS log. The function is passed a list with the log entries, + and can modify the entries in-place, or add or delete them. + --config hook.cvschangesets + Specify a Python function to be called after the changesets + are calculated from the the CVS log. The function is passed + a list with the changeset entries, and can modify the changesets + in-place, or add or delete them. An additional "debugcvsps" Mercurial command allows the builtin changeset merging code to be run without doing a conversion. Its diff --git a/hgext/convert/cvsps.py b/hgext/convert/cvsps.py --- a/hgext/convert/cvsps.py +++ b/hgext/convert/cvsps.py @@ -11,6 +11,7 @@ import re import cPickle as pickle from mercurial import util from mercurial.i18n import _ +from mercurial import hook class logentry(object): '''Class logentry has the following attributes: @@ -444,6 +445,8 @@ def createlog(ui, directory=None, root=" ui.status(_('%d log entries\n') % len(log)) + hook.hook(ui, None, "cvslog", True, log=log) + return log @@ -730,6 +733,8 @@ def createchangeset(ui, log, fuzz=60, me ui.status(_('%d changeset entries\n') % len(changesets)) + hook.hook(ui, None, "cvschangesets", True, changesets=changesets) + return changesets diff --git a/tests/test-convert-cvs b/tests/test-convert-cvs --- a/tests/test-convert-cvs +++ b/tests/test-convert-cvs @@ -16,10 +16,23 @@ echo "[extensions]" >> $HGRCPATH echo "convert = " >> $HGRCPATH echo "graphlog = " >> $HGRCPATH +cat > cvshooks.py <> $HGRCPATH +echo "cvslog=python:$hookpath/cvshooks.py:cvslog" >> $HGRCPATH +echo "cvschangesets=python:$hookpath/cvshooks.py:cvschangesets" >> $HGRCPATH + echo % create cvs repository mkdir cvsrepo cd cvsrepo -CVSROOT=`pwd` +CVSROOT=$PWD export CVSROOT CVS_OPTIONS=-f export CVS_OPTIONS diff --git a/tests/test-convert-cvs.out b/tests/test-convert-cvs.out --- a/tests/test-convert-cvs.out +++ b/tests/test-convert-cvs.out @@ -17,8 +17,10 @@ connecting to cvsrepo scanning source... collecting CVS rlog 5 log entries +cvslog hook: 5 entries creating changesets 3 changeset entries +cvschangesets hook: 3 changesets sorting... converting... 2 Initial revision @@ -34,8 +36,10 @@ connecting to cvsrepo scanning source... collecting CVS rlog 5 log entries +cvslog hook: 5 entries creating changesets 3 changeset entries +cvschangesets hook: 3 changesets sorting... converting... 2 Initial revision @@ -57,8 +61,10 @@ connecting to cvsrepo scanning source... collecting CVS rlog 7 log entries +cvslog hook: 7 entries creating changesets 4 changeset entries +cvschangesets hook: 4 changesets sorting... converting... 0 ci1 @@ -72,8 +78,10 @@ connecting to cvsrepo scanning source... collecting CVS rlog 7 log entries +cvslog hook: 7 entries creating changesets 4 changeset entries +cvschangesets hook: 4 changesets sorting... converting... 0 ci1 @@ -94,8 +102,10 @@ connecting to cvsrepo scanning source... collecting CVS rlog 8 log entries +cvslog hook: 8 entries creating changesets 5 changeset entries +cvschangesets hook: 5 changesets sorting... converting... 0 ci2 @@ -106,8 +116,10 @@ connecting to cvsrepo scanning source... collecting CVS rlog 8 log entries +cvslog hook: 8 entries creating changesets 5 changeset entries +cvschangesets hook: 5 changesets sorting... converting... 0 ci2 @@ -125,8 +137,10 @@ connecting to cvsrepo scanning source... collecting CVS rlog 9 log entries +cvslog hook: 9 entries creating changesets 6 changeset entries +cvschangesets hook: 6 changesets sorting... converting... 0 funny @@ -148,8 +162,10 @@ o 0 () Initial revision files: a b/c % testing debugcvsps collecting CVS rlog 9 log entries +cvslog hook: 9 entries creating changesets 8 changeset entries +cvschangesets hook: 8 changesets --------------------- PatchSet 1 Date: diff --git a/tests/test-convert.out b/tests/test-convert.out --- a/tests/test-convert.out +++ b/tests/test-convert.out @@ -140,6 +140,15 @@ convert a foreign SCM repository to a Me If a match occurs, then the conversion process will add the most recent revision on the branch indicated in the regex as the second parent of the changeset. + --config hook.cvslog + Specify a Python function to be called at the end of gathering the CVS + log. The function is passed a list with the log entries, and can + modify the entries in-place, or add or delete them. + --config hook.cvschangesets + Specify a Python function to be called after the changesets are + calculated from the the CVS log. The function is passed a list with + the changeset entries, and can modify the changesets in-place, or add + or delete them. An additional "debugcvsps" Mercurial command allows the builtin changeset merging code to be run without doing a conversion. Its parameters and