如何编写简单的版本控制系统代码? [英] How to code a simple versioning system?

查看:129
本文介绍了如何编写简单的版本控制系统代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一个简单的版本控制系统,但是我不知道如何构造数据和代码。

I want to do a simple versioning system but i don't have ideas on how to structure my datas, and my code.

这里是一个简短的示例:

Here is a short example:


  1. 用户登录

  2. 上传文件时,用户有两个选择:


    • 提交新文件

    • 提交文件的新版本

用户应该能够看到树。 (不同版本)
树最多只能包含2个级别:

Users should be able to see the tree. (the different version) The tree can only be up to 2 levels:

|
|--File_A_0
 \--File_A_1
 \--File_A_2
 \--File_A_3
 \--File_A_4

文件也有两种类型,即最终文件(最新批准的版本)和草稿版本(最新上传的文件)文件)
该文件将物理存储在服务器上。
每个文件都由一个(或多个)用户拥有,并且只有一个组。

There are also 2 types of file, a final (which is the latest approved version) and a draft version (which the latest uploaded file) The file will be physically stored on the server. Each files are owned by a user (or more) and only one group.

编辑:组代表一组文档,文件一次只能由一个组拥有。用户不依赖组。

Groups represent a group of document, document could only be owned by ONE group at once. Users do NOT depend on groups.

开始编辑:

这是什么我做到了,但是效率不是很高!

Here is what i did, but it is not really efficient !

id_article | relative_group_id | id_group | title | submited | date | abstract | reference | draft_version | count | status

id_draft | id_file | version | date

但是很难扩展。
我认为是因为组参数...

But it's difficult to manage, to extend. I think it's because the group paramater...

结束编辑

所以问题是:


  • 我怎样才能模式化数据库?

  • 什么样的的信息应该对
    的版本有用吗?


  • 文件夹,文件的结构是什么?

  • 您有
    什么样的提示,提示来做这种工作?

  • How can i schematize my database ?
  • What kind of infos should be usefull to version this work ?
  • What kind of structure for the folders, files ?
  • What kind of tips, hints do you have to do this kind of work ?

(该应用程序是用PHP开发的和Zend Framework,数据库应该是mysql或PostgreSQL)

(The application is developped with PHP and Zend Framework, database should be mysql or postgresql)

推荐答案

为了上帝,不要 。您真的不想走这条路。

For God's sake, don't. You really don't want to go down this road.

停下来,暂时考虑一下大局。您想要保留文档的早期版本,这意味着在某个时候,有人会希望看到其中的某些早期版本,对吗?然后他们要问,版本3和版本7有什么区别? 然后他们要说,我想回滚到版本3,但保持我在版本5中做了一些更改,嗯,好吗?

Stop and think about the bigger picture for a moment. You want to keep earlier versions of documents, which means that at some point, somebody is going to want to see some of those earlier versions, right? And then they are going to ask, "What's the difference between version 3 and version 7"? And then they are going to say, "I want to roll back to version 3, but keep some of the changes that I put in version 5, ummm, ok?"

版本控制非常重要,不需要重新发明轮子-有很多可行的版本控制系统,甚至有一些免费的。

Version control is non-trivial, and there's no need to reinvent the wheel-- there are lots of viable version control systems out there, some of them free, even.

从长远来看,学习以下版本的API会容易得多

In the long run, it will be much easier to learn the API of one of these systems, and code a web front-end that offers your users the subset of features they are looking for (now.)

您不会编写文本,而是为其中的一个系统编写代码,并为网络前端编写代码,从而为您的用户提供他们正在寻找的功能的子集。您的用户的编辑器,对吗?

You wouldn't code a text editor for your users, would you?

这篇关于如何编写简单的版本控制系统代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆