在持续重构的项目上使用git / mercurial? [英] Using git/mercurial on projects with continuous refactoring?

查看:149
本文介绍了在持续重构的项目上使用git / mercurial?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我工作的项目是java和c#项目,通常使用5-20向b $ ba共同目标努力的人(发布)。大多数开发人员都是专业开发人员,他们每时每刻都在为
重构代码。因此,当典型的linux内核在单独的文件中有大量的
相对独立的变化时,我们有一个不断变化的重构变化 -
通常会碰到很多文件和一个 很多的代码。没有人害怕在这里改变代码。



现在通过颠覆我们可以通过非常接近SVN HEAD来解决这个问题。我们中的一些人甚至在构建服务器的jabber广播上触发了
的自动svn up。我们大多数人也学到了
(或者真的很快学会)如何规划我们的工作以保持与SVN HEAD的距离。如果您正在进行重大重构,那么
会逐渐向新的方向弯曲源树,而不是离开时间过长。有时您只需计划
重构操作,并从较少争用的区域开始。几年后,这种方式工作
成为第二天性。我们大多数人根本不会离开svn头2小时以内的舒适区。自动构建和svn头是项目脉冲,我们喜欢它。



当然,我们分离每个版本,但发布分支的后期数量回到行李箱可以使
快速减少到微不足道(我们已经有了不错的测试范围)。与源代码的私人分支一起运行数天/周,听起来像
就像我们主动想要劝阻的东西,而且它不会经常发生。

git和mercurial的声音方式都很酷,稍微大一些,因为我更像McGyver类型而不是James Bond类型。
但是当谈到为实际切换构建一个案例时,感觉就像Linus和我生活在两个不同的星球上。
我们大多数时候都希望我们的团队专注于HEAD。

GIT如何让我的版本控制更好? GIT将如何让我改进我的过程?我是一个颠覆恐龙吗?

解决方案

在心态方面,有时可以创建一个软分支,在软分支中执行所有更改,测试软分支中的更改结果,然后当软分支完成时,将其与主分支重新集成到本地,重新测试它,然后传播它。

这在某些情况下比冲头更好,因为你没有经常中断其他人的存在,调试代码污染了你的代码,错误来处理。

这也意味着你可以更经常地提交,提供更全面的历史记录,因为提交不会立即在任何地方出现问题。



另外,在将软分支与共享主线进行协调时,您会看到一个很好的完整更改集,向您显示所有集体更改及其所有更改集体变化,为代码审查提供了很好的机会。另外,从测试的角度来看,如果你有更多的软分支,你可以在软分支上运行测试,然后将它们合并回主分支,并且拥有一个分支不会合并回主分支直到它有


  1. 自己通过测试

  2. 通过主分行变更后的测试合并到软分支中

因此为您提供额外保证的代码质量,因为您的主要协作分支是非常干净的,因为失败的代码不允许出现在它上面。



(这也限制了解决问题的领域,因为你只需要测试自己的大部分变化,当你完成时,只有你自己不得不担心别人做了什么,他们做了什么也应该通过测试,这意味着当 失败时,你只需要看看解决这个问题)


但是,我会不断从
中央回购站更新到我的softbranch吗?
这真的是我
问题的根本所在

分支系统的优点是可以将任何被他人视为稳定的东西视需要放入本地副本。

持续更新变得不必要,因为您没有相同的问题显示。

  a b中心
|
|
/ Key:/ - | \ =流量
/ ---- < - | | < > =流向
| / - < - / * =提交
* | | T =测试
| * | M =与公共分支
* |的当前状态合并| C =测试完成且当前状态为理智
| * |
T | |
| T |
| C |
| | / - < - /
* M |
| T |
* C |
| \ ---> -\
* / ---< - /
T | |
C * |
| / -----< - /
M | |
T * |
| T |
* C |
| | / - < - /
* M |
T T |
C \ - > - \
| / --- < - /
M |
T |
C |
\\ ---- ----> --- \
|

另外,由于系统的工作原理,以后也可能发生:

  ab中心
| | |
T | |
C * |
| /< / |
M | |
| * |
T |
C |
| / ---- < - /
M |
T |
C |
\\ - - > ----- \
|

在这种情况下,他们成为头的整个概念消失了。它有几十个头,你看到哪一个很容易看到。

我还可以补充一点,这些逻辑分支虽然在这里单独显示,但可以非常实际地表示单独的结账位置,或单个机器上仅仅是不同的软分支。一个& b实际上可能是一个开发人员。



从本质上讲,从mainbranch不断更新我的softbranch在概念上是毫无意义的。因为实际上,主分支中没有任何变化,你什么时候才能知道它们被推动了? SVN给你这种单一代码状态的错觉,实际上,即时一个用户在他们的文本编辑器中打开一个文件,实际上他们创建了一个非常短暂的生命软分支,一个正在发生的变化,没有人知道,并且为了让这种错觉能够以你认为有效的方式得到维持,实际上,用户必须承诺在每个角色之后,这是不切实际的。所以现实中,人们已经习惯了这样一个事实:不同的地点彼此之间不同步,并且学会了解决问题的方法,所以它不再是一个问题。 b
$ b

此外,随着每个人不断更新我的树都会改变它有一个核心问题,那就是,你有太多的分心,你会不断遭受任何东西的轰炸其他人都在这样做,如果他们做了一系列的1行提交来测试他们无法在自己的机器上测试的东西,那么对于不断变化的文件来说,你有一个噩梦,而用户看到看似随机的变化是无法理解的其中。通过允许提交之间的更长时间运行,然后在批次中查看净结果并仅查看净结果 的同龄人都会一次性更改,您可以立即看到自检出后代码已经发生了什么变化,以及对代码意味着什么的一致性概述,因此您可以编写自己的代码并将其结束。 如果您有任何疑问,请以简单的方式开始,不要过渡冷火鸡, DSCM中的概念可能有点令人望而生畏(我曾经看到很多人理解垂直堆叠的软分支的概念,但将代码的一小部分非必要部分移到了Git / Mercurial中,并随它一起玩同时,试验这些好处以及它可以做些什么。没有比自己亲自体验它的更好的证明了,我所有可爱的解释都不太可能传达你需要理解的东西,只能通过尝试来学习,并且失败几次(因为失败是学习的关键部分)


I am trying to understand if I really have any case for using git/mercurial.

The projects I work are java and c# projects, usually with 5-20 people working towards a common goal (the "release"). Most of the developers are professional developers who refactor code all of the time. So where the typical linux kernel has a large number of relatively independent changes in separate files, we have a constant flux of refactoring changes - often hitting a lot of files and a lot of code. No-one's scared of changing code here.

Now with subversion we solve this by staying extremely close to SVN HEAD. Some of us even have automated svn up's that trigger on the build server's jabber broadcast. Most of us have also learned (or learn really quickly) how to plan our work to stay close to SVN HEAD. If you're doing a major refactoring we incrementally bend the source tree in a new direction instead of going away for too long. Sometimes you just plan the refactoring operation and start off in the less contended areas. After some years of working this way it becomes second nature. Most of us simply never leave the "comfort zone" of being less than 2 hours away from svn head. The automated build and svn head is the project "pulse" and we like it.

Of course we branch off each release, but the number of backmerges from the release-branch back to trunk dwindle down quickly enough to be insignificant (we've got decent test coverage). Running off for days/weeks with private branches of the source sounds like something we actively want to discourage, and it simply doesn't happen very frequently.

Both git and mercurial sound way cool, git slightly more so since I'm more a McGyver type than a James Bond type. But when it comes to building a case for actually switching, it feels like Linus and I are living on two different planets. Most of the time we want our teams to stay focused on HEAD.

How can GIT make my version control better ? How would GIT let me improve my process ? Am I a subversion dinosaur ?

解决方案

In terms of mentality, there is sometimes a benefit in being able to create a soft-branch, perform all the changes in the soft branch, test the result of the changes in the soft branch, and then when the soft-branch is "complete", reintegrate it with the main branch locally, retest it, and then propagate it.

This in some cases is better than the rushed head, because you don't have the constant interruption of the existence of others debug code fouling up your code to add non-errors to handle.

It also means you can commit more often, giving a more comprehensive history, because commits don't instantly turn up everywhere creating problems.

Also, when reconciling the soft-branch with the shared mainline, you get to see a nice complete change-set, showing you both all your collective changes, and all their collective changes, which opens the door for nice code review opportunities.

Additionally, from a testing perspective, if you have more soft-branches, you can run the tests on the soft branches before merging them back into the main branch, and have a standard by which, a branch does not get merged back into the main branch until it has

  1. Passed Tests on its own
  2. Passed Tests after main branches changes have been reconciled into the soft-branch

Thus giving you an extra guarantee of code quality, in that your main collaboration branch is extra squeaky clean, because failing code is not permitted to appear on it.

( Which also limits the problem solving domain, because you only have to test your own changes for the most part, and when you are 'done', only then do you have to worry about what everyone else has done, and what they have done should also be passing tests, which means when something does fail, you only have to look at what you did to solve the problem )

But would I continiously update from central repo head into my softbranch ? This is really the essence of my problem

The beauty of the branch system is you can pull "whatever's been deemed stable by others" into your local copy as needed.

"Continuous Update" becomes unnecessary, because you don't have the same problems manifesting.

a  b   center
         |
         |
         /      Key:   / - | \   = Flow
/----<---|             < >       = Flow Directions
|  /--<--/             *         = Commit 
*  |     |             T         = Test
|  *     |             M         = Merging with "Current" state of common branch
*  |     |             C         = Tests Complete and Current state is "sane"
|  *     |
T  |     |
|  T     |
|  C     |
|  |/-<--/
*  M     |
|  T     |
*  C     |
|  \--->-\
*  /---<-/
T  |     |
C  *     |
|/-----<-/
M  |     |
T  *     |
|  T     |
*  C     |
|  |/-<--/
*  M     |
T  T     |
C  \-->--\
|/---<---/
M        |
T        |
C        |
\---->---\
         |

Also, because of how the system works, later on, this could also occur:

a  b   center
|  |     |
T  |     |
C  *     |
|/</     |
M  |     |
|  *     |
T        |
C        |
|/----<--/
M        |
T        |
C        |
\-->-----\
         |

The entire concept of their being a "head" in such a scenario vanishes. It there are dozens of heads, which one you see is prone to perspective.

I might also add, that these logical branches, although displayed as separate here, can quite feasibly represent either seperate checkout locations, or mere different soft branches on a singular machine. a & b could in fact be a single developer.

In essence, "Continuously updating my softbranch from mainbranch", is conceptually meaningless. Because in fact, there will be changes not represented in mainbranch yet, and when will you know that they have been pushed or not? SVN Gives you this false illusion of a "singular" code state, when in reality, the instant one user opens a file in their text editor, they have in fact created a very short life soft-branch, a change, that is occurring,that nobody knows about, and for this illusion to be sustained the way you think it works, in effect, the user has to commit after every character, which is hardly practical. So in reality, people get used to the fact that different locations get "out-of-sync" with each other, and learn ways to solve it so it's no longer a problem.

Also, the "constantly updating my tree with everyone elses changes" has a core problem, in that, you have far too many distractions, you are constantly being bombarded with everything everyone else is doing, and if they're making a series of 1 line commits to test something they cant test on their own machine, then you have a nightmare with the ever changing file, and the users seeing the seemingly random changes cant make sense of them.

By permitting longer runs between commits, and then seeing the net result in batches and seeing only the net result of your peers changes all at once, you can see immediately what code has been changed since you checked out and a cohesive overview of what it means for your code, so you can just write your own code and get it over with.

If you have any doubts

Start off with something simple and don't transition cold turkey, some of the concepts in DSCMs can be a bit daunting ( I've seen tragic failure by many to understand the concept of vertically stacked soft-branches ) , move a small non-essential part of the codebase to Git/Mercurial and play with it for a while, experiment with the benefits and what it can do. There's no better proof than experiencing it yourself, and all my lovely explanations are unlikely to communicate what you need to understand and can only be learned by trying it, and failing a few times ( because failure is a key part of learning )

这篇关于在持续重构的项目上使用git / mercurial?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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