couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject revs_info misses conflicting revs?
Date Thu, 29 Oct 2009 16:39:09 GMT
I am a bit confused about the intended semantics of ?revs_info=true, since
it does not show conflicting revs. Example:

---------------- script ---------------
HOST=http://127.0.0.1:5984
DB="$HOST/conflict_test"
EP="$DB/_bulk_docs"
curl -s "$HOST"
curl -sX DELETE "$DB"
curl -sX PUT "$DB"

resp=$(curl -sX POST -d @- $EP <<JSON)
{"all_or_nothing":true,"docs":[{
"_id":"mydoc",
"type":"test"
}]}
JSON
rev0=`expr "$resp" : '.*"rev":"\([^"]*\)"'`
echo $rev0

resp=$(curl -sX POST -d @- $EP <<JSON)
{"all_or_nothing":true,"docs":[{
"_id":"mydoc",
"_rev":"$rev0",
"type":"test",
"data":"foo"
}]}
JSON
rev1=`expr "$resp" : '.*"rev":"\([^"]*\)"'`
echo $rev1

resp=$(curl -sX POST -d @- $EP <<JSON)
{"all_or_nothing":true,"docs":[{
"_id":"mydoc",
"_rev":"$rev0",
"type":"wibble",
"data":"bar"
}]}
JSON
rev2=`expr "$resp" : '.*"rev":"\([^"]*\)"'`
echo $rev2

# Now we have two conflicting versions.
echo
echo "Getting the auto-selected version:"
curl -s "$DB/mydoc"
echo
echo "Getting the auto-selected version with 'conflicts':"
curl -s "$DB/mydoc?conflicts=true"
echo
echo "Getting the auto-selected version with 'revs':"
curl -s "$DB/mydoc?revs=true"
echo
echo "Getting the auto-selected version with 'revs_info':"
curl -s "$DB/mydoc?revs_info=true"

---------------- output -----------------
{"couchdb":"Welcome","version":"0.11.0bc7e681a3-git"}
{"ok":true}
{"ok":true}
1-3b717529ff0f515c2c5d8aa52a2c03ab
2-7170cc59f0d73ecf7bf60f3818fda4be
2-161b6901565fe9ffdc937da206b09e53

Getting the auto-selected version:
{"_id":"mydoc","_rev":"2-7170cc59f0d73ecf7bf60f3818fda4be","type":"test","data":"foo"}

Getting the auto-selected version with 'conflicts':
{"_id":"mydoc","_rev":"2-7170cc59f0d73ecf7bf60f3818fda4be","type":"test","data":"foo","_conflicts":["2-161b6901565fe9ffdc937da206b09e53"]}

Getting the auto-selected version with 'revs':
{"_id":"mydoc","_rev":"2-7170cc59f0d73ecf7bf60f3818fda4be","type":"test","data":"foo","_revisions":{"start":2,"ids":["7170cc59f0d73ecf7bf60f3818fda4be","3b717529ff0f515c2c5d8aa52a2c03ab"]}}

Getting the auto-selected version with 'revs_info':
{"_id":"mydoc","_rev":"2-7170cc59f0d73ecf7bf60f3818fda4be","type":"test","data":"foo","_revs_info":[{"rev":"2-7170cc59f0d73ecf7bf60f3818fda4be","status":"available"},{"rev":"1-3b717529ff0f515c2c5d8aa52a2c03ab","status":"available"}]}

So:
* the current version has _rev 2-717

* "conflicts" tells us about _conflicts 2-161

* "revs" tells us about _revisions 717 and 3b7. It says "start":2 but
actually the 3b7 is 1-3b7, so this doesn't seem to be useful in practice.

* "revs_info" tells us about 2-717 and 1-3b7 (but not 2-161)

You *can* apply both conflicts=true and revs_info=true. Is that what you're
supposed to do? Is revs_info only supposed to give the revs back along one
particular history branch?

Thanks,

Brian.

Mime
View raw message