Commit 72d4dce7 authored by Sriram Karra's avatar Sriram Karra

Allow --conflict-resolve to be set as 1 or 2

Earlier the argument only used to be the dbid - and as we did not allow
same-to-same synching, it was fine. With the present refactoring
we need to uniquely identify which of the two they are referring to.

With this commit we seamlessly migrate the identification of cr
flag from dbid to either 1 or 2. Existing state.json files will
work seamlessly as none of them would have issues with teh dbid
specification. Newly created profiles - whether same to same or
unique dbid syncs will all use 1 or 2 to specify the direction of
conflict resolution
parent 17e480d9
......@@ -505,7 +505,7 @@ class Config:
db1id = self.get_profile_db1(profile)
db2id = self.get_profile_db2(profile)
if not val in [db1id, db2id]:
if not val in [db1id, db2id, "1", "2"]:
raise AsynkConfigError(
('Invalid value for: %s[conflict_resolve]: %s' %
(profile, val)))
......
......@@ -212,9 +212,9 @@ class Sync:
cr = self.get_config().get_conflict_resolve(pname)
if cr == db2id:
if cr == db2id or cr == "2":
f1_mod = f1sl.remove_keys_from_mod(coma)
elif cr == db1id:
elif cr == db1id or cr == "1":
f2_mod = f2sl.remove_values_from_mod(coma)
else:
logging.error('Unknown conflict resolution dir: %s', cr)
......
......@@ -105,8 +105,10 @@ def setup_parser ():
p.add_argument('--conflict-resolve', action='store',
help='Specifies how to deal with conflicts in case of '
'a bidirectional sync and an item is modified in both '
'places. value should be one of the two dbids that are '
'already specified.')
'places. It should be set to 1 or 2 to specify the one '
'to be used; in case the dbs are unique. For e.g. if you '
'are synching from BBDB to Google Contacts, then you can '
'also specify the dbid itself (i.e. bb or gc)')
# Google Contacts authentication
gg = p.add_argument_group('Google Authentication')
......
......@@ -514,11 +514,20 @@ class Asynk:
cr = self.get_conflict_resolve()
if (not cr):
cr = dbid1
cr = "1"
else:
if (not cr in [dbid1, dbid2]):
if (not cr in [dbid1, dbid2, "1", "2"]):
raise AsynkParserError('--conflict-resolve should be one of '
'the two dbids specified earlier.')
'the two dbids specified earlier or '
'the numbers 1 or 2')
if (dbid1 == dbid2 and not cr in ["1", "2"]):
raise AsynkParserError('--conflict-resolve should be either 1 '
'or 2 as both dbs are the same')
if cr == dbid1:
cr = "1"
elif cr == dbid2:
cr = "2"
sync_dir = self.get_sync_dir()
if not sync_dir:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment