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

rpcserver: remove unneeded code

add stub for update_thgstatus

Changeset 8d68246470a3

Parent 683ef5cad6af

by Adrian Buehlmann

Changes to one file · Browse files at 8d68246470a3 Showing diff from parent 683ef5cad6af Diff from another changeset...

 
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 
 
 
179
180
181
 
238
239
240
241
242
243
244
245
246
247
248
 
249
250
251
 
253
254
255
256
257
258
259
260
261
262
 
26
27
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
30
31
32
33
34
 
91
92
93
 
 
 
 
 
94
95
 
96
97
98
99
 
101
102
103
 
 
104
 
105
106
107
@@ -26,156 +26,9 @@
  sys.stderr.write(str(a))  ui.ui.write_err = write_err   -# file/directory status -UNCHANGED = "unchanged" -ADDED = "added" -MODIFIED = "modified" -UNKNOWN = "unknown" -NOT_IN_REPO = "n/a" - -# file status cache -CACHE_TIMEOUT = 5000 -overlay_cache = {} -cache_tick_count = 0 -cache_root = None -cache_pdir = None - -# some misc constants -S_OK = 0 -S_FALSE = 1 - -def add_dirs(list): - dirs = set() - for f in list: - dir = os.path.dirname(f) - if dir in dirs: - continue - while dir: - dirs.add(dir) - dir = os.path.dirname(dir) - list.extend(dirs) - -def get_hg_state(upath): - """ - Get the state of a given path in source control. - """ - global overlay_cache, cache_tick_count - global cache_root, cache_pdir - - #print "called: _get_state(%s)" % path - tc = win32api.GetTickCount() - - try: - # handle some Asian charsets - path = upath.encode('mbcs') - except: - path = upath - - print "get_hg_state: path =", path - if not path: - return UNKNOWN - - # check if path is cached - pdir = os.path.dirname(path) - if cache_pdir == pdir and overlay_cache: - if tc - cache_tick_count < CACHE_TIMEOUT: - try: - status = overlay_cache[path] - except: - status = UNKNOWN - print "%s: %s (cached)" % (path, status) - return status - else: - print "Timed out!!" - overlay_cache.clear() - - # path is a drive - if path.endswith(":\\"): - overlay_cache[path] = UNKNOWN - return NOT_IN_REPO - - # open repo - if cache_pdir == pdir: - root = cache_root - else: - print "find new root" - cache_pdir = pdir - cache_root = root = paths.find_root(pdir) - print "_get_state: root = ", root - if root is None: - print "_get_state: not in repo" - overlay_cache = {None : None} - cache_tick_count = win32api.GetTickCount() - return NOT_IN_REPO - - try: - tc1 = win32api.GetTickCount() - repo = hg.repository(ui.ui(), path=root) - print "hg.repository() took %d ticks" % (win32api.GetTickCount() - tc1) - - # check if to display overlay icons in this repo - global_opts = ui.ui().configlist('tortoisehg', 'overlayicons', []) - repo_opts = repo.ui.configlist('tortoisehg', 'overlayicons', []) - - print "%s: global overlayicons = " % path, global_opts - print "%s: repo overlayicons = " % path, repo_opts - is_netdrive = paths.netdrive_status(path) is not None - if (is_netdrive and 'localdisks' in global_opts) \ - or 'False' in repo_opts: - print "%s: overlayicons disabled" % path - overlay_cache = {None : None} - cache_tick_count = win32api.GetTickCount() - return NOT_IN_REPO - except _repo.RepoError: - # We aren't in a working tree - print "%s: not in repo" % dir - overlay_cache[path] = UNKNOWN - return NOT_IN_REPO - - # get file status - tc1 = win32api.GetTickCount() - - modified, added, removed, deleted = [], [], [], [] - unknown, ignored, clean = [], [], [] - files = [] - try: - matcher = cmdutil.match(repo, [pdir]) - modified, added, removed, deleted, unknown, ignored, clean = \ - repo.status(match=matcher, ignored=True, - clean=True, unknown=True) - - # add directory status to list - for grp in (clean,modified,added,removed,deleted,ignored,unknown): - add_dirs(grp) - except util.Abort, inst: - print "abort: %s" % inst - print "treat as unknown : %s" % path - return UNKNOWN - - print "status() took %d ticks" % (win32api.GetTickCount() - tc1) - - # cached file info - tc = win32api.GetTickCount() - overlay_cache = {} - for grp, st in ( - (ignored, UNKNOWN), - (unknown, UNKNOWN), - (clean, UNCHANGED), - (added, ADDED), - (removed, MODIFIED), - (deleted, MODIFIED), - (modified, MODIFIED)): - for f in grp: - fpath = os.path.join(repo.root, os.path.normpath(f)) - overlay_cache[fpath] = st - - if path in overlay_cache: - status = overlay_cache[path] - else: - status = overlay_cache[path] = UNKNOWN - print "%s: %s" % (path, status) - cache_tick_count = win32api.GetTickCount() - return status +def update_thgstatus(path): + print "update thgstatus for path '%s'" % path + pass    class PipeServer:   def __init__(self): @@ -238,14 +91,9 @@
    if not data:   raise SystemExit # signal by dispatch terminate - - try: - data = data.decode('mbcs') - except: - pass     try: - status = get_hg_state(data) + update_thgstatus(data)   except SystemExit:   raise SystemExit # interrupted by thread2.terminate()   except: @@ -253,10 +101,7 @@
  print "WARNING: something went wrong in get_hg_state()"   print traceback.format_exc()   status = "ERROR" - - win32file.WriteFile(pipeHandle, status)   - # And disconnect from the client.   win32pipe.DisconnectNamedPipe(pipeHandle)   except win32file.error:   # Client disconnected without sending data