subcmds: display correct path multitree messages

Correct usage of project.relpath for multi manifest workspaces.

Change-Id: Idc32873552fcdae6eec7b03dde2b2f31134b72fd
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/347534
Reviewed-by: Xin Li <delphij@google.com>
Tested-by: LaMont Jones <lamontjones@google.com>
This commit is contained in:
LaMont Jones 2022-09-30 17:46:52 +00:00
parent f8af33c9f0
commit bee4efb874
3 changed files with 21 additions and 17 deletions

View File

@ -155,11 +155,11 @@ is shown, then the branch appears in all projects.
if i.IsSplitCurrent or (in_cnt <= project_cnt - in_cnt): if i.IsSplitCurrent or (in_cnt <= project_cnt - in_cnt):
in_type = 'in' in_type = 'in'
for b in i.projects: for b in i.projects:
relpath = b.project.relpath relpath = _RelPath(b.project)
if not i.IsSplitCurrent or b.current: if not i.IsSplitCurrent or b.current:
paths.append(_RelPath(b.project)) paths.append(relpath)
else: else:
non_cur_paths.append(_RelPath(b.project)) non_cur_paths.append(relpath)
else: else:
fmt = out.notinproject fmt = out.notinproject
in_type = 'not in' in_type = 'not in'

View File

@ -77,33 +77,35 @@ synced and their revisions won't be found.
metavar='<FORMAT>', metavar='<FORMAT>',
help='print the log using a custom git pretty format string') help='print the log using a custom git pretty format string')
def _printRawDiff(self, diff, pretty_format=None): def _printRawDiff(self, diff, pretty_format=None, local=False):
_RelPath = lambda p: p.RelPath(local=local)
for project in diff['added']: for project in diff['added']:
self.printText("A %s %s" % (project.relpath, project.revisionExpr)) self.printText("A %s %s" % (_RelPath(project), project.revisionExpr))
self.out.nl() self.out.nl()
for project in diff['removed']: for project in diff['removed']:
self.printText("R %s %s" % (project.relpath, project.revisionExpr)) self.printText("R %s %s" % (_RelPath(project), project.revisionExpr))
self.out.nl() self.out.nl()
for project, otherProject in diff['changed']: for project, otherProject in diff['changed']:
self.printText("C %s %s %s" % (project.relpath, project.revisionExpr, self.printText("C %s %s %s" % (_RelPath(project), project.revisionExpr,
otherProject.revisionExpr)) otherProject.revisionExpr))
self.out.nl() self.out.nl()
self._printLogs(project, otherProject, raw=True, color=False, pretty_format=pretty_format) self._printLogs(project, otherProject, raw=True, color=False, pretty_format=pretty_format)
for project, otherProject in diff['unreachable']: for project, otherProject in diff['unreachable']:
self.printText("U %s %s %s" % (project.relpath, project.revisionExpr, self.printText("U %s %s %s" % (_RelPath(project), project.revisionExpr,
otherProject.revisionExpr)) otherProject.revisionExpr))
self.out.nl() self.out.nl()
def _printDiff(self, diff, color=True, pretty_format=None): def _printDiff(self, diff, color=True, pretty_format=None, local=False):
_RelPath = lambda p: p.RelPath(local=local)
if diff['added']: if diff['added']:
self.out.nl() self.out.nl()
self.printText('added projects : \n') self.printText('added projects : \n')
self.out.nl() self.out.nl()
for project in diff['added']: for project in diff['added']:
self.printProject('\t%s' % (project.relpath)) self.printProject('\t%s' % (_RelPath(project)))
self.printText(' at revision ') self.printText(' at revision ')
self.printRevision(project.revisionExpr) self.printRevision(project.revisionExpr)
self.out.nl() self.out.nl()
@ -113,7 +115,7 @@ synced and their revisions won't be found.
self.printText('removed projects : \n') self.printText('removed projects : \n')
self.out.nl() self.out.nl()
for project in diff['removed']: for project in diff['removed']:
self.printProject('\t%s' % (project.relpath)) self.printProject('\t%s' % (_RelPath(project)))
self.printText(' at revision ') self.printText(' at revision ')
self.printRevision(project.revisionExpr) self.printRevision(project.revisionExpr)
self.out.nl() self.out.nl()
@ -123,7 +125,7 @@ synced and their revisions won't be found.
self.printText('missing projects : \n') self.printText('missing projects : \n')
self.out.nl() self.out.nl()
for project in diff['missing']: for project in diff['missing']:
self.printProject('\t%s' % (project.relpath)) self.printProject('\t%s' % (_RelPath(project)))
self.printText(' at revision ') self.printText(' at revision ')
self.printRevision(project.revisionExpr) self.printRevision(project.revisionExpr)
self.out.nl() self.out.nl()
@ -133,7 +135,7 @@ synced and their revisions won't be found.
self.printText('changed projects : \n') self.printText('changed projects : \n')
self.out.nl() self.out.nl()
for project, otherProject in diff['changed']: for project, otherProject in diff['changed']:
self.printProject('\t%s' % (project.relpath)) self.printProject('\t%s' % (_RelPath(project)))
self.printText(' changed from ') self.printText(' changed from ')
self.printRevision(project.revisionExpr) self.printRevision(project.revisionExpr)
self.printText(' to ') self.printText(' to ')
@ -148,7 +150,7 @@ synced and their revisions won't be found.
self.printText('projects with unreachable revisions : \n') self.printText('projects with unreachable revisions : \n')
self.out.nl() self.out.nl()
for project, otherProject in diff['unreachable']: for project, otherProject in diff['unreachable']:
self.printProject('\t%s ' % (project.relpath)) self.printProject('\t%s ' % (_RelPath(project)))
self.printRevision(project.revisionExpr) self.printRevision(project.revisionExpr)
self.printText(' or ') self.printText(' or ')
self.printRevision(otherProject.revisionExpr) self.printRevision(otherProject.revisionExpr)
@ -214,6 +216,8 @@ synced and their revisions won't be found.
diff = manifest1.projectsDiff(manifest2) diff = manifest1.projectsDiff(manifest2)
if opt.raw: if opt.raw:
self._printRawDiff(diff, pretty_format=opt.pretty_format) self._printRawDiff(diff, pretty_format=opt.pretty_format,
local=opt.this_manifest_only)
else: else:
self._printDiff(diff, color=opt.color, pretty_format=opt.pretty_format) self._printDiff(diff, color=opt.color, pretty_format=opt.pretty_format,
local=opt.this_manifest_only)

View File

@ -723,7 +723,7 @@ later is required to fix a server side protocol bug.
# ...we'll let existing jobs finish, though. # ...we'll let existing jobs finish, though.
if not success: if not success:
ret = False ret = False
err_results.append(project.relpath) err_results.append(project.RelPath(local=opt.this_manifest_only))
if opt.fail_fast: if opt.fail_fast:
if pool: if pool:
pool.close() pool.close()