Jump to content


How to use p4 command for getting Swarm review id

swarm perforce

  • Please log in to reply
4 replies to this topic

#1 hoang.nth

hoang.nth

    Member

  • Members
  • PipPip
  • 16 posts

Posted 12 December 2015 - 06:58 AM

Hello P4 administrators,

When i try to use P4V(already integrated with Swarm), i can see the reviewId, reviewState of each pending changelist,
So there is anyway for use p4 commands to get all changelist's ReviewID, ReviewState (even submitted and shelved) at a moment.

Thank you so much,
Best Regards,

#2 Matt Janulewicz

Matt Janulewicz

    Advanced Member

  • Members
  • PipPipPip
  • 187 posts
  • LocationSan Francisco, CA

Posted 14 December 2015 - 06:16 PM

I had user ask the same thing some time ago and I think the answer is 'no'. A lot of Swarm info is kept in Perforce keys, but apparently not this (relationship between Review and Changes.)

The only way we've been able to get at this info is through the API (GET /api/v1.1/reviews/{id}->commits)
-Matt Janulewicz
Staff SCM Engineer, Perforce Administrator
Dolby Laboratories, Inc.
1275 Market St.
San Francisco, CA 94103, USA
majanu@dolby.com

#3 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 16 December 2015 - 09:39 PM

View Posthoangnt00843, on 12 December 2015 - 06:58 AM, said:

When i try to use P4V(already integrated with Swarm), i can see the reviewId, reviewState of each pending changelist,
So there is anyway for use p4 commands to get all changelist's ReviewID, ReviewState (even submitted and shelved) at a moment.

Hello,

Have you tried using the 'p4 reviews' command?  For example:

p4 reviews -c 12345

$ p4 reviews -c 1689
Joe_Coder <jcoder@p4demo.com> (Joe_Coder)

$ p4 -Ztag reviews -c 1689
... user Joe_Coder
... email jcoder@p4demo.com
... name Joe_Coder

to list each user who has subscribed to review files in the submitted changelist.

To get a list of submitted or shelved changes, you can use the '-s' flag with the 'p4 changes' command to specify the type of change status. For example, for shelved changes:

$ p4 changes -s shelved //depot/Talkhouse/rel1.0/...
Change 12101 on 2011/11/07 by John_Wakeman@jw_admin *pending* 'Demo changes by John Wakeman '
Change 12100 on 2011/11/07 by Joe_Coder@jc_admin *pending* 'Joe_Coder classic work in progr'

The above command displays shelved changes for a particular directory. There are more flags to filter by user or client also.

Or for submitted changes, for example:

$ p4 changes -s submitted -m5 //depot/Talkhouse/rel1.0/...
Change 4403 on 2008/11/02 by Aruna_Gupta@Ag_Talkhouse 'Go back to simple version of fi'
Change 4399 on 2008/11/02 by Aruna_Gupta@Ag_Talkhouse 'New colour scheme for image '
Change 4398 on 2008/11/02 by Aruna_Gupta@Ag_Talkhouse 'Remove background '
Change 4397 on 2008/11/02 by Aruna_Gupta@Ag_Talkhouse 'Initial crop. Still work-in-pr'
Change 4396 on 2008/11/02 by Aruna_Gupta@Ag_Talkhouse 'New image file from main-dev fo'

The above command displays the max 5 most recent, submitted changes for a particular directory.

Also, we have an existing enhancement request for a command line utility to call swarm functionality. Would you like to be added to this request? Another work-around is to use curl to return json data.

REFERENCES

- 'p4 reviews'
http://www.perforce....p4_reviews.html

- 'p4 changes'
http://www.perforce....p4_changes.html

#4 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 16 December 2015 - 11:12 PM

Here is a work-around example to share with you, showing how to list the required reviewers on an individual review. You can request the data using "curl http://swarmhost/api...s/{review-id}"; the endpoint will return JSON data with an HTTP response of 200 OK if the review is found. Then it is just a matter of looking into the JSON data and seeing the Participants key:

curl http://swarmhost/api/v1.2/reviews/1330

{
   "review": {
	 "id": 1330,
	 "author": "bruno",
	 "changes": [
	   1329,
	   1331,
	   1388
	 ],
	 "commits": [],
	 "commitStatus": [],
	 "created": 1444950149,
	 "deployDetails": [],
	 "deployStatus": null,
	 "description": "Test Review",
	 "participants": {
	   "civet": {
		 "required": true
	   },
	   "bruno": []
	 },
	 "pending": true,
	 "projects": {
	   "test-project": [
		 "main"
	   ],
	   "testproject": [
		 "main",
		 "test"
	   ],
	   "testproject2": [
		 "test"
	   ]
	 },
	 "state": "needsReview",
	 "stateLabel": "Needs Review",
	 "testDetails": [],
	 "testStatus": null,
	 "type": "default",
	 "updated": 1450305726,
	 "versions": [
	   {
		 "difference": 1,
		 "stream": null,
		 "change": "1331",
		 "user": "bruno",
		 "time": 1444950150,
		 "pending": true
	   },
	   {
		 "difference": 1,
		 "stream": null,
		 "change": 1330,
		 "user": "bruno",
		 "time": 1448926190,
		 "pending": true,
		 "archiveChange": 1388
	   }
	 ]
   }
}

The participants key in this example includes "civet" as an object that has the "required" property set to true, so this can be used to differentiate required reviewers from reviewers who are not required.

Our Swarm development team is hoping to add more functionality to the API soon to make it easier and more effective to interact with Swarm from the command line (and from within other applications).

#5 Vince

Vince

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 22 May 2018 - 09:05 AM

HI !

I know this topic is two years old but I'm actually wondering if there are any changes since that question and if there is now a way to get the swarm id with a p4 command line.

Thanks for your replies. ^_^





Also tagged with one or more of these keywords: swarm, perforce

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users