@@ -339,7 +339,7 @@ NodeP4.prototype.fstat = function (options, callback)
339339
340340 callback ( null , result ) ;
341341 } ) ;
342- }
342+ } ;
343343
344344NodeP4 . prototype . changes = function ( options , callback )
345345{
@@ -358,7 +358,14 @@ NodeP4.prototype.changes = function (options, callback)
358358 result = stdout . trim ( ) . split ( / \r \n \r \n | \n \n (? = \. \. \. ) / ) . reduce ( function ( memo , changeinfo )
359359 {
360360 // process each line of change info, transforming into a hash
361- memo . push ( processZtagOutput ( changeinfo ) ) ;
361+ var item = processZtagOutput ( changeinfo ) ;
362+
363+ // If object representing change is not empty, push it onto array
364+ if ( Object . keys ( item ) . length != 0 )
365+ {
366+ memo . push ( item ) ;
367+ }
368+
362369 return memo ;
363370 } , [ ] ) ;
364371
@@ -410,6 +417,37 @@ NodeP4.prototype.users = function (options, callback)
410417 } ) ;
411418} ;
412419
420+ NodeP4 . prototype . diff2 = function ( options , callback )
421+ {
422+ if ( typeof options === 'function' )
423+ {
424+ callback = options ;
425+ options = undefined ;
426+ }
427+
428+ // TODO: Check that no more than two file arguments are provided
429+ execP4 ( '-ztag diff2' , options , function ( err , stdout )
430+ {
431+ var result ;
432+ if ( err ) return callback ( err ) ;
433+
434+ // process each change
435+ result = stdout . trim ( ) . split ( / \r \n \r \n | \n \n (? = \. \. \. ) / ) . reduce ( function ( memo , diff2info )
436+ {
437+ // process each line of change info, transforming into a hash
438+ var item = processZtagOutput ( diff2info ) ;
439+
440+ // If object representing change is not empty, push it onto array
441+ if ( Object . keys ( item ) . length != 0 )
442+ memo . push ( item ) ;
443+
444+ return memo ;
445+ } , [ ] ) ;
446+
447+ callback ( null , result ) ;
448+ } ) ;
449+ } ;
450+
413451NodeP4 . prototype . awaitCommand = function ( command , options )
414452{
415453 return new Promise ( ( resolve , reject ) =>
@@ -452,7 +490,7 @@ NodeP4.prototype.setDebugMode = function (debug_active)
452490} ;
453491
454492var commonCommands = [ 'add' , 'delete' , 'edit' , 'revert' , 'sync' , 'diff' , 'reconcile' , 'reopen' , 'resolved' ,
455- 'shelve' , 'unshelve' , 'client' , 'resolve' , 'submit' , 'describe' , 'files' ] ;
493+ 'shelve' , 'unshelve' , 'client' , 'resolve' , 'submit' , 'describe' , 'files' , 'have' ] ;
456494
457495commonCommands . forEach ( function ( command )
458496{
0 commit comments