From 4216a57efaa97b8b72cf16ddec26d8b3f80fe774 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Thu, 15 Mar 2012 22:23:08 -0500 Subject: [PATCH] More fixes to iter_svn_log_entries ancestry-handling * svn2svn/svnclient.py (iter_svn_log_entries): Correctly use and respect ancestors() array: look for the next copyfrom_rev, and once we crawl past the last copy-from then start at the final path+revision. * svn2svn/run/svn2svn.py (process_svn_log_entry): For action='R' don't run "svn remove" command if path_offset="", i.e. don't try to remove the root of the WC. --- svn2svn/run/svn2svn.py | 2 +- svn2svn/svnclient.py | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/svn2svn/run/svn2svn.py b/svn2svn/run/svn2svn.py index 2259351..54e7368 100644 --- a/svn2svn/run/svn2svn.py +++ b/svn2svn/run/svn2svn.py @@ -573,7 +573,7 @@ def process_svn_log_entry(log_entry, ancestors, commit_paths, prefix = ""): # then we need to run the "svn rm" first, then change action='A'. This # lets the normal code below handle re-"svn add"'ing the files. This # should replicate the "replace". - if in_svn(path_offset): + if path_offset and in_svn(path_offset): # Target path might not be under version-control yet, e.g. parent "add" # was a copy-from a branch which had no ancestry back to trunk, and each # child folder under that parent folder is a "replace" action on the final diff --git a/svn2svn/svnclient.py b/svn2svn/svnclient.py index 9faef8e..efb3212 100644 --- a/svn2svn/svnclient.py +++ b/svn2svn/svnclient.py @@ -311,40 +311,48 @@ def iter_svn_log_entries(svn_url, first_rev, last_rev, stop_on_copy=False, get_c """ info = get_svn_info(svn_url) svn_repos_url = info['repos_url'] + #print "iter_svn_log_entries: %s %s:%s" % (svn_url, first_rev, last_rev) if last_rev == "HEAD": last_rev = info['revision'] - if first_rev == "1": + if int(first_rev) == 1: start_log = get_first_svn_log_entry(svn_url, first_rev, last_rev, stop_on_copy=stop_on_copy, get_changed_paths=False) if start_log['revision'] > first_rev: first_rev = start_log['revision'] - #print "first_rev: %s" % first_rev + #print "first_rev: %s" % first_rev cur_url = svn_url cur_rev = first_rev cur_anc_idx = None cur_anc_end_rev = None if ancestors: #print ancestors - for idx in range(len(ancestors)-1, 0, -1): - if int(ancestors[idx]['revision']) > first_rev: - #print "Match ancestors[%s]: %s" % (idx, ancestors[idx]) - cur_url = svn_repos_url+ancestors[idx]['copyfrom_path'] - cur_anc_end_rev = ancestors[idx]['copyfrom_rev'] - cur_anc_idx = idx + # Crawl ancestry, from oldest to newest + for idx in range(len(ancestors)-1, -1, -1): # [n-1,...,0] + #print "(pre) Match ancestors[%s]: %s" % (idx, ancestors[idx]) + cur_url = svn_repos_url+ancestors[idx]['copyfrom_path'] + cur_anc_idx = idx + if first_rev < int(ancestors[idx]['copyfrom_rev']): + cur_anc_end_rev = int(ancestors[idx]['copyfrom_rev']) break + if cur_anc_end_rev is None: + #print "(pre) Match ancestors[0] (final): %s" % (ancestors[0]) + cur_anc_idx = -1 + cur_url = svn_repos_url+ancestors[0]['path'] chunk_length = log_min_chunk_length while cur_rev <= last_rev: - #print "cur_rev:%s cur_anc_end_rev:%s cur_anc_idx:%s" % (cur_rev, str(cur_anc_end_rev), cur_anc_idx) + #print "cur_rev:%s cur_anc_end_rev:%s cur_anc_idx:%s %s" % (cur_rev, str(cur_anc_end_rev), cur_anc_idx, cur_url) if cur_anc_end_rev and cur_rev >= cur_anc_end_rev: - cur_rev = ancestors[cur_anc_idx]['revision'] + cur_rev = int(ancestors[cur_anc_idx]['revision']) cur_anc_idx -= 1 if cur_anc_idx >= 0: idx = cur_anc_idx - #print "Match ancestors[%s]: %s" % (idx, ancestors[idx]) + #print "(loop) Match ancestors[%s]: %s" % (idx, ancestors[idx]) cur_url = svn_repos_url+ancestors[idx]['copyfrom_path'] - cur_anc_end_rev = ancestors[idx]['copyfrom_rev'] + cur_anc_end_rev = int(ancestors[idx]['copyfrom_rev']) else: + #print "(loop) Match ancestors[0] (final): %s" % (ancestors[0]) + cur_url = svn_repos_url+ancestors[0]['path'] cur_anc_end_rev = None - #print "cur_rev:%s cur_anc_end_rev:%s cur_anc_idx:%s" % (cur_rev, str(cur_anc_end_rev), cur_anc_idx) + #print "cur_rev:%s cur_anc_end_rev:%s cur_anc_idx:%s %s" % (cur_rev, str(cur_anc_end_rev), cur_anc_idx, cur_url) start_t = time.time() stop_rev = min(last_rev, cur_rev + chunk_length) stop_rev = min(stop_rev, cur_anc_end_rev) if cur_anc_end_rev else stop_rev @@ -361,7 +369,7 @@ def iter_svn_log_entries(svn_url, first_rev, last_rev, stop_on_copy=False, get_c yield e if e['revision'] >= last_rev: break - cur_rev = e['revision']+1 + cur_rev = int(e['revision'])+1 else: cur_rev = int(stop_rev)+1 # Adapt chunk length based on measured request duration -- 2.43.0