Bugs item #1879567, was opened at 2008-01-25 04:31
Message generated for change (Comment added) made by sborho
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=968354&aid=1879567&group_id=199155

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 2
Private: No
Submitted By: Peer Sommerlund (peso)
Assigned to: Nobody/Anonymous (nobody)
Summary: Clone to empty folder fails

Initial Comment:
Version: 0.2

If an existing empty folder "foo" is specified as destination the clone fails 
with message "*** destination 'C:\foo' already exists"

Workaround is to delete folder before cloning.

I would have expected an error if I tried to clone to an existing repository, 
but not to an empty folder.

----------------------------------------------------------------------

>Comment By: Steve Borho (sborho)
Date: 2009-03-16 13:51

Message:
Is this a dup of issue #53?  If not, can you append to that issue and bump
this
in the TODO list for 0.8?

----------------------------------------------------------------------

Comment By: Peer Sommerlund (peso)
Date: 2009-03-16 09:38

Message:
It is still an issue using TortoiseHg-090311

----------------------------------------------------------------------

Comment By: Steve Borho (sborho)
Date: 2009-03-05 01:17

Message:
reopen if it's an issue

----------------------------------------------------------------------

Comment By: Peter Ruibal (fmoo)
Date: 2008-07-27 03:02

Message:
Logged In: YES 
user_id=2006774
Originator: NO

I have a patchset that implements dgou's suggestion:

Patch #1 adds a signal to hgcmd dialog called "queue-empty" that is
emitted when the command is completed or terminates (before the user closes
the dialog)

Patch #2 modifies the commit dialog to detect if the destination folder is
empty (not len(os.listdir(dest))), and uses a temporary subdirectory within
the target for the dest.  It then uses the signal from patch 1 for a
"commit cleanup" callback that detects if a temporary folder was used; if
it was, it moves all the files from within into the normal dest and removes
the temporary folder.  

### Patch #1 ###
diff -r a6a515439320 hggtk/hgcmd.py
--- a/hggtk/hgcmd.py    Sat Jul 26 23:34:19 2008 -0700
+++ b/hggtk/hgcmd.py    Sat Jul 26 23:43:45 2008 -0700
@@ -17,6 +17,14 @@
 from shlib import set_tortoise_icon, get_system_times
 
 class CmdDialog(gtk.Dialog):
+    __gsignals__ = dict(
+        queue_empty=(
+            gobject.SIGNAL_RUN_FIRST,
+            gobject.TYPE_NONE,
+            (gobject.TYPE_PYOBJECT,) # Return Code, None if error 
+        )
+    )
+
     def __init__(self, cmdline, progressbar=True, width=520,
height=400):
         title = 'hg ' + ' '.join(cmdline[1:])
         gtk.Dialog.__init__(self,
@@ -131,6 +139,7 @@
             self.returncode = self.hgthread.return_code()
             if self.returncode is None:
                 self.write("[command interrupted]")
+            self.emit('queue-empty', self.returncode)
             return False # Stop polling this function
         else:
             return True


### Patch #2 ###
diff -r 72d3af7c1184 hggtk/clone.py
--- a/hggtk/clone.py    Sat Jul 26 23:43:45 2008 -0700
+++ b/hggtk/clone.py    Sun Jul 27 00:37:13 2008 -0700
@@ -264,18 +264,25 @@
         for p in paths:
             self._destlist.append([p])
  
+    __DEST_NOTEMPTY_TEMPDIR__ = ".thg.clone"
+    
     def _btn_clone_clicked(self, toolbutton, data=None):
         # gather input data
         src = self._src_input.get_text()
         dest = self._dest_input.get_text() or os.path.basename(src)
         remotecmd = self._remote_cmd.get_text()
         rev = self._rev_input.get_text()
-        
+
         # verify input
         if src == "":
             error_dialog(self, "Source path is empty", "Please enter")
             self._src_input.grab_focus()
             return False
+        
+        # If the target is an empty directory, make a temporary folder
for pull
+        if os.path.exists(dest) and not len(os.listdir(dest)):
+            dest = os.path.join(dest, self.__DEST_NOTEMPTY_TEMPDIR__)
+
         
         # start cloning        
         try:            
@@ -304,6 +311,7 @@
             print "cmdline: ", ' '.join(cmdline)
             from hgcmd import CmdDialog
             dlg = CmdDialog(cmdline)
+            dlg.connect('queue-empty', self._cleanup_clone)
             dlg.run()
             dlg.hide()
         except util.Abort, inst:
@@ -314,6 +322,22 @@
             error_dialog(self, "Clone error", traceback.format_exc())
             return False
 
+    def _cleanup_clone(self, cmd_dialog, exit_code):
+        # gather input data
+        src  = self._src_input.get_text()
+        dest = self._dest_input.get_text() or
os.path.basename(self._src_input.get_text())
+        dest_temp = os.path.join(dest, self.__DEST_NOTEMPTY_TEMPDIR__)
+        
+        # Move Files over if a temp location was used
+        if (exit_code == 0) and (os.path.exists(dest_temp)):
+            from shutil import move, rmtree
+            for f in os.listdir(dest_temp):
+                move(os.path.join(dest_temp, f), os.path.join(dest, f))
+
+            # Remove temporary location
+            rmtree(dest_temp)
+
+        # Update src and dest MRU
         self._add_src_to_recent(src)
         self._add_dest_to_recent(dest)
 




----------------------------------------------------------------------

Comment By: Doug Philips (dgou)
Date: 2008-04-13 16:05

Message:
Logged In: YES 
user_id=392583
Originator: NO

The right-clicking drag works great!
I'd still like to see the simple right-click on a folder pre-fill the
fields just the same. Since the drag can do it, its possible?

How about rather than deleting the folder, redirect the clone, and the
move it up:
pseudo command-line equivalent:
    hg clone source-repo
dest-repo-just-created-by-gui/gui-hack-temporary-directory
    mv dest-repo-just-created-by-gui/gui-hack-temporary-directory/{all
files} dest-repo-just-cerated-by-gui?



----------------------------------------------------------------------

Comment By: TK Soh (tksoh)
Date: 2008-04-13 09:53

Message:
Logged In: YES 
user_id=411637
Originator: NO

Instead of right-clicking, try [right] drag-and-drop the root folder. The
clone dialog will even prefill the dest path.

----------------------------------------------------------------------

Comment By: Doug Philips (dgou)
Date: 2008-04-13 09:46

Message:
Logged In: YES 
user_id=392583
Originator: NO

On the non-existance of the new repo, I understand that there is a deep
disconnect between the API and the GUI.

As to the default:
  a) I navigate in the explorer to the parent directory (or some
subdirectory) of a repo that I want to clone. Let's say I'm in the parent
directory.
  b) I select the repo folder and right click to get the context menu.
  c) I go into the TortoiseHG submenu.
  d) I select "Create Clone"
  e) I get a dialog box (or program, its hard to tell) "hg clone - <my
repos path here>"
  f) The "Source Path:" text entry box is -empty-.

I'd like to see the Source Path be defaulted with the path to the repo on
which I just clicked and which is also right there in the title
(un-copy-n-paste-able).


----------------------------------------------------------------------

Comment By: TK Soh (tksoh)
Date: 2008-04-13 09:32

Message:
Logged In: YES 
user_id=411637
Originator: NO

I share your frustration. A lot.

In some way the "browse" button is either wrong, or mis-targeted.
Honestly, I haven't been able to come up with a good way to hand this.

Claiming that hg clone expects the dest repo to be non-existent is not an
overstatement. The only way to get around this expectation of hg clone
require removal of the dest folder before calling the cloning 'API'. And,
it might be a little too much risk than I'd like to take.

Let me know if you have any ideas of a sound policy.

> Can we get the selected folder to be the default source (if it is a
repo
> or subdirectory of one) for 0.4?

I am not sure I follow you on this.

----------------------------------------------------------------------

Comment By: Doug Philips (dgou)
Date: 2008-04-13 09:16

Message:
Logged In: YES 
user_id=392583
Originator: NO

This is really annoying because the GUI interface "browse" has a "new
folder button" that encourages the user to say: "Oh, I see, I have to make
the new folder that I want to clone into so that -I can --select-- it-.

I struggled with this for 10 frustrating minutes before I finally realized
that I had to NOT make the new folder name.
Instead I had to:
 select the parent
 click into the destination box
 type in the new folder name at the end of the path.

That combined with --lack-- of defaulting the source to the folder on
which I used the "create clone" menu/context-menu option to start with made
this a triply frustrating experience. 

Claiming that the underlying command line interface works differently
doesn't hold much water. My coworkers will bitch up a storm because that is
not how other Windows GUIs treat the "New Folder" options when creating and
saving files, etc.

Can we get the selected folder to be the default source (if it is a repo
or subdirectory of one) for 0.4?


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2008-01-25 10:01

Message:
Logged In: NO 

It's a behavior of hg clone. I don't feel it's safe to assume it's okay to
overwrite an existing directory. Empty or otherwise.

-TK

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=968354&aid=1879567&group_id=199155

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to