Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.7, 0.7.1, and 0.7.2

cmenu: initial attempt to integrate new dialogs

Changeset e15597258047

Parent f9669ff287ac

by Steve Borho

Changes to 2 files · Browse files at e15597258047 Showing diff from parent f9669ff287ac Diff from another changeset...

Change 1 of 3 Show Changes Only hgproc.py Stacked
1
2
3
4
5
6
7
8
9
10
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
42
43
44
45
46
 
 
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
 
81
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
115
116
117
118
119
120
121
122
1
2
3
4
5
6
7
8
9
10
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
42
43
44
45
46
 
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
115
116
117
118
119
120
121
122
123
124
125
126
 #  # front-end for TortoiseHg dialogs  #  # Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>  #    import os  import sys  from mercurial import ui  from tortoise.thgutil import get_prog_root    # always use hg exe installed with TortoiseHg  thgdir = get_prog_root()  try:   os.environ['PATH'] = os.path.pathsep.join([thgdir, os.environ['PATH']])  except KeyError:   os.environ['PATH'] = thgdir    if not sys.stdin.isatty():   try:   import win32traceutil     # FIXME: quick workaround traceback caused by missing "closed"   # attribute in win32trace.   from mercurial import ui   def write_err(self, *args):   for a in args:   sys.stderr.write(str(a))   ui.ui.write_err = write_err   except ImportError:   pass   except pywintypes.error:   pass    # Map hgproc commands to dialog modules in hggtk/  from hggtk import commit, status, addremove, tagadd, tags, history, merge  from hggtk import diff, revisions, update, serve, clone, synch, hgcmd, about -from hggtk import recovery, thgconfig, datamine, hginit +from hggtk import recovery, thgconfig, datamine, hginit, shelve, rename +from hggtk import hgignore  _dialogs = { 'commit' : commit, 'status' : status, 'revert' : status,   'add' : addremove, 'remove' : addremove, 'tag' : tagadd,   'tags' : tags, 'log' : history, 'history': history,   'diff' : diff, 'merge' : merge, 'tip' : revisions,   'parents': revisions, 'heads' : revisions, 'update' : update,   'clone' : clone, 'serve' : serve, 'synch' : synch,   'about' : about, 'config' : thgconfig, 'recovery': recovery, - 'datamine': datamine, 'init' : hginit } + 'datamine': datamine, 'init' : hginit, 'shelve' : thgshelve, + 'hgignore': hgignore, 'rename' : rename }    def get_list_from_file(filename):   fd = open(filename, "r")   lines = [ x.replace("\n", "") for x in fd.readlines() ]   fd.close()   return lines    def get_option(args):   import getopt   long_opt_list = ('command=', 'exepath=', 'listfile=', 'root=', 'cwd=',   'deletelistfile', 'nogui')   opts, args = getopt.getopt(args, "c:e:l:dR:", long_opt_list)   # Set default options   options = {}   options['hgcmd'] = 'help'   options['cwd'] = os.getcwd()   options['files'] = []   options['gui'] = True   listfile = None   delfile = False     for o, a in opts:   if o in ("-c", "--command"):   options['hgcmd'] = a   elif o in ("-l", "--listfile"):   listfile = a   elif o in ("-d", "--deletelistfile"):   delfile = True   elif o in ("--nogui"):   options['gui'] = False   elif o in ("-R", "--root"):   options['root'] = a   elif o in ("--cwd"):   options['cwd'] = a + elif o in ("--detect"): + options['detect'] = True     if listfile:   options['files'] = get_list_from_file(listfile)   if delfile:   os.unlink(listfile)     return (options, args)    def parse(args):   option, args = get_option(args)     cmdline = ['hg', option['hgcmd']]   if 'root' in option:   cmdline.append('--repository')   cmdline.append(option['root'])   cmdline.extend(args)   cmdline.extend(option['files'])   option['cmdline'] = cmdline     global _dialogs   dialog = _dialogs.get(option['hgcmd'], hgcmd)   dialog.run(**option)      def run_trapped(args):   try:   dlg = parse(sys.argv[1:])   except:   import traceback   from hggtk.dialog import error_dialog   tr = traceback.format_exc()   print tr   error_dialog(None, "Error executing hgproc", tr)    if __name__=='__main__':   #dlg = parse(['-c', 'help', '--', '-v'])   #dlg = parse(['-c', 'log', '--root', 'c:\hg\h1', '--', '-l1'])   #dlg = parse(['-c', 'status', '--root', 'c:\hg\h1', ])   #dlg = parse(['-c', 'add', '--root', 'c:\hg\h1', '--listfile', 'c:\\hg\\h1\\f1', '--notify'])   #dlg = parse(['-c', 'rollback', '--root', 'c:\\hg\\h1'])   print "hgproc sys.argv =", sys.argv   dlg = run_trapped(sys.argv[1:])
 
328
329
330
 
 
 
 
 
 
 
331
332
333
 
 
 
334
335
336
 
339
340
341
 
 
 
 
 
 
 
 
 
342
343
344
 
549
550
551
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
553
554
 
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
 
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
 
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
@@ -328,9 +328,19 @@
  self._init, icon="menucreaterepos.ico",   state=os.path.isdir(rpath)))   else: + for f in self._filenames: + if f.endswith('.hgignore'): + result.append(TortoiseMenu(_("Modify ignore filter"), + _("Modify repository ignore filter"), + self._hgignore, icon="general.ico")) # needs ico + break +   result.append(TortoiseMenu(_("View File Status"),   _("Repository status"),   self._status, icon="menushowchanged.ico")) + result.append(TortoiseMenu(_("(Un)Shelve Changes"), + _("Shelve repository changes"), + self._shelve, icon="general.ico")) # needs ico     # Visual Diff (any extdiff command)   has_vdiff = repo.ui.config('tortoisehg', 'vdiff', '') != '' @@ -339,6 +349,15 @@
  self._vdiff, icon="TortoiseMerge.ico",   state=has_vdiff))   + if len(self._filenames) == 0: + result.append(TortoiseMenu(_("Guess Renames"), + _("Detect renames and copies"), + self._guess_rename, icon="general.ico")) # needs ico + elif len(self._filenames) == 1: + result.append(TortoiseMenu(_("Rename file"), + _("Rename file or directory"), + self._rename, icon="general.ico")) # needs ico +   result.append(TortoiseMenu(_("Add Files"),   _("Add files to Hg repository"),   self._add, icon="menuadd.ico")) @@ -549,6 +568,22 @@
  def _init(self, parent_window):   self._run_dialog('init')   + def _shelve(self, parent_window): + self._run_dialog('shelve') + + def _hgignore(self, parent_window): + self._run_dialog('hgignore') + + def _rename(self, parent_window): + src = self._filenames[0] + root = self._folder + cmdopts = "--verbose" + open_dialog('rename', cmdopts, root, filelist=[src]) + + def _guess_rename(self, parent_window): + root = self._folder + open_dialog('rename', '--detect', root) +   def _status(self, parent_window):   self._run_dialog('status')