Commits

Steve Borho committed 3318efb Merge

merge

  • Participants
  • Parent commits ab39e06, dfbc57c

Comments (0)

Files changed (5)

 build/
 dist/
 Output/
+.*.swp

File hggtk/serve.py

 import pango
 import Queue
 import signal
+import socket
 import subprocess
 import sys
 from tempfile import mkstemp
 
 class ServeDialog(gtk.Dialog):
     """ Dialog to run web server"""
-    def __init__(self, cwd='', repo='.'):
+    def __init__(self, cwd='', repo = None):
         """ Initialize the Dialog """
         super(ServeDialog, self).__init__(flags=gtk.DIALOG_MODAL)
 
         self._button_stop.connect('clicked', self._on_stop_clicked)
         self.action_area.pack_end(self._button_stop)
         self._button_stop.set_sensitive(False)
-        
+
         self._repo = repo
         if cwd: os.chdir(cwd)
         
         if port:
             self.cmdline += ' --port %d' % port
 
-        # run hg in unbuffered mode, so the output can be captured and display a.s.a.p.
+        # run hg in unbuffered mode, so the output can be captured and
+        # display a.s.a.p.
         os.environ['PYTHONUNBUFFERED'] = "1"
-        self.queue.put(self.cmdline + '\n')
+        #self.write(self.cmdline + '\n')
+        self.write('Web server started, now available at ')
+        self.write('http://%s:%d/\n' % (socket.getfqdn(), port))
 
         self._button_start.set_sensitive(False)
         self._button_stop.set_sensitive(True)
         gobject.timeout_add(10, self.process_queue)
 
     def _on_stop_clicked(self, button):
-        if self.proc.poll() == None:
-            self.write('Killing server process\n')
+        if self.proc and self.proc.poll() == None:
             file = os.fdopen(self.tmp_fd, "r")
             pid = int(file.read())
             file.close()
                 win32api.TerminateProcess(handle, 0)
             else:
                 os.kill(pid, signal.SIGHUP)
+            self.write('Web server stopped.\n')
 
     def write(self, msg, append=True):
         msg = unicode(msg, 'iso-8859-1')
         except IOError:
             pass
 
-def run(cwd='', repo='.'):
+def run(cwd='', repo=None):
     dialog = ServeDialog(cwd, repo)
     dialog.run()
+    dialog._on_stop_clicked(None)
     dialog.hide()
     
 if __name__ == "__main__":

File hgwin/__init__.py

+# placeholder
 # A distutils setup script to register TortoiseHg COM server
 #
 
-# By default, the installer will be created as dist\Output\setup.exe.
+# To build stand-alone package, use 'python setup.py py2exe' then use
+# InnoSetup to build the installer.  By default, the installer will be
+# created as dist\Output\setup.exe.
+
+# To build a source MSI package (for the NSI Mercurial installer), use
+# 'python setup.py bdist_msi'
 
 import time
 import sys
 from distutils.core import setup
 import py2exe
 
-# FIXME: quick hack to include installed hg extensions in py2exe binary
-import hgext
-hgextdir = os.path.dirname(hgext.__file__)
-hgextmods = set(["hgext." + os.path.splitext(f)[0]
+_data_files = []
+extra = {}
+hgextmods = []
+
+if 'py2exe' in sys.argv:
+    # FIXME: quick hack to include installed hg extensions in py2exe binary
+    import hgext
+    hgextdir = os.path.dirname(hgext.__file__)
+    hgextmods = set(["hgext." + os.path.splitext(f)[0]
                   for f in os.listdir(hgextdir)])
+    _data_files = [(root, [os.path.join(root, file_) for file_ in files])
+                        for root, dirs, files in os.walk('icons')]
+    extra['windows'] = [{"script":"hggtk/tracelog.py",
+                        "icon_resources": [(1, "icons/tortoise/python.ico")]}]
+    extra['com_server'] = ["tortoisehg"]
+    extra['console'] = ["hg", "hgproc.py", "hgutils/simplemerge"]
+elif 'bdist_msi' in sys.argv:
+    _data_files = [(os.path.join('share/tortoisehg', root),
+                [os.path.join(root, file_) for file_ in files])
+                for root, dirs, files in os.walk('icons')]
+    _data_files.append(('mercurial/hgrc.d', ['tortoisehg.rc']))
+    extra['scripts'] = ['tortoisehg.py', 'hgproc.py', 'hggtk/tracelog.py']
 
-py2exe_options = dict(
-        # Don't pull in all this MFC stuff used by the makepy UI.
-        excludes = "pywin,pywin.dialogs,pywin.dialogs.list",
-        
-        # add library files to support PyGtk-based dialogs/windows
-        # Note:
-        #    after py2exe build, copy GTK's etc and lib directories into
-        #    the dist directory created by py2exe.
-        #    also needed is the GTK's share/themes (as dist/share/themes), 
-        #    for dialogs to display in MS-Windows XP theme.
-        includes = "pango,atk,pangocairo,cairo,gobject," + ",".join(hgextmods),
+opts = {
+   "py2exe" : {
+       # Don't pull in all this MFC stuff used by the makepy UI.
+       "excludes" : "pywin,pywin.dialogs,pywin.dialogs.list",
+
+       # add library files to support PyGtk-based dialogs/windows
+       # Note:
+       #    after py2exe build, copy GTK's etc and lib directories into
+       #    the dist directory created by py2exe.
+       #    also needed is the GTK's share/themes (as dist/share/themes), 
+       #    for dialogs to display in MS-Windows XP theme.
+       "includes" : "pango,atk,pangocairo,cairo,gobject," + ",".join(hgextmods),
+   }
+}
+
+setup(name="TortoiseHg",
+        version='0.1',
+        author='TK Soh',
+        author_email='teekaysoh@gmail.com',
+        url='http://tortoisehg.sourceforge.net',
+        description='Windows shell extension for Mercurial VCS',
+        license='GNU GPL2',
+        packages=['tortoise', 'hggtk', 'hgwin'],
+        data_files = _data_files,
+        options=opts,
+        **extra
     )
-
-setup(name="TortoiseHg COM server",
-        com_server=["tortoisehg"],
-        console=[
-                 "hg",
-                 "hgproc.py",
-                 "hgutils/simplemerge",         
-                ],
-        windows=[{"script":"hggtk/tracelog.py",
-                  "icon_resources":[(1, "icons/tortoise/python.ico")]}],
-        options = dict(py2exe=py2exe_options),
-        modules="win32com.shell",
-        data_files=[(os.path.join('', root),
-                [os.path.join(root, file_) for file_ in files])
-                for root, dirs, files in os.walk('icons')],
-    )

File tortoisehg.rc

+; Configuration file for TortoiseHg Windows COM Server
+; This is intended to be copied into your system wide configuration
+; directory (C:\Python25\Mercurial\hgrc.d) or to be appended to your
+; system wide configuration file (C:\Program Files\Mercurial\Mercurial.ini)
+
+[tortoisehg]
+;
+; Favorite commit tool.  Options 'qct', 'gcommit', 'internal'
+commit = qct
+;
+; Favorite history browser.  Options 'hgk', 'hgview', 'glog', 'internal'
+view = hgk
+;
+; Visual diff command.  Requires extdiff extension to be configured
+vdiff = vdiff
+;
+; Working directory status tool.  Options 'gstatus', 'internal'
+status = gstatus
+;
+; Flag which declares you have hg-config installed, enables options menu
+hgconfig = 1