Re: [changeset] don't remove whitespace within @example in docstrings

classic Classic list List threaded Threaded
42 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: ChangeLogs

Jaroslav Hajek-2
On Wed, Mar 17, 2010 at 2:07 AM, Rik <[hidden email]> 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 <[hidden email]>
# 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

Reply | Threaded
Open this post in threaded view
|

Re: ChangeLogs

Rik-5
Jaroslav Hajek wrote:
> On Wed, Mar 17, 2010 at 2:07 AM, Rik <[hidden email]> 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.

I think an important question to consider is how coders will interact with
the code base.  If a bug comes up in a script .m file I imagine a debug
flow that looks like this.  I would start by going to the scripts/ChangeLog
file, searching there for every occurrence of the script file name in
question, examining the log note and deciding whether I think it is
related, and then taking action.  If all of the changes were in a single
ChangeLog this wouldn't affect the workflow, only the regular expression
used to search for the file name.

If I were working in a purely Mercurial flow I would just find the file in
the source tree and run 'hg log suspected_file.m' to see the changes.

I'm wary of the ChangeLogs because they require human intervention.  What
if someone forgets to mention a file they changed?  The debug search above
would fail.  On the other hand, Mercurial knows definitively which files
were changed.

As an aside, if per-directory ChangeLogs are a requirement then it would be
a trivial Perl script to parse the output of 'hg log --stytle changelog'
and group the changes based on directory.

>
> 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):
This looks like a nice addition.  I would still prefer to run a vanilla
Mercurial and make the ChangeLogs derived files from the Mercurial logs.
But, if we don't go that direction I will definitely be patching my local
sources with this.

--Rik
123