Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

merge with Simon

Changeset ac1a90bf293b

Parents dd3702788cde

Parents aaff0d60ad32

by Steve Borho

Changes to 5 files · Browse files at ac1a90bf293b Showing diff from parent dd3702788cde aaff0d60ad32 Diff from another changeset...

 
261
262
263
264
 
 
 
265
266
267
 
261
262
263
 
264
265
266
267
268
269
@@ -261,7 +261,9 @@
  cachethg.MODIFIED: ('cvs-modified', 'modified'),   cachethg.UNKNOWN: ('new', 'unrevisioned'),   cachethg.IGNORED: (None, 'ignored'), - cachethg.NOT_IN_REPO: (None, '')} + cachethg.NOT_IN_REPO: (None, ''), + cachethg.ROOT: ('generic', 'root'), + cachethg.UNRESOLVED: ('cvs-confilict', 'unresolved')}   emblem, status = cache2state.get(cachestate, (None, '?'))   return emblem, status  
 
1
2
 
3
4
5
 
35
36
37
38
39
40
41
42
43
44
 
 
 
 
 
45
46
47
 
68
69
70
71
 
 
72
73
74
 
94
95
96
97
 
98
99
 
100
101
102
 
106
107
108
109
 
110
111
112
 
115
116
117
118
 
119
120
121
 
123
124
125
126
 
127
128
129
130
131
 
132
133
134
 
143
144
145
146
 
147
148
149
150
151
 
152
153
154
155
156
 
157
158
159
 
164
165
166
167
 
168
169
170
 
 
 
171
172
173
174
175
176
177
178
179
180
181
 
 
 
 
 
 
 
 
 
 
 
 
 
182
183
184
185
186
187
188
 
 
189
190
191
192
193
194
195
 
 
1
 
2
3
4
5
 
35
36
37
 
 
 
 
 
 
 
38
39
40
41
42
43
44
45
 
66
67
68
 
69
70
71
72
73
 
93
94
95
 
96
97
 
98
99
100
101
 
105
106
107
 
108
109
110
111
 
114
115
116
 
117
118
119
120
 
122
123
124
 
125
126
127
128
129
 
130
131
132
133
 
142
143
144
 
145
146
147
148
149
 
150
151
152
153
154
 
155
156
157
158
 
163
164
165
 
166
167
168
 
169
170
171
172
173
174
 
 
 
 
 
 
 
 
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
 
 
 
192
193
194
195
196
197
198
 
 
199
@@ -1,5 +1,5 @@
 import os -from mercurial import hg, cmdutil, util, ui +from mercurial import hg, cmdutil, util, ui, node, merge  import thgutil  import sys  try: @@ -35,13 +35,11 @@
  def debugf(str, args=None):   pass   -UNCHANGED = "unchanged" -ADDED = "added" -MODIFIED = "modified" -UNKNOWN = "unknown" -IGNORED = "ignored" -NOT_IN_REPO = "n/a" -ROOT = "root" +STATUS_STATES = 'MAR!?IC' +MODIFIED, ADDED, REMOVED, DELETED, UNKNOWN, IGNORED, UNCHANGED = STATUS_STATES +NOT_IN_REPO = ' ' +ROOT = "r" +UNRESOLVED = 'U'    # file status cache  overlay_cache = {} @@ -68,7 +66,8 @@
  """   Get the state of a given path in source control.   """ - return get_states(upath, repo)[-1] + states = get_states(upath, repo) + return states and states[0] or NOT_IN_REPO      def get_states(upath, repo=None): @@ -94,9 +93,9 @@
  if not status:   if os.path.isdir(os.path.join(path, '.hg')):   add(path, ROOT) - status = ROOT, + status = ROOT   else: - status = overlay_cache.get(pdir, [NOT_IN_REPO]) + status = overlay_cache.get(pdir, NOT_IN_REPO)   debugf("%s: %s (cached)", (path, status))   return status   else: @@ -106,7 +105,7 @@
  # path is a drive   if path.endswith(":\\"):   add(path, NOT_IN_REPO) - return [NOT_IN_REPO] + return NOT_IN_REPO   # open repo   if cache_pdir == pdir:   root = cache_root @@ -115,7 +114,7 @@
  root = thgutil.find_root(path)   if root == path:   add(path, ROOT) - return [ROOT] + return ROOT   cache_root = root   cache_pdir = pdir   @@ -123,12 +122,12 @@
  debugf("_get_state: not in repo")   overlay_cache = {None: None}   cache_tick_count = GetTickCount() - return [NOT_IN_REPO] + return NOT_IN_REPO   debugf("_get_state: root = " + root)   hgdir = os.path.join(root, '.hg', '')   if pdir == hgdir[:-1] or pdir.startswith(hgdir):   add(pdir, NOT_IN_REPO) - return [NOT_IN_REPO] + return NOT_IN_REPO   try:   tc1 = GetTickCount()   if not repo or (repo.root != root and repo.root != os.path.realpath(root)): @@ -143,17 +142,17 @@
  debugf("%s: overlayicons disabled", path)   overlay_cache = {None: None}   cache_tick_count = GetTickCount() - return [NOT_IN_REPO] + return NOT_IN_REPO   except RepoError:   # We aren't in a working tree   debugf("%s: not in repo", pdir)   add(pdir, IGNORED) - return [IGNORED] + return IGNORED   except StandardError, e:   debugf("error while handling %s:", pdir)   debugf(e)   add(pdir, UNKNOWN) - return [UNKNOWN] + return UNKNOWN   # get file status   tc1 = GetTickCount()   @@ -164,32 +163,37 @@
  except util.Abort, inst:   debugf("abort: %s", inst)   debugf("treat as unknown : %s", path) - return [UNKNOWN] + return UNKNOWN     debugf("status() took %g ticks", (GetTickCount() - tc1)) - modified, added, removed, deleted, unknown, ignored, clean = repostate + mergestate = repo.dirstate.parents()[1] != node.nullid and \ + hasattr(merge, 'mergestate') +   # cached file info   tc = GetTickCount()   overlay_cache = {} - for grp, st in ( - (ignored, IGNORED), - (unknown, UNKNOWN), - (clean, UNCHANGED), - (added, ADDED), - (removed, MODIFIED), - (deleted, MODIFIED), - (modified, MODIFIED)): + add(root, ROOT) + states = STATUS_STATES + if mergestate: + mstate = merge.mergestate(repo) + unresolved = [f for f in mstate if mstate[f] == 'u'] + if unresolved: + modified = repostate[0] + modified[:] = set(modified) - set(unresolved) + repostate.insert(0, unresolved) + states = [UNRESOLVED] + states + states = zip(repostate, states) + states[-1], states[-2] = states[-2], states[-1] #clean before ignored + for grp, st in states:   add_dirs(grp)   for f in grp:   fpath = os.path.join(root, os.path.normpath(f))   add(fpath, st) - add(root, ROOT) - status = overlay_cache.get(path, [UNKNOWN]) - debugf("\n%s: %s", (path, status)) + status = overlay_cache.get(path, UNKNOWN) + debugf("%s: %s", (path, status))   cache_tick_count = GetTickCount()   return status      def add(path, state): - c = overlay_cache.setdefault(path, []) - c.append(state) + overlay_cache[path] = overlay_cache.get(path, '') + state
 
58
59
60
61
 
62
63
64
 
93
94
95
96
97
98
 
 
 
 
 
 
 
 
 
58
59
60
 
61
62
63
64
 
93
94
95
 
 
 
96
97
98
99
100
101
102
103
@@ -58,7 +58,7 @@
  try:   cache_lock.acquire()   tc = win32api.GetTickCount() - if cachethg.get_state(path) == self.state: + if cachethg.get_state(path) in self.state:   return S_OK   return S_FALSE   finally: @@ -93,6 +93,11 @@
  globals()[classname] = cls    _overlay_classes = [] -make_icon_overlay("Changed", "Modified", cachethg.MODIFIED, "{4D0F33E1-654C-4A1B-9BE8-E47A98752BAB}") -make_icon_overlay("Unchanged", "Normal", cachethg.UNCHANGED, "{4D0F33E2-654C-4A1B-9BE8-E47A98752BAB}") -make_icon_overlay("Added", "Added", cachethg.ADDED, "{4D0F33E3-654C-4A1B-9BE8-E47A98752BAB}") +THG_CLSID = "{4D0F33E1-654C-4A1B-9BE8-E47A98752BAB}" +modified = cachethg.REMOVED + cachethg.DELETED + cachethg.MODIFIED + +make_icon_overlay("Changed", "Modified", modified, THG_CLSID) +make_icon_overlay("Unchanged", "Normal", cachethg.UNCHANGED, THG_CLSID) +make_icon_overlay("Added", "Added", cachethg.ADDED, THG_CLSID) +make_icon_overlay("Ignored", "Ignored", cachethg.IGNORED, THG_CLSID) +make_icon_overlay("Conflict", "Conflict", cachethg.UNRESOLVED, THG_CLSID)
 
147
148
149
150
 
151
152
153
154
155
156
157
 
158
159
160
 
147
148
149
 
150
151
152
153
154
155
156
 
157
158
159
160
@@ -147,14 +147,14 @@
  drag_repo = None   drop_repo = None   - drag_path = self.srcfiles[0] + drag_path = srcfiles[0]   drag_repo = open_repo(drag_path)   if not drag_repo:   return []   if drag_repo and drag_repo.root != drag_path:   return [] # dragged item must be a hg repo root directory   - drop_repo = open_repo(self._folder) + drop_repo = open_repo(destfolder)     menu = thg_menu(drag_repo.ui, self.name)   menu.add_menu(_("Create Clone"),
Change 1 of 2 Show Changes Only tortoisehg.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
127
128
129
130
131
132
133
134
135
136
137
138
139
 #  # Simple TortoiseSVN-like Mercurial plugin for the Windows Shell  # Published under the GNU GPL, v2 or later.  # Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>  # Copyright (C) 2007 Henry Ludemann <misc@hl.id.au>  # Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>  #    import pythoncom  from mercurial import demandimport  demandimport.ignore.append('win32traceutil')  demandimport.enable()    import os  import sys  import _winreg    # shell extension classes  from tortoise.contextmenu import ContextMenuExtension -from tortoise.iconoverlay import ChangedOverlay, AddedOverlay, UnchangedOverlay +import tortoise.iconoverlay + +overlays = [getattr(tortoise.iconoverlay, overlay) for overlay in + tortoise.iconoverlay.__dict__ if overlay.endswith('Overlay')]    bin_path = os.path.dirname(os.path.join(os.getcwd(), sys.argv[0]))  print "bin path = ", bin_path    def check_tortoise_overlays():   # TortoiseOverlays must be installed, and we must be able to write there.   try:   hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,   r"Software\TortoiseOverlays", 0,   _winreg.KEY_ALL_ACCESS)   except WindowsError:   print "TortoiseOverlays is not installed."   sys.exit(1)    # TortoiseHg registry setup  def register_tortoise_path(unregister=False):   key = r"Software\TortoiseHg"   cat = _winreg.HKEY_LOCAL_MACHINE   if (unregister):   try:   _winreg.DeleteKey(cat, key)   print "TortoiseHg unregistered"   except WindowsError:   print 'TortoiseHg was not registered'   else:   _winreg.SetValue(cat, key, _winreg.REG_SZ, bin_path)   print "TortoiseHg registered"    # for COM registration via py2exe  def DllRegisterServer():   check_tortoise_overlays()   RegisterServer(ContextMenuExtension) - RegisterServer(ChangedOverlay) - RegisterServer(AddedOverlay) - RegisterServer(UnchangedOverlay) + for overlay in overlays: + RegisterServer(overlay)   register_tortoise_path()    # for COM registration via py2exe  def DllUnregisterServer():   UnregisterServer(ContextMenuExtension) - UnregisterServer(ChangedOverlay) - UnregisterServer(AddedOverlay) - UnregisterServer(UnchangedOverlay) + for for overlay in overlays: + UnregisterServer(overlay)   register_tortoise_path(unregister=True)    def RegisterServer(cls):   # Add mercurial to the library path   try:   import mercurial   except ImportError:   from win32com.server import register   register.UnregisterClasses(cls)   raise "Error: Failed to find mercurial module!"     hg_path = os.path.dirname(os.path.dirname(mercurial.__file__))   try:   key = "CLSID\\%s\\PythonCOMPath" % cls._reg_clsid_   path = _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, key)   _winreg.SetValue(_winreg.HKEY_CLASSES_ROOT, key, _winreg.REG_SZ, "%s;%s" % (path, hg_path))   except:   pass     # Add the appropriate shell extension registry keys   for category, keyname, values in cls.registry_keys:   hkey = _winreg.CreateKey(category, keyname)   for (name, val) in values:   # todo: handle ints?   _winreg.SetValueEx(hkey, name, 0, _winreg.REG_SZ, val)     # register the extension on Approved list   try:   apath = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved'   key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, apath, 0, _winreg.KEY_WRITE)   _winreg.SetValueEx(key, cls._reg_clsid_, 0, _winreg.REG_SZ, 'TortoiseHg')   except:   pass     print cls._reg_desc_, "registration complete."    def UnregisterServer(cls):   for category, keyname, values in cls.registry_keys:   hkey = _winreg.OpenKey(category, keyname, 0, _winreg.KEY_ALL_ACCESS)   for (name, val) in values:   # todo: handle ints?   try:   _winreg.DeleteValue(hkey, name)   except WindowsError, exc:   print "Failed to remove registry key %s: %s" % (keyname, exc)     # unregister the extension from Approved list   try:   apath = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved'   key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, apath, 0, _winreg.KEY_WRITE)   _winreg.DeleteValue(key, cls._reg_clsid_)   except:   pass     print cls._reg_desc_, "unregistration complete."    if __name__=='__main__':   check_tortoise_overlays()     from win32com.server import register   register.UseCommandLine(ContextMenuExtension,   finalize_register = lambda: RegisterServer(ContextMenuExtension),   finalize_unregister = lambda: UnregisterServer(ContextMenuExtension))     for cls in (ChangedOverlay, AddedOverlay, UnchangedOverlay):   register.UseCommandLine(cls,   finalize_register = lambda: RegisterServer(cls),   finalize_unregister = lambda: UnregisterServer(cls))     if "--unregister" in sys.argv[1:]:   register_tortoise_path(unregister=True)   else:   register_tortoise_path()