[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ChangeLogs
From: |
Jaroslav Hajek |
Subject: |
Re: ChangeLogs |
Date: |
Wed, 17 Mar 2010 07:50:14 +0100 |
On Wed, Mar 17, 2010 at 2:07 AM, Rik <address@hidden> wrote:
>
>>>
>> What happened to the plan (or was it a plan already?) to move the ChangeLog
>> entries into the mercurial commit messages?
> This seems like a very good idea.
Well, as has been pointed out previously, it has some negative
effects. In particular we'd lose the advantage of having the related
changelogs grouped per directory.
> One of the current complications with
> using a non-linear commit strategy is that everyone touches the same file,
> ChangeLog, on every commit. This leads Mercurial into attempting an
> unnecessary 3-way merge of that file whenever a personal repository is
> pushed back to the main repository.
>
> --Rik
>
I made the following modification to my Mercurial to combat this
problem (may require a trivial merge in the import section if the
parent is outdated):
# HG changeset patch
# User Jaroslav Hajek <address@hidden>
# Date 1264432918 -3600
# Node ID 436f14ca18e80ba8c72a22a106eccdc366782d61
# Parent f68eaaf6891032750d26ea989607983a297806c3
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
@@ -41,6 +41,7 @@
'ignorewsamount': False,
'ignoreblanklines': False,
'upgrade': 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, diffhelpers, copies
import cStringIO, email.Parser, os, re
-import sys, tempfile, zlib
+import sys, tempfile, zlib, fnmatch
gitre = re.compile('diff --git a/(.*) b/(.*)')
@@ -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, similarity=0):
@@ -1415,6 +1416,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()),
with this patch, I can set
changelogmask=*ChangeLog
in my .hgrc to force mercurial generate a context-free diff for
ChangeLogs, if a hunk of text is only prepended to them. Together with
the mq extension, this eliminates 99% of problems with ChangeLogs,
because the context-free diffs re-apply smoothly in any order. This
also works well for transplanting (which was actually the reason I did
it).
--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz