Skip to content

Commit f06a3a5

Browse files
committed
Fix replicate.py for single db to single db
1 parent 145dc9b commit f06a3a5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

couchdb/tools/replicate.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,22 @@ def main():
8181

8282
if '*' in tpath:
8383
raise parser.error('invalid target path: must be single db or empty')
84-
elif '*' in spath and tpath:
85-
raise parser.error('target path must be empty with multiple sources')
8684

8785
all = sorted(i for i in source if i[0] != '_') # Skip reserved names.
8886
if not spath:
8987
raise parser.error('source database must be specified')
9088

91-
databases = [(i, i) for i in all if fnmatch.fnmatchcase(i, spath)]
92-
if not databases:
89+
sources = [i for i in all if fnmatch.fnmatchcase(i, spath)]
90+
if not sources:
9391
raise parser.error("no source databases match glob '%s'" % spath)
9492

93+
if len(sources) > 1 and tpath:
94+
raise parser.error('target path must be empty with multiple sources')
95+
elif len(sources) == 1:
96+
databases = [(sources[0], tpath)]
97+
else:
98+
databases = [(i, i) for i in sources]
99+
95100
# do the actual replication
96101

97102
for sdb, tdb in databases:

0 commit comments

Comments
 (0)