This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 245270 - Switch to Branch not working under special condition
Summary: Switch to Branch not working under special condition
Status: RESOLVED INVALID
Alias: None
Product: versioncontrol
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: Ondrej Vrabec
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-26 15:09 UTC by ulfzibis
Modified: 2014-06-30 13:05 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
error not allowing switch to branch (20.93 KB, image/png)
2014-06-27 06:40 UTC, Ondrej Vrabec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ulfzibis 2014-06-26 15:09:21 UTC
[ JDK VERSION : 1.7.0_45 ]

STEPS:
   * Have 2 branches A and B.
   * Update working directory to A.
   * Do some changes.
   * Merge Changes with B
   * Switch to B -> positive acknowledge.
   * Commit

ACTUAL:
   Commit was recorded on branch A.

EXPECTED:
   Commit should be recorded on branch B.
Comment 1 Ondrej Vrabec 2014-06-26 15:20:20 UTC
Did you commit between:
>    * Merge Changes with B
and
>    * Switch to B -> positive acknowledge.
? Or are you trying to commit the actual merge into the other branch?
Comment 2 ulfzibis 2014-06-26 17:39:37 UTC
No, I was trying to commit the merge to the other branch.

The reason was:
The changes contained a refactored move of some java classes in A to another package path to merge with the files, just in the same path in the other branch B, so I wanted to track the move + merge within the Mercurial repository.
Comment 3 Ondrej Vrabec 2014-06-27 06:40:29 UTC
you must have missed some steps in your scenario or at least i do not understand it. If i:
1) have two branches and am currently on A
2) merge branch B into A
3) try to switch to B => i get an error correctly saying hg update is not allowed after a merge. See the screenshot.

For example iin your scenario you surely missed a commit between * Do some changes. and * Merge Changes with B. You should never merge into a dirty working copy. If you do that you probably do not know how distributed systems work.
Comment 4 Ondrej Vrabec 2014-06-27 06:40:36 UTC
Created attachment 147796 [details]
error not allowing switch to branch
Comment 5 ulfzibis 2014-06-27 13:33:44 UTC
(In reply to Ondrej Vrabec from comment #3)
> you must have missed some steps in your scenario or at least i do not
> understand it.

No, I intentionally left out the commit between "some change", i.e. refactor to different java package, and "merge with B".

> 1) have two branches and am currently on A
> 2) merge branch B into A
> 3) try to switch to B => i get an error correctly saying hg update is not
> allowed after a merge. See the screenshot.
Don't you think, this error message should also appear, if there additionally was a change between 1) and 2), if such scenario is not allowed? I didn't have it.
Could you reproduce my experience if you insert such package renaming or other changes before the merge? If not, I may prepare my little .hg folder and send it to you.

> You should never merge into a dirty working copy.
I often profit from this. If I do some changes manually before the merge, than I have less weird conflicts to solve with the Conflicts Resolver. This works fine except when I additionally want to commit the result to a different branch as demonstrated by this bug.

> If you do that you probably do not know how distributed systems work.
Hm, may be, in my case I do not share the repository with others, so the "distributed systems" concerns do not matter here.
If I understand correct, technically a commit on 2 heads is nothing more than 2 diffs (in respect of possible renamings in contrast to subversion) combined in 1 changeset. So I do not see a reason why my scenario should be impossible to process.
Comment 6 Ondrej Vrabec 2014-06-27 17:57:06 UTC
> If I understand correct, technically a commit on 2 heads is nothing more than 2 diffs (in respect of possible renamings in contrast to subversion) combined in 1 changeset. So I do not see a reason why my scenario should be impossible to process.
Sure, technically yes. But the merge commit should never contain any actual changes besides the conflict resolution. Otherwise the changes will be more difficult to find (when searching history), harder to revert (if you later realize the change was incorrect). But if you use the repo only locally i guess it does not matter.
If * Switch to B passed without any errors for you it is strange. Can you paste here the content of the output window? After such a switch to branch action I'm getting:
> Switch to branch BRANCH in:
> C:\Users\Ondra\Documents\NetBeansProjects\merc\245270\2\245270
> ERROR Command failed:
> Command: [hg, update, -v, --config, ui.merge=internal:merge, --repository, C:\Users\Ondra\Documents\NetBeansProjects\merc\245270\2\245270, BRANCH]
> Output: [abort: outstanding uncommitted merges]
> INFO: End of Switch
means the command failed. Maybe we just parse the output of your hg executable in a wrong way.
Comment 7 ulfzibis 2014-06-29 22:29:48 UTC
Hi Ondrej,

I've tried to reproduce the case and realized, that it seems I have misinterpreted the message box. From flippant reading I interpreted "invoke Commit" as "Don't forget to commit".
I feel sorry for the noise.
Additionally I discovered, that my "rename first and than merge" trick to track the move didn't work as expected. The source information, to see with "hg status -C", was lost after the merge :-(
Even later "hg copy -A src/path/file test/path/file" was rejected by error message.

FYI: I opened an issue here: https://bitbucket.org/tortoisehg/thg/issue/3796/allow-commit-to-different-branch
Comment 8 Ondrej Vrabec 2014-06-30 07:10:23 UTC
> FYI: I opened an issue here: https://bitbucket.org/tortoisehg/thg/issue/3796/allow-commit-to-different-branch
TortoiseHG will hardly fix it. If it's a general issue for hg client, it should go here: http://mercurial.selenic.com/wiki/BugTracker, http://bz.selenic.com/
Comment 9 ulfzibis 2014-06-30 10:03:15 UTC
Thanks! Now here: http://bz.selenic.com/show_bug.cgi?id=4293
Comment 10 ulfzibis 2014-06-30 11:51:00 UTC
Oops!
Comment 11 ulfzibis 2014-06-30 13:05:22 UTC
The discussion from http://bz.selenic.com/show_bug.cgi?id=4293 discovered a new bug 245322.