Skip to content

Instantly share code, notes, and snippets.

@dustin
Created March 22, 2011 21:58
Show Gist options
  • Save dustin/882174 to your computer and use it in GitHub Desktop.
Save dustin/882174 to your computer and use it in GitHub Desktop.
Bulk conflict resolver.
#!/usr/bin/env python
import sys
import couchdb
MINIMATA='http://minimata:5984/'
LOCAL='http://localhost:5984/'
db = couchdb.Server(MINIMATA)['photo']
docs = []
for d in db.view('hack/conflicts'):
print d.id
for r in d.value:
print " %s" % r
docs.append({'_id': d.id, '_rev': r, '_deleted': True})
# docs.append(doc)
print docs
if docs:
print "Deleting %d conflicts (if you press enter)" % len(docs)
sys.stdin.readline()
print db.update(docs)
else:
print "No docs to delete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment