2

I'm working on customizing our build activity. I'd like to have your help for an issue.

Following is our version control hierarchy.

Main
 |- Dev
 |- QA

we are working on Dev branch and while taking the build we need to merge Dev branch to Main then to QA. Main is the root branch as you might know.

In our build template, I've added two custom activities to merge one from Dev to Main and another one to merge from Main to QA. Following is the code for the custom activity.

protected override string Execute(CodeActivityContext context)
{
   string lstrStatus = string.Empty;

   string lstrSourceBranchPath = context.GetValue(this.SourceBranchPath);
   string lstrTargetBranchPath = context.GetValue(this.TargetBranchPath);

   // Obtain the runtime value of the input arguments
   Workspace workspace = context.GetValue(this.Workspace);

   GetStatus status = workspace.Merge(lstrSourceBranchPath,
             lstrTargetBranchPath,
             null,
             null,
             LockLevel.None,
             RecursionType.Full,
             MergeOptions.None);

   // resolve the conflicts, if any

   if (status.NumConflicts > 0)
   {
      Conflict[] conflicts = workspace.QueryConflicts(new string[]
                             { lstrTargetBranchPath }, true);

      foreach (Conflict conflict in conflicts)
      {
         conflict.Resolution = Resolution.AcceptTheirs;
         workspace.ResolveConflict(conflict);
      }
   }

   // checkin the changes
   PendingChange[] pendingChanges = workspace.GetPendingChanges();
   if (pendingChanges != null && pendingChanges.Length > 0)
   {
      workspace.CheckIn(pendingChanges, "Merged by MERGE BRANCHES activity");
   }
   return lstrStatus;
}

Problem is, merging happens perfectly in the server. But, it's not getting reflected in the local folder. I tried to add SyncWorkspace activity after each Merge custom activity. Still not working.

rene
  • 41,474
  • 78
  • 114
  • 152
Saravanan AR
  • 81
  • 1
  • 3

1 Answers1

0

My guess was that a SyncWorkspace should be the only thing to do.
You could try doing a RevertWorkspace before that.

EDIT
After you now stated that even this wouldn't work, I would generate a bug against MS at least to get an official answer.
In the meanwhile you can try with the following method, which I absolutely see as an overkill: Once you have checked in, redo all the steps within sequence Initialize Workspace.

If even that doesn't work I'd consider two different builds, one that does your merge & one that does the actual build. You can then organize a scheme where your first build, once it's done, triggers the second one. Here is a good resource for that.

pantelif
  • 8,524
  • 2
  • 33
  • 48
  • Hi, as you suggested I added RevertWorkspace then SyncWorkspace activities after the merging activity. But, it did not help though. – Saravanan AR Nov 17 '11 at 16:49
  • hi, thanks for your suggestion and efforts. Could you please explain what do you mean by this ".........In the meanwhile you can try with the following method, which I absolutely see as an overkill: One you have checked in, redo all the steps within sequence Initialize Workspace. "? What I do now is, inside a sequence, get workspace, sync workspace and merge branches. Could you please explain? – Saravanan AR Nov 20 '11 at 01:05
  • `Initialize Workspace` also contains steps that clear your last workspace. So you could run your build up to the point where you merge & checkin your merge, then initialize again your workspace & get the latest of all your source code. This should contain your checkins. I consider this an overkill, still it should work. – pantelif Nov 20 '11 at 09:29