--- bsync 2016-02-17 15:50:54.882968741 +0100 +++ bsync.vste 2016-02-18 15:37:37.157430486 +0100 @@ -142,6 +142,7 @@ rsyncdst = getdirstr(sshDst, dirnameDst)+"/" #vste + #args = [ "-a", "--files-from=-", "--from0", "--no-implied-dirs", "--out-format=rsync: %n%L" ] args = [ "-a", "--acls", "--xattrs", "--compress", "--files-from=-", "--from0", "--no-implied-dirs", "--out-format=rsync: %n%L" ] if ssh != None: cmdlist = ssh.getcmdlist() @@ -508,9 +509,16 @@ # ask the user about conflicting changes # conflict can be on type, date, size, perms def ask_conflict(f1, f2, path, tokeep): - if tokeep=="1a" or tokeep=="2a": +#vste +# if tokeep=="1a" or tokeep=="2a": + if tokeep=="1a" or tokeep=="2a" or tokeep=="ra": return tokeep +#vste START + if autoanswer: + return autoanswer +#vste END + resp = None while True: print_line() @@ -522,13 +530,19 @@ if resp!=None: print(" 1 Keep left version") print(" 2 Keep right version") + print(" r Automatic (the most recent version, or not delete file/dir, or path1)") #vste print(" 1a Keep left version for all") print(" 2a Keep right version for all") + print(" ra Automatic for all (the most recent version, or not delete file/dir, or path1)") #vste print(" Please note: you will be able to confirm the actions later.\n") - resp = myinput("Which one do I keep? [1/2/1a/2a/Quit/Help] ") - - if resp == "1" or resp == "2" or resp == "1a" or resp == "2a": +#vste +# resp = myinput("Which one do I keep? [1/2/1a/2a/Quit/Help] ") + resp = myinput("Which one do I keep? [1/2/1a/2a/r/ra/Quit/Help] ") + +#vste +# if resp == "1" or resp == "2" or resp == "1a" or resp == "2a": + if resp == "1" or resp == "2" or resp == "r" or resp == "1a" or resp == "2a" or resp == "ra": return resp elif resp == "q" or resp == "Q" or resp == "Quit": sys.exit(0) @@ -743,13 +757,16 @@ usage+= " -b Batch mode (exit on conflict)\n" usage+= " -p PORT Port for SSH\n" usage+= " -o SSHARGS Custom options for SSH\n" + usage+= " -a ANSWEROPT Automatic answer for conflicts\n" printerr(usage) ##################################################### #### process commandline args try: - opts, args = getopt.gnu_getopt(sys.argv[1:], "vcibp:o:") +#vste +# opts, args = getopt.gnu_getopt(sys.argv[1:], "vcibp:o:") + opts, args = getopt.gnu_getopt(sys.argv[1:], "vcibp:o:a:") except getopt.GetoptError as err: printerr(err) usage() @@ -757,6 +774,7 @@ verbose = check = ignoreperms = noninteractive = False sshport = None +autoanswer = None #vste sshargs = "" for o, a in opts: if o == "-v": @@ -771,6 +789,10 @@ sshargs = a elif o == "-b": noninteractive = True +#vste START + elif o == "-a": + autoanswer = a + 'a' +#vste END else: assert False, "unhandled option" @@ -940,6 +962,26 @@ copy12.append(f1) else: sync12.append(path) + #vste START + elif tokeep[0] == "r": #r or ra + if f1 == None: + if f2.type == "d": + mkdir1.append(f2) + else: + copy21.append(f2) + elif f2 == None: + if f1.type == "d": + mkdir2.append(f1) + else: + copy12.append(f1) + elif f1.type != "d" and f2.type != "d": + if f1.date >= f2.date: + sync12.append(path) + else: + sync21.append(path) + else: + sync12.append(path) + #vste END else: # tokeep == 2 if f2 == None: if f1.type == "d": # f1 isdir @@ -979,6 +1021,16 @@ tokeep = ask_conflict(f1, f2, path, tokeep); if tokeep[0] == "1": sync12.append(path) + #vste START + elif tokeep[0] == "r": #r or ra + if f1.type != "d" and f2.type != "d": + if f1.date >= f2.date: + sync12.append(path) + else: + sync21.append(path) + else: + sync12.append(path) + #vste END else: # tokeep == 2 sync21.append(path)