wex v24.04.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
wex::vcs Class Reference

This class collects all vcs handling. More...

#include <wex/vcs/vcs.h>

Public Types

typedef std::vector< vcs_entrystore_t
 The store is a vector of vcs entries.
 

Public Member Functions

 vcs (const std::vector< wex::path > &files=std::vector< wex::path >(), int command_no=-1)
 Default constructor.
 
int config_dialog (const data::window &data=data::window()) const
 Shows a dialog allowing you to choose which vcs to use and to set the path for each vcs entry.
 
auto & entry ()
 Returns the current writeable vcs entry.
 
const auto & entry () const
 Returns the current readonly vcs entry.
 
bool execute ()
 Executes the current vcs command for the current vcs entry, and collects the output.
 
bool execute (const std::string &command)
 Executes the specified command (git, svn subcommand).
 
const std::string get_branch () const
 Returns branch for current vcs entry, or empty string if vcs is not used.
 
const std::string name () const
 Returns name for current vcs entry, or empty string if vcs is not used.
 
wxStandardID request (const data::window &data=data::window())
 Combines show_dialog, execute and vcs entry show_output in one method.
 
bool set_entry_from_base (wxWindow *parent=nullptr)
 Sets the vcs entry using base folder.
 
int show_dialog (const data::window &data=data::window())
 Shows dialog for the current vcs entry.
 
path toplevel () const
 Returns toplevel dir.
 
bool use () const
 Returns true if vcs usage is set in the config.
 

Static Public Member Functions

static void destroy_dialog ()
 Destroys dialog.
 
static bool dir_exists (const path &filename)
 Returns true if specified filename (a path) is a vcs directory.
 
static bool empty ()
 Returns true if vcs is empty.
 
static bool load_document ()
 Loads all entries (first clears them) from vcs document.
 
static void on_exit ()
 Exits vcs, cleans up store.
 
static void on_init ()
 Initializes the vcs store and loads document.
 
static size_t size ()
 Returns the number of vcs entries.
 

Detailed Description

This class collects all vcs handling.

The VCS entries are loaded from menus.xml, this is done during app startup.

Constructor & Destructor Documentation

◆ vcs()

wex::vcs::vcs ( const std::vector< wex::path > & files = std::vector< wex::path >(),
int command_no = -1 )

Default constructor.

Parameters
filesSpecify several files for which you want vcs action. Sets the vcs entry for first of the specified files, or to the base folder if vector is empty.
command_noThe command no that is used to set the current vcs command (index in vcs entry commands).

Member Function Documentation

◆ config_dialog()

int wex::vcs::config_dialog ( const data::window & data = data::window()) const

Shows a dialog allowing you to choose which vcs to use and to set the path for each vcs entry.

Returns dialog return code.

◆ execute() [1/2]

bool wex::vcs::execute ( )

Executes the current vcs command for the current vcs entry, and collects the output.

Returns return code from vcs entry execute.

◆ execute() [2/2]

bool wex::vcs::execute ( const std::string & command)

Executes the specified command (git, svn subcommand).

Return value is false if process could not execute.

◆ load_document()

static bool wex::vcs::load_document ( )
static

Loads all entries (first clears them) from vcs document.

Returns true if document is loaded.

◆ on_exit()

static void wex::vcs::on_exit ( )
static

Exits vcs, cleans up store.

The wex::del::app::OnExit takes care of this.

◆ on_init()

static void wex::vcs::on_init ( )
static

Initializes the vcs store and loads document.

The wex::del::app::OnInit takes care of this.

◆ request()

wxStandardID wex::vcs::request ( const data::window & data = data::window())

Combines show_dialog, execute and vcs entry show_output in one method.

  • Returns wxID_CANCEL if dialog was cancelled, or an execute error occurred.
  • Returns wxID_OK if okay (use vcs entry error to check whether the output contains errors or normal info).

◆ set_entry_from_base()

bool wex::vcs::set_entry_from_base ( wxWindow * parent = nullptr)

Sets the vcs entry using base folder.

If not, it will show a dialog for selecting a vcs folder (if parent is not nullptr). Returns true if entry is under vcs control.

Parameters
parentParent window for showing dir dialog if there is not a current directory.