Skip to content

Commit 07703de

Browse files
authored
CBL-7554: Use the actual winner and loser revision id when calling c4doc_resolveConflict (#3468)
* Remove space - unrelated * Set winner and losing rev correctly
1 parent b9c588d commit 07703de

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Objective-C/CBLCollection.mm

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,9 @@ - (BOOL) saveResolvedDocument: (CBLDocument*)resolvedDoc
753753
error: (NSError**)outError
754754
{
755755
CBL_LOCK(_mutex) {
756+
CBLStringBytes winningRevID;
757+
CBLStringBytes losingRevID;
758+
756759
CBLDatabase* db = self.database;
757760
if (![self database: db isValid: outError])
758761
return NO;
@@ -769,19 +772,21 @@ - (BOOL) saveResolvedDocument: (CBLDocument*)resolvedDoc
769772
resolvedDoc = remoteDoc;
770773
}
771774

772-
if (resolvedDoc != localDoc)
775+
if (resolvedDoc == localDoc) {
776+
winningRevID = localDoc.revisionID;
777+
losingRevID = remoteDoc.revisionID;
778+
} else {
773779
resolvedDoc.collection = self;
774-
775-
// The remote branch has to win, so that the doc revision history matches the server's.
776-
CBLStringBytes winningRevID = remoteDoc.revisionID;
777-
CBLStringBytes losingRevID = localDoc.revisionID;
780+
winningRevID = remoteDoc.revisionID;
781+
losingRevID = localDoc.revisionID;
782+
}
778783

779784
// mergedRevFlags:
780785
C4RevisionFlags mergedFlags = 0;
781786

782787
// mergedBody:
783788
alloc_slice mergedBody;
784-
if (resolvedDoc != remoteDoc) {
789+
if (resolvedDoc != localDoc && resolvedDoc != remoteDoc) {
785790
if (resolvedDoc) {
786791
// Unless the remote revision is being used as-is, we need a new revision:
787792
NSError* err = nil;

Swift/Authenticator.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public struct BasicAuthenticator: IAuthenticator {
5555
}
5656

5757
// MARK: Internal
58-
5958
func toImpl() -> CBLAuthenticator {
6059
return CBLBasicAuthenticator(username: username, password: password)
6160
}

0 commit comments

Comments
 (0)