Commits

anatoly techtonik committed 19cc307

module checkout works

Comments (0)

Files changed (3)

+Split Python source into separate Mercurial repositories using module definition file.
+
+'svn' and 'hgsvn' should be installed and accessible from shell PATH.

distutils.module.def

 sources=[
   'Doc/distutils',
   'Lib/distutils',
-  'test/test_distutils.py',
+  'Lib/test/test_distutils.py',
 ]
 import glob
 import logging
 import subprocess
+import sys
 
 
 # TODO: logging into file
   debug("  call: %s" % cmd)
   # TODO - redirect svn output in non-debug mode
   retcode = subprocess.call(cmd, shell=True)
-  debug("  call exit code: %s" % retcode)
+  debug("  retcode: %s" % retcode)
   return retcode
 
 
       repopath = repository+'/'+branches[0]
       debug(" no SVN working copy, making shallow checkout")
       ret = call("svn co %s --depth=empty ." % repopath)
-            
+      if ret != 0:
+        warning("return code %s is not 0, exiting" % ret)
+        sys.exit(ret)
 
-    # TODO: validate all required files/dirs are present
+
+      # building list of intermediate dirs that are updated with --depth=empty
+      # interm is a list of sets for each nesting level
+      interm = []
+      for src in sources:
+        names = src.split('/')
+        if len(names) > 1:
+          for level in range(0, len(names)-1):
+            if len(interm) < level+1:
+              interm.append(set())
+            interm[level].add(names[level])
+        
+      debug("  intermediate dirs that will be checked out with --depth=empty:")
+      debug(interm)
+          
+      # checkout intermediate dirs
+      for levelset in interm:
+        for interdir in levelset:
+          ret = call("svn up %s --set-depth=empty" % interdir)
+          if ret != 0:
+            warning("return code %s is not 0, exiting" % ret)
+            sys.exit(ret)
+          
+
+      for src in sources:
+        if os.path.exists(src):
+          # TODO: evaluate possible scenarious when source files already exist
+          #       not exiting for now as it may happen as a result of invalid
+          #       module definition
+          warning("  file/dir to be updated already exists")
+
+
+        ret = call("svn up %s --set-depth=infinity" % src)
+        if ret != 0:
+          warning("return code %s is not 0, exiting" % ret)
+          sys.exit(ret)
+        # TODO: target exists after checkout
+      
+
+
+    else: # if .svn exists
+      # TODO: validate all required files/dirs are present
+      #       (dirs should be recheckouted to catch all file changes within)
+      # TODO: validate no extra files/dirs are present in working copy
+      pass
+      
+
     os.chdir(savedcwd)
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 ProjectModifiedEvent.java.
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.