因爲它是顯然的待辦事項爲
,而
年和不可用,我寫我自己subtools.py
:
from __future__ import print_function
import hglib
import os
import sys
def get_substate(client, rev=None):
substate_filename = os.path.join(client.root(), '.hgsubstate')
if os.path.isfile(substate_filename):
lines = client.cat([substate_filename], rev).split('\n')
return { key : value for (value,key) in [ line.split() for line in lines if line ]}
else:
return {}
def substate_diff(client, revA, revB):
substate_a = get_substate(client, revA)
substate_b = get_substate(client, revB)
key_union = set(substate_b) | set(substate_a)
diff = {}
for key in key_union:
diff[key] = (substate_a[key], substate_b[key])
return diff
def recursive_log(path, revA, revB):
logtree = { 'logs': [], 'subrepos': {}}
try:
client = hglib.open(path)
except:
return logtree
if revA == revB:
print("no changes on {}".format(client.root()))
return logtree
print("Checking {} between {} and {}...".format(client.root(), revA, revB))
for key, revisions in substate_diff(client, revA, revB).iteritems():
if revisions[0] and revisions[1]:
logtree['subrepos'][key] = recursive_log(os.path.join(client.root(),key), revisions[0], revisions[1])
elif revisions[0] and not revisions[1]:
print("removed subrepo with path: %s"%key, file=sys.stderr)
elif revisions[1] and not revisions[2]:
print("added subrepo with path: %s"%key, file=sys.stderr)
logtree['logs'] = client.log("%s:%s"%(revA,revB))
return logtree
用作這樣的:
In [15]: log = subtools.recursive_log('./', '947', '951')
參見[這個問題] (http://stackoverflow.com/q/5757511/800151),它解決了這個問題,如果不是重複的話。此外,請注意合併日誌[在Hg Todo列表中](http://mercurial.selenic.com/wiki/SubrepoWork#log)。 –