How to revert the changes once its submitted in Gerrit

How to revert the changes once its submitted in Gerrit

The Revert button is available if the change has been submitted. This Reverts the change via creating a new one. When the Revert button is pressed, a panel will appear to allow the user to enter a commit message for the reverting change.

Once a revert change is created, the original author and any reviewers of the original change are added as reviewers and a message is posted to the original change linking to the revert.

However, patchsets can not be reverted. so first you have to checkout one of the previous patchset. you can get the command from Gerrit review board at each patchset download panel. After checking it out amend it to generate new commit hash then pushed again as a new patchset.

If I have multiple patch set versions for one change in Gerrit, You can only submit the latest patch set version. The design assumes that the most recent patch set is the one developers will review and test, and as such older patch sets can not be submitted.

Good Read
http://www.saros-project.org/node/155

Tagged : / / / / / /

Perforce Customization To Revert Changelist

Perforce Customization To Revert Changelist

Attachech Python File: Download here Perforce Python script to revert Changelist

Purpose

In Perforce if we check in any change list and in case if we want to revert the change list. Perforce does not have feature to Revert Change List.

We have to do it manually by using following steps.

1) Take a change list version which is predecessor of the current one which we want to revert
2) Do head sync to that change list revision.
3) Check out the files which we want to revert. Resolve them and check in

But we can very well eliminate the above three manual steps and automate the process of Reverting Change list by Customizing Perforce to have Revert Change List Feature.
This feature will be very useful if the Changelist which we want to revert have large number of files

Risk
There is no Risk with this feature because the changelist which we revert are not directly submitted. When we do a Revert Change List a new Change List will be created and we have the capability to resolve the conflict if there are more than one Revision for that file.

Required Software Version
Download Recent version of Python from http://www.python.org/download/ and   Install Python and set the path for library files of python in the environment variables just like java.

Software Program Required for Customization

I have downloaded Python Program from the following URL which will help in Reverting Change List. (http://www.tilander.org/aurora/2007/06/reverting-a-perforce-changelis.html).

Perforce Client Side Changes for Customization

Following Customization needs to be done to add Revert ChangeList option in  perforce.

1.    Open Perforce
2.    Go to Tools >> Customize
3.    Click Add Button
4.    Enter Name as RevertChangeList, Give the location of the Python Program
5.    Give the argument as -c $c -p $p -u $u %c
C – Client
P –  Port Number
U –User

image

Note : Make sure “Close window upon exit” is not checked initially for the first time. So that we can see the success message in console.
In case if it is checked. If the Python Program fails. Then we may not be able to see the message.

6.    Once this is done then Click View Submitted Change List. Right click the change list which you want to revert and click RevertChangeList.

 

image

7.    Once this is done all the files that were reverted will be available under Default Changelist.
8.    Create New Changelist and move all from Default Changelist.
9.    Check the whether they are reverted properly. If there are some version conflict then resolve them and checkin.
10.    Using this feature I had reverted changelist Number : 163806
11.    Outside Perforce also this utility can be run. We can also run the utility from windows prompt by giving following command

Command :
p4revert.py -c <Client> -p <Port> -u <User> <ChangeList>

Example:
p4revert.py -c Mramchandran -p 10.10.50.201:1666 -u jayesh 163806

This is not tested. It is also convenient to use through perforce.

Troubleshooting

1.If my Revert ChangeList contains file say A.java and that file is also part of another change list in the client machine. Then the file A.java will not be reverted.
2. Always check the number of files that are present in the changelist is same as same number of files that are present in the new change list once RevertChangeList is done.

Limitations
1. The only limitation this tool has is the Revert ChangeList customization is written in Python. It will be good if we can understand the logic and convert to Java.

References

1. http://www.tilander.org/aurora/2007/06/reverting-a-perforce-changelis.html
2. http://kb.perforce.com/?article=014
3. http://www.python.org/download/

Contributed Made by: Ramchandran M

Tagged : / / / /

Reopen and revert files in perforce.

rajeshkumar created the topic: Reopen and revert files in perforce.
If the perforce user access has been removed/blocked from user table and they have so many files opened. There could be two ways to to revert the files.

Problem:
p4 -p server:port -u username -c clientname -H hostname revert //…
Access for user ‘username ‘ has not been enabled by ‘p4 protect’.
p4 -p server:port -u username1 -c clientname -H hostname revert -k //… ( tried using differernt user ‘username’)
//depot/rajesh/file1.txt#none – belongs to user username, not reverted

Solution 1:
So I found one solution for it
another user could take ownership of the files. Here’s an example:
Users ‘rajesh’ and ‘kumar’ have each opened a file in workspace ‘temporary’.
>p4 opened -a //depot/test…
//depot/test.js#3 – edit default change (xtext) by rajesh@temporary
//depot/test2.js#2 – edit default change (text) by kumar@temporary

I use the ‘reopen’ command to change the user:
>p4 -u kumar -c temporary reopen //depot/test…
//depot/test.js#3 – reopened; user kumar
//depot/test2.js#2 – reopened; user kumar

As these changes are now ‘mine’, I can revert them (noting the ‘-k’ flag here):
>p4 -u kumar -c temporary revert -k //depot/test…
//depot/test.js#3 – was edit, cleared
//depot/test2.js#2 – was edit, cleared

Solution 2: Add the missing user for temporary and follow the steps as in problem statement
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re: Reopen and revert files in perforce.
Problem

Error message when you try to delete the clientspec of users
Client ‘rajesh-test-client’ has files shelved; use ‘shelve -df’ to remove them, and then try again.

Solution:

Some times you may not able to delete client spec and user due to many reason. if user has opened few files in another users clientspec. please follow the steps as given

p4 -p server:port -u username users | grep username
p4 -p server:port -u username clients | grep username
p4 -p server:port -u username client -f -d clientname
p4 -p server:port -u username user -d -f username
p4 -p server:port -u username opened -C clientname //…
p4 -p server:port -u username client clientname
p4 -p server:port -u username describe 662626
p4 -p server:port -u username protect -o | grep jfung
p4 -p server:port -u username protect
p4 -p server:port -u username login jfung
p4 -p server:port -u username -c clientname -H localhost.localdomain revert -k //…
p4 -p server:port -u username clients | grep username
p4 -p server:port -u username opened -u username //…
p4 -p server:port -u username client -d -f clientanam
p4 -p server:port -u username user -d -f username
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re: Reopen and revert files in perforce.
Problem: One more very interesting scenario where there is no files pending but few files shelved in pending change list.

Answer:
p4 -p server:port -u username client -d -f worksapce_name
Client ‘worksapce_name’ has files shelved; use ‘shelve -df’ to remove them, and then try again.

p4 -p server:port -u username opened -a //… | grep worksapce_name
NONE

p4 -p server:port -c clientname changes -s pending -c workspace_name //…
Change 217927 on 2011/07/13 by username@workspace_name *pending* ‘ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re: Reopen and revert files in perforce.
How to reverts file opened by Perforce user?
To Revert these changes –
This will list down the files and client’s name where the file has been opened.
p4 -p Server:port -u rajesh opened –a | grep other_user

Now get the host name of the client,
p4 -p Server:port -u rajesh client -o admin-ols-dump | grep –i host

Login as user from super user account.
p4 -p Server:port -u rajesh login other_user

Frame the commands and run it in the given fashion.
p4 -p Server:port -u other_user -c -h revert -k //depot/releases/filename.txt
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :