subversion: Is it correct to use svn merge command(with rev B) on already merged code(for rev A) - svn-merge

I've merged my code with a branch for revision(say X), now there have been commits in the other branch and i want to take those changes in the merged code(which is not committed yet). Now can i run the svn merge command(to say revsion Y) on already modified files.
Assuming in my repo i've src files(say tmp1.c. tm2.c)
code :
$>svn merge rev#branch_out : orig_rev#merge url/to/the/branch/that/is/being/merged/
U tmp1.c
A tmp3.c
$>svn st
M tmp1.c
A + tmp3.c
Now the question is can i again do
$>svn merge rev#branch_out : new_rev#merge url/to/the/branch/that/is/being/merged/

Related

Create multiple directories based on files found

I'm trying to create directories to store image sequences based on a 'find' command.
Let's say there are 2 image sequences in different locations within the 'test' directory
test_123.####.dpx
test_abc.####.dpx
I would run something like:
testDir=$(find /Users/Tim/test/ -type f -name "test*.dpx")
and it would return all of the files as listed above.
What I would like to do is create two directories named test_123 and test_abc.
mkdir /Users/Tim/test/scan/${testDir:t:r:r}
If I run this then it will only create one directory, presumably based on the first result.
How would I be able to make this work to create directories that share the same base name for an unlimited number of results? (not just two as in the case of this example).
if it's not important that it's done in zsh, you could just do it in python like this:
#!/usr/bin/python3
import os
x = 0
y = 0
if input(f"{os.getcwd()} is current working dir. press y to continue \n") == "y":
for file in os.listdir(): # get files in current folder
split = file.split(".") # split by .
if len(split) > 1: # only files with more than one . are considered
if split[0] not in os.listdir(): # if the folder it fits doesn't exist
os.mkdir(split[0]) # make the folder
print(f"made new folder {split[0]}")
y = y + 1
os.rename(file, os.path.join(split[0],file)) # then move it there - OS agnostic path generated!
x = x + 1
print(f"moved {x} files to {y} folders!")
I added a check before it runs, just to prevent random people who find this from wreaking havoc. The if len(split) > 1: should also prevent some accidents by making sure it's only files with at least 2 dots that are moved, as that's an unusual naming scheme.

How to change randomly the dates of creation and modification of files

I need to change the files creation / modification dates for an exercice.
According to http://theautomatic.net/2018/12/18/how-to-change-file-last-modified-date-with-r/ , I can find files info with file.info()function.
I can also change the dates modification of all the files in a folder combining sapply and Sys.setFileTime :
sapply(list.files("path", full.names = TRUE),
function(FILE) Sys.setFileTime(FILE, "1975-01-01"))
How can I also change date of creation ? (ctime <S3: POSIXct>)
What I expect : for the exercice : I want to change randomly the dates of creation and modification of files (in a range of a year, files are not are created at the same day)
What I tried (changing only date of modification) :
sapply(list.files("C:/Users/cariou-w/Nextcloud/sync-uncloud/1920-1921/master/web_scrapping/plans", full.names = TRUE),
function(FILE) Sys.setFileTime(FILE, paste0("2020-11-", sample(days,1))))
There is no generic cross platform way to change file creation time in R - many file systems do not even track it. You can use system or system2 to call whatever the appropriate shell command is for you. E.g. on OS X, touch -t 202001011234 /path/to/my/file

No extension exist for r:eval

I'm trying to run the RScriptSample present in the samples in the Stream Processor.
I've followed the steps given here.
I have installed R and rJava, and set R_HOME and JRI_HOME accordingly.
#App:name("RScriptSample")
#App:description('Use a R script to process events and produce aggregated outputs based on the provided input variable parameters and expected output attributes.')
define stream weather (time long, temp double);
#sink(type='log')
define stream dataOut (time long, temp double, c long, m double );
#info(name = 'query')
from weather#window.lengthBatch(2)#r:eval("c <- sum(time); m <- sum(temp)", "c long, m double", time, temp)
select * insert into dataOut;
The code does not compile. I'm getting this error in the last line.
No extension exist for r:eval
What am I doing wrong?
Since this extension is under GPL extension, it is not copied to the pack by default. Add the jar to {SP_HOME}/lib folder and try out the sample.
Compatible Version: 4.x.x

Multiple diff outputs in one patchfile

I was trying to store multiple diff outputs in one .patch file to keep versioning in one file instead of running multiple
diff -u f1 f2 > f1.patch
commands. Preferably I'd keep running
diff -u[other params?] f1 f2 >> f1.patch
to have one file containing all changes which would allow me to later on run patch on those files to have a f1 file available in any given moment.
Unfortunately patch fails with file generated in such manner. It only seems to apply first patch from the file and then quits with error.
My question: is that possible with diff and patch? And if so, how?
Thank you in advance.

Automating version increase of R packages

Problem
I am developing an R package and I want to increase the version automatically each time I build it. I want that to be able to associate my results to package versions. For now I was using my own ugly function to do that.
My question is: is there a way to do it better? Or, should I avoid doing that in general?
Another option
Another option I was thinking of is to install my package (hosted in github) using ´devtools::install_github´ and then save with my results (or adding to plots) the GithubSHA1 that is saved in the installed DESCRIPTION file.
For example I can get the version and GithubSHA1 like that for the ´devtools´ package:
read.dcf(file=system.file("DESCRIPTION", package="devtools"),
fields=c("Version", "GithubSHA1"))
## Version GithubSHA1
## [1,] "1.5.0.99" "3ae58a2a2232240e67b898f875b8da5e57d1b3a8"
My tries so far
I wrote the following function to produce a new DESCRIPTION file, with updated version and date. (Increasing the major version is something I don't mind increasing per hand)
incVer <- function(pkg, folder=".", increase="patch"){
## Read DESCRIPTION from installed package ´pkg´ and make new one on the specified
## ´folder´. Two options for ´increase´ are "patch" and "minor"
f <- read.dcf(file=system.file("DESCRIPTION", package=pkg),
fields=c("Package", "Type", "Title", "Version", "Date",
"Author", "Maintainer", "Description", "License",
"Depends", "Imports", "Suggests"))
curVer <- package_version(f[4])
if(increase == "patch") {
curVer[[1,3]] <- ifelse(is.na(curVer$patchlevel), 1, curVer$patchlevel + 1)
} else if (increase == "minor") {
curVer[[1,2]] <- ifelse(is.na(curVer$minor), 1, curVer$minor + 1)
curVer[[1,3]] <- 0
} else {
stop(paste("Can not identify the increase argument: " , increase))
}
f[4] <- toString(curVer)
## Update also the date
f[5] <- format (Sys.time(), "%Y-%m-%d")
write.dcf(f, file=paste(folder, "DESCRIPTION", sep="/"))
}
If you are using git, then you can use git tags to create a version string. This is how we generate the version string of our igraph library:
git describe HEAD --tags | rev | sed 's/g-/./' | sed 's/-/+/' | rev
It gives you a format like this:
0.8.0-pre+131.ca78343
0.8.0-pre is the last tag on the current branch. (The last released version was 0.7.1, and we create a -pre tag immediately after the release tag.) 131 is the number of commits since the last tag. ca78343 is the first seven character of the hex id of the last commit.
This would be great, except that you cannot have version strings like this in R packages, R does not allow it. So for R we transform this version string using the following script: https://github.com/igraph/igraph/blob/develop/interfaces/R/tools/convertversion.sh
Essentially it creates a version number that is larger than the last released version and smaller than the next versions (the one in the -pre tag). From 0.8.0-pre+131.ca78343 it creates
0.7.999-131
where 131 is the number of commits since the last release.
I put the generation of the DESCRIPTION file in a Makefile. This replaces the date, and the version number:
VERSION=$(shell ./tools/convertversion.sh)
igraph/DESCRIPTION: src/DESCRIPTION version_number
sed 's/^Version: .*$$/Version: '$(VERSION)'/' $< | \
sed 's/^Date: .*$$/Date: '`date "+%Y-%m-%d"`'/' > $#
This is quite convenient, you don't need to do anything, except for adding the release tags and
the -pre tags.
Btw. this was mostly worked out by my friend and igraph co-developer, Tamás Nepusz, so the credit is his.
For a simpler approach, consider using the crant tool with the -u switch. For instance,
crant -u 3
will increment the third component of the version by one. There is also Git and SVN integration, and a bunch of other useful switches for roxygenizing, building, checking etc..
As auto-incrementing version numbering is not going to be built into the devtools package, I figured out a way based on Gabor's answer (the link to igraph in his answer is dead btw).
When I am about to commit to our repository, I run this bash script to set the date to today and to set the version number based on the latest tag, the .9000 suffix (as suggested here in the book R Packages by Hadley Wickham) and the number of commits within that tag:
echo "••••••••••••••••••••••••••••••••••••••••••••"
echo "• Updating package date and version number •"
echo "••••••••••••••••••••••••••••••••••••••••••••"
sed -i -- "s/^Date: .*/Date: $(date '+%Y-%m-%d')/" DESCRIPTION
# get latest tags
git pull --tags --quiet
current_tag=`git describe --tags --abbrev=0 | sed 's/v//'`
current_commit=`git describe --tags | sed 's/.*-\(.*\)-.*/\1/'`
# combine tag (e.g. 0.1.0) and commit number (like 40) increased by 9000 to indicate beta version
new_version="$current_tag.$((current_commit + 9000))" # results in 0.1.0.9040
sed -i -- "s/^Version: .*/Version: ${new_version}/" DESCRIPTION
echo "First 3 lines of DESCRIPTION:"
head -3 DESCRIPTION
echo
# ... after here more commands like devtools::document() and git commit
To be clear - this script actually makes these changes to the DESCRIPTION file.
EDIT: support for hundreds - now just increases the commit sequence number by 9000. So commit #120 in tag v0.6.1 leads to 0.6.1.9120.

Resources