diff options
-rw-r--r-- | project.py | 13 | ||||
-rw-r--r-- | subcmds/diffmanifests.py | 21 |
2 files changed, 24 insertions, 10 deletions
@@ -2439,7 +2439,7 @@ class Project(object): | |||
2439 | def _allrefs(self): | 2439 | def _allrefs(self): |
2440 | return self.bare_ref.all | 2440 | return self.bare_ref.all |
2441 | 2441 | ||
2442 | def _getLogs(self, rev1, rev2, oneline=False, color=True): | 2442 | def _getLogs(self, rev1, rev2, oneline=False, color=True, pretty_format=None): |
2443 | """Get logs between two revisions of this project.""" | 2443 | """Get logs between two revisions of this project.""" |
2444 | comp = '..' | 2444 | comp = '..' |
2445 | if rev1: | 2445 | if rev1: |
@@ -2450,6 +2450,8 @@ class Project(object): | |||
2450 | out = DiffColoring(self.config) | 2450 | out = DiffColoring(self.config) |
2451 | if out.is_on and color: | 2451 | if out.is_on and color: |
2452 | cmd.append('--color') | 2452 | cmd.append('--color') |
2453 | if pretty_format is not None: | ||
2454 | cmd.append('--pretty=format:%s' % pretty_format) | ||
2453 | if oneline: | 2455 | if oneline: |
2454 | cmd.append('--oneline') | 2456 | cmd.append('--oneline') |
2455 | 2457 | ||
@@ -2466,14 +2468,17 @@ class Project(object): | |||
2466 | raise | 2468 | raise |
2467 | return None | 2469 | return None |
2468 | 2470 | ||
2469 | def getAddedAndRemovedLogs(self, toProject, oneline=False, color=True): | 2471 | def getAddedAndRemovedLogs(self, toProject, oneline=False, color=True, |
2472 | pretty_format=None): | ||
2470 | """Get the list of logs from this revision to given revisionId""" | 2473 | """Get the list of logs from this revision to given revisionId""" |
2471 | logs = {} | 2474 | logs = {} |
2472 | selfId = self.GetRevisionId(self._allrefs) | 2475 | selfId = self.GetRevisionId(self._allrefs) |
2473 | toId = toProject.GetRevisionId(toProject._allrefs) | 2476 | toId = toProject.GetRevisionId(toProject._allrefs) |
2474 | 2477 | ||
2475 | logs['added'] = self._getLogs(selfId, toId, oneline=oneline, color=color) | 2478 | logs['added'] = self._getLogs(selfId, toId, oneline=oneline, color=color, |
2476 | logs['removed'] = self._getLogs(toId, selfId, oneline=oneline, color=color) | 2479 | pretty_format=pretty_format) |
2480 | logs['removed'] = self._getLogs(toId, selfId, oneline=oneline, color=color, | ||
2481 | pretty_format=pretty_format) | ||
2477 | return logs | 2482 | return logs |
2478 | 2483 | ||
2479 | class _GitGetByExec(object): | 2484 | class _GitGetByExec(object): |
diff --git a/subcmds/diffmanifests.py b/subcmds/diffmanifests.py index 05998681..751a2026 100644 --- a/subcmds/diffmanifests.py +++ b/subcmds/diffmanifests.py | |||
@@ -71,6 +71,10 @@ synced and their revisions won't be found. | |||
71 | p.add_option('--no-color', | 71 | p.add_option('--no-color', |
72 | dest='color', action='store_false', default=True, | 72 | dest='color', action='store_false', default=True, |
73 | help='does not display the diff in color.') | 73 | help='does not display the diff in color.') |
74 | p.add_option('--pretty-format', | ||
75 | dest='pretty_format', action='store', | ||
76 | metavar='<FORMAT>', | ||
77 | help='print the log using a custom git pretty format string') | ||
74 | 78 | ||
75 | def _printRawDiff(self, diff): | 79 | def _printRawDiff(self, diff): |
76 | for project in diff['added']: | 80 | for project in diff['added']: |
@@ -92,7 +96,7 @@ synced and their revisions won't be found. | |||
92 | otherProject.revisionExpr)) | 96 | otherProject.revisionExpr)) |
93 | self.out.nl() | 97 | self.out.nl() |
94 | 98 | ||
95 | def _printDiff(self, diff, color=True): | 99 | def _printDiff(self, diff, color=True, pretty_format=None): |
96 | if diff['added']: | 100 | if diff['added']: |
97 | self.out.nl() | 101 | self.out.nl() |
98 | self.printText('added projects : \n') | 102 | self.printText('added projects : \n') |
@@ -124,7 +128,8 @@ synced and their revisions won't be found. | |||
124 | self.printText(' to ') | 128 | self.printText(' to ') |
125 | self.printRevision(otherProject.revisionExpr) | 129 | self.printRevision(otherProject.revisionExpr) |
126 | self.out.nl() | 130 | self.out.nl() |
127 | self._printLogs(project, otherProject, raw=False, color=color) | 131 | self._printLogs(project, otherProject, raw=False, color=color, |
132 | pretty_format=pretty_format) | ||
128 | self.out.nl() | 133 | self.out.nl() |
129 | 134 | ||
130 | if diff['unreachable']: | 135 | if diff['unreachable']: |
@@ -139,9 +144,13 @@ synced and their revisions won't be found. | |||
139 | self.printText(' not found') | 144 | self.printText(' not found') |
140 | self.out.nl() | 145 | self.out.nl() |
141 | 146 | ||
142 | def _printLogs(self, project, otherProject, raw=False, color=True): | 147 | def _printLogs(self, project, otherProject, raw=False, color=True, |
143 | logs = project.getAddedAndRemovedLogs(otherProject, oneline=True, | 148 | pretty_format=None): |
144 | color=color) | 149 | |
150 | logs = project.getAddedAndRemovedLogs(otherProject, | ||
151 | oneline=(pretty_format is None), | ||
152 | color=color, | ||
153 | pretty_format=pretty_format) | ||
145 | if logs['removed']: | 154 | if logs['removed']: |
146 | removedLogs = logs['removed'].split('\n') | 155 | removedLogs = logs['removed'].split('\n') |
147 | for log in removedLogs: | 156 | for log in removedLogs: |
@@ -192,4 +201,4 @@ synced and their revisions won't be found. | |||
192 | if opt.raw: | 201 | if opt.raw: |
193 | self._printRawDiff(diff) | 202 | self._printRawDiff(diff) |
194 | else: | 203 | else: |
195 | self._printDiff(diff, color=opt.color) | 204 | self._printDiff(diff, color=opt.color, pretty_format=opt.pretty_format) |