Changeset b5fada4be594…
Parent fe8a7a1fc323…
by
Changes to 18 files · Browse files at b5fada4be594 Showing diff from parent fe8a7a1fc323 Diff from another changeset...
@@ -10,9 +10,7 @@ import threading
from thgutil.i18n import _
-from thgutil.hglib import hgversion
-from thgutil import shlib
-from thgutil import paths
+from thgutil import version, paths, hglib
from hggtk import gtklib, hgtk
@@ -45,7 +43,7 @@ gtklib.set_tortoise_keys(self)
lib_versions = ', '.join([
- "Mercurial-%s" % hgversion,
+ "Mercurial-%s" % hglib.hgversion,
"Python-%s" % make_version(sys.version_info[0:3]),
"PyGTK-%s" % make_version(gtk.pygtk_version),
"GTK-%s" % make_version(gtk.gtk_version),
@@ -55,7 +53,7 @@
self.set_website("http://bitbucket.org/tortoisehg/stable/")
self.set_name("TortoiseHg")
- self.set_version("(version %s)" % shlib.version())
+ self.set_version("(version %s)" % version.version())
if hasattr(self, 'set_wrap_license'):
self.set_wrap_license(True)
self.set_copyright("Copyright 2009 TK Soh and others")
|
@@ -10,9 +10,8 @@
from mercurial import extensions
from thgutil.i18n import _
-from thgutil import shlib
+from thgutil import hglib, version
from hggtk.gdialog import GDialog
-from hggtk.about import hgversion
class BugReport(GDialog):
"""GTK+ based dialog for displaying traceback info to the user in a
@@ -49,7 +48,7 @@ ' tortoisehg-discuss@lists.sourceforge.net or'
' http://bitbucket.org/tortoisehg/stable/issues\n')
text += _('** Mercurial version (%s). TortoiseHg version (%s)\n') % (
- hgversion, shlib.version())
+ hglib.hgversion, version.version())
text += _('** Command: %s\n') % (self.opts['cmd'])
text += _('** CWD: %s\n') % os.getcwd()
extlist = [x[0] for x in extensions.extensions()]
|
@@ -11,7 +11,7 @@
from mercurial import ui, util
from thgutil.i18n import _
-from thgutil import shlib
+from thgutil import shlib, settings
from hggtk import gdialog, gtklib, hgcmd
class CloneDialog(gtk.Window):
@@ -25,7 +25,7 @@ self.set_title(_('TortoiseHg Clone'))
self.ui = ui.ui()
- self._settings = shlib.Settings('clone')
+ self._settings = settings.Settings('clone')
self._recent_src = self._settings.mrul('src_paths')
self._recent_dest = self._settings.mrul('dest_paths')
@@ -70,7 +70,7 @@ vbox.pack_start(srcbox, False, False, 2)
# add pre-defined src paths to pull-down list
- sync_src = shlib.Settings('synch').mrul('src_paths')
+ sync_src = settings.Settings('synch').mrul('src_paths')
sympaths = [x[1] for x in self.ui.configitems('paths')]
recent = [x for x in self._recent_src]
syncsrc = [x for x in sync_src]
|
@@ -18,8 +18,7 @@ from mercurial import ui, hg, util, patch
from thgutil.i18n import _
-from thgutil import hglib
-from thgutil import shlib
+from thgutil import shlib, hglib
from hggtk.status import GStatus, FM_STATUS, FM_CHECKED, FM_PATH_UTF8
from hggtk.status import DM_REJECTED, DM_CHUNK_ID
|
@@ -20,7 +20,7 @@ from hgext import extdiff
from thgutil.i18n import _
-from thgutil import shlib, hglib, paths
+from thgutil import settings, hglib, paths
from hggtk import gtklib
@@ -124,7 +124,7 @@ self.opts = opts
self.tmproot = None
self.toolbuttons = {}
- self.settings = shlib.Settings(self.__class__.__name__)
+ self.settings = settings.Settings(self.__class__.__name__)
self.init()
### Following methods are meant to be overridden by subclasses ###
|
@@ -16,7 +16,7 @@
from thgutil.i18n import _
from thgutil.hglib import toutf, fromutf, diffexpand, RepoError
-from thgutil import shlib, paths, thread2
+from thgutil import shlib, paths, thread2, settings
from hggtk import gtklib
@@ -46,7 +46,7 @@ self.notify_func = None
path = toutf(os.path.basename(self.root))
self.set_title(_('Detect Copies/Renames in ') + path)
- settings = shlib.Settings('guess')
+ settings = settings.Settings('guess')
dims = settings.get_value('dims', (800, 600))
self.set_default_size(dims[0], dims[1])
|
@@ -11,11 +11,9 @@ import Queue
from thgutil.i18n import _
-from thgutil import shlib
-from thgutil import hglib
+from thgutil import shlib, hglib
-from hggtk import gtklib
-from hggtk import hgthread
+from hggtk import gtklib, hgthread
class CmdDialog(gtk.Dialog):
def __init__(self, cmdline, progressbar=True, width=520, height=400):
|
@@ -15,7 +15,7 @@ from mercurial import hg, ui, extensions
from thgutil.i18n import _
-from thgutil import hglib, shlib
+from thgutil import hglib, settings
from hggtk import gtklib, dialog, thgconfig, hgcmd
@@ -207,7 +207,7 @@ for v in history.get_value(cpath):
vlist.append([v])
- history = shlib.Settings('email')
+ history = settings.Settings('email')
try:
repo = hg.repository(ui.ui(), path=self.root)
self.repo = repo
@@ -329,7 +329,7 @@ return
if not test:
- history = shlib.Settings('config_history')
+ history = settings.Settings('email')
record_new_value('email.to', history, totext)
record_new_value('email.cc', history, cctext)
record_new_value('email.from', history, fromtext)
|
@@ -10,11 +10,9 @@ from mercurial import hg, ui, util
from thgutil.i18n import _
-from thgutil import hglib
-from thgutil import shlib
+from thgutil import hglib, shlib
-from hggtk import dialog
-from hggtk import gtklib
+from hggtk import dialog, gtklib
class InitDialog(gtk.Window):
""" Dialog to initialize a Mercurial repo """
|
@@ -11,11 +11,9 @@ from mercurial import ui, util
from thgutil.i18n import _
-from thgutil import hglib
-from thgutil import thread2
+from thgutil import hglib, thread2
-from hggtk import dialog
-from hggtk import gdialog
+from hggtk import dialog, gdialog
class GtkUi(ui.ui):
'''
|
@@ -23,6 +23,7 @@
from thgutil.i18n import _
from thgutil import hglib, paths, shlib
+from thgutil import version as thgversion
nonrepo_commands = 'userconfig clone debugcomplete init about help version'
@@ -555,7 +556,7 @@ """output version and copyright information"""
ui.write(_('TortoiseHg Dialogs (version %s), '
'Mercurial (version %s)\n') %
- (shlib.version(), util.version()))
+ (thgversion.version(), hglib.hgversion))
if not ui.quiet:
ui.write(shortlicense)
|
@@ -10,6 +10,7 @@ import pango
import Queue
import os
+import time
from mercurial import hg, ui
@@ -128,7 +129,6 @@ self._exec_cmd(cmd, postfunc=self._notify)
def _notify(self, ret, *args):
- import time
time.sleep(0.5) # give fs some time to pick up changes
shlib.shell_notify([self.root])
|
@@ -15,7 +15,7 @@ from mercurial import hg, ui, extensions, url
from thgutil.i18n import _
-from thgutil import hglib, shlib, paths
+from thgutil import hglib, settings, paths
from hggtk import dialog, gtklib, hgthread, history, thgconfig, hgemail
@@ -31,7 +31,7 @@ self.hgthread = None
# persistent app data
- self._settings = shlib.Settings('synch')
+ self._settings = settings.Settings('synch')
self.set_default_size(655, 552)
|
@@ -14,7 +14,7 @@ from mercurial import hg, ui, util, url, filemerge
from thgutil.i18n import _
-from thgutil import hglib, shlib, paths, iniparse
+from thgutil import hglib, settings, paths, iniparse
from hggtk import dialog, gdialog, gtklib, hgcmd
@@ -412,7 +412,7 @@ self.dirty = False
self.pages = []
self.tooltips = gtk.Tooltips()
- self.history = shlib.Settings('thgconfig')
+ self.history = settings.Settings('thgconfig')
# create pages for each section of configuration file
self.tortoise_frame = self.add_page(notebook, 'TortoiseHG')
|
@@ -19,7 +19,7 @@ from mercurial import hg, ui, cmdutil, util
from thgutil.i18n import _
-from thgutil import hglib, shlib, paths
+from thgutil import hglib, settings, paths
from hggtk import gdialog, gtklib
@@ -78,7 +78,7 @@
hbox = gtk.HBox()
self.vbox.pack_start(hbox, False, False, 2)
- settings = shlib.Settings('visdiff')
+ settings = settings.Settings('visdiff')
single = settings.get_value('launchsingle', False)
check = gtk.CheckButton(_('Always launch single files'))
check.set_active(single)
@@ -203,7 +203,7 @@ self.launch(*model[0])
def delete_tmproot(self, _, tmproot):
- settings = shlib.Settings('visdiff')
+ settings = settings.Settings('visdiff')
settings.set_value('launchsingle', self.singlecheck.get_active())
settings.write()
shutil.rmtree(tmproot)
|
|
@@ -1,19 +1,14 @@ """
-shlib.py - TortoiseHg shell utilities
+settings.py - TortoiseHg dialog settings library
Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>
This software may be used and distributed according to the terms
of the GNU General Public License, incorporated herein by reference.
-
"""
import os
-import sys
import cPickle
-import time
-from mercurial.i18n import _
from mercurial import util
-from mercurial import hg
class SimpleMRUList(object):
def __init__(self, size=10, reflist=[], compact=True):
@@ -113,132 +108,3 @@ if os.path.exists(os.path.dirname(self._path)):
return
os.makedirs(os.path.dirname(self._path))
-
-def get_system_times():
- t = os.times()
- if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
- t = (t[0], t[1], t[2], t[3], time.clock())
- return t
-
-def get_tortoise_icon(thgicon):
- '''Find a tortoise icon, apply to PyGtk window'''
- # The context menu should set this variable
- var = os.environ.get('THG_ICON_PATH', None)
- paths = var and [ var ] or []
- try:
- # Else try relative paths from hggtk, the repository layout
- fdir = os.path.dirname(__file__)
- paths.append(os.path.join(fdir, '..', 'icons'))
- # ... or the unix installer layout
- paths.append(os.path.join(fdir, '..', '..', '..',
- 'share', 'pixmaps', 'tortoisehg', 'icons'))
- paths.append(os.path.join(fdir, '..', '..', '..', '..',
- 'share', 'pixmaps', 'tortoisehg', 'icons'))
- except NameError: # __file__ is not always available
- pass
- for p in paths:
- path = os.path.join(p, 'tortoise', thgicon)
- if os.path.isfile(path):
- return path
- else:
- print _('icon not found'), thgicon
- return None
-
-def version():
- try:
- import __version__
- return __version__.version
- except ImportError:
- return _('unknown')
-
-if os.name == 'nt':
- def shell_notify(paths):
- try:
- from win32com.shell import shell, shellcon
- import pywintypes
- except ImportError:
- return
- dirs = set()
- for path in paths:
- abspath = os.path.abspath(path)
- if not os.path.isdir(abspath):
- abspath = os.path.dirname(abspath)
- dirs.add(abspath)
- # send notifications to deepest directories first
- for dir in sorted(dirs, key=len, reverse=True):
- try:
- pidl, ignore = shell.SHILCreateFromPath(dir, 0)
- except pywintypes.com_error:
- return
- if pidl is None:
- continue
- shell.SHChangeNotify(shellcon.SHCNE_UPDATEITEM,
- shellcon.SHCNF_IDLIST | shellcon.SHCNF_FLUSH,
- pidl, None)
-
- def update_thgstatus(ui, root, wait=False):
- '''Rewrite the file .hg/thgstatus
-
- Caches the information provided by repo.status() in the file
- .hg/thgstatus, which can then be read by the overlay shell extension
- to display overlay icons for directories.
-
- The file .hg/thgstatus contains one line for each directory that has
- removed, modified or added files (in that order of preference). Each
- line consists of one char for the status of the directory (r, m or a),
- followed by the relative path of the directory in the repo. If the
- file .hg/thgstatus is empty, then the repo's working directory is
- clean.
-
- Specify wait=True to wait until the system clock ticks to the next
- second before accessing Mercurial's dirstate. This is useful when
- Mercurial's .hg/dirstate contains unset entries (in output of
- "hg debugstate"). unset entries happen if .hg/dirstate was updated
- within the same second as Mercurial updated the respective file in
- the working tree. This happens with a high probability for example
- when cloning a repo. The overlay shell extension will display unset
- dirstate entries as (potentially false) modified. Specifying wait=True
- ensures that there are no unset entries left in .hg/dirstate when this
- function exits.
- '''
- if wait:
- tref = time.time()
- tdelta = float(int(tref)) + 1.0 - tref
- if (tdelta > 0.0):
- time.sleep(tdelta)
- repo = hg.repository(ui, root) # a fresh repo object is needed
- repostate = repo.status() # will update .hg/dirstate as a side effect
- modified, added, removed, deleted = repostate[:4]
- dirstatus = {}
- def dirname(f):
- return '/'.join(f.split('/')[:-1])
- for fn in added:
- dirstatus[dirname(fn)] = 'a'
- for fn in modified:
- dirstatus[dirname(fn)] = 'm'
- for fn in removed + deleted:
- dirstatus[dirname(fn)] = 'r'
- f = open(repo.join("thgstatus"), 'wb')
- for dn in sorted(dirstatus):
- f.write(dirstatus[dn] + dn + '\n')
- f.close()
-
-else:
- def shell_notify(paths):
- if not paths:
- return
- notify = os.environ.get('THG_NOTIFY', '.tortoisehg/notify')
- if not os.path.isabs(notify):
- notify = os.path.join(os.path.expanduser('~'), notify)
- os.environ['THG_NOTIFY'] = notify
- if not os.path.isfile(notify):
- return
- f_notify = open(notify, 'w')
- try:
- f_notify.write('\n'.join([os.path.abspath(path) for path in paths]))
- finally:
- f_notify.close()
-
- def update_thgstatus(*args, **kws):
- pass
-
|
|
@@ -4,146 +4,20 @@
This software may be used and distributed according to the terms
of the GNU General Public License, incorporated herein by reference.
-
"""
import os
import sys
-import cPickle
import time
from mercurial.i18n import _
-from mercurial import util
from mercurial import hg
-class SimpleMRUList(object):
- def __init__(self, size=10, reflist=[], compact=True):
- self._size = size
- self._list = reflist
- if compact:
- self.compact()
-
- def __iter__(self):
- for elem in self._list:
- yield elem
-
- def add(self, val):
- if val in self._list:
- self._list.remove(val)
- self._list.insert(0, val)
- self.flush()
-
- def get_size(self):
- return self._size
-
- def set_size(self, size):
- self._size = size
- self.flush()
-
- def flush(self):
- while len(self._list) > self._size:
- del self._list[-1]
-
- def compact(self):
- ''' remove duplicate in list '''
- newlist = []
- for v in self._list:
- if v not in newlist:
- newlist.append(v)
- self._list[:] = newlist
-
-
-class Settings(object):
- def __init__(self, appname, path=None):
- self._appname = appname
- self._data = {}
- self._path = path and path or self._get_path(appname)
- self._audit()
- self.read()
-
- def get_value(self, key, default=None, create=False):
- if key in self._data:
- return self._data[key]
- elif create:
- self._data[key] = default
- return default
-
- def set_value(self, key, value):
- self._data[key] = value
-
- def mrul(self, key, size=10):
- ''' wrapper method to create a most-recently-used (MRU) list '''
- ls = self.get_value(key, [], True)
- ml = SimpleMRUList(size=size, reflist=ls)
- return ml
-
- def get_keys(self):
- return self._data.keys()
-
- def get_appname(self):
- return self._appname
-
- def read(self):
- self._data.clear()
- if os.path.exists(self._path):
- try:
- f = file(self._path, 'rb')
- self._data = cPickle.loads(f.read())
- f.close()
- except Exception:
- pass
-
- def write(self):
- self._write(self._path, self._data)
-
- def _write(self, appname, data):
- s = cPickle.dumps(data)
- f = util.atomictempfile(appname, 'wb', None)
- f.write(s)
- f.rename()
-
- def _get_path(self, appname):
- if os.name == 'nt':
- return os.path.join(os.environ.get('APPDATA'), 'TortoiseHg',
- appname)
- else:
- return os.path.join(os.path.expanduser('~'), '.tortoisehg',
- appname)
-
- def _audit(self):
- if os.path.exists(os.path.dirname(self._path)):
- return
- os.makedirs(os.path.dirname(self._path))
-
def get_system_times():
t = os.times()
if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
t = (t[0], t[1], t[2], t[3], time.clock())
return t
-def get_tortoise_icon(thgicon):
- '''Find a tortoise icon, apply to PyGtk window'''
- # The context menu should set this variable
- var = os.environ.get('THG_ICON_PATH', None)
- paths = var and [ var ] or []
- try:
- # Else try relative paths from hggtk, the repository layout
- fdir = os.path.dirname(__file__)
- paths.append(os.path.join(fdir, '..', 'icons'))
- # ... or the unix installer layout
- paths.append(os.path.join(fdir, '..', '..', '..',
- 'share', 'pixmaps', 'tortoisehg', 'icons'))
- paths.append(os.path.join(fdir, '..', '..', '..', '..',
- 'share', 'pixmaps', 'tortoisehg', 'icons'))
- except NameError: # __file__ is not always available
- pass
- for p in paths:
- path = os.path.join(p, 'tortoise', thgicon)
- if os.path.isfile(path):
- return path
- else:
- print _('icon not found'), thgicon
- return None
-
def version():
try:
import __version__
@@ -241,4 +115,3 @@
def update_thgstatus(*args, **kws):
pass
-
|
|
@@ -0,0 +1,18 @@ + """
+version.py - TortoiseHg version
+ Copyright (C) 2009 Steve Borho <steve@borho.org>
+
+This software may be used and distributed according to the terms
+of the GNU General Public License, incorporated herein by reference.
+"""
+
+from thgutil.i18n import _
+
+def version():
+ try:
+ import __version__
+ return __version__.version
+ except ImportError:
+ return _('unknown')
+
+
|
Loading...