Thursday 26 July 2012

SVN Merge Tree Conflict Resolution

I've been trying to merge our code into our feature branches and have experienced mysterious conflicts  Thought I'd record what I'm doing, maybe it will be useful to someone else out there. I think the svn book doesn't treat this functionality thoroughly enough with examples (that being said, our use of svn hasn't been the ideal, so its most likely you won't experience these conflicts in your environment).


A - local missing, incoming edit upon merge

Why does this happen?

 The 'local missing vs. incoming edit' conflicts  can
happen if:

"
 - You delete a file which existed in the common ancestor of both
   branches, and the file is later modified on trunk and you merge
   this modification. in this case you probably want to keep the file
   deleted (or you might decide to resurrect it, in which case the
   best approach would be to first revert the entire working copy,
   undo the file's deletion on the local branch and commit (see
   http://svnbook.red-bean.com/en/1.7/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo), and then repeat the first merge (which
   should now not conflict anymore).

 - After your branch is created, a new file is created on trunk in
   revision A and later modified in revision B. You only merge revision
   B which means the file is not created on your branch before the
   merge tries to apply the modification. In this case you should
   probably also merge revision A. A normal sync merge of the
   'svn merge ^/trunk' variety will always do this."

*Excerpt from email conversation with Stefan Sperling  from the subversion user's mailing list.

 So lets see how we resolve this:

1.  svn status pointed to a tree conflict:

!     C core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
      >   local missing, incoming edit upon merge

I'm guessing the "!" means it doesn't exist in the local copy.

2.  First step, I perform an svn info, which tells me what revisions are conflicting. What is strange is that the revision that's conflicting is a very old one from a different branch, I'm not sure why its ending up here. (will update once I have an answer from the forum).

 svn info core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java

Path: core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
Name: SubscriberPIDMatrixDTO.java
Node Kind: none
Tree conflict: local missing, incoming edit upon merge
  Source  left: (file) svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@6896
  Source right: (file) svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@9841

2. So I tried my luck and hoped svn would bring the file in automatically.

svn resolve --accept=working svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@9841
svn: warning: 'svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub' is not a working copy

This is the correct response, because the file doesn't exist in my local copy:)



3. I do an svn copy to copy the file from the trunk into my local repo.

svn cp svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@9841 core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub

A         core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java

Yay, its been added. 

4. svn status

svn status core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java

A  +  C core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
      >   local missing, incoming edit upon merge

I've added the file I want, but its still in the conflicted state.

5. Mark the conflict as resolved

svn resolve --accept=working core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java

6. svn status now shows the file as being resolved.

svn status core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
A  +    core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java

Tree conflict resolved!

 

B - local add, incoming add upon merge


Okay, now for another tree conflict:"local add, incoming add upon merge".
I'm not sure what this means, I think that the files been added locally, but the message to me means I added a file locally and the incoming merge

 1. svn status

svn status  business_services/main_servlet/src/main/resources/testconfigs/pams.properties
      C business_services/main_servlet/src/main/resources/testconfigs/pams.properties
      C business_services/main_servlet/src/main/resources/testconfigs/pams.properties
      >   local add, incoming add upon merge


2.  svn info business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Path: business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Name: pams.properties
URL: svn://bcx-svn/acme.za/pams/server/branches/v1-4-3-AM-CR3159-BatchActivations/business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Repository Root: svn://bcx-svn/acme.za
Repository UUID: 5545304e-a938-48f1-8c5a-7cf7c6df13d1
Revision: 9841
Node Kind: file
Schedule: normal
Last Changed Author: kiren
Last Changed Rev: 9673
Last Changed Date: 2012-06-26 10:47:45 +0200 (Tue, 26 Jun 2012)
Text Last Updated: 2012-07-25 17:42:47 +0200 (Wed, 25 Jul 2012)
Checksum: 0c70c81698528185a3a80d704f423c3f
Tree conflict: local add, incoming add upon merge
  Source  left: (file) svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@6896
  Source right: (file) svn://bcx-svn/acme.za/pams/server/trunk/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@9841

 3. Does the file exist in the local revision?

 svn info svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@6896
svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@6896:  (Not a valid URL)

svn: A problem occurred; see other errors for details

Nope, as expected.

4. The trunk version?

 svn status svn://bcx-svn/acme.za/pams/server/trunk/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@9841
svn: warning: 'svn://bcx-svn/acme.za/pams/server/trunk/business_services/main_servlet/src/main/resources/testconfigs/pams.properties' is not a working copy

Apparently not.

5. Let me check my working copy.
 ls -la business_services/main_servlet/src/main/resources/testconfigs/pams.properties
-rw-rw-r-- 1 kiren kiren 137 Jul 25 17:42 business_services/main_servlet/src/main/resources/testconfigs/pams.properties

Damn, it's there? How is this possible? (will check later, its probably that conflict with an older revision).

6. I don't want this file here anyway, so I'm going to delete it.
 
 svn delete business_services/main_servlet/src/main/resources/testconfigs/pams.properties
D         business_services/main_servlet/src/main/resources/testconfigs/pams.properties

7. Check status, should still be in conflicted state

 svn status business_services/main_servlet/src/main/resources/testconfigs/pams.properties
D     C business_services/main_servlet/src/main/resources/testconfigs/pams.properties
      >   local add, incoming add upon merge



8. Resolve the conflict

svn resolve --accept=working business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Resolved conflicted state of 'business_services/main_servlet/src/main/resources/testconfigs/pams.properties'


9. File should be in a deleted state.

 svn status business_services/main_servlet/src/main/resources/testconfigs/pams.properties
D       business_services/main_servlet/src/main/resources/testconfigs/pams.properties

10. Wonder if the file still exists on the file-system?
 ls -la business_services/main_servlet/src/main/resources/testconfigs/pams.properties
ls: cannot access business_services/main_servlet/src/main/resources/testconfigs/pams.properties: No such file or directory

Aah, nice. Next commit should be rid of it. Tree conflict resolved!


C- local delete, incoming delete upon merge

 Okay, here's another one:

1.
 svn status core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used 
!     C core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used
      >   local delete, incoming delete upon merge



2. Again, the ! means it doesn't exist in the working copy, let's confirm:

ls -la core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.usedls: cannot access core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used: No such file or directory

 Cool, the file needs to be deleted, its one of those annoying files that hangs around and people are afraid to ask :)  (I'm not going to svn info as I'm not really interested in this file.)

3. Everything is good as it is, just need to resolve it now.

svn resolve --accept=working core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used
Resolved conflicted state of 'core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used'

4. Check the status

svn status core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used'

No output. Perfect!

Conclusion


While there seems to be some problem with our source tree in terms of the version V1-1-1-preprod, I think showing the steps I used to resolve the problem may help people working with tree conflict issues.

  1. It looks like our decision not to use --reintegrate merges may have cause problems.
  2. Also, mixed revisions when merging can cause a problem later on with merging, so avoid merging mixed revisions.  
  3. A tip from Stefan on the user forum is that svn copies should be done with URL to URL to avoid mixed revisions issue. 

Update

Subversion 1.6 onwards does not allow merging into mixed revision working copies.










Thursday 22 March 2012

Ubuntu 11.10 - 1 step forward, 2 steps back?

I was just beginning to think that Ubuntu was ready to take on Windows with the release of 11.04, I was enjoying Gnome 2 and feeling really comfortable with it. Then 11.10 came along and this release was the worst Ubuntu release I've seen (I've been using Ubuntu from 10.04).

Things they shouldn't have done:


1. Unity interface - This is meant more for Tablets and touch screens. Granted its becoming a bigger market, but as a desktop user, do I really want this? Lots of apps where buggy because of Unity (e.g. eclipse). Maybe they should have come out with a tablet edition of Ubuntu (by the way, I wonder what % of tablets/touch devices are using Ubuntu?).

Also, because the Menu is now always at the top bar of the screen, the amount of mouse travel to select an option has increased. On a portable device this isn't an issue.

PS: I am using GNOME3 and its so much more usable.


2. Network Proxy Manager - This is one of the most useful features for me. It allows you to have a separate profile for each proxy server setting.

I am a roaming consultant and I normally work in three environments:
  1. Home
  2. Office
  3. Client's Office.

With this manager, I could set up a profile and basically enable it in from one location on my system.

This was removed in 11.10, and is replaced with a new network proxy application.  Also this proxy doesn't have an ignored hosts list (really a core requirement for any proxy settings IMO,  a real loss in my books.
I remember my friend saying this was one thing Windows was missin.

3. (Ok I resolved the shutdown icon issue. Hit ALT and click on the preferences and you'll see the shutdown button :)

Check this cheat-sheet out.


" Shutdown not possible as a logged-in user. 
 
Now you have to logout from your session first, then click on the shutdown icon to switch off the machine, then click 'shutdown' if you really want to shutdown.

This is annoying since generally you're the  only user on your machine, do you really want to wait to do this?



4. Shutdown times are dreadful - I know, I may have some bad apps installed, but my machine takes up to a minute to shut down! I know rely on my ext4 journal to keep my data safe and force the machine off with the power button (5secs). Not the best idea, but really this is crazy.

My new install of 12.04 has fixed this.

5. Its still very difficult to add a custom launcher to the tool-bar. I'd like to go Right-click->add application. (Gnome3 also has this issue)

6. ATI proprietary driver - damn, when are AMD going to opensource their drivers? Currently, this driver is not compatible with the latest version of X (or was it the Linux 3 kernel). Not nice knowing this when you've forked out a pretty penny for your super duper ATI card and now be told you can't use its full features. (In the words of many unknown South Africans - eish (pronounced ay-sh)...painful.

I'm not sure whats better, according to Linus Torvalds nVidia is really bad too.
(check the rant from Linux here)

Things I like


1. GNOME3 - I know people have been complaining that they hate it, but once I got the icon to close a window working, its actually a very pleasant experience! I like the mini task bar on the bottom right that shows open applications.

Sliding to mouse to the top left corner will bring up a high-level view of your windows, so far the most useful way for me to select a window. You can even close a window from this context - Nice!

2. Apt-get (enough said)

Release Management

I wonder how the release management happens. Do the Ubuntu release managers decide the versions of the kernel, X etc before hand. If so, do they communicate it to the downstream vendors so that they can prepare for the next release to ensure that compatibility is maintained?
 

Conclusion


I'm sure there's a process being followed where features are voted in and out. It just feels like when there are gains in moving the OS forward, there is likely to be a major change that throws them all away.

There should be governing body that decides what path to take, rather than having one person decide this. Okay, thanks to Mr. Shuttleworth for Ubuntu, its really an amazing distro in terms of ease-of-use compared to certain others, but this Unity move was too radical in my opinion.

In the case of voting polls for features, I guess the guys with the biggest vote won. Democracy won for some (not me).

Linux doesn't have a Steve Jobs to drive usability or prettiness or simple ease of use (or does it??). Sometimes group-think can be a good thing, sometimes bad. I wouldn't mind follow a distro who's direction is based on a single person who has ease-of-use and aesthetics at the top of his priority list.

The beauty is that in Linux you have that choice! (I downloaded Mint, hopefully its as fresh as they say it is!)
I install 13 Mate, and wasn't too impressed. I changed to Gnome3 and am loving it!