Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] egencache --update-changelogs: fix timestamp assumptions (bug 579292)
Date: Fri, 08 Apr 2016 06:52:28
Message-Id: 20160407235130.458a3f9f.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] egencache --update-changelogs: fix timestamp assumptions (bug 579292) by Zac Medico
1 On Thu, 7 Apr 2016 22:46:25 -0700
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Since commit times are not necessarily ordered, synchronize the
5 > ChangeLog mtime with the last commit time, and use exact comparison
6 > to detect changes.
7 >
8 > X-Gentoo-bug: 579292
9 > X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=579292
10 > ---
11 > bin/egencache | 9 +++++++--
12 > 1 file changed, 7 insertions(+), 2 deletions(-)
13 >
14 > diff --git a/bin/egencache b/bin/egencache
15 > index 0123d57..41612e5 100755
16 > --- a/bin/egencache
17 > +++ b/bin/egencache
18 > @@ -775,12 +775,16 @@ class GenChangeLogs(object):
19 > # This cp has not been added to the repo.
20 > return
21 >
22 > + lmod = long(lmod)
23 > +
24 > try:
25 > - cmod = os.stat('ChangeLog').st_mtime
26 > + cmod = os.stat('ChangeLog')[stat.ST_MTIME]
27 > except OSError:
28 > cmod = 0
29 >
30 > - if float(cmod) >= float(lmod):
31 > + # Use exact comparison, since commit times are
32 > + # not necessarily ordered.
33 > + if cmod == lmod:
34 > return
35 >
36 > try:
37 > @@ -903,6 +907,7 @@ class GenChangeLogs(object):
38 > '\n%s\n\n' %
39 > '\n'.join(self._wrapper.fill(x) for x in body))
40 > output.close()
41 > + os.utime(self._changelog_output, (lmod, lmod))
42 >
43 > def _task_iter(self):
44 > if not os.path.isdir(os.environ.get('GIT_DIR',
45 > os.path.join(self._repo_path, '.git'))):
46
47 the above looks good, but what about:
48
49
50 [19:01] <dwfreed|phone> just use --first-parent
51 [19:01] <dwfreed|phone> also take into account merge commits
52 [19:03] <dwfreed|phone> git really complicates ChangeLog generation in general
53 [19:03] <dwfreed|phone> because your ChangeLog should reflect when these commits became part of master, but you still need to perserve their messages
54 [19:04] * zmedico is skeptical about the linearizability of the timestamps
55 [19:04] <dwfreed|phone> if you don't look at merge commits for your timestamps of changes, correct, it is not linear
56 [19:05] <dwfreed|phone> but if you take a set of commits and determine when they became part of master, it is linear
57 [19:05] <dol-sen> so: git log --first-parent --format=%ct -1 .
58 [19:05] <dol-sen> to get the last timestamp of changes to htat pkg
59 [19:06] <dol-sen> then use that timestamp
60 [19:06] <dol-sen> lmod = self.grab(['git', self._work_tree, 'log', '--format=%ct', '-1', '.'])
61 [19:06] <dol-sen> that is the current code
62 [19:06] <dwfreed|phone> git log -m --first-parent --format=%ct -1 .
63 [19:06] <dol-sen> so just add the --first-parent option?
64 [19:07] <dwfreed|phone> you want -m toolmod = self.grab(['git',
65 self._work_tree, 'log', '--format=%ct', '-1', '.'])
66
67 [19:06] <dwfreed|phone> git log -m --first-parent --format=%ct -1 .
68 [19:06] <dol-sen> so just add the --first-parent option?
69 [19:07] <dwfreed|phone> you want -m too
70
71
72 Don't we need to add the -m --first-parent ???
73 --
74 Brian Dolbec <dolsen>

Replies