Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc1, 0.4rc2, and 0.4rc3

merge

Changeset 8a6b2ec1828e

Parents 56b0e87afac3

Parents 15d08463ac53

by TK Soh

Changes to 7 files · Browse files at 8a6b2ec1828e Showing diff from parent 56b0e87afac3 15d08463ac53 Diff from another changeset...

Change 1 of 6 Show Entire File hggtk/​clone.py Stacked
 
13
14
15
 
16
17
18
19
20
 
21
22
23
 
25
26
27
28
 
29
30
31
 
35
36
37
 
38
39
40
 
80
81
82
83
 
 
 
 
 
84
 
 
 
 
 
 
 
 
85
86
87
88
 
89
90
91
 
 
 
 
 
 
92
93
94
 
186
187
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
190
191
 
233
234
235
 
 
236
237
238
 
13
14
15
16
17
18
19
20
 
21
22
23
24
 
26
27
28
 
29
30
31
32
 
36
37
38
39
40
41
42
 
82
83
84
 
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 
102
103
104
105
106
107
108
109
110
111
112
113
114
 
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
 
274
275
276
277
278
279
280
281
@@ -13,11 +13,12 @@
 import os  import sys  import gtk +import pango  from dialog import question_dialog, error_dialog, info_dialog  from mercurial import hg, ui, cmdutil, util  from mercurial.i18n import _  from mercurial.node import * -from shlib import set_tortoise_icon +import shlib    class CloneDialog(gtk.Window):   """ Dialog to add tag to Mercurial repo """ @@ -25,7 +26,7 @@
  """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)   - set_tortoise_icon(self, 'menuclone.ico') + shlib.set_tortoise_icon(self, 'menuclone.ico')   if cwd: os.chdir(cwd)     # set dialog title @@ -35,6 +36,7 @@
    self._src_path = ''   self._dest_path = '' + self._settings = shlib.Settings('clone')     try:   self._src_path = repos[0] @@ -80,15 +82,33 @@
  lbl = gtk.Label("Source Path:")   lbl.set_property("width-chars", ewidth)   lbl.set_alignment(0, 0.5) - self._src_input = gtk.Entry() + + # create drop-down list for source paths + self._srclist = gtk.ListStore(str) + self._srclistbox = gtk.ComboBoxEntry(self._srclist, 0) + self._src_input = self._srclistbox.get_child()   self._src_input.set_text(self._src_path) + + # replace the drop-down widget so we can modify it's properties + self._srclistbox.clear() + cell = gtk.CellRendererText() + cell.set_property('ellipsize', pango.ELLIPSIZE_MIDDLE) + self._srclistbox.pack_start(cell) + self._srclistbox.add_attribute(cell, 'text', 0) +   self._btn_src_browse = gtk.Button("Browse...")   self._btn_src_browse.connect('clicked', self._btn_src_clicked)   srcbox.pack_start(lbl, False, False) - srcbox.pack_start(self._src_input, True, True) + srcbox.pack_start(self._srclistbox, True, True)   srcbox.pack_end(self._btn_src_browse, False, False, 5)   vbox.pack_start(srcbox, False, False, 2)   + # add pre-defined src paths to pull-down list + sympaths = [x[1] for x in ui.ui().configitems('paths')] + recentsrc = self._settings.get('src_paths', []) + paths = list(set(sympaths + recentsrc)) + paths.sort() + for p in paths: self._srclist.append([p])     # clone destination   destbox = gtk.HBox() @@ -186,6 +206,27 @@
  if rev is not None:   self._rev_input.set_text(rev)   + def _add_src_to_recent(self, src): + if os.path.exists(src): + src = os.path.abspath(src) + + srclist = [x[0] for x in self._srclist] + if src in srclist: + return + + # update drop-down list + srclist.append(src) + srclist.sort() + self._srclist.clear() + for p in srclist: + self._srclist.append([p]) + + # save path to recent list in history + if not 'src_paths' in self._settings: + self._settings['src_paths'] = [] + self._settings['src_paths'].append(src) + self._settings.write() +   def _btn_clone_clicked(self, toolbutton, data=None):   # gather input data   src = self._src_input.get_text() @@ -233,6 +274,8 @@
  error_dialog("Clone error", traceback.format_exc())   return False   + self._add_src_to_recent(src) +  def run(cwd='', files=[], **opts):   dialog = CloneDialog(cwd, repos=files)   dialog.show_all()
Change 1 of 3 Show Entire File hggtk/​gdialog.py Stacked
 
27
28
29
30
 
31
32
33
 
97
98
99
 
100
101
102
 
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
 
 
 
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
 
 
 
 
 
351
352
353
 
27
28
29
 
30
31
32
33
 
97
98
99
100
101
102
103
 
313
314
315
 
316
 
 
 
 
 
 
 
 
 
 
317
318
319
320
 
 
321
322
323
324
325
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
327
328
329
330
331
332
333
@@ -27,7 +27,7 @@
 from mercurial.node import *  from mercurial import cmdutil, util, ui, hg, commands, patch  from hgext import extdiff -from shlib import shell_notify, set_tortoise_icon +from shlib import shell_notify, set_tortoise_icon, Settings  from thgconfig import ConfigDialog    class SimpleMessage(gtk.MessageDialog): @@ -97,6 +97,7 @@
  self.opts = opts   self.main = main   self.tmproot = None + self.settings = Settings(self.__class__.__name__)     ### Following methods are meant to be overridden by subclasses ###   @@ -312,42 +313,21 @@
    def _destroying(self, gtkobj):   try: - file = None   settings = self.save_settings() - versioned = (GDialog.settings_version, settings) - dirname = os.path.join(os.path.expanduser('~'), '.hgext/gtools') - filename = os.path.join(dirname, self.__class__.__name__) - try: - if not os.path.exists(dirname): - os.makedirs(dirname) - file = open(filename, 'wb') - cPickle.dump(versioned, file, cPickle.HIGHEST_PROTOCOL) - except (IOError, cPickle.PickleError): - pass + self.settings['settings_version'] = GDialog.settings_version + self.settings['dialogs'] = settings + self.settings.write()   finally: - if file: - file.close()   if self.main:   gtk.main_quit()       def _load_settings(self): - try: - file = None - settings = None - dirname = os.path.join(os.path.expanduser('~'), '.hgext/gtools') - filename = os.path.join(dirname, self.__class__.__name__) - try: - file = open(filename, 'rb') - versioned = cPickle.load(file) - if versioned[0] == GDialog.settings_version: - settings = versioned[1] - except (IOError, cPickle.PickleError), inst: - pass - finally: - if file: - file.close() - self.load_settings(settings) + settings = {} + version = self.settings.get('settings_version', None) + if version == GDialog.settings_version: + settings = self.settings.get('dialogs', {}) + self.load_settings(settings)       def _hg_call_wrapper(self, title, command, showoutput=True):
Change 1 of 2 Show Entire File hggtk/​hgemail.py Stacked
 
194
195
196
197
 
198
199
200
 
281
282
283
284
 
285
286
287
288
289
 
290
291
292
 
194
195
196
 
197
198
199
200
 
281
282
283
 
284
285
286
287
288
 
289
290
291
292
@@ -194,7 +194,7 @@
  for v in history[cpath]:   vlist.append([v])   - history = shlib.read_history() + history = shlib.Settings('config_history')   try:   repo = hg.repository(ui.ui(), path=self.root)   self.repo = repo @@ -281,12 +281,12 @@
  self._refresh(False)   return   - history = shlib.read_history() + history = shlib.Settings('config_history')   record_new_value('email.to', history, totext)   record_new_value('email.cc', history, cctext)   record_new_value('email.from', history, fromtext)   record_new_value('email.subject', history, subjtext) - shlib.save_history(history) + history.write()     cmdline = ['hg', 'email', '-f', fromtext, '-t', totext, '-c', cctext]   cmdline += ['--repository', self.repo.root]
Change 1 of 1 Show Entire File hggtk/​shlib.py Stacked
 
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
40
41
@@ -11,29 +11,31 @@
 import shelve  import time   +class Settings(dict): + def __init__(self, key): + self.key = key + self.path = os.path.join(os.path.expanduser('~'), '.hgext', 'tortoisehg') + if not os.path.exists(os.path.dirname(self.path)): + os.makedirs(os.path.dirname(self.path)) + self.read() + + def read(self): + self.clear() + dbase = shelve.open(self.path) + self.update(dbase.get(self.key, {})) + dbase.close() + + def write(self): + dbase = shelve.open(self.path) + dbase[self.key] = dict(self) + dbase.close() +  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 read_history(key='config_history'): - path = os.path.join(os.path.expanduser('~'), '.hgext', 'tortoisehg') - if not os.path.exists(os.path.dirname(path)): - os.makedirs(os.path.dirname(path)) - dbase = shelve.open(path) - dict = dbase.get(key, {}) - dbase.close() - return dict - -def save_history(dict, key='config_history'): - path = os.path.join(os.path.expanduser('~'), '.hgext', 'tortoisehg') - if not os.path.exists(os.path.dirname(path)): - os.makedirs(os.path.dirname(path)) - dbase = shelve.open(path) - dbase[key] = dict - dbase.close() -  def set_tortoise_icon(window, icon):   window.set_icon_from_file(get_tortoise_icon(icon))  
Change 1 of 7 Show Entire File hggtk/​synch.py Stacked
 
20
21
22
23
 
24
25
26
 
28
29
30
31
 
32
33
34
35
 
 
 
 
 
 
 
36
37
38
 
101
102
103
104
105
 
 
106
107
108
 
114
115
116
117
 
118
119
120
 
123
124
125
 
 
 
126
127
128
 
349
350
351
352
 
353
354
 
355
356
357
 
413
414
415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
417
418
 
20
21
22
 
23
24
25
26
 
28
29
30
 
31
32
33
34
 
35
36
37
38
39
40
41
42
43
44
 
107
108
109
 
 
110
111
112
113
114
 
120
121
122
 
123
124
125
126
 
129
130
131
132
133
134
135
136
137
 
358
359
360
 
361
362
 
363
364
365
366
 
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
@@ -20,7 +20,7 @@
 from mercurial import hg, ui, util  from dialog import error_dialog, question_dialog  from hglib import HgThread -from shlib import set_tortoise_icon +import shlib  import gtklib    class SynchDialog(gtk.Window): @@ -28,11 +28,17 @@
  """ Initialize the Dialog. """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)   - set_tortoise_icon(self, 'menusynch.ico') + shlib.set_tortoise_icon(self, 'menusynch.ico')   self.root = root   self.cwd = cwd   self.selected_path = None - + + # persistent app data + self._settings = shlib.Settings('synch') + if not 'src_paths' in self._settings: + self._settings['src_paths'] = [] + self.recent_paths = self._settings['src_paths'] +   self.set_default_size(610, 400)     self.paths = self._get_paths() @@ -101,8 +107,8 @@
  lbl.connect('clicked', self._btn_remotepath_clicked)     # revisions combo box - self.revlist = gtk.ListStore(str) - self._pathbox = gtk.ComboBoxEntry(self.revlist, 0) + self.pathlist = gtk.ListStore(str) + self._pathbox = gtk.ComboBoxEntry(self.pathlist, 0)   self._pathtext = self._pathbox.get_child()     defrow = None @@ -114,7 +120,7 @@
  defpushrow = row   elif name == 'default-push':   defpushrow = row - self.revlist.append([path]) + self.pathlist.append([path])     if repos:   self._pathtext.set_text(repos[0]) @@ -123,6 +129,9 @@
  elif defpushrow is not None:   self._pathbox.set_active(defpushrow)   + for p in self.recent_paths: + self.pathlist.append([p]) +   # create checkbox to disable proxy   self._use_proxy = gtk.CheckButton("use proxy server")   if ui.ui().config('http_proxy', 'host', ''): @@ -349,9 +358,9 @@
  dlg.run()   dlg.hide()   self.paths = self._get_paths() - self.revlist.clear() + self.pathlist.clear()   for row, (name, path) in enumerate(self.paths): - self.revlist.append([path]) + self.pathlist.append([path])     def _email_clicked(self, toolbutton, data=None):   path = self._pathtext.get_text() @@ -413,6 +422,27 @@
  self.stbar.begin()   self.stbar.set_status_text('hg ' + ' '.join(cmd + [remote_path]))   + self._add_src_to_recent(remote_path) + + def _add_src_to_recent(self, src): + if os.path.exists(src): + src = os.path.abspath(src) + + srclist = [x[0] for x in self.pathlist] + if src in srclist: + return + + # update drop-down list + srclist.append(src) + srclist.sort() + self.pathlist.clear() + for p in srclist: + self.pathlist.append([p]) + + # save path to recent list in history + self.recent_paths.append(src) + self._settings.write() +   def write(self, msg, append=True):   msg = unicode(msg, 'iso-8859-1')   if append:
 
66
67
68
69
 
70
71
72
 
535
536
537
538
 
539
540
541
 
561
562
563
564
 
565
566
567
 
66
67
68
 
69
70
71
72
 
535
536
537
 
538
539
540
541
 
561
562
563
 
564
565
566
567
@@ -66,7 +66,7 @@
  self.dirty = False   self.pages = []   self.tooltips = gtk.Tooltips() - self.history = shlib.read_history() + self.history = shlib.Settings('config_history')     # create pages for each section of configuration file   self._tortoise_info = ( @@ -535,7 +535,7 @@
    def _apply_clicked(self, *args):   # Reload history, since it may have been modified externally - self.history = shlib.read_history() + self.history.read()     # flush changes on paths page   if len(self.pathlist): @@ -561,7 +561,7 @@
  newvalue = widgets[w].child.get_text()   self.record_new_value(cpath, newvalue)   - shlib.save_history(self.history) + self.history.write()   try:   f = open(self.fn, "w")   f.write(str(self.ini))
 
44
45
46
47
 
 
 
 
 
 
 
 
48
49
50
 
52
53
54
 
55
56
57
58
59
60
61
62
 
 
 
 
 
63
64
65
 
44
45
46
 
47
48
49
50
51
52
53
54
55
56
57
 
59
60
61
62
63
64
65
 
 
 
 
 
66
67
68
69
70
71
72
73
@@ -44,7 +44,14 @@
  continue   # New head.   revs.append(curr_rev) - rev_color[curr_rev] = nextcolor ; nextcolor += 1 + rev_color[curr_rev] = curcolor = nextcolor ; nextcolor += 1 + r = __get_parents(repo, curr_rev) + while r: + r0 = r[0] + if r0 < stop_rev: break + if r0 in rev_color: break + rev_color[r0] = curcolor + r = __get_parents(repo, r0)   curcolor = rev_color[curr_rev]   rev_index = revs.index(curr_rev)   next_revs = revs[:] @@ -52,14 +59,15 @@
  # Add parents to next_revs.   parents = __get_parents(repo, curr_rev)   parents_to_add = [] + preferred_color = curcolor   for parent in parents:   if parent not in next_revs:   parents_to_add.append(parent) - if len(parents) > 1: - rev_color[parent] = nextcolor ; nextcolor += 1 - else: - rev_color[parent] = curcolor - parents_to_add.sort() + if parent not in rev_color: + if preferred_color: + rev_color[parent] = preferred_color; preferred_color = None + else: + rev_color[parent] = nextcolor ; nextcolor += 1   next_revs[rev_index:rev_index + 1] = parents_to_add     lines = []