patch to support multiple line keyword expansion

Tobias Sargeant tobias.sargeant at gmail.com
Mon Jun 16 06:03:43 CDT 2008


Hi,
I've attached a small patch that adds multiple line keyword expansion to the
keyword extension. I don't know if it will have wide enough appeal to
warrant being included, but I thought I'd offer it up for consideration. The
patch is made against keyword.py in the 1.0.1 mercurial release.

The idea was to allow me to manage separate repositories with different
source code licenses, and to still be able to push changesets between them
without the license differences getting pushed between repositories.

RCS style expansions work as before (and are also functional within
multiline expansions).

The markers for the beginning and end of the expanded block are similar in
style to emacs local variable blocks (Begin XYZ: to End:).

Cheers,
Toby.

As an example, my .hg/hgrc file for the GPL'ed version of my code contains:

[extensions]
hglocal.keyword=

[keyword]
**.cpp=
**.hpp=

[longkeywordmaps]
License = \
        // Copyright (C) 2006-2008 Tobias Sargeant (
tobias.sargeant at gmail.com).
        // All rights reserved.
        //
        // This file is part of the Carve CSG Library (http://carve-csg.com/
)
        //
        // This file may be used under the terms of the GNU General Public
        // License version 2.0 as published by the Free Software Foundation
        // and appearing in the file LICENSE.GPL2 included in the packaging
of
        // this file.
        //
        // This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
        // INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS
FOR
        // A PARTICULAR PURPOSE.

and this means that:

// Begin License:
// End:

is expanded to:

// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant at gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20080616/2e24b1b3/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: keyword.patch
Type: application/octet-stream
Size: 5319 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20080616/2e24b1b3/attachment.obj 


More information about the Mercurial-devel mailing list