Пример #1
0
        public BranchVM(AreaVM areaVM, Branch branch)
        {
            _areaVM = areaVM;
            _branch = branch;

            CheckoutCommand = new DelegateCommand(Checkout);
            LogCommand = new DelegateCommand(Log);
        }
Пример #2
0
 public static Branch Create(string name, Guid? rootVersion, Guid? parent)
 {
     Branch b = new Branch();
     b.ID = Guid.NewGuid();
     b.Parent = parent;
     b.RootVersion = rootVersion;
     b.Name = name;
     return b;
 }
Пример #3
0
        private static bool QueryBranch(SharedNetworkInfo info, Stack<Branch> branchesToSend, Branch branch)
        {
            try
            {
                if (info.RemoteCheckedBranches.Contains(branch.ID))
                    return true;
                Printer.PrintDiagnostics("Sending remote vault local branch information.");
                Branch currentBranch = branch;
                while (true)
                {
                    int branchesPerBlock = 16;
                    List<Objects.Branch> branchIDs = new List<Objects.Branch>();
                    while (branchesPerBlock > 0)
                    {
                        if (info.RemoteCheckedBranches.Contains(currentBranch.ID))
                            break;
                        info.RemoteCheckedBranches.Add(currentBranch.ID);
                        branchesPerBlock--;
                        branchIDs.Add(currentBranch);
                        if (currentBranch.Parent.HasValue)
                            currentBranch = info.Workspace.GetBranch(currentBranch.Parent.Value);
                        else
                        {
                            currentBranch = null;
                            break;
                        }
                    }

                    if (branchIDs.Count > 0)
                    {
                        PushObjectQuery query = new PushObjectQuery();
                        query.Type = ObjectType.Branch;
                        query.IDs = branchIDs.Select(x => x.ID.ToString()).ToArray();

                        ProtoBuf.Serializer.SerializeWithLengthPrefix<NetCommand>(info.Stream, new NetCommand() { Type = NetCommandType.PushObjectQuery }, ProtoBuf.PrefixStyle.Fixed32);
                        Utilities.SendEncrypted<PushObjectQuery>(info, query);

                        PushObjectResponse response = Utilities.ReceiveEncrypted<PushObjectResponse>(info);
                        if (response.Recognized.Length != query.IDs.Length)
                            throw new Exception("Invalid response!");
                        int recognized = 0;
                        for (int i = 0; i < response.Recognized.Length; i++)
                        {
                            Printer.PrintDiagnostics(" - Branch ID: {0}", query.IDs[i]);
                            if (!response.Recognized[i])
                            {
                                branchesToSend.Push(branchIDs[i]);
                                Printer.PrintDiagnostics("   (not recognized on remote vault)");
                            }
                            else
                            {
                                info.RemoteCheckedBranches.Add(branchIDs[i].ID);
                                recognized++;
                                Printer.PrintDiagnostics("   (branch already on remote vault)");
                            }
                        }
                        if (recognized != 0) // we found a common parent somewhere
                            break;
                    }
                    else if (info.RemoteCheckedBranches.Count > 0)
                        break;
                }
                return true;
            }
            catch (Exception e)
            {
                Printer.PrintError("Error: {0}", e);
                return false;
            }
        }
Пример #4
0
 public List<Objects.Head> GetHeads(Branch branch)
 {
     return Table<Objects.Head>().Where(x => x.Branch == branch.ID).ToList();
 }