Mercurial and Oracle Apps version control (lot's of DDL)

Haszlakiewicz, Eric EHASZLA at transunion.com
Tue Nov 16 18:14:11 UTC 2010


>-----Original Message-----
>From: mercurial-bounces at selenic.com [mailto:mercurial-bounces at selenic.com]
>
>On Mon, Nov 15, 2010 at 11:19 PM, Joe Ferr <jferr at brocade.com> wrote:
>> I think that using hg status --rev X:Y would work if there wasn't a
>better option.  I would need to parse the output of this command to figure
>out which files I'd need to copy/execute.
>
>See Matt's response: you can use "hg status" to stitch together
>everything you need.
>
>> What I'm ideally looking for...it would be great if I could get this both
>from the command line and from hgweb...is a way to get all of these files
>in one command.  E.g. an export command which would let me pass two
>identifiers (tags or revs) and a directory name and mercurial would
>retrieve all files changed or added between these two tags/revs.
>
>That's not the Mercurial way, because it's not the Unix way.

The Unix way is great for command line work, but not so great for a web interface. :(  AFAIK, you can't pipe the output from "hg status" through hgweb.
Thinking pie in the sky, I wonder if it would be possible to have a form field on a hgweb page that lets you enter arbitrary hg commands and feed their output to an display module. e.g.:
status --rev X:Y | renderfiles
 or
incoming /some/bundle | showchangesets -graph
(perhaps with the display modules being available as dropdowns and custom forms to make it a bit nicer to use)

>Mercurial and Unix provide all the tools you need to do this.  Put 'em
>together in a little shell script and you're done.  Here's one
>possible approach:
>
>  # X is the changeset of the previous run
>  # Y is the  new changeset containing new/changed scripts
>  hg update Y
>  files=`hg status -nma --rev X:Y`
>  tmpdir=`mktemp -d`
>  tar -cf - $files | (cd $tmpdir && tar -xf -)
>  cd $tmpdir
>  for script in $files;
>      run $script
>  done
>
>That make a couple of assumptions:
>  * no spaces in filenames or directory names

You can fix this problem with careful use of IFS and loops instead of capturing file output in variables.  e.g.:

oIFS="$IFS"
# Just a newline between the quotes:
IFS="
"
for script in $(hg status -nma --rev X:Y) ; do
	run $script
done
IFS="$oIFS"   # restore original value

Or, you can redirect the hg output to a file, and use tar's -T option (aka --files-from).
Or, even better, you can use the -print0 option to use a NUL character between files and then pipe the output to xargs -0, which has the benefit that then you can handle filenames with newlines in them.  (tar also has a --null option that modified -T to handle this)

eric



More information about the Mercurial mailing list