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

shellext: add InitStatus class to help diagnose installation problems

InitStatus checks if all overlay handlers we need have been initialized.
If not, it prints an error line in the debug trace output. Example output:
[220] [THG] ***** InitStatus: error: uninitialized handlers: added, notinrepo

The check is done on context menu actions and whenever DllMain is called
(happens periodically). So this won't get overlooked in debug trace.

Changeset e859ae81c80a

Parent b5c317e3927b

by Adrian Buehlmann

Changes to 6 files · Browse files at e859ae81c80a Showing diff from parent b5c317e3927b Diff from another changeset...

 
5
6
7
 
8
9
10
 
417
418
419
 
420
421
422
 
616
617
618
 
619
620
621
622
 
623
 
5
6
7
8
9
10
11
 
418
419
420
421
422
423
424
 
618
619
620
621
622
623
624
625
626
627
@@ -5,6 +5,7 @@
 #include "Dirstatecache.h"  #include "Thgstatus.h"  #include "Winstat.h" +#include "InitStatus.h"  #include <map>     @@ -417,6 +418,7 @@
    InsertMenu(hMenu, indexMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);   + InitStatus::check();   return ResultFromShort(idCmd - idCmdFirst);  }   @@ -616,8 +618,10 @@
  if (cmd == "thgstatus")   {   Thgstatus::remove(cwd); + InitStatus::check();   return;   }     LaunchCommand(hgcmd, cwd); + InitStatus::check();  }
Change 1 of 1 Show Entire File win32/​shellext/​InitStatus.cpp 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
@@ -0,0 +1,58 @@
+ +// 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/>. + +#include "stdafx.h" + +#include "InitStatus.h" + + +InitStatus& InitStatus::inst() +{ + static InitStatus s; + return s; +} + + +void InitStatus::add(std::string& s, const char* missing) +{ + if (!s.empty()) + s += ", "; + s += missing; +} + + +std::string InitStatus::check() +{ + const InitStatus& self = inst(); + std::string missing; + + if (self.unchanged_ == 0) + add(missing, "unchanged"); + if (self.added_ == 0) + add(missing, "added"); + if (self.modified_ == 0) + add(missing, "modified"); + if (self.notinrepo_ == 0) + add(missing, "notinrepo"); + + if (missing.empty()) + return ""; + + std::string res = "InitStatus: error: uninitialized handlers: "; + res += missing; + TDEBUG_TRACE("***** " << res); + return res; +}
Change 1 of 1 Show Entire File win32/​shellext/​InitStatus.h 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
@@ -0,0 +1,35 @@
+ +// 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/>. + +#include <string> + +class InitStatus +{ +public: + int unchanged_; + int added_; + int modified_; + int notinrepo_; + + static InitStatus& inst(); + static std::string check(); + +private: + InitStatus() + : unchanged_(0), added_(0), modified_(0), notinrepo_(0) {} + + static void add(std::string& s, const char* missing); +};
 
5
6
7
 
8
9
10
 
5
6
7
8
9
10
11
@@ -5,6 +5,7 @@
  Winstat.o    OBJECTS_THGSGELL = $(OBJECTS_DIRSTATE) \ + InitStatus.o \   ContextMenu.o \   IconOverlay.o \   ShellExt.o \
 
5
6
7
 
8
9
10
 
5
6
7
8
9
10
11
@@ -5,6 +5,7 @@
  Winstat.obj    OBJECTS_THGSGELL = $(OBJECTS_DIRSTATE) \ + InitStatus.obj \   ContextMenu.obj \   IconOverlay.obj \   ShellExt.obj \
 
2
3
4
 
5
6
7
 
53
54
55
 
 
 
56
57
58
 
76
77
78
 
79
80
81
 
83
84
85
 
86
87
88
 
90
91
92
 
93
94
95
 
97
98
99
 
100
101
102
 
2
3
4
5
6
7
8
 
54
55
56
57
58
59
60
61
62
 
80
81
82
83
84
85
86
 
88
89
90
91
92
93
94
 
96
97
98
99
100
101
102
 
104
105
106
107
108
109
110
@@ -2,6 +2,7 @@
 #include "ShellExt.h"  #include "TortoiseUtils.h"  #include "StringUtils.h" +#include "InitStatus.h"  #include <olectl.h>    #define INITGUID @@ -53,6 +54,9 @@
  _UnloadResources();   }   + if (g_cRefThisDll > 0) + InitStatus::check(); +   return 1;  }   @@ -76,6 +80,7 @@
  CDllRegSxClassFactory *pcf =   new CDllRegSxClassFactory(TORTOISE_OLE_UNCHANGED);   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg0"); + ++InitStatus::inst().unchanged_;   return pcf->QueryInterface(riid, ppvOut);   }   else if (IsEqualIID(rclsid, CLSID_TortoiseHg1)) @@ -83,6 +88,7 @@
  CDllRegSxClassFactory *pcf =   new CDllRegSxClassFactory(TORTOISE_OLE_ADDED);   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg1"); + ++InitStatus::inst().added_;   return pcf->QueryInterface(riid, ppvOut);   }   else if (IsEqualIID(rclsid, CLSID_TortoiseHg2)) @@ -90,6 +96,7 @@
  CDllRegSxClassFactory *pcf =   new CDllRegSxClassFactory(TORTOISE_OLE_MODIFIED);   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg2"); + ++InitStatus::inst().modified_;   return pcf->QueryInterface(riid, ppvOut);   }   else if (IsEqualIID(rclsid, CLSID_TortoiseHg6)) @@ -97,6 +104,7 @@
  CDllRegSxClassFactory *pcf =   new CDllRegSxClassFactory(TORTOISE_OLE_NOTINREPO);   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg6"); + ++InitStatus::inst().notinrepo_;   return pcf->QueryInterface(riid, ppvOut);   }