sysadmin-bin r83 - trunk



Author: ovitters
Date: Sun Nov  2 15:18:57 2008
New Revision: 83
URL: http://svn.gnome.org/viewvc/sysadmin-bin?rev=83&view=rev

Log:
	* svn-migrate-repos (dump_into_new): Create new function which only
	dumps new revisions into destination repository.



Modified:
   trunk/ChangeLog
   trunk/svn-migrate-repos

Modified: trunk/svn-migrate-repos
==============================================================================
--- trunk/svn-migrate-repos	(original)
+++ trunk/svn-migrate-repos	Sun Nov  2 15:18:57 2008
@@ -5,6 +5,31 @@
 
 os.nice(19)
 
+def dump_into_new(origsvn, destsvn, latestorigrev=None, latestdestrev=None):
+    if latestdestrev is None:
+        latestdestrev = int(subprocess.Popen(["svnlook", "youngest", destsvn], stdout=subprocess.PIPE).communicate()[0].strip())
+    if latestorigrev is None:
+        latestorigrev = int(subprocess.Popen(["svnlook", "youngest", origsvn], stdout=subprocess.PIPE).communicate()[0].strip())
+
+    if latestdestrev == 0:
+        dumpfrom = 0
+    else:
+        dumpfrom = latestdestrev + 1
+
+    dumpto = latestorigrev
+
+    if latestdestrev != latestorigrev:
+        # Dump old repository into new one
+        p_dump = subprocess.Popen(['svnadmin', 'dump', '-q', '--incremental', '--deltas', '-r', '%s:%s' % (dumpfrom, dumpto), origsvn], stdout=subprocess.PIPE)
+        p_load = subprocess.Popen(['svnadmin', 'load', '-q', '--force-uuid', destsvn], stdin=p_dump.stdout)
+        p_dump.wait()
+        p_load.wait()
+
+        latestorigrev = int(subprocess.Popen(["svnlook", "youngest", origsvn], stdout=subprocess.PIPE).communicate()[0].strip())
+        latestdestrev = int(subprocess.Popen(["svnlook", "youngest", destsvn], stdout=subprocess.PIPE).communicate()[0].strip())
+
+    return latestorigrev, latestdestrev
+
 if __name__ == '__main__':
     orig, backup, tmp = sys.argv[1:]
     
@@ -12,30 +37,27 @@
         if not os.path.isdir(os.path.join(origsvn, 'hooks')):
             continue
 
-        latestrev = subprocess.Popen(["svnlook", "youngest", origsvn], stdout=subprocess.PIPE).communicate()[0].strip()
+        latestrev = int(subprocess.Popen(["svnlook", "youngest", origsvn], stdout=subprocess.PIPE).communicate()[0].strip())
         svnname = os.path.basename(origsvn)
 
         tmpsvn = os.path.join(tmp, svnname)
         backupsvn = os.path.join(backup, svnname)
-        if os.path.isdir(tmpsvn) or os.path.isdir(backupsvn):
+        if os.path.isdir(backupsvn):
             print 'ERROR: Path already exists: %s' % svnname
             continue
-
-        # Setup new repository
-        subprocess.check_call(['svnadmin', 'create', tmpsvn])
-        subprocess.check_call(['find', '%s/hooks' % origsvn, '-type', 'f', '(', '-name', '*.tmpl', '-prune', '-o', '-exec', 'cp', '-p', '{}', '%s/hooks' % tmpsvn, ')'])
-        subprocess.check_call(['chown', '-R', '--reference', origsvn, '--', tmpsvn])
-        subprocess.check_call(['chmod', '-R', '--reference', origsvn, '--', tmpsvn])
-        subprocess.check_call(['find', tmpsvn, '-type', 'f', '-exec', 'chmod', '-x', '{}', ';'])
-        subprocess.check_call(['find', '%s/hooks' % tmpsvn, '-type', 'f', '(', '-name', '*.tmpl', '-prune', '-o', '-exec', 'chmod', '+x', '{}', ';', ')'])
-
-        # Dump old repository into new one
-        p_dump = subprocess.Popen(['svnadmin', 'dump', '-q', '--incremental', '--deltas', origsvn], stdout=subprocess.PIPE)
-        p_load = subprocess.Popen(['svnadmin', 'load', '-q', '--force-uuid', tmpsvn], stdin=p_dump.stdout)
-        p_dump.wait()
-        p_load.wait()
-        
-        latestrev2 = subprocess.Popen(["svnlook", "youngest", origsvn], stdout=subprocess.PIPE).communicate()[0].strip()
-        
-        print svnname, latestrev, latestrev2
+ 
+        if os.path.isdir(tmpsvn):
+            print 'WARNING: Path already exists: %s' % svnname
+        else: 
+            # Setup new repository
+            subprocess.check_call(['svnadmin', 'create', tmpsvn])
+            subprocess.check_call(['find', '%s/hooks' % origsvn, '-type', 'f', '(', '-name', '*.tmpl', '-prune', '-o', '-exec', 'cp', '-p', '{}', '%s/hooks' % tmpsvn, ';', ')'])
+            subprocess.check_call(['chown', '-R', '--reference', origsvn, '--', tmpsvn])
+            subprocess.check_call(['chmod', '-R', '--reference', origsvn, '--', tmpsvn])
+            subprocess.check_call(['find', tmpsvn, '-type', 'f', '-exec', 'chmod', '-x', '{}', ';'])
+            subprocess.check_call(['find', '%s/hooks' % tmpsvn, '-type', 'f', '(', '-name', '*.tmpl', '-prune', '-o', '-exec', 'chmod', '+x', '{}', ';', ')'])
+
+        latestorigrev, latestdestrev = dump_into_new(origsvn, tmpsvn)
+         
+        print svnname, latestorigrev, latestdestrev
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]