VCS Interface classes

Jakob Petsovits jpetso at gmx.at
Mon Apr 30 16:03:50 UTC 2007


On Monday, 30. April 2007, Andreas Pakulat wrote:
> On 30.04.07 16:32:55, Jakob Petsovits wrote:
> > On further thought, I really think this should apply to both directories
> > AND files. After all, it may be a good thing to tell apart all the source
> > files that have been left out of the repository from the "real files".
> >
> > That would (perhaps not important at all, but anyways) also provide a way
> > to emulate an "export" action. Speaking of which, has this one been left
> > out of the interfaces conciously?
>
> No, it was just forgotten :) And I'm not sure every VCS supports this,
> but I guess it can be emulated...

Dead easy.

void export( srcdir, targetdir ) {
  foreach ( file in srcdir.files() ) {
    if ( file.name() == "." || file.name() == ".." ) {
      return;
    }
    else if ( !isVersionControlled( file ) ) {
      return;
    }
    else if ( isDirectory( file ) ) {
      mkdir( targetdir.path() + "/" + file.name() );
      export( file, targetdir->findChild( file.name() ) );
    }
    else {
      cp( file, targetdir );
    }
  }
}

Actual implementation may slightly differ.

> > As a nice side effect, that makes a real good case for isWorkingCopy() :D
>
> Uhm, no. Then the function should rather be isVersionControlled() or
> isUnderVersionControl().

isVersionControlled()! I love that one.

> Also the export function in svn allows local or repository URL's, but I
> think we should limit this to local urls for now.

Agreed.

> Actually at some point I wanted to split local and remote methods, so
> remove methods would be in a separate interface....

I'm glad that you did it this way instead :-]

Greetings,
  Jakob




More information about the KDevelop-devel mailing list