How do I revert unresolved merges?
Simon King
simon at simonking.org.uk
Fri Dec 5 10:57:36 UTC 2014
[re-adding mercurial list]
On Thu, Dec 4, 2014 at 6:20 PM, Brent Scriver <bscriver at phxlabs.ca> wrote:
>
> Thank you Simon!
>
> Yes, they are completely unrelated.
>
> I failed to read the revert doc carefully--much appreciated.
>
> To clarify the phenomena I was seeing, let's say I had two files requiring
> resolve: A & B. If I resolved conflicts in A but not B, hg revert would
> revert A and would not do anything with B. I'm coming from Perforce world
> where a revert means reverting unresolved merges as well hence some of the
> confusion at this behavior.
>
> Brent
I'm still a bit confused. I just tested the exact scenario you
describe, and when I try to run either "hg revert A" or "hg revert B"
before committing the merge, I get an error:
$: hg revert A
abort: uncommitted merge with no revision specified
(use "hg update" or see "hg help revert")
Just to be sure, I'll resolve conflicts in A:
$: vi A # fix conflicts
$: hg resolve -m A # mark file as resolved
$: hg resolve -l # list state of merged files
R A
U B
So A is resolved, B is unresolved
$: hg revert A
abort: uncommitted merge with no revision specified
(use "hg update" or see "hg help revert")
$: hg revert B
abort: uncommitted merge with no revision specified
(use "hg update" or see "hg help revert")
So as far as I can tell, whether or not a file has been resolved has
no bearing on whether you can call "hg revert" on it.
Simon
>
> On Thu, Dec 4, 2014 at 12:08 PM, Simon King <simon at simonking.org.uk> wrote:
>>
>> On Thu, Dec 4, 2014 at 4:04 PM, Brent Scriver <bscriver at phxlabs.ca> wrote:
>> >
>> > Hi all,
>> >
>> > I am working with Mercurial 3.2.1 and I'm running experiments with it to
>> > get
>> > familiar with the work flow, primarily for merging changes from
>> > different
>> > repositories as we use a number of third party tools (with occasional
>> > custom
>> > edits).
>> >
>> > I encountered a scenario I couldn't easily identify a way to back out
>> > of.
>> > Given repository A & B and having done a pull -f of B into A, I want to
>> > merge subsequent changes.
>>
>> [side note: the "-f" flag to "hg pull" means "force", and it is only
>> necessary if you are pulling the history of a completely unrelated
>> repository into your own, which should be a very rare occurrence. Are
>> the source repositories that you are trying to merge completely
>> unrelated?]
>>
>> >
>> > It looks like until I complete the merge, hg revert will only revert
>> > changes
>> > that have been resolved. How do I revert those that are not resolved
>> > (and
>> > the entire merge altogether as if the pull request hasn't happened)?
>> >
>>
>> The help for "hg merge" says:
>>
>> To undo an uncommitted merge, use "hg update --clean ." which will
>> check
>> out a clean copy of the original merge parent, losing all changes.
>>
>> To explain a bit further, when you have started a merge, but before
>> you commit, your working copy has 2 parents (the 2 revisions that you
>> are merging). To give up on the merge, you simply "hg update" to a
>> different revision. "." represents the first parent of your working
>> copy, which is the revision you were at before you started the merge,
>> and "--clean" tells it to discard any uncommitted changes.
>>
>> I'm not sure I understand what you are saying about "hg revert" - I
>> wasn't aware that it had any dependence on whether or not a merged
>> file was resolved. Could you give an example?
>>
>> (The note about cancelling an uncommitted merge also appears in the
>> help for "hg revert" as well, by the way)
>>
>> > The only guaranteed solution I could find was to delete my local of A
>> > and
>> > re-clone it (making it very important that all pending changes in the
>> > working copy have been pushed back).
>> >
>> > Recommendations?
>>
>> Recloning definitely shouldn't be necessary. Even if you wanted to
>> start the merge over, you should only need to:
>>
>> hg update --clean .
>> hg merge
>>
>> >
>> > Thank you,
>> > Brent Scriver
>> >
>>
>> Hope that helps,
>>
>> Simon
>
>
More information about the Mercurial
mailing list