Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] egencache --update-changelogs: fix timestamp assumptions (bug 579292)
Date: Fri, 08 Apr 2016 05:46:48
Message-Id: 1460094385-11889-1-git-send-email-zmedico@gentoo.org
1 Since commit times are not necessarily ordered, synchronize the
2 ChangeLog mtime with the last commit time, and use exact comparison
3 to detect changes.
4
5 X-Gentoo-bug: 579292
6 X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=579292
7 ---
8 bin/egencache | 9 +++++++--
9 1 file changed, 7 insertions(+), 2 deletions(-)
10
11 diff --git a/bin/egencache b/bin/egencache
12 index 0123d57..41612e5 100755
13 --- a/bin/egencache
14 +++ b/bin/egencache
15 @@ -775,12 +775,16 @@ class GenChangeLogs(object):
16 # This cp has not been added to the repo.
17 return
18
19 + lmod = long(lmod)
20 +
21 try:
22 - cmod = os.stat('ChangeLog').st_mtime
23 + cmod = os.stat('ChangeLog')[stat.ST_MTIME]
24 except OSError:
25 cmod = 0
26
27 - if float(cmod) >= float(lmod):
28 + # Use exact comparison, since commit times are
29 + # not necessarily ordered.
30 + if cmod == lmod:
31 return
32
33 try:
34 @@ -903,6 +907,7 @@ class GenChangeLogs(object):
35 '\n%s\n\n' % '\n'.join(self._wrapper.fill(x) for x in body))
36
37 output.close()
38 + os.utime(self._changelog_output, (lmod, lmod))
39
40 def _task_iter(self):
41 if not os.path.isdir(os.environ.get('GIT_DIR', os.path.join(self._repo_path, '.git'))):
42 --
43 2.7.4

Replies