Skip to content

Commit

Permalink
Fix label syncing (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
ca-johnson authored Feb 21, 2020
1 parent 17fa9cf commit ad6a695
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 4 additions & 2 deletions python/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def main():

repo.p4print_unshelve(changelist)

revision = get_build_revision()
description = repo.description(get_users_changelist() or revision.strip('@'))
description = repo.description(
# Prefer users change description over latest submitted change
get_users_changelist() or repo.head_at_revision(revision)
)
set_build_info(revision, description)


Expand Down
20 changes: 15 additions & 5 deletions python/perforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,25 @@ def info(self):
def head(self):
"""Get current head revision"""
self._setup_client()
client_head = self.perforce.run_changes([
'-m', '1', '-s', 'submitted', '//%s/...' % self._get_clientname()])
# Get head based on client view (e.g. within the stream)
client_head = self.head_at_revision('//%s/...' % self._get_clientname())
if client_head:
return client_head[0]['change']
# Fallback for when client view has no submitted changes
return client_head
# Fallback for when client view has no submitted changes, global head revision
return self.perforce.run_counter("maxCommitChange")[0]['value']

def head_at_revision(self, revision):
"""Get head submitted changelist at revision specifier"""
# Resolve revision specifier like "@labelname" to a concrete submitted change
result = self.perforce.run_changes([
'-m', '1', '-s', 'submitted', revision
])
if not result:
return None # Revision spec had no submitted changes
return result[0]['change']

def description(self, changelist):
"""Get description of a given changelist"""
"""Get description of a given changelist number"""
return self.perforce.run_describe(str(changelist))[0]['desc']

def sync(self, revision=None):
Expand Down

0 comments on commit ad6a695

Please sign in to comment.