From b118d3a4a0a1523e50dad3ee1bbaba91b795d04a Mon Sep 17 00:00:00 2001
From: Christophe Dumez <christophe@nexedi.com>
Date: Wed, 17 May 2006 14:10:03 +0000
Subject: [PATCH] - update local working copy when clicking on subversion tab.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7326 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Subversion/Tool/SubversionTool.py | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Subversion/Tool/SubversionTool.py b/product/ERP5Subversion/Tool/SubversionTool.py
index 3ec3f5f78a..f3a2a5a83f 100644
--- a/product/ERP5Subversion/Tool/SubversionTool.py
+++ b/product/ERP5Subversion/Tool/SubversionTool.py
@@ -660,6 +660,15 @@ class SubversionTool(BaseTool, UniqueObject, Folder):
     client.update(path)
     # Import in zodb
     return self.importBT(bt)
+  
+    security.declareProtected('Import/Export objects', 'updatewc')
+  def updatewc(self, bt):
+    """Update a working copy.
+    """
+    path = self._getWorkingPath(self.getSubversionPath(bt))
+    client = self._getClient()
+    # Update from SVN
+    client.update(path)
 
   security.declareProtected('Import/Export objects', 'switch')
   def switch(self, bt, url):
@@ -941,6 +950,8 @@ class SubversionTool(BaseTool, UniqueObject, Folder):
     return somethingModified and root
   
   def extractBT(self, bt):
+    # first update working copy
+    self.updatewc(bt)
     bt.build()
     svn_path = self._getWorkingPath(self.getSubversionPath(bt) + os.sep)
     path = mktemp() + os.sep
@@ -954,8 +965,16 @@ class SubversionTool(BaseTool, UniqueObject, Folder):
     self.activate().removeAllInList([path,])
     
   def importBT(self, bt):
-    return bt.download(self._getWorkingPath(self.getSubversionPath(bt)))
-  
+    # Do svn export before importing to get rid of .svn stuff
+    # and unversioned files.
+    tmp_path = mktemp() + os.sep
+    self.export(self._getWorkingPath(self.getSubversionPath(bt)), tmp_path)
+    # Import 
+    id = bt.download(tmp_path)
+    # Clean up
+    self.activate().removeAllInList([tmp_path,])
+    return id
+    
   # Get a list of files and keep only parents
   # Necessary before recursively commit removals
   def cleanChildrenInList(self, list):
-- 
2.30.9