Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
jio
Commits
c1c73f90
Commit
c1c73f90
authored
Aug 06, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revisionstorage.js amd compatible now
parent
e3d3b88f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
946 additions
and
926 deletions
+946
-926
src/jio.storage/revisionstorage.js
src/jio.storage/revisionstorage.js
+946
-926
No files found.
src/jio.storage/revisionstorage.js
View file @
c1c73f90
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global jIO: true, hex_sha256: true, setTimeout: true */
/*global jIO, hex_sha256, setTimeout, define */
/**
/**
* JIO Revision Storage.
* JIO Revision Storage.
* It manages document version and can generate conflicts.
* It manages document version and can generate conflicts.
...
@@ -9,8 +10,18 @@
...
@@ -9,8 +10,18 @@
* "sub_storage": <sub storage description>
* "sub_storage": <sub storage description>
* }
* }
*/
*/
jIO
.
addStorageType
(
"
revision
"
,
function
(
spec
,
my
)
{
// define([module_name], [dependencies], module);
(
function
(
dependencies
,
module
)
{
"
use strict
"
;
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
return
define
(
dependencies
,
module
);
}
module
(
jIO
,
hex_sha256
);
}([
'
jio
'
,
'
sha256
'
],
function
(
jIO
,
hex_sha256
)
{
"
use strict
"
;
"
use strict
"
;
jIO
.
addStorageType
(
"
revision
"
,
function
(
spec
,
my
)
{
var
that
=
{},
priv
=
{};
var
that
=
{},
priv
=
{};
spec
=
spec
||
{};
spec
=
spec
||
{};
that
=
my
.
basicStorage
(
spec
,
my
);
that
=
my
.
basicStorage
(
spec
,
my
);
...
@@ -106,7 +117,9 @@ jIO.addStorageType("revision", function (spec, my) {
...
@@ -106,7 +117,9 @@ jIO.addStorageType("revision", function (spec, my) {
if
(
typeof
doc
.
_revs
.
start
!==
"
number
"
||
if
(
typeof
doc
.
_revs
.
start
!==
"
number
"
||
typeof
doc
.
_revs
.
ids
!==
"
object
"
||
typeof
doc
.
_revs
.
ids
!==
"
object
"
||
typeof
doc
.
_revs
.
ids
.
length
!==
"
number
"
)
{
typeof
doc
.
_revs
.
ids
.
length
!==
"
number
"
)
{
return
send_error
(
"
The document revision history is not well formated
"
);
return
send_error
(
"
The document revision history is not well formated
"
);
}
}
}
}
if
(
typeof
doc
.
_revs_info
===
"
object
"
)
{
if
(
typeof
doc
.
_revs_info
===
"
object
"
)
{
...
@@ -320,7 +333,10 @@ jIO.addStorageType("revision", function (spec, my) {
...
@@ -320,7 +333,10 @@ jIO.addStorageType("revision", function (spec, my) {
getWinnerRevsInfoRec
=
function
(
doc_tree
,
tmp_revs_info
)
{
getWinnerRevsInfoRec
=
function
(
doc_tree
,
tmp_revs_info
)
{
var
i
;
var
i
;
if
(
doc_tree
.
rev
)
{
if
(
doc_tree
.
rev
)
{
tmp_revs_info
.
unshift
({
"
rev
"
:
doc_tree
.
rev
,
"
status
"
:
doc_tree
.
status
});
tmp_revs_info
.
unshift
({
"
rev
"
:
doc_tree
.
rev
,
"
status
"
:
doc_tree
.
status
});
}
}
if
(
doc_tree
.
children
.
length
===
0
)
{
if
(
doc_tree
.
children
.
length
===
0
)
{
if
(
revs_info
.
length
===
0
||
if
(
revs_info
.
length
===
0
||
...
@@ -532,7 +548,8 @@ jIO.addStorageType("revision", function (spec, my) {
...
@@ -532,7 +548,8 @@ jIO.addStorageType("revision", function (spec, my) {
priv
.
getRevisionTree
(
doc
,
option
,
callback
.
getRevisionTree
);
priv
.
getRevisionTree
(
doc
,
option
,
callback
.
getRevisionTree
);
};
};
callback
.
getRevisionTree
=
function
(
err
,
response
)
{
callback
.
getRevisionTree
=
function
(
err
,
response
)
{
var
winner_info
,
previous_revision
=
doc
.
_rev
,
var
winner_info
,
previous_revision
,
generate_new_revision
;
previous_revision
=
doc
.
_rew
;
generate_new_revision
=
doc
.
_revs
||
doc
.
_revs_info
?
false
:
true
;
generate_new_revision
=
doc
.
_revs
||
doc
.
_revs_info
?
false
:
true
;
if
(
err
)
{
if
(
err
)
{
if
(
err
.
status
!==
404
)
{
if
(
err
.
status
!==
404
)
{
...
@@ -949,7 +966,8 @@ jIO.addStorageType("revision", function (spec, my) {
...
@@ -949,7 +966,8 @@ jIO.addStorageType("revision", function (spec, my) {
that
.
success
(
result
);
that
.
success
(
result
);
}
}
};
};
priv
.
send
(
"
allDocs
"
,
null
,
command
.
cloneOption
(),
function
(
err
,
response
)
{
priv
.
send
(
"
allDocs
"
,
null
,
command
.
cloneOption
(
),
function
(
err
,
response
)
{
var
i
,
j
,
row
,
selector
,
selected
;
var
i
,
j
,
row
,
selector
,
selected
;
if
(
err
)
{
if
(
err
)
{
return
that
.
error
(
err
);
return
that
.
error
(
err
);
...
@@ -1019,4 +1037,6 @@ jIO.addStorageType("revision", function (spec, my) {
...
@@ -1019,4 +1037,6 @@ jIO.addStorageType("revision", function (spec, my) {
// END //
// END //
priv
.
RevisionStorage
();
priv
.
RevisionStorage
();
return
that
;
return
that
;
});
// end RevisionStorage
});
// end RevisionStorage
}));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment