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

rpcserver: simplify and ignore duplicates in same batch

Changeset 2ab806534bd3

Parent 384d2c94ca2c

by Adrian Buehlmann

Changes to one file · Browse files at 2ab806534bd3 Showing diff from parent 384d2c94ca2c Diff from another changeset...

 
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
54
55
56
 
 
 
 
57
58
59
 
63
64
65
66
 
67
68
 
69
70
71
 
75
76
77
78
79
 
80
81
82
83
84
85
86
 
87
88
89
 
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
 
70
71
72
 
73
74
 
75
76
77
78
 
82
83
84
 
 
85
86
 
 
 
 
 
 
87
88
89
90
@@ -37,23 +37,30 @@
 ui.ui.write_err = write_err     -def update_thgstatus(path): - root = paths.find_root(path) - _ui = ui.ui(); - if root is not None: - shlib.update_thgstatus(_ui, root, wait=False) - print "updated repo %s" % root - else: - roots = [] - for f in os.listdir(path): - r = paths.find_root(os.path.join(path, f)) - if r is not None: - roots.append(r) - for r in roots: +def update_batch(batch): + '''updates thgstatus for all paths in batch''' + roots = [] + notifypaths = [] + for path in batch: + r = paths.find_root(path) + if r is None: + for n in os.listdir(path): + r = paths.find_root(os.path.join(path, n)) + if (r is not None) and (r not in roots): + roots.append(r) + notifypaths.append(r) + elif r not in roots: + roots.append(r); + notifypaths.append(path) + if roots: + _ui = ui.ui(); + for r in sorted(roots):   shlib.update_thgstatus(_ui, r, wait=False) - shlib.shell_notify([r])   print "updated repo %s" % r - + if notifypaths: + time.sleep(2) + shlib.shell_notify(notifypaths) + print "shell notified"    requests = Queue.Queue(0)   @@ -63,9 +70,9 @@
  while True:   batch = []   r = requests.get() - print "got request %s (new batch)" % r + print "got request %s (first in batch)" % r   batch.append(r) - print "waiting a bit" + print "wait a bit for additional requests..."   time.sleep(0.2)   try:   while True: @@ -75,15 +82,9 @@
  except Queue.Empty:   pass   n += 1 - msg = "--- batch %i complete with %i requests" - msg += ", processing --" + msg = "--- processing batch %i with %i requests ---"   print msg % (n, len(batch)) - if batch: - for r in batch: - update_thgstatus(r) - time.sleep(2) - shlib.shell_notify(batch) - print "shell notified" + update_batch(batch)    Updater().start()