hggtk/clone.py
author Germán Póo-Caamaño <gpoo@calcifer.org>
Mon, 21 Jul 2008 11:51:12 -0400
changeset 1182 cbe418752174
parent 1120 08eca2607f01
permissions -rw-r--r--
hggtk: get rid of close buttons
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     1
#
397
517f7511f496 hggtk: fix comment at top of clone.py
Steve Borho <steve@borho.org>
parents: 395
diff changeset
     2
# TortoiseHg dialog to clone a repo
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     3
#
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     4
# Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     5
#
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     6
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     7
try:
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     8
    import pygtk
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
     9
    pygtk.require("2.0")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    10
except:
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    11
    pass
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    12
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    13
import os
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    14
import sys
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    15
import gtk
1060
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    16
import pango
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    17
from dialog import question_dialog, error_dialog, info_dialog
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    18
from mercurial import hg, ui, cmdutil, util
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    19
from mercurial.i18n import _
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    20
from mercurial.node import *
1052
b4bf54ece7f9 hggtk/clone: save recently cloned source
TK Soh <teekaysoh@yahoo.com>
parents: 1051
diff changeset
    21
import shlib
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    22
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
    23
class CloneDialog(gtk.Window):
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    24
    """ Dialog to add tag to Mercurial repo """
408
fcfad6e1aa90 hggtk: hgpath obsolete for most dialogs
Steve Borho <steve@borho.org>
parents: 402
diff changeset
    25
    def __init__(self, cwd='', repos=[]):
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    26
        """ Initialize the Dialog """
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
    27
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    28
1052
b4bf54ece7f9 hggtk/clone: save recently cloned source
TK Soh <teekaysoh@yahoo.com>
parents: 1051
diff changeset
    29
        shlib.set_tortoise_icon(self, 'menuclone.ico')
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    30
        if cwd: os.chdir(cwd)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    31
        
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    32
        # set dialog title
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    33
        title = "hg clone "
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    34
        title += " - %s" % (os.getcwd())
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    35
        self.set_title(title)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    36
299
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    37
        self._src_path = ''
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    38
        self._dest_path = ''
1054
be9114b959cc hggtk: use new Settings class in clone and config dialogs
TK Soh <teekaysoh@yahoo.com>
parents: 1052
diff changeset
    39
        self._settings = shlib.Settings('clone')
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
    40
        self._recent_src = self._settings.mrul('src_paths')
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
    41
        self._recent_dest = self._settings.mrul('dest_paths')
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
    42
299
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    43
        try:
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    44
            self._src_path = repos[0]
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    45
            self._dest_path = repos[1]
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    46
        except:
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    47
            pass
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    48
            
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    49
        # build dialog
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    50
        self._create()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    51
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    52
    def _create(self):
1111
ac943349fcb1 hggtk/clone: make dialog a little wider
TK Soh <teekaysoh@yahoo.com>
parents: 1110
diff changeset
    53
        self.set_default_size(520, 180)
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
    54
        self.connect('destroy', gtk.main_quit)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    55
        ewidth = 16
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    56
        
618
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    57
        # add toolbar with tooltips
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    58
        self.tbar = gtk.Toolbar()
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    59
        self.tips = gtk.Tooltips()
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    60
        
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    61
        self._btn_clone = self._toolbutton(
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    62
                gtk.STOCK_COPY,
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    63
                'clone', 
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    64
                self._btn_clone_clicked,
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    65
                tip='Clone a repository')
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    66
        tbuttons = [
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    67
                self._btn_clone,
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    68
            ]
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    69
        for btn in tbuttons:
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    70
            self.tbar.insert(btn, -1)
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
    71
        vbox = gtk.VBox()
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
    72
        self.add(vbox)
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
    73
        vbox.pack_start(self.tbar, False, False, 2)
618
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
    74
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    75
        # clone source
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    76
        srcbox = gtk.HBox()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    77
        lbl = gtk.Label("Source Path:")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    78
        lbl.set_property("width-chars", ewidth)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    79
        lbl.set_alignment(0, 0.5)
1049
f40e8e960740 hggtk/clone: make src path combo box prefilled with symbolic paths
TK Soh <teekaysoh@yahoo.com>
parents: 866
diff changeset
    80
1060
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    81
        # create drop-down list for source paths
1049
f40e8e960740 hggtk/clone: make src path combo box prefilled with symbolic paths
TK Soh <teekaysoh@yahoo.com>
parents: 866
diff changeset
    82
        self._srclist = gtk.ListStore(str)
f40e8e960740 hggtk/clone: make src path combo box prefilled with symbolic paths
TK Soh <teekaysoh@yahoo.com>
parents: 866
diff changeset
    83
        self._srclistbox = gtk.ComboBoxEntry(self._srclist, 0)
f40e8e960740 hggtk/clone: make src path combo box prefilled with symbolic paths
TK Soh <teekaysoh@yahoo.com>
parents: 866
diff changeset
    84
        self._src_input = self._srclistbox.get_child()
299
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
    85
        self._src_input.set_text(self._src_path)
1072
cdbb0252bbd9 hggtk/clone: show end of src and dest paths on startup
TK Soh <teekaysoh@yahoo.com>
parents: 1067
diff changeset
    86
        self._src_input.set_position(-1)
1060
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    87
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    88
        # replace the drop-down widget so we can modify it's properties
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    89
        self._srclistbox.clear()
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    90
        cell = gtk.CellRendererText()
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    91
        cell.set_property('ellipsize', pango.ELLIPSIZE_MIDDLE)
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    92
        self._srclistbox.pack_start(cell)
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    93
        self._srclistbox.add_attribute(cell, 'text', 0)
dcd907aac480 hggtk/clone: ellipsize long source paths on drop-down list
TK Soh <teekaysoh@yahoo.com>
parents: 1054
diff changeset
    94
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    95
        self._btn_src_browse = gtk.Button("Browse...")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    96
        self._btn_src_browse.connect('clicked', self._btn_src_clicked)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    97
        srcbox.pack_start(lbl, False, False)
1049
f40e8e960740 hggtk/clone: make src path combo box prefilled with symbolic paths
TK Soh <teekaysoh@yahoo.com>
parents: 866
diff changeset
    98
        srcbox.pack_start(self._srclistbox, True, True)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
    99
        srcbox.pack_end(self._btn_src_browse, False, False, 5)
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
   100
        vbox.pack_start(srcbox, False, False, 2)
299
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
   101
        
1049
f40e8e960740 hggtk/clone: make src path combo box prefilled with symbolic paths
TK Soh <teekaysoh@yahoo.com>
parents: 866
diff changeset
   102
        # add pre-defined src paths to pull-down list
1052
b4bf54ece7f9 hggtk/clone: save recently cloned source
TK Soh <teekaysoh@yahoo.com>
parents: 1051
diff changeset
   103
        sympaths = [x[1] for x in ui.ui().configitems('paths')]
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   104
        paths = list(set(sympaths + [x for x in self._recent_src]))
1049
f40e8e960740 hggtk/clone: make src path combo box prefilled with symbolic paths
TK Soh <teekaysoh@yahoo.com>
parents: 866
diff changeset
   105
        paths.sort()
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   106
        for p in paths:
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   107
            self._srclist.append([p])
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   108
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   109
        # clone destination
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   110
        destbox = gtk.HBox()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   111
        lbl = gtk.Label("Destination Path:")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   112
        lbl.set_property("width-chars", ewidth)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   113
        lbl.set_alignment(0, 0.5)
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   114
        self._destlist = gtk.ListStore(str)
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   115
        self._destlistbox = gtk.ComboBoxEntry(self._destlist, 0)
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   116
        self._dest_input = self._destlistbox.get_child()
299
f9ca63c50859 hggtk/clone: accept src and dest paths from command line
TK Soh <teekaysoh@yahoo.com>
parents: 298
diff changeset
   117
        self._dest_input.set_text(self._dest_path)
1072
cdbb0252bbd9 hggtk/clone: show end of src and dest paths on startup
TK Soh <teekaysoh@yahoo.com>
parents: 1067
diff changeset
   118
        self._dest_input.set_position(-1)
cdbb0252bbd9 hggtk/clone: show end of src and dest paths on startup
TK Soh <teekaysoh@yahoo.com>
parents: 1067
diff changeset
   119
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   120
        # replace the drop-down widget so we can modify it's properties
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   121
        self._destlistbox.clear()
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   122
        cell = gtk.CellRendererText()
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   123
        cell.set_property('ellipsize', pango.ELLIPSIZE_MIDDLE)
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   124
        self._destlistbox.pack_start(cell)
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   125
        self._destlistbox.add_attribute(cell, 'text', 0)
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   126
        
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   127
        self._btn_dest_browse = gtk.Button("Browse...")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   128
        self._btn_dest_browse.connect('clicked', self._btn_dest_clicked)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   129
        destbox.pack_start(lbl, False, False)
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   130
        destbox.pack_start(self._destlistbox, True, True)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   131
        destbox.pack_end(self._btn_dest_browse, False, False, 5)
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
   132
        vbox.pack_start(destbox, False, False, 2)
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   133
        
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   134
        # add most-recent dest paths to pull-down list
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   135
        paths = list(self._recent_dest)
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   136
        paths.sort()
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   137
        for p in paths:
1066
20732ba6b474 hggtk/clone: do not show symbolic paths on dest list
TK Soh <teekaysoh@yahoo.com>
parents: 1065
diff changeset
   138
            self._destlist.append([p])
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   139
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   140
        # revision input
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   141
        revbox = gtk.HBox()
303
8107174c1d1e hggtk/clone: rev option is for cloning instead of updating
TK Soh <teekaysoh@yahoo.com>
parents: 299
diff changeset
   142
        lbl = gtk.Label("Clone To Revision:")
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   143
        lbl.set_property("width-chars", ewidth)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   144
        lbl.set_alignment(0, 0.5)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   145
        self._rev_input = gtk.Entry()
303
8107174c1d1e hggtk/clone: rev option is for cloning instead of updating
TK Soh <teekaysoh@yahoo.com>
parents: 299
diff changeset
   146
        self._rev_input.set_text("")
304
6a49f3883031 hggtk/clone: add checkbox for cloning all revisions
TK Soh <teekaysoh@yahoo.com>
parents: 303
diff changeset
   147
        self._opt_allrev = gtk.CheckButton("Clone all revisions")
6a49f3883031 hggtk/clone: add checkbox for cloning all revisions
TK Soh <teekaysoh@yahoo.com>
parents: 303
diff changeset
   148
        self._opt_allrev.set_active(True)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   149
        self._btn_rev_browse = gtk.Button("Select...")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   150
        self._btn_rev_browse.connect('clicked', self._btn_rev_clicked)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   151
        revbox.pack_start(lbl, False, False)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   152
        revbox.pack_start(self._rev_input, False, False)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   153
        #revbox.pack_start(self._btn_rev_browse, False, False, 5)
304
6a49f3883031 hggtk/clone: add checkbox for cloning all revisions
TK Soh <teekaysoh@yahoo.com>
parents: 303
diff changeset
   154
        revbox.pack_start(self._opt_allrev, False, False)
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
   155
        vbox.pack_start(revbox, False, False, 2)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   156
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   157
        # options
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   158
        option_box = gtk.VBox()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   159
        self._opt_update = gtk.CheckButton("do not update the new working directory")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   160
        self._opt_pull = gtk.CheckButton("use pull protocol to copy metadata")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   161
        self._opt_uncomp = gtk.CheckButton("use uncompressed transfer")
1110
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   162
        self._opt_proxy = gtk.CheckButton("use proxy server")        
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   163
        option_box.pack_start(self._opt_update, False, False)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   164
        option_box.pack_start(self._opt_pull, False, False)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   165
        option_box.pack_start(self._opt_uncomp, False, False)
1110
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   166
        option_box.pack_start(self._opt_proxy, False, False)
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
   167
        vbox.pack_start(option_box, False, False, 15)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   168
1110
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   169
        if ui.ui().config('http_proxy', 'host', ''):   
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   170
            self._opt_proxy.set_active(True)
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   171
        else:
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   172
            self._opt_proxy.set_sensitive(False)
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   173
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   174
        # remote cmd
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   175
        lbl = gtk.Label("Remote Cmd:")
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   176
        lbl.set_alignment(0, 0.5)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   177
        self._remote_cmd = gtk.Entry()
866
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
   178
        vbox.pack_end(self._remote_cmd, False, False, 1)
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
   179
        vbox.pack_end(lbl, False, False, 1)
8a384bad1160 hggtk/vis: switch to new window layout
Steve Borho <steve@borho.org>
parents: 618
diff changeset
   180
618
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   181
    def _toolbutton(self, stock, label, handler,
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   182
                    menu=None, userdata=None, tip=None):
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   183
        if menu:
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   184
            tbutton = gtk.MenuToolButton(stock)
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   185
            tbutton.set_menu(menu)
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   186
        else:
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   187
            tbutton = gtk.ToolButton(stock)
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   188
            
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   189
        tbutton.set_label(label)
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   190
        if tip:
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   191
            tbutton.set_tooltip(self.tips, tip)
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   192
        tbutton.connect('clicked', handler, userdata)
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   193
        return tbutton
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   194
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   195
    def _btn_dest_clicked(self, button):
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   196
        """ select folder as clone destination """
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   197
        dialog = gtk.FileChooserDialog(title=None,
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   198
                action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   199
                buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   200
                         gtk.STOCK_OPEN,gtk.RESPONSE_OK))
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   201
        dialog.set_default_response(gtk.RESPONSE_OK)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   202
        response = dialog.run()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   203
        if response == gtk.RESPONSE_OK:
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   204
            self._dest_input.set_text(dialog.get_filename())
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   205
        dialog.destroy()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   206
        
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   207
    def _btn_src_clicked(self, button):
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   208
        """ select source folder to clone """
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   209
        dialog = gtk.FileChooserDialog(title=None,
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   210
                action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   211
                buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   212
                         gtk.STOCK_OPEN,gtk.RESPONSE_OK))
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   213
        dialog.set_default_response(gtk.RESPONSE_OK)
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   214
        response = dialog.run()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   215
        if response == gtk.RESPONSE_OK:
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   216
            self._src_input.set_text(dialog.get_filename())
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   217
        dialog.destroy()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   218
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   219
    def _btn_rev_clicked(self, button):
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   220
        """ select revision from history dialog """
392
21df78721916 hggtk: copy history select code to new file
Steve Borho <steve@borho.org>
parents: 304
diff changeset
   221
        import histselect
21df78721916 hggtk: copy history select code to new file
Steve Borho <steve@borho.org>
parents: 304
diff changeset
   222
        rev = histselect.select(self.root)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   223
        if rev is not None:
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   224
            self._rev_input.set_text(rev)
1073
2326651b2694 hggtk/clone: remember only ten most-recent src & dest paths
TK Soh <teekaysoh@yahoo.com>
parents: 1072
diff changeset
   225
1051
9355a4da1a9c hggtk/clone: add recently cloned src path to pulldown list
TK Soh <teekaysoh@yahoo.com>
parents: 1049
diff changeset
   226
    def _add_src_to_recent(self, src):
1052
b4bf54ece7f9 hggtk/clone: save recently cloned source
TK Soh <teekaysoh@yahoo.com>
parents: 1051
diff changeset
   227
        if os.path.exists(src):
b4bf54ece7f9 hggtk/clone: save recently cloned source
TK Soh <teekaysoh@yahoo.com>
parents: 1051
diff changeset
   228
            src = os.path.abspath(src)
b4bf54ece7f9 hggtk/clone: save recently cloned source
TK Soh <teekaysoh@yahoo.com>
parents: 1051
diff changeset
   229
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   230
        # save path to recent list in history
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   231
        self._recent_src.add(src)
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   232
        self._settings.write()
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   233
1052
b4bf54ece7f9 hggtk/clone: save recently cloned source
TK Soh <teekaysoh@yahoo.com>
parents: 1051
diff changeset
   234
        # update drop-down list
1051
9355a4da1a9c hggtk/clone: add recently cloned src path to pulldown list
TK Soh <teekaysoh@yahoo.com>
parents: 1049
diff changeset
   235
        self._srclist.clear()
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   236
        sympaths = [x[1] for x in ui.ui().configitems('paths')]
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   237
        paths = list(set(sympaths + [x for x in self._recent_src]))
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   238
        paths.sort()
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   239
        for p in paths:
1051
9355a4da1a9c hggtk/clone: add recently cloned src path to pulldown list
TK Soh <teekaysoh@yahoo.com>
parents: 1049
diff changeset
   240
            self._srclist.append([p])
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   241
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   242
    def _add_dest_to_recent(self, dest):
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   243
        if os.path.exists(dest):
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   244
            dest = os.path.abspath(dest)
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   245
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   246
        # save path to recent list in history
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   247
        self._recent_dest.add(dest)
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   248
        self._settings.write()
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   249
        
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   250
        # update drop down list
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   251
        paths = list(self._recent_dest)
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   252
        paths.sort()
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   253
        self._destlist.clear()
1075
896539c063a7 hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents: 1073
diff changeset
   254
        for p in paths:
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   255
            self._destlist.append([p])
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   256
 
618
01a8cd2f66cd hggtk/clone: add toolbar
TK Soh <teekaysoh@yahoo.com>
parents: 455
diff changeset
   257
    def _btn_clone_clicked(self, toolbutton, data=None):
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   258
        # gather input data
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   259
        src = self._src_input.get_text()
1067
20d428b65e03 hggtk/clone: handle empty dest path
TK Soh <teekaysoh@yahoo.com>
parents: 1066
diff changeset
   260
        dest = self._dest_input.get_text() or os.path.basename(src)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   261
        remotecmd = self._remote_cmd.get_text()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   262
        rev = self._rev_input.get_text()
304
6a49f3883031 hggtk/clone: add checkbox for cloning all revisions
TK Soh <teekaysoh@yahoo.com>
parents: 303
diff changeset
   263
        
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   264
        # verify input
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   265
        if src == "":
1120
08eca2607f01 hggtk/dialog: set transient parent for all message dialogs
TK Soh <teekaysoh@yahoo.com>
parents: 1111
diff changeset
   266
            error_dialog(self, "Source path is empty", "Please enter")
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   267
            self._src_input.grab_focus()
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   268
            return False
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   269
        
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   270
        # start cloning        
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   271
        try:            
408
fcfad6e1aa90 hggtk: hgpath obsolete for most dialogs
Steve Borho <steve@borho.org>
parents: 402
diff changeset
   272
            cmdline = ['hg', 'clone']
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   273
            if self._opt_update.get_active():
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   274
                cmdline.append('--noupdate')
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   275
            if self._opt_uncomp.get_active():
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   276
                cmdline.append('--uncompressed')
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   277
            if self._opt_pull.get_active():
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   278
                cmdline.append('--pull')
1110
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   279
            if not (self._opt_proxy.get_active() and
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   280
                    ui.ui().config('http_proxy', 'host', '')):
46ddcd7f078c hggtk/clone: add checkbox to control use of proxy serve
TK Soh <teekaysoh@yahoo.com>
parents: 1102
diff changeset
   281
                cmdline += ["--config", "http_proxy.host="]
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   282
            if remotecmd:   
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   283
                cmdline.append('--remotecmd')
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   284
                cmdline.append(remotecmd)
304
6a49f3883031 hggtk/clone: add checkbox for cloning all revisions
TK Soh <teekaysoh@yahoo.com>
parents: 303
diff changeset
   285
            if not self._opt_allrev.get_active() and rev:   
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   286
                cmdline.append('--rev')
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   287
                cmdline.append(rev)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   288
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   289
            cmdline.append('--verbose')
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   290
            cmdline.append(src)
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   291
            if dest:
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   292
                cmdline.append(dest)
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   293
408
fcfad6e1aa90 hggtk: hgpath obsolete for most dialogs
Steve Borho <steve@borho.org>
parents: 402
diff changeset
   294
            print "cmdline: ", ' '.join(cmdline)
401
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   295
            from hgcmd import CmdDialog
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   296
            dlg = CmdDialog(cmdline)
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   297
            dlg.run()
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   298
            dlg.hide()
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   299
        except util.Abort, inst:
1120
08eca2607f01 hggtk/dialog: set transient parent for all message dialogs
TK Soh <teekaysoh@yahoo.com>
parents: 1111
diff changeset
   300
            error_dialog(self, "Clone aborted", str(inst))
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   301
            return False
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   302
        except:
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   303
            import traceback
1120
08eca2607f01 hggtk/dialog: set transient parent for all message dialogs
TK Soh <teekaysoh@yahoo.com>
parents: 1111
diff changeset
   304
            error_dialog(self, "Clone error", traceback.format_exc())
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   305
            return False
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   306
1051
9355a4da1a9c hggtk/clone: add recently cloned src path to pulldown list
TK Soh <teekaysoh@yahoo.com>
parents: 1049
diff changeset
   307
        self._add_src_to_recent(src)
1065
66b4d5869034 hggtk/clone: add recent dest paths to drop-down list
Amino Acid <aminoacid@users.sourceforge.net>
parents: 1060
diff changeset
   308
        self._add_dest_to_recent(dest)
1051
9355a4da1a9c hggtk/clone: add recently cloned src path to pulldown list
TK Soh <teekaysoh@yahoo.com>
parents: 1049
diff changeset
   309
408
fcfad6e1aa90 hggtk: hgpath obsolete for most dialogs
Steve Borho <steve@borho.org>
parents: 402
diff changeset
   310
def run(cwd='', files=[], **opts):
fcfad6e1aa90 hggtk: hgpath obsolete for most dialogs
Steve Borho <steve@borho.org>
parents: 402
diff changeset
   311
    dialog = CloneDialog(cwd, repos=files)
401
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   312
    dialog.show_all()
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   313
    gtk.gdk.threads_init()
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   314
    gtk.gdk.threads_enter()
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   315
    gtk.main()
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   316
    gtk.gdk.threads_leave()
291
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   317
    
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   318
if __name__ == "__main__":
503cc1730873 hggtk: add clone dialog
TK Soh <teekaysoh@yahoo.com>
parents:
diff changeset
   319
    import sys
401
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   320
    opts = {}
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   321
    opts['cwd'] = os.getcwd()
402
876a00de6972 hggtk: pass hgpath to dialogs that need it
Steve Borho <steve@borho.org>
parents: 401
diff changeset
   322
    opts['files'] = sys.argv[1:]
401
9ab309fbc25c hggtk: gtk threads and hgproc cleanup
Steve Borho <steve@borho.org>
parents: 397
diff changeset
   323
    run(**opts)