Can I merge multiple consecutive changesets into a changeset in Mercurial - version-control

Let's say I have changeset A, and I make changesets B1, B2, and B3 on top of A, while another developer makes changesets C1, C2, and C3 on top of A:
B1 --- B2 --- B3
/
--- A
\
C1 --- C2 --- C3
The other developer pushes his code to the central repository, and now I want to push my code, but I can't because there are multiple heads. I could rebase my changesets to go on top of his (and this is what I've been doing), but it would be more accurate to merge.
However, as far as I'm aware, I can only merge one changeset at a time. So I'd have to merge B1 onto C3 creating M1, and B2 onto M1 creating M2, and and B3 onto M2 creating M3. That's three merges I have to perform, and three new merge changesets cluttering up the repository! Is there a way that I can merge B1, B2, and B3 onto C3 all at once, or do I have to settle for modifying history using a rebase?

You can merge B3 and C3 to get:
B1 --- B2 --- B3
/ \
--- A M
\ /
C1 --- C2 --- C3
That is the traditional way to reconsile the two lines of development. The merge changeset will have two parents (merges always have two parents in Mercurial) B3 and C3, but you're still merging the combined effect of B1 to B3 with the combined effect of C1 to C3.
In fact, merges are only concerned with three states: A, B3, and C3. Since the state B3 include the changes you made in B1 and B2, you end up merging the changes in B1 to B3 into the state C3.
What you describe with three merges is actually what rebase does internally! After creating M1 to M3, it deletes the second parent of these merge commits and deletes B1 to B3. That leaves you with
--- A --- C1 --- C2 --- C3 --- M1 --- M2 --- M3
where Mi ~= Bi. As you note, this is a less accurate picture of what actually happened in the repository because you've linearized history what was really done in parallel.

Related

How to default highest version filter in tableau dashboard?

I am trying to build a dashboard which displays record count by product, category and versions. One product can have multiple versions and one version will have multiple categories. I want to build this dashboard by defaulting it to show the record count by category for the highest version of the selected product whenever any user opens the Tableau dashboard. How do I set my filter so that initially, the dashboard only displays record count for the highest version for each category for the selected product?
I tried using max version for each product and use that as a filter but when I change the product filter, the dashboard becomes blank as the selected max version is not applicable for this next product.
Data:
Product Versions Category Count
P1 1 C1 15
P1 1 C3 20
P1 1 C4 150
P1 1 C5 200
P1 2 C1 60
P1 2 C3 50
P1 2 C4 10
P1 2 C5 25
P2 8 C1 1500
P2 8 C3 2001
P2 8 C4 1505
P2 8 C5 250
P2 12 C1 600
P2 12 C3 550
P2 12 C4 160
P2 12 C5 258
I expect the output when the user opens the dashboard as:
Filter selection: Product: P2
Category Version Count
C1 12 600
C3 12 550
C4 12 160
C5 12 258
Filter selection: Product: P1
Category Version Count
C1 2 60
C3 2 50
C4 2 10
C5 2 25
There are multiple ways of solving this. One would be to change the product filter to a context filter and keep using the MAX function as the aggregation of the variable count. You do this by right-clicking the filter pill and select "Add to context" This way the product filters out first and the Version filter is applied afterward.
This is probably the simplest in regards that it does not involve creating calculated fields and is just two clicks away.
You can read more about the order of operations here if you want to know more.

Dependency Preserving Decomposition with a functional dependency doesn't appear in the sub-schema

I'm reading a textbook containing the following question:
Given the following relation R {A,B,C,D,E,H} and the functional
dependencies AB->CD, BC->D, C->H, D->HB, CH->AE
does the following decomposition is dependency preserving?
R1(A,C,E,H) R2(B,D,H), R3(A,B,C), R4(B,C,D)
The answer of the textbook was that it is in fact functional dependency preserving, where I thought it wasn't because of the dependency AB->D
Reading this answer made it even more confusing, because it made it seems like if there is a key inside one of the sub relations, the decomposition must be dependency preserving
A counter example that I couldn't dispute is For the two rows
a1 b1 c1 d1 h1 e2
and
a2 b1 c2 d2 h2 e2 all the F.D of R hold, but now R3 has a1 b1 c1 and a2 b1 c2
and R4 has
b1 c1 d1
and
b1 c2 d2, joining R3 and R4 on B gives a1 b1 c2 d2 which breaks the AB->D F.D
In the example the dependencies are preserved as indicated by AntC in the comments.
The condition that a candidate key of the original relation is present in a decomposed relation is not a guarantee that dependencies are preserved.
Consider for instance the relation R(A B C D E) with dependencies {A → E, BCE → A, D → C} and the decomposition R1(A B D), R2(A E), R3(C D). The relation R1 contains one of the candidate keys of the original relation ({ABD}), but in the decomposition the dependency {BCE → A} is not preserved.
The fact that one of the original keys is present in one decomposed relation could be an indication that the decomposition is lossless, but in general there is no relation between lossless decomposition and dependencies preservation (see for instance this). There is however a result that connects in some way the two properties, as shown in an answer to the question cited.

Using constraints across multiple edges in OrientDB

I have a use case where I have 3 nodes connected by 2 edges.
In the example below, how can I constrain the relationship between the nodes so that I can only traverse the graph from A1 to C1 and A2 to C2 but I shouldn't be able to go from A1 to C2 or A2 to C1.
A1 <--edge--> B1 <--edge--> C1
A2 <--edge--> B1 <--edge--> C2
Example use case:
Character(A) PlayedBy(edge) Actor(B) In(edge) Movie(C)
where multiple characters can by played by a single actor in multiple movies but not all characters appeared in all movies linked by the actor. It's a many to one to many relationship where A is also linked to C.

how to interchange columns and rows in a file using spark

how to convert columns to rows and from rows to columns similar to transpose of matrix for the data present in the file.
for ex:-
input file:-
aa ab ac ad ae af ag
ba bb bc bd be bf bg
ca cb cc cd ce cf cg
output file:-
aa ba ca
ab bb cb
ac bc cc
ad bd cd
ae be ce
af bf cf
ag bg cg
Thank you :)
Similar to the question here:
How to transpose an RDD in Spark
You can convert the DataFrame back to an rdd by calling df.rdd and follow the same steps provided in the post about RDDs.
If the DataFrame is small enough, his first example of a simple transform using collect() would work.

Break a command into several lines in do-file in Stata

I want to run the keep command in a do-file in Stata 12:
keep a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4
What I want is to do the following:
keep {a1 a2 a3 a4 a5
b1 b2 b3 b4 b5
c1 c2 c3 c4}
I know the {} brackets don't do the trick but I'm looking for the command that does it. Using #delimiter ; does not work either.
I want to do this because subgroups of variables have a relation among themselves (which I intended to signal above by using a, b and c) and I want to have that clear in my code. I permanently add and delete variables. Note that I don't want to use the drop command (in which case the solution is trivial).
There are several ways. One is using ///. An example:
clear all
set more off
*----- example data -----
set obs 1
forvalues i = 1/25 {
gen var`i' = `i'
}
describe
*----- what you want -----
keep var1 var2 ///
var3-var7 ///
var8 var11
describe
#delimit will work if used correctly. An example:
<snip>
*----- what you want -----
#delimit ;
keep var1 var2
var3-var7
var8 var11 ;
#delimit cr
describe
There is still another way. help delimit (which you already knew about) states:
See [U] 16.1.3 Long lines in do-files for more information.
That manual entry points you directly to the relevant information.
I suspect lack of research/effort in this case. A Google search (with "stata + break lines in do files") would have easily gotten you there. I'm not recommending this be your first strategy when trying to solve problems in Stata. Rather, start with Stata resources: I recommend reading
[U] 3 Resources for learning and using Stata
[U] 4 Stata’s help and search facilities.
This is just a very simple trick to complement the real solutions by Roberto. Since you have so many variables, one thing I found sometimes useful is to use macros to group variables, especially if you can use the grouping in more than one occasion.
loca a a1 a2 a3 a4 a5
loca b b1 b2 b3 b4 b5
loca c c1 c2 c3 c4 c5
keep `a' `b' `c'