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

thgstatus.py: implement --remove and --show

Changeset 06f4688b4143

Parent 80264ebb8212

by Adrian Buehlmann

Changes to one file · Browse files at 06f4688b4143 Showing diff from parent 80264ebb8212 Diff from another changeset...

 
17
18
19
 
20
21
22
 
24
25
26
 
 
 
27
28
29
 
37
38
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41
42
 
48
49
50
51
 
 
 
52
53
54
55
56
57
 
 
 
58
59
 
17
18
19
20
21
22
23
 
25
26
27
28
29
30
31
32
33
 
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
69
70
71
 
72
73
74
75
76
77
78
79
 
80
81
82
83
84
@@ -17,6 +17,7 @@
   from mercurial.i18n import _  from mercurial import commands +import os    def cachefilepath(repo):   return repo.root + "/.hg/thgstatus" @@ -24,6 +25,9 @@
 def dirname(f):   return '/'.join(f.split('/')[:-1])   +def showentry(f, e): + f("%s %s\n" % (e[0], e[1:-1])) +  def thgstatus(ui, repo, **opts):   '''update directory status cache for TortoiseHg   @@ -37,6 +41,23 @@
  If the file is empty, then the repo is clean.   '''   + 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 +   repostate = repo.status()   modified, added, removed, deleted, unknown, ignored, clean = repostate   dirstatus = {} @@ -48,12 +69,16 @@
  dirstatus[dirname(fn)] = 'r'   f = open(cachefilepath(repo), 'wb')   for dn in sorted(dirstatus): - f.write(dirstatus[dn] + dn + '\n') + e = dirstatus[dn] + dn + '\n' + f.write(e) + showentry(ui.note, e)   f.close()    cmdtable = {   'thgstatus':   (thgstatus, - [ ], + [ ('', 'remove', None, _('remove the status file')), + ('s', 'show', None, _('just show the contents of ' + 'the status file (no update)')) ],   _('hg thgstatus')),  }