Luke Plant committed 90f1f9d

Use 'hg clone' to create project srcs on server, instead of 'cp'

Comments (0)

Files changed (1)

     # This also copies the virtualenv which is contained in the same folder,
     # which saves a lot of time with installing.
-    current_srcs = target.current_version.src_dir
-    if files.exists(current_srcs):
-        # By copying, we can avoid recreating the virtualenv and the project
-        # sources, saving time and bandwidth.
-        run("cp -a -L %s %s" % (current_srcs, version.src_dir))
-    else:
-        # Starting from scratch
-        run("mkdir %s" % version.src_dir)
-        with cd(version.src_dir):
+    run("mkdir -p %s" % version.src_dir)
+    with cd(version.src_dir):
+        if files.exists(target.current_version.project_dir + "/.hg"):
+            # Clone local copy if we can
+            run("hg clone %s project" % target.current_version.project_dir)
+        else:
             run("hg clone ssh:// project")
-    with cd(version.project_dir):
-        run("hg pull -u")
+        with cd(version.project_dir):
+            # We update to the version that is currently checked out locally,
+            # because, at least for staging, it might not be the tip of default.
+            current_rev = local("hg id -i", capture=True)
+            run("hg pull ssh://")
+            run("hg update -r %s" % current_rev.strip("+"))
+        # Avoid recreating the virtualenv if we can
+        if files.exists(target.current_version.venv_dir):
+            run("cp -a -L %s %s" % (target.current_version.venv_dir,
+                                    version.src_dir))
     # Also need to sync files that are not in main sources VCS repo.
     local("rsync christchurch/" % version.project_dir)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.