p4ruby 2017.1.1699426 → 2021.1.2156749

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
37
  #include <ruby.h>
38
38
  #include "undefdups.h"
39
39
  #include <p4/clientapi.h>
40
+ #include <p4/strtable.h>
40
41
  #include <p4/i18napi.h>
41
42
  #include <p4/enviro.h>
42
43
  #include <p4/hostenv.h>
@@ -142,6 +143,21 @@ P4ClientApi::GetEnviroFile()
142
143
  return enviro->GetEnviroFile();
143
144
  }
144
145
 
146
+ void
147
+ P4ClientApi::SetEVar( const char *var, const char *val )
148
+ {
149
+ StrRef sVar( var );
150
+ StrRef sVal( val );
151
+ client.SetEVar( sVar, sVal );
152
+ }
153
+
154
+ const StrPtr *
155
+ P4ClientApi::GetEVar( const char *var )
156
+ {
157
+ StrRef sVar( var );
158
+ return client.GetEVar( sVar );
159
+ }
160
+
145
161
  void
146
162
  P4ClientApi::SetApiLevel( int level )
147
163
  {
@@ -323,6 +339,9 @@ P4ClientApi::Disconnect()
323
339
  // Clear the specdef cache.
324
340
  specMgr.Reset();
325
341
 
342
+ // Clear out any results from the last command
343
+ ui.Reset();
344
+
326
345
  return Qtrue;
327
346
  }
328
347
 
@@ -426,12 +445,6 @@ P4ClientApi::IsIgnored( const char *path )
426
445
  return ignore->Reject( p, client.GetIgnoreFile() );
427
446
  }
428
447
 
429
- VALUE
430
- P4ClientApi::Reset()
431
- {
432
- ui.Reset();
433
- }
434
-
435
448
  //
436
449
  // Run returns the results of the command. If the client has not been
437
450
  // connected, then an exception is raised but errors from Perforce
@@ -764,3 +777,48 @@ P4ClientApi::Except( const char *func, Error *e )
764
777
  Except( func, m.Text() );
765
778
  }
766
779
 
780
+ //
781
+ // SSO Handlers
782
+ //
783
+
784
+ VALUE
785
+ P4ClientApi::SetEnableSSO( VALUE e )
786
+ {
787
+ return ui.EnableSSO( e );
788
+ }
789
+
790
+ VALUE
791
+ P4ClientApi::GetEnableSSO()
792
+ {
793
+ return ui.SSOEnabled();
794
+ }
795
+
796
+ VALUE
797
+ P4ClientApi::GetSSOVars()
798
+ {
799
+ return ui.GetSSOVars();
800
+ }
801
+
802
+ VALUE
803
+ P4ClientApi::SetSSOPassResult( VALUE r )
804
+ {
805
+ return ui.SetSSOPassResult( r );
806
+ }
807
+
808
+ VALUE
809
+ P4ClientApi::GetSSOPassResult()
810
+ {
811
+ return ui.GetSSOPassResult();
812
+ }
813
+
814
+ VALUE
815
+ P4ClientApi::SetSSOFailResult( VALUE r )
816
+ {
817
+ return ui.SetSSOFailResult( r );
818
+ }
819
+
820
+ VALUE
821
+ P4ClientApi::GetSSOFailResult()
822
+ {
823
+ return ui.GetSSOFailResult();
824
+ }
data/ext/P4/p4clientapi.h CHANGED
@@ -73,6 +73,7 @@ public:
73
73
  void SetClient( const char *c ) { client.SetClient( c ); }
74
74
  void SetCwd( const char *c );
75
75
  void SetEnviroFile( const char *c );
76
+ void SetEVar( const char *var, const char *val );
76
77
  void SetHost( const char *h ) { client.SetHost( h ); }
77
78
  void SetIgnoreFile( const char *f ) { client.SetIgnoreFile( f ); }
78
79
  void SetMaxResults( int v ) { maxResults = v; }
@@ -96,6 +97,7 @@ public:
96
97
  const StrPtr &GetCwd() { return client.GetCwd(); }
97
98
  const char * GetEnv( const char *v);
98
99
  const StrPtr *GetEnviroFile();
100
+ const StrPtr *GetEVar(const char *v);
99
101
  const StrPtr &GetHost() { return client.GetHost(); }
100
102
  const StrPtr &GetIgnoreFile() { return client.GetIgnoreFile();}
101
103
  const StrPtr &GetLanguage() { return client.GetLanguage(); }
@@ -121,7 +123,6 @@ public:
121
123
  VALUE Connect(); // P4Exception on error
122
124
  VALUE Connected(); // Return true if connected and not dropped.
123
125
  VALUE Disconnect();
124
- VALUE Reset(); // Clear out any results from the previous command
125
126
 
126
127
  // Executing commands.
127
128
  VALUE Run( const char *cmd, int argc, char * const *argv );
@@ -170,6 +171,15 @@ public:
170
171
  VALUE SetProgress( VALUE progress );
171
172
  VALUE GetProgress() { return ui.GetProgress(); }
172
173
 
174
+ // SSO handler
175
+ VALUE SetEnableSSO( VALUE e );
176
+ VALUE GetEnableSSO();
177
+ VALUE GetSSOVars();
178
+ VALUE SetSSOPassResult( VALUE r );
179
+ VALUE GetSSOPassResult();
180
+ VALUE SetSSOFailResult( VALUE r );
181
+ VALUE GetSSOFailResult();
182
+
173
183
  // Ruby garbage collection
174
184
  void GCMark();
175
185
 
@@ -248,4 +258,3 @@ private:
248
258
  int maxScanRows;
249
259
  int maxLockTime;
250
260
  };
251
-
data/ext/P4/p4result.cpp CHANGED
@@ -57,6 +57,7 @@ P4Result::P4Result()
57
57
  VALUE cP4 = rb_const_get_at( rb_cObject, idP4 );
58
58
  cP4Msg = rb_const_get_at( cP4, idP4Msg );
59
59
 
60
+ Reset();
60
61
  }
61
62
 
62
63
 
@@ -106,3 +106,32 @@ SpecDataRuby::SetLine( SpecElem *sd, int x, const StrPtr *v, Error *e )
106
106
  }
107
107
  return;
108
108
  }
109
+
110
+ void
111
+ SpecDataRuby::Comment ( SpecElem *sd, int x, const char **wv, int nl, Error *e )
112
+ {
113
+ VALUE key;
114
+ VALUE val;
115
+ VALUE ary;
116
+ StrBuf t;
117
+
118
+ key = P4Utils::ruby_string( sd->tag.Text(), sd->tag.Length() );
119
+ val = P4Utils::ruby_string( *wv );
120
+
121
+ if( sd->IsList() )
122
+ {
123
+
124
+ ary = rb_hash_aref( hash, key ); // rb_hash_aref - get the value for hash key
125
+ if( ary == Qnil )
126
+ {
127
+ ary = rb_ary_new();
128
+ rb_hash_aset( hash, key, ary ); // rb_hash_aset(hash, key, value) - set the hash key to value
129
+ }
130
+ rb_ary_store( ary, x, val );
131
+ }
132
+ else
133
+ {
134
+ rb_hash_aset( hash, key, val );
135
+ }
136
+ return;
137
+ }
data/ext/P4/p4specdata.h CHANGED
@@ -44,6 +44,8 @@ class SpecDataRuby : public SpecData
44
44
  virtual StrPtr *GetLine( SpecElem *sd, int x, const char **cmt );
45
45
  virtual void SetLine( SpecElem *sd, int x, const StrPtr *val,
46
46
  Error *e );
47
+ virtual void Comment( SpecElem *sd, int x, const char **wv,
48
+ int nl, Error *e );
47
49
 
48
50
  private:
49
51
  VALUE hash;
data/ext/P4/specmgr.cpp CHANGED
@@ -63,21 +63,6 @@ struct defaultspec {
63
63
  "unlocked/locked;;"
64
64
  "View;code:311;type:wlist;words:2;len:64;;"
65
65
  },
66
- {
67
- "changeX",
68
- "Change;code:201;rq;ro;fmt:L;seq:1;len:10;;"
69
- "Date;code:202;type:date;ro;fmt:R;seq:3;len:20;;"
70
- "Client;code:203;ro;fmt:L;seq:2;len:32;;"
71
- "User;code:204;ro;fmt:L;seq:4;len:32;;"
72
- "Status;code:205;ro;fmt:R;seq:5;len:10;;"
73
- "Type;code:211;seq:6;type:select;fmt:L;len:10;"
74
- "val:public/restricted;;"
75
- "ImportedBy;code:212;type:line;ro;fmt:L;len:32;;"
76
- "Identity;code:213;type:line;;"
77
- "Description;code:206;type:text;rq;;"
78
- "Jobs;code:209;type:wlist;words:2;len:32;;"
79
- "Files;code:210;type:llist;len:64;;"
80
- },
81
66
  {
82
67
  "change",
83
68
  "Change;code:201;rq;ro;fmt:L;seq:1;len:10;;"
@@ -92,6 +77,7 @@ struct defaultspec {
92
77
  "Description;code:206;type:text;rq;seq:7;;"
93
78
  "JobStatus;code:207;fmt:I;type:select;seq:9;;"
94
79
  "Jobs;code:208;type:wlist;seq:8;len:32;;"
80
+ "Stream;code:214;type:line;len:64;;"
95
81
  "Files;code:210;type:llist;len:64;;"
96
82
  },
97
83
  {
@@ -115,47 +101,12 @@ struct defaultspec {
115
101
  "Stream;code:314;type:line;len:64;;"
116
102
  "StreamAtChange;code:316;type:line;len:64;;"
117
103
  "ServerID;code:315;type:line;ro;len:64;;"
118
- "Type;code:318;type:select;len:10;val:writeable/readonly;;"
104
+ "Type;code:318;type:select;len:10;val:"
105
+ "writeable/readonly/graph/partitioned;;"
119
106
  "Backup;code:319;type:select;len:10;val:enable/disable;;"
120
107
  "View;code:311;type:wlist;words:2;len:64;;"
121
108
  "ChangeView;code:317;type:llist;len:64;;"
122
109
  },
123
- {
124
- "clientX",
125
- "Client;code:301;rq;ro;seq:1;len:32;;"
126
- "Update;code:302;type:date;ro;seq:2;fmt:L;len:20;;"
127
- "Access;code:303;type:date;ro;seq:4;fmt:L;len:20;;"
128
- "Owner;code:304;seq:3;fmt:R;len:32;;"
129
- "Host;code:305;seq:5;fmt:R;len:32;;"
130
- "Description;code:306;type:text;len:128;;"
131
- "Root;code:307;rq;type:line;len:64;;"
132
- "AltRoots;code:308;type:llist;len:64;;"
133
- "Options;code:309;type:line;len:64;val:"
134
- "noallwrite/allwrite,noclobber/clobber,nocompress/compress,"
135
- "unlocked/locked,nomodtime/modtime,normdir/rmdir;;"
136
- "SubmitOptions;code:313;type:select;fmt:L;len:25;val:"
137
- "submitunchanged/submitunchanged+reopen/revertunchanged/"
138
- "revertunchanged+reopen/leaveunchanged/leaveunchanged+reopen;;"
139
- "LineEnd;code:310;type:select;fmt:L;len:12;val:"
140
- "local/unix/mac/win/share;;"
141
- "View;code:311;type:wlist;words:2;len:64;;"
142
- },
143
- {
144
- "clientSpecing021",
145
- "Client;code:301;rq;ro;len:32;;"
146
- "Update;code:302;type:date;ro;len:20;;"
147
- "Access;code:303;type:date;ro;len:20;;"
148
- "Owner;code:304;len:32;;"
149
- "Host;code:305;len:32;;"
150
- "Description;code:306;type:text;len:128;;"
151
- "Root;code:307;rq;type:line;len:64;;"
152
- "AltRoots;code:308;type:text;len:64;;"
153
- "Options;code:309;type:line;len:64;val:"
154
- "noallwrite/allwrite,noclobber/clobber,nocompress/compress,"
155
- "unlocked/locked,nomodtime/modtime,normdir/rmdir;;"
156
- "LineEnd;code:310;type:select;len:12;val:local/unix/mac/win/share;;"
157
- "View;code:311;type:wlist;words:2;len:64;;"
158
- },
159
110
  {
160
111
  "depot",
161
112
  "Depot;code:251;rq;ro;len:32;;"
@@ -175,11 +126,13 @@ struct defaultspec {
175
126
  "MaxResults;code:402;type:word;len:12;;"
176
127
  "MaxScanRows;code:403;type:word;len:12;;"
177
128
  "MaxLockTime;code:407;type:word;len:12;;"
129
+ "MaxOpenFiles;code:413;type:word;len:12;;"
178
130
  "Timeout;code:406;type:word;len:12;;"
179
131
  "PasswordTimeout;code:409;type:word;len:12;;"
180
132
  "LdapConfig;code:410;type:line;len:128;;"
181
133
  "LdapSearchQuery;code:411;type:line;len:128;;"
182
134
  "LdapUserAttribute;code:412;type:line;len:128;;"
135
+ "LdapUserDNAttribute;code:414;type:line;len:128;;"
183
136
  "Subgroups;code:404;type:wlist;len:32;opt:default;;"
184
137
  "Owners;code:408;type:wlist;len:32;opt:default;;"
185
138
  "Users;code:405;type:wlist;len:32;opt:default;;"
@@ -247,36 +200,67 @@ struct defaultspec {
247
200
  "Clients;code:458;len:8;;"
248
201
  "Users;code:459;len:8;;"
249
202
  "Files;code:460;len:8;;"
250
- },
203
+ "Repos;code:462;len:8;;"
204
+ "ExtraCapabilities;code:463;type:llist;len:512;;"
205
+ },
251
206
  {
252
207
  "protect",
253
- "Protections;code:501;fmt:C;type:wlist;words:5;opt:default;len:64;;"
208
+ "SubPath;code:502;ro;len:64;;"
209
+ "Update;code:503;type:date;ro;fmt:L;len:20;;"
210
+ "Protections;code:501;fmt:C;type:wlist;words:5;opt:default;z;len:64;;"
254
211
  },
255
212
  {
256
213
  "remote",
257
- "RemoteID;code:851;rq;ro;len:32;;"
214
+ "RemoteID;code:851;rq;ro;fmt:L;len:32;;"
258
215
  "Address;code:852;rq;type:line;len:32;;"
259
216
  "Owner;code:853;fmt:R;len:32;;"
260
217
  "RemoteUser;code:861;fmt:R;len:32;;"
261
218
  "Options;code:854;type:line;len:32;val:"
262
- "unlocked/lockednocompress/compress;;"
219
+ "unlocked/locked,nocompress/compress,copyrcs/nocopyrcs;;"
263
220
  "Update;code:855;type:date;ro;fmt:L;len:20;;"
264
221
  "Access;code:856;type:date;ro;fmt:L;len:20;;"
265
222
  "Description;code:857;type:text;len:128;;"
266
223
  "LastFetch;code:858;fmt:L;len:10;;"
267
224
  "LastPush;code:859;fmt:L;len:10;;"
268
225
  "DepotMap;code:860;type:wlist;words:2;len:64;;"
226
+ "ArchiveLimits;code:862;type:wlist;words:2;len:64;;"
269
227
  },
270
228
  {
271
- "specW",
272
- "Fields;code:351;type:wlist;words:5;rq;;"
273
- "Required;code:357;type:wlist;;"
274
- "Readonly;code:358;type:wlist;;"
275
- "Words;code:352;type:wlist;words:2;;"
276
- "Formats;code:353;type:wlist;words:3;;"
277
- "Values;code:354;type:wlist;words:2;;"
278
- "Presets;code:355;type:wlist;words:2;;"
279
- "Comments;code:356;type:text;;"
229
+ "repo",
230
+ "Repo;code:1001;rq;ro;fmt:L;len:128;;"
231
+ "Owner;code:1002;fmt:R;len:32;;"
232
+ "Created;code:1003;type:date;ro;fmt:L;len:20;;"
233
+ "Pushed;code:1004;type:date;ro;fmt:R;len:20;;"
234
+ "ForkedFrom;code:1005;ro;fmt:L;len:128;;"
235
+ "Description;code:1006;type:text;len:128;;"
236
+ "DefaultBranch;code:1007;fmt:L;len:32;;"
237
+ "MirroredFrom;code:1008;fmt:R;len:32;;"
238
+ "Options;code:1009;type:select;len:10;val:lfs/nolfs;;"
239
+ "GconnMirrorServerId;code:1010;fmt:L;len:32;;"
240
+ "GconnMirrorSecretToken;code:NNN;len:36;;"
241
+ "GconnMirrorStatus;code:NNN;len:8;;"
242
+ "GconnMirrorExcludedBranches;code:NNN;len:256;;"
243
+ "GconnMirrorHideFetchUrl;code:NNN;len:5;;"
244
+ },
245
+ {
246
+ "server",
247
+ "ServerID;code:751;rq;ro;len:32;;"
248
+ "Type;code:752;rq;len:32;;"
249
+ "Name;code:753;type:line;len:32;;"
250
+ "Address;code:754;type:line;len:32;;"
251
+ "ExternalAddress;code:755;type:line;len:32;;"
252
+ "Services;code:756;rq;len:128;;"
253
+ "Options;code:764;type:line;len:32;val:"
254
+ "nomandatory/mandatory;;"
255
+ "ReplicatingFrom;code:765;type:line;len:32;;"
256
+ "Description;code:757;type:text;len:128;;"
257
+ "User;code:761;type:line;len:64;;"
258
+ "AllowedAddresses;code:763;type:wlist;len:64;;"
259
+ "UpdateCachedRepos;code:766;type:wlist;len:64;;"
260
+ "ClientDataFilter;code:758;type:wlist;len:64;;"
261
+ "RevisionDataFilter;code:759;type:wlist;len:64;;"
262
+ "ArchiveDataFilter;code:760;type:wlist;len:64;;"
263
+ "DistributedConfig;code:762;type:text;len:128;;"
280
264
  },
281
265
  {
282
266
  "spec",
@@ -286,6 +270,7 @@ struct defaultspec {
286
270
  "Values;code:354;type:wlist;words:2;;"
287
271
  "Presets;code:355;type:wlist;words:2;;"
288
272
  "Openable;code:362;type:wlist;words:2;;"
273
+ "Maxwords;code:361;type:wlist;words:2;;"
289
274
  "Comments;code:356;type:text;;"
290
275
  },
291
276
  {
@@ -293,28 +278,30 @@ struct defaultspec {
293
278
  "Stream;code:701;rq;ro;len:64;;"
294
279
  "Update;code:705;type:date;ro;fmt:L;len:20;;"
295
280
  "Access;code:706;type:date;ro;fmt:L;len:20;;"
296
- "Owner;code:704;len:32;;"
297
- "Name;code:703;rq;type:line;len:32;;"
281
+ "Owner;code:704;len:32;open:isolate;;"
282
+ "Name;code:703;rq;type:line;len:32;open:isolate;;"
298
283
  "Parent;code:702;rq;len:64;open:isolate;;"
299
284
  "Type;code:708;rq;len:32;open:isolate;;"
300
- "Description;code:709;type:text;len:128;;"
285
+ "Description;code:709;type:text;len:128;open:isolate;;"
301
286
  "Options;code:707;type:line;len:64;val:"
302
287
  "allsubmit/ownersubmit,unlocked/locked,"
303
288
  "toparent/notoparent,fromparent/nofromparent,"
304
- "mergedown/mergeany;;"
305
- "Paths;code:710;rq;type:wlist;words:2;maxwords:3;len:64;open:isolate;;"
306
- "Remapped;code:711;type:wlist;words:2;len:64;open:isolate;;"
307
- "Ignored;code:712;type:wlist;words:1;len:64;open:isolate;;"
289
+ "mergedown/mergeany;open:isolate;;"
290
+ "ParentView;code:NNN;rq;open:isolate;"
291
+ "pre:inherit;val:noinherit/inherit;;"
292
+ "Paths;code:710;rq;type:wlist;words:2;maxwords:3;len:64;open:propagate;fmt:C;;"
293
+ "Remapped;code:711;type:wlist;words:2;len:64;open:propagate;fmt:C;;"
294
+ "Ignored;code:712;type:wlist;words:1;len:64;open:propagate;fmt:C;;"
308
295
  "View;code:713;type:wlist;words:2;len:64;;"
309
296
  "ChangeView;code:714;type:llist;ro;len:64;;"
310
297
  },
311
298
  {
312
299
  "triggers",
313
- "Triggers;code:551;type:wlist;words:4;len:64;opt:default;"
300
+ "Triggers;code:551;type:wlist;words:4;len:64;opt:default;z;;"
314
301
  },
315
302
  {
316
303
  "typemap",
317
- "TypeMap;code:601;type:wlist;words:2;len:64;opt:default;"
304
+ "TypeMap;code:601;type:wlist;words:2;len:64;opt:default;z;;"
318
305
  },
319
306
  {
320
307
  "user",
@@ -326,23 +313,10 @@ struct defaultspec {
326
313
  "FullName;code:655;fmt:R;type:line;rq;len:32;;"
327
314
  "JobView;code:656;type:line;len:64;;"
328
315
  "Password;code:657;len:32;;"
329
- "AuthMethod;code:662;fmt:L;len:10;val:perforce/ldap;;"
316
+ "AuthMethod;code:662;fmt:L;len:10;val:"
317
+ "perforce/perforce+2fa/ldap/ldap+2fa;;"
330
318
  "Reviews;code:658;type:wlist;len:64;;"
331
319
  },
332
- {
333
- "server",
334
- "ServerID;code:751;rq;ro;len:32;;"
335
- "Type;code:752;rq;len:32;;"
336
- "Name;code:753;type:line;len:32;;"
337
- "Address;code:754;type:line;len:32;;"
338
- "ExternalAddress;code:755;type:line;len:32;;"
339
- "Services;code:756;rq;len:128;;"
340
- "Description;code:757;type:text;len:128;;"
341
- "User;code:761;type:line;len:64;;"
342
- "ClientDataFilter;code:758;type:wlist;len:64;;"
343
- "RevisionDataFilter;code:759;type:wlist;len:64;;"
344
- "ArchiveDataFilter;code:760;type:wlist;len:64;;"
345
- },
346
320
  { 0, 0 }
347
321
  };
348
322
 
data/lib/P4.rb CHANGED
@@ -557,7 +557,7 @@ class P4
557
557
 
558
558
  def set_attribute( name, value )
559
559
  name = name.downcase
560
- if( value =~ /^\d+$/ )
560
+ if( value.to_s =~ /^\d+$/ )
561
561
  @attributes[ name ] = value.to_i
562
562
  else
563
563
  @attributes[ name ] = value