diff options
Diffstat (limited to 'subcmds/diffmanifests.py')
-rw-r--r-- | subcmds/diffmanifests.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/subcmds/diffmanifests.py b/subcmds/diffmanifests.py index b999699e..f6cc30a2 100644 --- a/subcmds/diffmanifests.py +++ b/subcmds/diffmanifests.py | |||
@@ -1,5 +1,3 @@ | |||
1 | # -*- coding:utf-8 -*- | ||
2 | # | ||
3 | # Copyright (C) 2014 The Android Open Source Project | 1 | # Copyright (C) 2014 The Android Open Source Project |
4 | # | 2 | # |
5 | # Licensed under the Apache License, Version 2.0 (the "License"); | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -16,12 +14,14 @@ | |||
16 | 14 | ||
17 | from color import Coloring | 15 | from color import Coloring |
18 | from command import PagedCommand | 16 | from command import PagedCommand |
19 | from manifest_xml import XmlManifest | 17 | from manifest_xml import RepoClient |
18 | |||
20 | 19 | ||
21 | class _Coloring(Coloring): | 20 | class _Coloring(Coloring): |
22 | def __init__(self, config): | 21 | def __init__(self, config): |
23 | Coloring.__init__(self, config, "status") | 22 | Coloring.__init__(self, config, "status") |
24 | 23 | ||
24 | |||
25 | class Diffmanifests(PagedCommand): | 25 | class Diffmanifests(PagedCommand): |
26 | """ A command to see logs in projects represented by manifests | 26 | """ A command to see logs in projects represented by manifests |
27 | 27 | ||
@@ -31,7 +31,7 @@ class Diffmanifests(PagedCommand): | |||
31 | deeper level. | 31 | deeper level. |
32 | """ | 32 | """ |
33 | 33 | ||
34 | common = True | 34 | COMMON = True |
35 | helpSummary = "Manifest diff utility" | 35 | helpSummary = "Manifest diff utility" |
36 | helpUsage = """%prog manifest1.xml [manifest2.xml] [options]""" | 36 | helpUsage = """%prog manifest1.xml [manifest2.xml] [options]""" |
37 | 37 | ||
@@ -68,16 +68,16 @@ synced and their revisions won't be found. | |||
68 | def _Options(self, p): | 68 | def _Options(self, p): |
69 | p.add_option('--raw', | 69 | p.add_option('--raw', |
70 | dest='raw', action='store_true', | 70 | dest='raw', action='store_true', |
71 | help='Display raw diff.') | 71 | help='display raw diff') |
72 | p.add_option('--no-color', | 72 | p.add_option('--no-color', |
73 | dest='color', action='store_false', default=True, | 73 | dest='color', action='store_false', default=True, |
74 | help='does not display the diff in color.') | 74 | help='does not display the diff in color') |
75 | p.add_option('--pretty-format', | 75 | p.add_option('--pretty-format', |
76 | dest='pretty_format', action='store', | 76 | dest='pretty_format', action='store', |
77 | metavar='<FORMAT>', | 77 | metavar='<FORMAT>', |
78 | help='print the log using a custom git pretty format string') | 78 | help='print the log using a custom git pretty format string') |
79 | 79 | ||
80 | def _printRawDiff(self, diff): | 80 | def _printRawDiff(self, diff, pretty_format=None): |
81 | for project in diff['added']: | 81 | for project in diff['added']: |
82 | self.printText("A %s %s" % (project.relpath, project.revisionExpr)) | 82 | self.printText("A %s %s" % (project.relpath, project.revisionExpr)) |
83 | self.out.nl() | 83 | self.out.nl() |
@@ -90,7 +90,7 @@ synced and their revisions won't be found. | |||
90 | self.printText("C %s %s %s" % (project.relpath, project.revisionExpr, | 90 | self.printText("C %s %s %s" % (project.relpath, project.revisionExpr, |
91 | otherProject.revisionExpr)) | 91 | otherProject.revisionExpr)) |
92 | self.out.nl() | 92 | self.out.nl() |
93 | self._printLogs(project, otherProject, raw=True, color=False) | 93 | self._printLogs(project, otherProject, raw=True, color=False, pretty_format=pretty_format) |
94 | 94 | ||
95 | for project, otherProject in diff['unreachable']: | 95 | for project, otherProject in diff['unreachable']: |
96 | self.printText("U %s %s %s" % (project.relpath, project.revisionExpr, | 96 | self.printText("U %s %s %s" % (project.relpath, project.revisionExpr, |
@@ -181,26 +181,26 @@ synced and their revisions won't be found. | |||
181 | self.OptionParser.error('missing manifests to diff') | 181 | self.OptionParser.error('missing manifests to diff') |
182 | 182 | ||
183 | def Execute(self, opt, args): | 183 | def Execute(self, opt, args): |
184 | self.out = _Coloring(self.manifest.globalConfig) | 184 | self.out = _Coloring(self.client.globalConfig) |
185 | self.printText = self.out.nofmt_printer('text') | 185 | self.printText = self.out.nofmt_printer('text') |
186 | if opt.color: | 186 | if opt.color: |
187 | self.printProject = self.out.nofmt_printer('project', attr = 'bold') | 187 | self.printProject = self.out.nofmt_printer('project', attr='bold') |
188 | self.printAdded = self.out.nofmt_printer('green', fg = 'green', attr = 'bold') | 188 | self.printAdded = self.out.nofmt_printer('green', fg='green', attr='bold') |
189 | self.printRemoved = self.out.nofmt_printer('red', fg = 'red', attr = 'bold') | 189 | self.printRemoved = self.out.nofmt_printer('red', fg='red', attr='bold') |
190 | self.printRevision = self.out.nofmt_printer('revision', fg = 'yellow') | 190 | self.printRevision = self.out.nofmt_printer('revision', fg='yellow') |
191 | else: | 191 | else: |
192 | self.printProject = self.printAdded = self.printRemoved = self.printRevision = self.printText | 192 | self.printProject = self.printAdded = self.printRemoved = self.printRevision = self.printText |
193 | 193 | ||
194 | manifest1 = XmlManifest(self.manifest.repodir) | 194 | manifest1 = RepoClient(self.repodir) |
195 | manifest1.Override(args[0], load_local_manifests=False) | 195 | manifest1.Override(args[0], load_local_manifests=False) |
196 | if len(args) == 1: | 196 | if len(args) == 1: |
197 | manifest2 = self.manifest | 197 | manifest2 = self.manifest |
198 | else: | 198 | else: |
199 | manifest2 = XmlManifest(self.manifest.repodir) | 199 | manifest2 = RepoClient(self.repodir) |
200 | manifest2.Override(args[1], load_local_manifests=False) | 200 | manifest2.Override(args[1], load_local_manifests=False) |
201 | 201 | ||
202 | diff = manifest1.projectsDiff(manifest2) | 202 | diff = manifest1.projectsDiff(manifest2) |
203 | if opt.raw: | 203 | if opt.raw: |
204 | self._printRawDiff(diff) | 204 | self._printRawDiff(diff, pretty_format=opt.pretty_format) |
205 | else: | 205 | else: |
206 | self._printDiff(diff, color=opt.color, pretty_format=opt.pretty_format) | 206 | self._printDiff(diff, color=opt.color, pretty_format=opt.pretty_format) |