[oe-commits] org.oe.dev contrib/mtn2git: Ignore unknown certs, try to be more robust against CTRL-C when saving the status
freyther commit
openembedded-commits at lists.openembedded.org
Mon Jan 7 20:13:15 UTC 2008
contrib/mtn2git: Ignore unknown certs, try to be more robust against CTRL-C when saving the status
Author: freyther at openembedded.org
Branch: org.openembedded.dev
Revision: 0a162b9a7775765cce2300d5905d64da4167a2da
ViewMTN: http://monotone.openembedded.org/revision/info/0a162b9a7775765cce2300d5905d64da4167a2da
Files:
1
contrib/mtn2git/mtn2git.py
contrib/mtn2git/status.py
Diffs:
#
# mt diff -rda2d354de8a54d22ccdfb56cb35a22cfe1eb470d -r0a162b9a7775765cce2300d5905d64da4167a2da
#
#
#
# patch "contrib/mtn2git/mtn2git.py"
# from [f336e19760df662e35b161bf5791041c5a6e1824]
# to [ef2f536d1f3ef8e1e749df1cc8645740a9accdfd]
#
# patch "contrib/mtn2git/status.py"
# from [d3682877d9debb3e8439b6a0558bb11e6e2262b0]
# to [f6bd6e54ea9b86318ee717e4f86cc27701263844]
#
============================================================
--- contrib/mtn2git/mtn2git.py f336e19760df662e35b161bf5791041c5a6e1824
+++ contrib/mtn2git/mtn2git.py ef2f536d1f3ef8e1e749df1cc8645740a9accdfd
@@ -519,7 +519,7 @@ def parse_revision(operations, revision)
revision_description["committer"] = cert[1]
else:
print >> sys.stderr, "Unknown Cert: Ignoring", cert[5], cert[7]
- assert(False)
+ #assert(False)
return revision_description
@@ -565,24 +565,37 @@ def main(mtn_cli, db, rev):
ops.automate.stop()
all_revs = []
+ branch_heads = {}
for branch in branches:
heads = [head for head in ops.heads(branch)]
+ if len(heads) != 1:
+ print >> sys.stderr, "Skipping branch '%s' due multiple heads" % (branch)
+ continue
+
if branch in status.former_heads:
old_heads = status.former_heads[branch]
else:
old_heads = []
for head in heads:
+ print >> sys.stderr, old_heads, head
all_revs += ops.ancestry_difference(head, old_heads)
- status.former_heads[branch] = heads
+ for rev in all_revs:
+ if not rev in branch_heads:
+ branch_heads[rev] = []
+ branch_heads[rev].append(branch)
+
sorted_revs = [rev for rev in ops.toposort(all_revs)]
for rev in sorted_revs:
if has_mark(rev):
- print >> sys.stderr, "Already having commit '%s'" % rev
+ print >> sys.stderr, "B: Already having commit '%s'" % rev
else:
print >> sys.stderr, "Going to import revision ", rev
fast_import(ops, parse_revision(ops, rev))
+ branches = branch_heads[rev]
+ for branch in branches:
+ status.former_heads[branch] = [rev]
if __name__ == "__main__":
============================================================
--- contrib/mtn2git/status.py d3682877d9debb3e8439b6a0558bb11e6e2262b0
+++ contrib/mtn2git/status.py f6bd6e54ea9b86318ee717e4f86cc27701263844
@@ -20,7 +20,7 @@
THE SOFTWARE.
"""
-import pickle
+import os, pickle
marks = {}
last_mark = 0
@@ -39,9 +39,16 @@ def store(status_name):
def store(status_name):
global marks, last_mark, mark_file, former_heads, same_revisions
- file = open(status_name, "wb")
+ file = open("%s.tmp-foo" % status_name, "wb")
pickle.dump(marks, file)
pickle.dump(last_mark, file)
pickle.dump(former_heads, file)
pickle.dump(same_revisions, file)
file.close()
+
+ # Almost atomic rename, without the risk to destroy something
+ try:
+ os.remove(status_name)
+ except:
+ pass
+ os.rename("%s.tmp-foo" % status_name, status_name)
More information about the Openembedded-commits
mailing list