Add the "diffmanifests" command
This command allows a deeper diff between two manifest projects. In addition to changed projects, it displays the logs of the commits between both revisions for each project. Change-Id: I86d30602cfbc654f8c84db2be5d8a30cb90f1398 Signed-off-by: Julien Campergue <julien.campergue@parrot.com>
This commit is contained in:
parent
baca5f7e88
commit
dd6542268a
3 changed files with 287 additions and 1 deletions
54
project.py
54
project.py
|
@ -1100,6 +1100,23 @@ class Project(object):
|
|||
for copyfile in self.copyfiles:
|
||||
copyfile._Copy()
|
||||
|
||||
def GetCommitRevisionId(self):
|
||||
"""Get revisionId of a commit.
|
||||
|
||||
Use this method instead of GetRevisionId to get the id of the commit rather
|
||||
than the id of the current git object (for example, a tag)
|
||||
|
||||
"""
|
||||
if not self.revisionExpr.startswith(R_TAGS):
|
||||
return self.GetRevisionId(self._allrefs)
|
||||
|
||||
try:
|
||||
return self.bare_git.rev_list(self.revisionExpr, '-1')[0]
|
||||
except GitError:
|
||||
raise ManifestInvalidRevisionError(
|
||||
'revision %s in %s not found' % (self.revisionExpr,
|
||||
self.name))
|
||||
|
||||
def GetRevisionId(self, all_refs=None):
|
||||
if self.revisionId:
|
||||
return self.revisionId
|
||||
|
@ -2187,6 +2204,43 @@ class Project(object):
|
|||
def _allrefs(self):
|
||||
return self.bare_ref.all
|
||||
|
||||
def _getLogs(self, rev1, rev2, oneline=False, color=True):
|
||||
"""Get logs between two revisions of this project."""
|
||||
comp = '..'
|
||||
if rev1:
|
||||
revs = [rev1]
|
||||
if rev2:
|
||||
revs.extend([comp, rev2])
|
||||
cmd = ['log', ''.join(revs)]
|
||||
out = DiffColoring(self.config)
|
||||
if out.is_on and color:
|
||||
cmd.append('--color')
|
||||
if oneline:
|
||||
cmd.append('--oneline')
|
||||
|
||||
try:
|
||||
log = GitCommand(self, cmd, capture_stdout=True, capture_stderr=True)
|
||||
if log.Wait() == 0:
|
||||
return log.stdout
|
||||
except GitError:
|
||||
# worktree may not exist if groups changed for example. In that case,
|
||||
# try in gitdir instead.
|
||||
if not os.path.exists(self.worktree):
|
||||
return self.bare_git.log(*cmd[1:])
|
||||
else:
|
||||
raise
|
||||
return None
|
||||
|
||||
def getAddedAndRemovedLogs(self, toProject, oneline=False, color=True):
|
||||
"""Get the list of logs from this revision to given revisionId"""
|
||||
logs = {}
|
||||
selfId = self.GetRevisionId(self._allrefs)
|
||||
toId = toProject.GetRevisionId(toProject._allrefs)
|
||||
|
||||
logs['added'] = self._getLogs(selfId, toId, oneline=oneline, color=color)
|
||||
logs['removed'] = self._getLogs(toId, selfId, oneline=oneline, color=color)
|
||||
return logs
|
||||
|
||||
class _GitGetByExec(object):
|
||||
def __init__(self, project, bare, gitdir):
|
||||
self._project = project
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue