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 2/2] egencache --update-changelogs: Support reversing order
Date: Mon, 02 Nov 2015 21:46:43
Message-Id: 1446500786-23199-2-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 1/2] egencache --update-changelogs: Support setting ChangeLog file name by "Michał Górny"
1 ---
2 bin/egencache | 15 ++++++++++++---
3 man/egencache.1 | 4 ++++
4 2 files changed, 16 insertions(+), 3 deletions(-)
5
6 diff --git a/bin/egencache b/bin/egencache
7 index 984d9f2..51d115a 100755
8 --- a/bin/egencache
9 +++ b/bin/egencache
10 @@ -171,6 +171,9 @@ def parse_args(args):
11 dest="uld_output")
12
13 uc = parser.add_argument_group('--update-changelogs options')
14 + uc.add_argument("--changelog-reversed",
15 + action="store_true",
16 + help="log commits in reverse order (oldest first)")
17 uc.add_argument("--changelog-output",
18 help="output filename for change logs",
19 dest="changelog_output",
20 @@ -745,7 +748,7 @@ class _special_filename(_filename_base):
21 return self.file_name < other.file_name
22
23 class GenChangeLogs(object):
24 - def __init__(self, portdb, changelog_output):
25 + def __init__(self, portdb, changelog_output, changelog_reversed):
26 self.returncode = os.EX_OK
27 self._portdb = portdb
28 self._wrapper = textwrap.TextWrapper(
29 @@ -754,6 +757,7 @@ class GenChangeLogs(object):
30 subsequent_indent = ' '
31 )
32 self._changelog_output = changelog_output
33 + self._changelog_reversed = changelog_reversed
34
35 @staticmethod
36 def grab(cmd):
37 @@ -781,7 +785,11 @@ class GenChangeLogs(object):
38 ''' % (cp, time.strftime('%Y'))))
39
40 # now grab all the commits
41 - commits = self.grab(['git', 'rev-list', 'HEAD', '--', '.']).split()
42 + revlist_cmd = ['git', 'rev-list']
43 + if self._changelog_reversed:
44 + revlist_cmd.append('--reverse')
45 + revlist_cmd.extend(['HEAD', '--', '.'])
46 + commits = self.grab(revlist_cmd).split()
47
48 for c in commits:
49 # Explaining the arguments:
50 @@ -1140,7 +1148,8 @@ def egencache_main(args):
51
52 if options.update_changelogs:
53 gen_clogs = GenChangeLogs(portdb,
54 - changelog_output=options.changelog_output)
55 + changelog_output=options.changelog_output,
56 + changelog_reversed=options.changelog_reversed)
57 gen_clogs.run()
58 ret.append(gen_clogs.returncode)
59
60 diff --git a/man/egencache.1 b/man/egencache.1
61 index b4a95b3..2465ddf 100644
62 --- a/man/egencache.1
63 +++ b/man/egencache.1
64 @@ -46,6 +46,10 @@ the package directories.
65 .br
66 Defaults to ChangeLog.
67 .TP
68 +.BR "\-\-changelog\-reversed"
69 +Reverses the commit order in ChangeLogs. The oldest commits are output
70 +first, the newest last.
71 +.TP
72 .BR "\-\-config\-root=PORTAGE_CONFIGROOT"
73 Location of portage config files.
74 .br
75 --
76 2.6.2