git-cl: fix 'status --field=patch' for Gerrit
We don't set the branch.<name>.gerritpatchset git config value
during "git cl upload" because it isn't returned from the
server either during push or during any of our subsequent RPCs,
and adding another RPC just for that metadata would be slower
that we would like.
But calling "git cl status" already makes an RPC per branch, so
take advantage of that to cache the gerritpatchset value during
that operation.
R=robertma
Bug: 792611
Change-Id: I37b09f3c4cfced86668b457eff82f2424012b14b
Reviewed-on: https://chromium-review.googlesource.com/815137
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 277951d..171e2fd 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2574,7 +2574,9 @@
def GetMostRecentPatchset(self):
data = self._GetChangeDetail(['CURRENT_REVISION'])
- return data['revisions'][data['current_revision']]['_number']
+ patchset = data['revisions'][data['current_revision']]['_number']
+ self.SetPatchset(patchset)
+ return patchset
def FetchDescription(self, force=False):
data = self._GetChangeDetail(['CURRENT_REVISION', 'CURRENT_COMMIT'],
@@ -4427,7 +4429,7 @@
if issueid:
print(issueid)
elif options.field == 'patch':
- patchset = cl.GetPatchset()
+ patchset = cl.GetMostRecentPatchset()
if patchset:
print(patchset)
elif options.field == 'status':