Ejemplo n.º 1
0
 public ItemAction(GlobalChangeset gs, DocSetChangeset ds, FileChangeset fs, Change c)
 {
     globalset = gs;
     docset    = ds;
     fileset   = fs;
     change    = c;
 }
Ejemplo n.º 2
0
        public static void AccountForChanges(XmlDocument d, string doc_set, string real_file)
        {
            try {
                FileChangeset fcs = changes.GetChangeset(doc_set, real_file);
                if (fcs == null)
                {
                    return;
                }

                foreach (Change c in fcs.Changes)
                {
                    // Filter out old changes
                    if (c.FromVersion != RootTree.MonodocVersion)
                    {
                        continue;
                    }

                    XmlNode old = d.SelectSingleNode(c.XPath);
                    if (old != null)
                    {
                        old.ParentNode.ReplaceChild(d.ImportNode(c.NewNode, true), old);
                    }
                }
            } catch {
                return;
            }
        }
Ejemplo n.º 3
0
        void SaveDocument(XmlDocument d, DocSetChangeset docset, FileChangeset fileset)
        {
            string basedir = (string)providers [docset.DocSet];
            string file    = basedir + "/" + fileset.RealFile;

            d.Save(file);
            RenderReview(current_id, current_serial);
        }
Ejemplo n.º 4
0
        public void AddChange(string doc_set, string real_file, string xpath, XmlNode new_node, string node_url)
        {
            FileChangeset new_file_change_set;
            Change        new_change = NewChange(xpath, new_node, node_url);

            if (real_file == null)
            {
                throw new Exception("Could not find real_file. Please talk to Miguel or Ben about this");
            }

            foreach (DocSetChangeset dscs in DocSetChangesets)
            {
                if (dscs.DocSet != doc_set)
                {
                    continue;
                }

                foreach (FileChangeset fcs in dscs.FileChangesets)
                {
                    if (fcs.RealFile != real_file)
                    {
                        continue;
                    }

                    foreach (Change c in fcs.Changes)
                    {
                        if (c.XPath == xpath)
                        {
                            c.NewNode = new_node;
                            c.Serial  = SettingsHandler.Settings.SerialNumber;
                            return;
                        }
                    }

                    fcs.Changes.Add(new_change);
                    return;
                }

                new_file_change_set          = new FileChangeset();
                new_file_change_set.RealFile = real_file;
                new_file_change_set.Changes.Add(new_change);
                dscs.FileChangesets.Add(new_file_change_set);
                return;
            }

            DocSetChangeset new_dcs = new DocSetChangeset();

            new_dcs.DocSet = doc_set;

            new_file_change_set          = new FileChangeset();
            new_file_change_set.RealFile = real_file;

            new_file_change_set.Changes.Add(new_change);
            new_dcs.FileChangesets.Add(new_file_change_set);
            DocSetChangesets.Add(new_dcs);
        }
Ejemplo n.º 5
0
        void Merge(FileChangeset fcs, string path)
        {
            XmlDocument d = new XmlDocument();

            d.Load(Path.Combine(path, fcs.RealFile));

            foreach (Change c in fcs.Changes)
            {
                XmlNode old = d.SelectSingleNode(c.XPath);
                if (old != null)
                {
                    old.ParentNode.ReplaceChild(d.ImportNode(c.NewNode, true), old);
                }
            }

            d.Save(Path.Combine(path, fcs.RealFile));
        }
Ejemplo n.º 6
0
        public void RemoveChange(string doc_set, string real_file, string xpath)
        {
            if (real_file == null)
            {
                throw new Exception("Could not find real_file. Please talk to Miguel or Ben about this");
            }

            for (int i = 0; i < DocSetChangesets.Count; i++)
            {
                DocSetChangeset dscs = DocSetChangesets [i] as DocSetChangeset;
                if (dscs.DocSet != doc_set)
                {
                    continue;
                }

                for (int j = 0; j < dscs.FileChangesets.Count; j++)
                {
                    FileChangeset fcs = dscs.FileChangesets [j] as FileChangeset;
                    if (fcs.RealFile != real_file)
                    {
                        continue;
                    }

                    for (int k = 0; k < fcs.Changes.Count; k++)
                    {
                        Change c = fcs.Changes [k] as Change;
                        if (c.XPath == xpath)
                        {
                            fcs.Changes.Remove(c);
                            break;
                        }
                    }
                    if (fcs.Changes.Count == 0)
                    {
                        dscs.FileChangesets.Remove(fcs);
                    }
                }

                if (dscs.FileChangesets.Count == 0)
                {
                    DocSetChangesets.Remove(dscs);
                }
            }
        }
Ejemplo n.º 7
0
        public FileChangeset GetFrom(int starting_serial_id)
        {
            FileChangeset fcs = null;

            foreach (Change c in Changes)
            {
                if (c.Serial < starting_serial_id)
                {
                    continue;
                }
                if (fcs == null)
                {
                    fcs          = new FileChangeset();
                    fcs.RealFile = RealFile;
                }
                fcs.Changes.Add(c);
            }
            return(fcs);
        }
Ejemplo n.º 8
0
	void SaveDocument (XmlDocument d, DocSetChangeset docset, FileChangeset fileset)
	{
		string basedir = (string) providers [docset.DocSet];
		string file = basedir + "/" + fileset.RealFile;
		
		d.Save (file);
		RenderReview (current_id, current_serial);
	}
Ejemplo n.º 9
0
		public ItemAction (GlobalChangeset gs, DocSetChangeset ds, FileChangeset fs, Change c)
		{
			globalset = gs;
			docset = ds;
			fileset = fs;
			change = c;
		}
Ejemplo n.º 10
0
		public FileAction (GlobalChangeset gs, DocSetChangeset ds, FileChangeset fs)
		{
			globalset = gs;
			docset = ds;
			fileset = fs;
		}
Ejemplo n.º 11
0
		void Merge (FileChangeset fcs, string path)
		{
			XmlDocument d = new XmlDocument ();
			d.Load (Path.Combine (path, fcs.RealFile));
			
			foreach (Change c in fcs.Changes) {
				XmlNode old = d.SelectSingleNode (c.XPath);
				if (old != null)
					old.ParentNode.ReplaceChild (d.ImportNode (c.NewNode, true), old);
			}
			
			d.Save (Path.Combine (path, fcs.RealFile));
		}
Ejemplo n.º 12
0
		public FileChangeset GetFrom (int starting_serial_id)
		{
			FileChangeset fcs = null;

			foreach (Change c in Changes){
				if (c.Serial < starting_serial_id)
					continue;
				if (fcs == null){
					fcs = new FileChangeset ();
					fcs.RealFile = RealFile;
				}
				fcs.Changes.Add (c);
			}
			return fcs;
		}
Ejemplo n.º 13
0
		public void AddChange (string doc_set, string real_file, string xpath, XmlNode new_node, string node_url)
		{
			FileChangeset new_file_change_set;
			Change new_change = NewChange (xpath, new_node, node_url);
			
			if (real_file == null)
				throw new Exception ("Could not find real_file. Please talk to Miguel or Ben about this");
			
			foreach (DocSetChangeset dscs in DocSetChangesets) {
				if (dscs.DocSet != doc_set) 
					continue;

				foreach (FileChangeset fcs in dscs.FileChangesets) {
					if (fcs.RealFile != real_file)
						continue;
					
					foreach (Change c in fcs.Changes) {
						if (c.XPath == xpath) {
							c.NewNode = new_node;
							c.Serial = SettingsHandler.Settings.SerialNumber;
							return;
						}
					}

					fcs.Changes.Add (new_change);
					return;
					
				}
				
				new_file_change_set = new FileChangeset ();
				new_file_change_set.RealFile = real_file;
				new_file_change_set.Changes.Add (new_change);
				dscs.FileChangesets.Add (new_file_change_set);
				return;
					
			}
			
			DocSetChangeset new_dcs = new DocSetChangeset ();
			new_dcs.DocSet = doc_set;
			
			new_file_change_set = new FileChangeset ();
			new_file_change_set.RealFile = real_file;
			
			new_file_change_set.Changes.Add (new_change);
			new_dcs.FileChangesets.Add (new_file_change_set);
			DocSetChangesets.Add (new_dcs);
		}
Ejemplo n.º 14
0
 public FileAction(GlobalChangeset gs, DocSetChangeset ds, FileChangeset fs)
 {
     globalset = gs;
     docset    = ds;
     fileset   = fs;
 }