Update Command with Branches

Nov 5, 2012 at 11:16 AM
Hi,

I am working with branches in Mercurial and I need an update command that uses the name of the branch to update to it. I investigate a little into your code and only found this function:

public UpdateCommand WithAcrossBranches(bool value = true)

I have decided to create a new function that supports updates with branch name using --check <branchname> option. 

This is the additional code:

private string _Branch = String.Empty;
...
[NullableArgument]
[DefaultValue("")]
public string branch
{
	get
	{
		return _Branch;
	}

	set
	{
		_Branch = (value ?? String.Empty).Trim();
	}
}
...
public UpdateCommand WithBranch(string value)
{
	branch = value;
	return this;
}
I would like to know if this modification is needed and if it fits into the 
Mercurial.NET current code.
 
Thanks in advance





Coordinator
Nov 5, 2012 at 11:22 AM

You should be able to use the normal update command to do this. The update command takes a parameter already, which can be a lot of things, including the name of a branch or bookmark.

So while I cannot categorically say that your modification is not needed, you should try this and see for yourself:

repo.Update(branchName);

The "WithAcrossBranches" method was added to handle cross-merging of uncommitted changes to another branch, but there have been updates to Mercurial that I sadly have not had the time to incorporate that changes a lot of this.