Reputation: 1605
UPDATED PROBLEM DESCRIPTION : Thanks in advance!
Working in the master
branch, I made changes to a file and arc diff --create
'ed a differential to be reviewed. I then addressed another user-story, still working in the master
branch, and again arc diff --create
'ed a differential for review. Two user-stories, two differentials ready for review. Good so far.
[ I understand creating a differential
for review via arc diff
, is like making a pull request
. ]
Here is the problem... I then re-addressed the first user-story, making further changes (still working in the master
branch, and proceeded to arc diff <commit_hash>~ --update <diff_id>
. The differential now shows changes between the initially created diff and it's update, and not changes overall!
....
I've been told I should have made a new branch before making changes. Then all arc --update
's of a revision would result in an overall difference (not the difference between the last two updates).
I've also been told that I can still make that new branch to contain all of my changes (that I have arc diff
'ed), and repair the revisions.
What do I type to create a new branch to contain all of the changes (namely those already 'arc diff
'ed for revision), restore the master
branch (supposedly), and re-arc diff --update
my latest revision with my latest commit? ... (/ or whatever fixes my problem.)
Upvotes: 3
Views: 4057
Reputation: 4606
If you create a new working branch before you start making changes, this usually works automatically. But in cases where it doesn't (because arc cannot figure out the upstream branch point), there are command line arguments to diff that allow you to specify your intentions:
--update REVISIONID
- Update a specific revisionFor example, arc diff --update D1
To go back and fix up your tree, start by creating a new branch that will hold your current work in progress so you can always go back to it:
git checkout -b current_wip
Now, delete your local master, and recheckout the state of the master as it is on the upstream server. This takes you back to before you made any changes, but since you created the current_wip branch, you aren't going to lose anything (you actually wouldn't lose the commits even if you skipped creating that branch, they would just become difficult to find due to not being attached to a branch). Having a clean master will also avoid some warnings later when you arc land
the changes.
git branch -D master
git checkout master
Now you can recreate your two original patches, but on separate branches this time. arc patch
can be used to pull the patches from Differential, and automatically creates a branch for you with the name arcpatch-D1
(where D1 is the diff ID). Here I am calling them D1 and D2, but you will use the actual identifiers that diffusion assigned to your diffs when you submitted them.
arc patch D1
git checkout master
arc patch D2
Now you just have the last change you made, which you want applied on top of D1 to take care of.
git log current_wip
Note down the first few digits from the commit id. For a repository with less than a few thousand commits, you probably need only the first 5 digits. Even large repositories like the Linux kernel generally uniquely identify the commit within the first 7 digits. Below, I'm calling it 1234abc
, but you'll use the actual commit id.
Next, you're going to go back to the branch with the first patch you made, and cherry-pick just that commit on top of it. Cherry-pick takes only that specific commit, as opposed to a merge, which would take anything missing in between. After cherry-picking, provided you do not get conflicts, you are ready to update the diff.
git checkout arcpatch-D1
git cherry-pick 1234abc
arc diff
Once you are happy that everything is safely in Differential (or maybe you want to wait until you arc land
both patches), you can delete the current_wip
branch you used as a backup.
git branch -D current_wip
Upvotes: 3