Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: robbat2@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 4/4] egencache --update-changelogs: Support reversing order
Date: Mon, 02 Nov 2015 18:19:29
Message-Id: 1446488321-3140-5-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCHES] egencache --update-changelogs: fixes for infra rsync by "Michał Górny"
1 ---
2 bin/egencache | 15 ++++++++++++---
3 1 file changed, 12 insertions(+), 3 deletions(-)
4
5 diff --git a/bin/egencache b/bin/egencache
6 index 984d9f2..51d115a 100755
7 --- a/bin/egencache
8 +++ b/bin/egencache
9 @@ -171,6 +171,9 @@ def parse_args(args):
10 dest="uld_output")
11
12 uc = parser.add_argument_group('--update-changelogs options')
13 + uc.add_argument("--changelog-reversed",
14 + action="store_true",
15 + help="log commits in reverse order (oldest first)")
16 uc.add_argument("--changelog-output",
17 help="output filename for change logs",
18 dest="changelog_output",
19 @@ -745,7 +748,7 @@ class _special_filename(_filename_base):
20 return self.file_name < other.file_name
21
22 class GenChangeLogs(object):
23 - def __init__(self, portdb, changelog_output):
24 + def __init__(self, portdb, changelog_output, changelog_reversed):
25 self.returncode = os.EX_OK
26 self._portdb = portdb
27 self._wrapper = textwrap.TextWrapper(
28 @@ -754,6 +757,7 @@ class GenChangeLogs(object):
29 subsequent_indent = ' '
30 )
31 self._changelog_output = changelog_output
32 + self._changelog_reversed = changelog_reversed
33
34 @staticmethod
35 def grab(cmd):
36 @@ -781,7 +785,11 @@ class GenChangeLogs(object):
37 ''' % (cp, time.strftime('%Y'))))
38
39 # now grab all the commits
40 - commits = self.grab(['git', 'rev-list', 'HEAD', '--', '.']).split()
41 + revlist_cmd = ['git', 'rev-list']
42 + if self._changelog_reversed:
43 + revlist_cmd.append('--reverse')
44 + revlist_cmd.extend(['HEAD', '--', '.'])
45 + commits = self.grab(revlist_cmd).split()
46
47 for c in commits:
48 # Explaining the arguments:
49 @@ -1140,7 +1148,8 @@ def egencache_main(args):
50
51 if options.update_changelogs:
52 gen_clogs = GenChangeLogs(portdb,
53 - changelog_output=options.changelog_output)
54 + changelog_output=options.changelog_output,
55 + changelog_reversed=options.changelog_reversed)
56 gen_clogs.run()
57 ret.append(gen_clogs.returncode)
58
59 --
60 2.6.2