Class MultiVersionControl

java.lang.Object
org.plumelib.multiversioncontrol.MultiVersionControl

public class MultiVersionControl extends Object
This program simplifies managing your clones/checkouts. This program lets you run a version control command, such as "status" or "pull", on a set of CVS/Git/Hg/SVN clones/checkouts rather than just one. You might want to pull/update all of them, or you might want to know whether any of them have uncommitted changes. When setting up a new account, you might want to clone them all. This program does those tasks.

You can specify the set of clones for the program to manage in a file .mvc-checkouts, or you can pass --search to make the program search your directory structure to find all of your clones. For example (assuming you have a mvc alias), to list all un-committed changed files under your home directory:

 mvc status --search=true

This program accepts these arguments:

   clone     -- Clone (check out) all repositories.
   checkout  -- Same as clone.
   pull      -- Pull and update all clones.
   update    -- Same as pull.
   status    -- Show files that are changed but not committed, or committed
                but not pushed, or have shelved/stashed changes.
   list      -- List the clones/checkouts that this program is aware of.
 

(The commit action is not supported, because that is not something that should be done in an automated way — it needs a user-written commit message.)

Command-line arguments

The command-line options are as follows:

  • Configuration file
    • --home=string. User home directory. [default Java user.home property]
    • --checkouts=string. File with list of clones. Set it to /dev/null to suppress reading. [default .mvc-checkouts in home directory]
  • Miscellaneous options
    • --redo-existing=boolean. If false, clone command skips existing directories. [default: false]
    • --timeout=int. Terminating the process can leave the repository in a bad state, so set this rather high for safety. Also, the timeout needs to account for the time to run hooks (that might recompile or run tests). [default: 600]
  • Searching for clones
    • --search=boolean. If true, search for all clones, not just those listed in a file. [default: false]
    • --search-prefix=boolean. If true, search for all clones whose directory is a prefix of one in the cofiguration file. [default: false]
    • --dir=string [+]. Directory under which to search for clones, when using --search [default home directory]
    • --ignore-dir=string [+]. Directories under which to NOT search for clones. May include leading "~/".
  • Paths to programs
    • --cvs-executable=string. Path to the cvs program. [default: cvs]
    • --git-executable=string. Path to the git program. [default: git]
    • --hg-executable=string. Path to the hg program. [default: hg]
    • --svn-executable=string. Path to the svn program. [default: svn]
    • --insecure=boolean. If true, use --insecure when invoking programs. [default: false]
    • --cvs-arg=string [+]. Extra argument to pass to the cvs program.
    • --git-arg=string [+]. Extra argument to pass to the git program.
    • --hg-arg=string [+]. Extra argument to pass to the hg program.
    • --svn-arg=string [+]. Extra argument to pass to the svn program.
  • Diagnostics
    • --show=boolean. If true, display each command is it is executed. [default: false]
    • --print-directory=boolean. If true, print the directory before executing commands in it. [default: false]
    • --dry-run=boolean. Perform a "dry run": print commands but do not execute them. [default: false]
    • -q --quiet=boolean. If true, run quietly (e.g., no output about missing directories). [default: true]
    • --debug=boolean. Print debugging output. [default: false]
    • --debug-replacers=boolean. Debug 'replacers' that filter command output. [default: false]
    • --debug-process-output=boolean. Lightweight debugging of 'replacers' that filter command output. [default: false]
[+] means option can be specified multiple times

File format for .mvc-checkouts file

The remainder of this document describes the file format for the .mvc-checkouts file.

(Note: because mvc can search for all checkouts in your directory, you don't need a .mvc-checkouts file. Using a .mvc-checkouts file makes the program faster because it does not have to search all of your directories. It also permits you to process only a certain set of checkouts.)

The .mvc-checkouts file contains a list of sections. Each section names either a root from which a sub-part (e.g., a module or a subdirectory) will be checked out, or a repository all of which will be checked out. Examples include:

 CVSROOT: :ext:login.csail.mit.edu:/afs/csail.mit.edu/u/m/mernst/.CVS/.CVS-mernst
 SVNROOT: svn+ssh://tricycle.cs.washington.edu/cse/courses/cse403/09sp
 SVNREPOS: svn+ssh://login.csail.mit.edu/afs/csail/u/a/user/.SVN/papers/parameterize-paper/trunk
 HGREPOS: https://jsr308-langtools.googlecode.com/hg

Within each section is a list of directories that contain a checkout from that repository. If the section names a root, then a module or subdirectory is needed. By default, the directory's basename is used. This can be overridden by specifying the module/subdirectory on the same line, after a space. If the section names a repository, then no module information is needed or used.

When performing a checkout, the parent directories are created if needed.

In the file, blank lines, and lines beginning with "#", are ignored.

Here are some example sections:

 CVSROOT: :ext:login.csail.mit.edu:/afs/csail.mit.edu/group/pag/projects/classify-tests/.CVS
 ~/research/testing/symstra-eclat-paper
 ~/research/testing/symstra-eclat-code
 ~/research/testing/eclat

 SVNROOT: svn+ssh://login.csail.mit.edu/afs/csail/group/pag/projects/.SVNREPOS/
 ~/research/typequals/igj
 ~/research/typequals/annotations-papers

 SVNREPOS: svn+ssh://login.csail.mit.edu/afs/csail/group/pag/projects/abb/REPOS
 ~/prof/grants/2008-06-abb/abb

 HGREPOS: https://checker-framework.googlecode.com/hg/
 ~/research/types/checker-framework

 SVNROOT: svn+ssh://login.csail.mit.edu/afs/csail/u/d/dannydig/REPOS/
 ~/research/concurrency/concurrentPaper
 ~/research/concurrency/mit.edu.refactorings concRefactor/project/mit.edu.refactorings

Furthermore, these 2 sections have identical effects:

 SVNROOT: https://crashma.googlecode.com/svn/
 ~/research/crashma trunk

 SVNREPOS: https://crashma.googlecode.com/svn/trunk
 ~/research/crashma

and, all 3 of these sections have identical effects:

 SVNROOT: svn+ssh://login.csail.mit.edu/afs/csail/group/pag/projects/
 ~/research/typequals/annotations

 SVNROOT: svn+ssh://login.csail.mit.edu/afs/csail/group/pag/projects/
 ~/research/typequals/annotations annotations

 SVNREPOS: svn+ssh://login.csail.mit.edu/afs/csail/group/pag/projects/annotations
 ~/research/typequals/annotations

Installation

 git clone https://github.com/plume-lib/multi-version-control
 cd multi-version-control
 ./gradlew shadowJar

 alias mvc='java -ea -cp CURRENT_DIR/build/libs/multi-version-control-all.jar org.plumelib.multiversioncontrol.MultiVersionControl'
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    File with list of clones.
    Extra argument to pass to the cvs program.
    Path to the cvs program.
    static boolean
    Print debugging output.
    boolean
    Lightweight debugging of 'replacers' that filter command output.
    boolean
    Debug 'replacers' that filter command output.
    Directory under which to search for clones, when using --search [default = home directory].
    boolean
    Perform a "dry run": print commands but do not execute them.
    Extra argument to pass to the git program.
    Path to the git program.
    Extra argument to pass to the hg program.
    Path to the hg program.
    static String
    User home directory.
    Directories under which to NOT search for clones.
    boolean
    If true, use --insecure when invoking programs.
    boolean
    If true, print the directory before executing commands in it.
    boolean
    If true, run quietly (e.g., no output about missing directories).
    boolean
    If false, clone command skips existing directories.
    boolean
    If true, search for all clones, not just those listed in a file.
    boolean
    If true, search for all clones whose directory is a prefix of one in the cofiguration file.
    boolean
    If true, display each command is it is executed.
    Extra argument to pass to the svn program.
    Path to the svn program.
    int
    Terminating the process can leave the repository in a bad state, so set this rather high for safety.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a MultiVersionControl instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Runs a version control command, such as "status" or "update", on a set of CVS/Git/Hg/SVN clones rather than just one.
    void
    parseArgs(String[] args)
    Parse the command-line arguments.
    void
    process(Set<org.plumelib.multiversioncontrol.MultiVersionControl.Checkout> checkouts)
    Run the action described by field action, for each of the clones in checkouts.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • home

      public static String home
      User home directory. [default Java user.home property]
    • checkouts

      public String checkouts
      File with list of clones. Set it to /dev/null to suppress reading. [default .mvc-checkouts in home directory]
    • redoExisting

      public boolean redoExisting
      If false, clone command skips existing directories.
    • timeout

      public int timeout
      Terminating the process can leave the repository in a bad state, so set this rather high for safety. Also, the timeout needs to account for the time to run hooks (that might recompile or run tests).
    • searchPrefix

      public boolean searchPrefix
      If true, search for all clones whose directory is a prefix of one in the cofiguration file.
    • dir

      public List<String> dir
      Directory under which to search for clones, when using --search [default = home directory].
    • ignoreDir

      public List<String> ignoreDir
      Directories under which to NOT search for clones. May include leading "~/".
    • cvsExecutable

      public String cvsExecutable
      Path to the cvs program.
    • gitExecutable

      public String gitExecutable
      Path to the git program.
    • hgExecutable

      public String hgExecutable
      Path to the hg program.
    • svnExecutable

      public String svnExecutable
      Path to the svn program.
    • insecure

      public boolean insecure
      If true, use --insecure when invoking programs.
    • cvsArg

      public List<String> cvsArg
      Extra argument to pass to the cvs program.
    • gitArg

      public List<String> gitArg
      Extra argument to pass to the git program.
    • hgArg

      public List<String> hgArg
      Extra argument to pass to the hg program.
    • svnArg

      public List<String> svnArg
      Extra argument to pass to the svn program.
    • show

      public boolean show
      If true, display each command is it is executed.
    • printDirectory

      public boolean printDirectory
      If true, print the directory before executing commands in it.
    • dryRun

      public boolean dryRun
      Perform a "dry run": print commands but do not execute them.
    • quiet

      public boolean quiet
      If true, run quietly (e.g., no output about missing directories).
    • debug

      public static boolean debug
      Print debugging output.
    • debugReplacers

      public boolean debugReplacers
      Debug 'replacers' that filter command output.
    • debugProcessOutput

      public boolean debugProcessOutput
      Lightweight debugging of 'replacers' that filter command output.
  • Constructor Details

    • MultiVersionControl

      public MultiVersionControl(String[] args)
      Create a MultiVersionControl instance.
      Parameters:
      args - the command-line arguments to MultiVersionControl
  • Method Details

    • main

      public static void main(String[] args)
      Runs a version control command, such as "status" or "update", on a set of CVS/Git/Hg/SVN clones rather than just one.
      Parameters:
      args - the command-line arguments
      See Also:
    • parseArgs

      @RequiresNonNull({"dir","checkouts"}) @EnsuresNonNull("action") @EnsuresInitializedFields(fields="action") public void parseArgs(@UnknownInitialization MultiVersionControl this, String[] args)
      Parse the command-line arguments.
      Parameters:
      args - the command-line arguments
      See Also:
    • process

      public void process(Set<org.plumelib.multiversioncontrol.MultiVersionControl.Checkout> checkouts)
      Run the action described by field action, for each of the clones in checkouts.
      Parameters:
      checkouts - the clones and checkouts to process