Veracity Q&A home login about faq

I'm trying to write a script for PDB source server indexing, and one of the things I need to do is generate a Veracity command to grab a file from a repo, at a particular changeset, to a file. It appears that 'vv cat' almost gets me there, but it always writes to stdout. Is there a way I can get it to write it to a specified file path?

asked Feb 04 at 21:20

jslutter's gravatar image

jslutter
2165919

Having looked at the source code that I have (it is not recent, maybe from 1.5.0) it looks like you can not get cat to do anything but write to stdout. Which, on Windows, causes some file transformations to happen: 1) My Byte Order Mark at the start of the file gets munged 2) rn sequences are becoming rrn 3) An extra rn is at the end of the file

Unfortunately this means that the file is now different (in the eyes of Visual Studio) from what was used during build. I guess the hash of the file is stored in the PDB file.

Adding on to my question, can I make a script for vscript that would, like 'cat', but write the contents directly to a file? This would work for binary files then to right?

For a future version of Veracity can we get a "-o FILENAME" option for cat to dump it right to file instead of stdout?

Thanks again! We're in the process of adopting Veracity at work and it looks like we have Jenkins doing builds using Veracity as a source control provider, and we should soon have symbol/source server support for PDB files built from sources managed by Veracity.

(Feb 05 at 00:42) jslutter

As for a vscript to help you, here is a rough example. We don't currently have a 'cat' api in the JavaScript API or an exact equivalent to do what you want, but this isn't too bad until we fix the other problem. This uses the code we use to fetch individual file versions that we use before launching one of the diff tools.

Hope this helps.

// the name of your repo.
var reponame = "vv10_public";

// the revision/changeset.  this must be the full HID of
// the desired changeset (not a unique prefix like --rev
// usually allows).
var rev      = "231e280789a007057ac37f5a5f471f2c19c95cb9";

// the repo-path of the file THAT IT HAD IN THAT CHANGESET.
// (one of the things that 'vv cat' does is try to allow
// you to specify a current path and reverse map it into
// the path as was at that point in the history (which 
// can get confusing if the file (and/or any parent directories)
// have been moved or renamed).)
var repopath = "@/LICENSE.txt";

// where you want the file created.
var output   = "/tmp/output.txt";

var repo = sg.open_repo( reponame );
var tne  = repo.get_treenode_info_by_path( rev, repopath );
// print( sg.to_json__pretty_print(tne) );
var temp = repo.fetch_blob_into_tempfile( tne.hid, true );
// print( sg.to_json__pretty_print(temp) );

sg.fs.move( temp.path, output );
link

answered Feb 06 at 08:32

Jeff%20Hostetler's gravatar image

Jeff Hostetler ♦♦
1.2k720

Thank you, great stuff. I love vscript, just hard to discover the API without digging into the source. In the version of vscript I have (1.5.1) it looks like vscript skips over the first script argument.

Running:
vscript -i one two
Then:
vscript> for(i in arguments){print(arguments[i])}
Prints:
two
Is this expected behavior? (Like how argv[0] is usually the program name)

(Feb 06 at 09:46) jslutter

We've logged a bug for that.

The first arg "one" is naming a 'scriptfile' that should be loaded. When the -i option is we're not throwing an error when the file doesn't exist.

(Feb 06 at 10:59) Jeff Hostetler ♦♦

I just looked at the source of 'cat' (it'd be a while). And yes, it is hard-coded to splat the contents to stdout. I'll log a feature request to have an output file option and/or make it more friendly to output binary data.

link

answered Feb 06 at 07:35

Jeff%20Hostetler's gravatar image

Jeff Hostetler ♦♦
1.2k720

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1

Asked: Feb 04 at 21:20

Seen: 338 times

Last updated: Feb 06 at 10:59

Related questions

powered by OSQA