# HG changeset patch # User Jaroslav Hajek # Date 1221634923 -7200 # Node ID 1345c8e50ce897a25e74b445861525f6d8df78d0 # Parent d80a9247e8dd106ee559b7c7cdffce7a0f3f816a allow smart treatment of GNU-style ChangeLog files diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -37,6 +37,7 @@ 'ignorews': False, 'ignorewsamount': False, 'ignoreblanklines': False, + 'changelogmask': False, } __slots__ = defaults.keys() diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -10,7 +10,7 @@ from node import hex, nullid, short import base85, cmdutil, mdiff, util, revlog, diffhelpers, copies import cStringIO, email.Parser, os, popen2, re, errno -import sys, tempfile, zlib +import sys, tempfile, zlib, fnmatch class PatchError(Exception): pass @@ -1065,6 +1065,7 @@ ignorews=get('ignore_all_space', 'ignorews'), ignorewsamount=get('ignore_space_change', 'ignorewsamount'), ignoreblanklines=get('ignore_blank_lines', 'ignoreblanklines'), + changelogmask=get('changelog_mask', 'changelogmask', getter=ui.config), context=get('unified', getter=ui.config)) def updatedir(ui, repo, patches): @@ -1257,6 +1258,19 @@ if dodiff == 'binary': text = b85diff(to, tn) else: + # check whether this can be a ChangeLog entry + ischangelogentry = False + if (a == b and opts.changelogmask + and fnmatch.fnmatch(a, opts.changelogmask)): + lto = len(to) + ltn = len(tn) + if ltn > lto and tn[-lto:] == to and tn[-lto-1] == '\n': + ischangelogentry = True + # if so, strip the rest of the file to get only the prepended + # lines dumped + if ischangelogentry: + tn = tn[:-lto] + to = '' text = mdiff.unidiff(to, date1, # ctx2 date may be dynamic tn, util.datestr(ctx2.date()),