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 Adrian

Changeset e32407c7a099

Parents cb03cecd4876

Parents 2c98ae1e0f42

by Steve Borho

Changes to 7 files · Browse files at e32407c7a099 Showing diff from parent cb03cecd4876 2c98ae1e0f42 Diff from another changeset...

 
1
2
3
4
 
 
5
6
7
 
 
 
1
2
 
 
3
4
5
 
 
6
7
@@ -1,7 +1,7 @@
 @echo off   -:: calls hg thgstatus for all directories in current dir - +:: calls hgtk thgstatus for all directories in current dir +  for /F "tokens=*" %%G in ('dir /b /A:D') do ( - echo %%G - hg -R %%G thgstatus --notify %%G) + echo updating %%G + call hgtk -R %%G thgstatus --notify %%G)
Change 1 of 1 Show Entire File hgext/​thgstatus.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,114 +0,0 @@
-# thgstatus.py - TortoiseHg status cache extension for Mercurial -# -# Copyright (C) 2009 Adrian Buehlmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -'''update directory status cache for TortoiseHg''' - -from mercurial.i18n import _ -from mercurial import commands -import os -import time - -def cachefilepath(repo): - return repo.join("thgstatus") - -def dirname(f): - return f[:max(0, f.rfind("/"))] - -def showentry(f, e): - f("%s %s\n" % (e[0], e[1:-1])) - -def thgstatus(ui, repo, **opts): - '''update directory status cache for TortoiseHg - - Caches the information provided by 'hg status' in the file .hg/thgstatus - which can then be used by the TortoiseHg shell extension to display - overlay icons for directories. - - The file .hg/thgstatus contains one line for each directory that has - removed, modified or added files (in that order of preference). Each line - consists of one char for the status of the directory (r, m or a), followed - by the relative path of the directory in the repo. - If the file is empty, then the repo is clean. - - Specify --delay to wait until the system clock ticks to the next second - before accessing the dirstate. This is useful when the dirstate contains - unset entries (in output of "hg debugstate"). unset entries happen if the - dirstate was updated within the same second as the respective file in the - working tree was updated. This happens with a high probability for example - when cloning a repo. The TortoiseHg shell extension will display unset - dirstate entries as (potentially false) modified. Specifying --delay ensures - that there are no unset entries in the dirstate. - ''' - - if opts.get('remove'): - try: - os.remove(cachefilepath(repo)) - except OSError: - pass - return - - if opts.get('show'): - try: - f = open(cachefilepath(repo), 'rb') - for e in f: - showentry(ui.status, e) - f.close() - except IOError: - ui.status("*no status*\n") - return - - if opts.get('delay'): - tref = time.time() - tdelta = float(int(tref)) + 1.0 - tref - if (tdelta > 0.0): - time.sleep(tdelta) - - repostate = repo.status() - modified, added, removed, deleted = repostate[:4] - dirstatus = {} - for fn in added: - dirstatus[dirname(fn)] = 'a' - for fn in modified: - dirstatus[dirname(fn)] = 'm' - for fn in removed + deleted: - dirstatus[dirname(fn)] = 'r' - - f = open(cachefilepath(repo), 'wb') - for dn in sorted(dirstatus): - e = dirstatus[dn] + dn + '\n' - f.write(e) - showentry(ui.note, e) - f.close() - - if opts.get('notify'): - from mercurial import demandimport - demandimport.disable() - from thgutil import shlib - shlib.shell_notify(opts.get('notify')) - demandimport.enable() - ui.note("thgstatus updated\n") - -cmdtable = { - 'thgstatus': - (thgstatus, - [ ('', 'delay', None, _('wait until the second ticks over')), - ('n', 'notify', [], _('notify the shell for path(s) given')), - ('', 'remove', None, _('remove the status file')), - ('s', 'show', None, _('just show the contents of ' - 'the status file (no update)')) ], - _('hg thgstatus [OPTION]...')), -}
Change 1 of 3 Show Entire File hggtk/​hgtk.py Stacked
 
175
176
177
 
178
179
180
 
232
233
234
235
236
237
 
 
 
238
239
240
 
612
613
614
615
 
 
 
 
 
 
 
616
617
618
 
175
176
177
178
179
180
181
 
233
234
235
 
 
 
236
237
238
239
240
241
 
613
614
615
 
616
617
618
619
620
621
622
623
624
625
@@ -175,6 +175,7 @@
  lui = ui   if options['repository']:   path = lui.expandpath(options['repository']) + cmdoptions['repository'] = path     _loaded = {}   extensions.loadall(ui) @@ -232,9 +233,9 @@
  shlib.shell_notify([os.getcwd()])    def thgstatus(ui, *pats, **opts): - """update thgstatus""" - shlib.update_thgstatus(ui, paths.find_root()) - shlib.shell_notify([os.getcwd()]) + """update TortoiseHg status cache""" + from hggtk.thgstatus import run + run(ui, *pats, **opts)    def clone(ui, *pats, **opts):   """clone tool""" @@ -612,7 +613,13 @@
  (serve,   [('', 'webdir-conf', '', _('name of the webdir config file'))],   _('hgtk serve [OPTION]...')), - "thgstatus": (thgstatus, [], _('hgtk thgstatus')), + "thgstatus": (thgstatus, + [('', 'delay', None, _('wait until the second ticks over')), + ('n', 'notify', [], _('notify the shell for path(s) given')), + ('', 'remove', None, _('remove the status cache')), + ('s', 'show', None, _('show the contents of the' + ' status cache (no update)'))], + _('hgtk thgstatus [OPTION]')),   "^update|checkout|co": (update,   [('r', 'rev', '', _('revision to update'))],   ('hgtk update')),
Change 1 of 1 Show Entire File hggtk/​thgstatus.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
@@ -0,0 +1,47 @@
+# +# thgstatus.py - update TortoiseHg status cache +# +# Copyright (C) 2009 Adrian Buehlmann +# + +'''update TortoiseHg status cache''' + +from mercurial import hg +from thgutil import shlib +import os + +def cachefilepath(repo): + return repo.join("thgstatus") + +def dirname(f): + return f[:max(0, f.rfind("/"))] + +def run(_ui, *pats, **opts): + path = '.' + if opts.get('repository'): + path = opts.get('repository') + repo = hg.repository(_ui, path) + + if opts.get('remove'): + try: + os.remove(cachefilepath(repo)) + except OSError: + pass + return + + if opts.get('show'): + try: + f = open(cachefilepath(repo), 'rb') + for e in f: + _ui.status("%s %s\n" % (e[0], e[1:-1])) + f.close() + except IOError: + _ui.status("*no status*\n") + return + + wait = opts.get('delay') is not None + shlib.update_thgstatus(_ui, path, wait=wait) + + if opts.get('notify'): + shlib.shell_notify(opts.get('notify')) + _ui.note("thgstatus updated\n")
Change 1 of 1 Show Entire File thgutil/​shlib.py Stacked
 
94
95
96
97
 
 
 
98
99
100
 
94
95
96
 
97
98
99
100
101
102
@@ -94,7 +94,9 @@
  dirstatus[dirname(fn)] = 'r'   f = open(repo.join("thgstatus"), 'wb')   for dn in sorted(dirstatus): - f.write(dirstatus[dn] + dn + '\n') + s = dirstatus[dn] + f.write(s + dn + '\n') + ui.note("%s %s\n" % (s, dn))   f.close()    else:
 
481
482
483
 
484
485
486
 
481
482
483
484
485
486
487
@@ -481,6 +481,7 @@
  std::string hgroot = GetHgRepoRoot(cwd);   if (!hgroot.empty())   Dirstatecache::invalidate(hgroot); + hgcmd += " --notify .";   }     LaunchCommand(hgcmd, cwd);
 
35
36
37
 
 
 
 
38
39
40
 
35
36
37
38
39
40
41
42
43
44
@@ -35,6 +35,10 @@
  int read(FILE* f, std::vector<char>& relpath);   char status(const Winstat& stat) const;   + bool unset() const { + return (state == 'n') && (mode == 0) && (size == -1) && (mtime == -1); + } +  private:   static uint32_t ntohl(uint32_t x)   {