Don't allow starting a fresh (non-continue) replay into a non-empty target directory...
authorTony Duckles <tony@nynim.org>
Sun, 25 Mar 2012 04:26:02 +0000 (23:26 -0500)
committerTony Duckles <tony@nynim.org>
Sun, 25 Mar 2012 04:26:02 +0000 (23:26 -0500)
* svn2svn/run/svn2svn.py (real_main): Prevent user from starting a
fresh replay into a non-empty target directory, since chances are
they wanted to do a continue instead. Introduce "--force" arg to
allow replaying into a non-empty target directory.

svn2svn/run/svn2svn.py

index 452a97cbfa3b72f1a9ade46c04fd1952e6e2603b..9e34b8dabacda069b6f0d3611e6097df1ab434ed 100644 (file)
@@ -1002,7 +1002,13 @@ def real_main(args):
         full_svn_revert()
 
     if not options.cont_from_break:
-        # TODO: Warn user if trying to start (non-continue) into a non-empty target path?
+        # Warn user if trying to start (non-continue) into a non-empty target path
+        if not options.force_nocont:
+            top_paths = run_svn(["list", "-r", "HEAD", target_url])
+            if len(top_paths)>0:
+                print "Error: Trying to replay (non-continue-mode) into a non-empty target_url location. " \
+                      "Use --force if you're sure this is what you want."
+                sys.exit(1)
         # Get the first log entry at/after source_start_rev, which is where
         # we'll do the initial import from.
         source_ancestors = find_svn_ancestors(source_repos_url, source_base, source_end_rev, prefix="  ")
@@ -1196,6 +1202,8 @@ Examples:
                             "revisions (by modifying a 'svn2svn:keep-revnum' property at the root of the target repo)")
     parser.add_option("-c", "--continue", action="store_true", dest="cont_from_break",
                       help="continue from last source commit to target (based on svn2svn:* revprops)")
+    parser.add_option("-f", "--force", action="store_true", dest="force_nocont",
+                      help="allow replaying into a non-empty target folder")
     parser.add_option("-r", "--revision", type="string", dest="revision", metavar="ARG",
                       help="revision range to replay from source_url\n"
                            "A revision argument can be one of:\n"