【发布时间】:2012-01-11 18:26:03
【问题描述】:
考虑一下这个简单的 python 代码,它演示了一个非常简单的字典版本控制设计:
def build_current(history):
current = {}
for action, key, value in history:
assert action in ('set', 'del')
if action == 'set':
current[key] = value
elif action == 'del':
del current[key]
return current
history = []
history.append(('set', '1', 'one'))
history.append(('set', '2', 'two'))
history.append(('set', '3', 'three'))
print build_current(history)
history.append(('del', '2', None))
history.append(('set', '1', 'uno'))
history.append(('set', '4', 'four'))
print build_current(history)
for action, key, value in history:
if key == '2':
print '(%s, %s, %s)' % (action, key, value)
请注意,通过使用历史列表,您可以将当前字典重建为它曾经存在的任何状态。我认为这是一个“前向构建”(因为没有更好的术语),因为要构建当前字典,必须从头开始并处理整个历史列表。我认为这是最明显和最直接的方法。
据我所知,早期的版本控制系统使用这种“前向构建”过程,但它们并不是最优的,因为大多数用户更关心构建的最新版本。此外,当用户只关心查看最新版本时,他们不想下载整个历史记录。
那么我的问题是,还有哪些其他方法可以在版本控制系统中存储历史记录?也许可以使用“向后构建”?这可能允许用户只下载最近的修订而不需要整个历史。我还有seen 几种不同的历史存储格式,即:变更集、快照和补丁。变更集、快照和补丁之间有什么区别?
在可用的现代流行版本控件中,它们如何存储历史记录以及各种设计的优势是什么?
【问题讨论】:
-
这可能属于programmers.SE。
-
我正在寻找有关特定算法和应用程序的具体细节;这是否属于程序员 SE 的所有职业建议问题?
-
实际上,职业建议在那里是题外话,这类问题很快就解决了。算法非常切题。见the FAQ。
-
听起来不错。问题是如何转移的?
-
@Buttons840:将其标记为离题。
标签: python git svn version-control mercurial