@@ -225,6 +225,10 @@ private void initDB(Statement s) throws SQLException {
225
225
s .execute (getQuery ("createTableFilechanges" ));
226
226
}
227
227
228
+ if (!tableExists (dmd , SCHEMA , "FILEMOVES" )) {
229
+ s .execute (getQuery ("createTableFilemoves" ));
230
+ }
231
+
228
232
// Derby has some performance problems with auto-generated identity
229
233
// columns when multiple threads insert into the same table
230
234
// concurrently. Therefore, we have our own light-weight id generators
@@ -617,6 +621,9 @@ public void store(History history, Repository repository)
617
621
618
622
private static final PreparedQuery ADD_FILECHANGE =
619
623
new PreparedQuery (getQuery ("addFilechange" ));
624
+
625
+ private static final PreparedQuery ADD_FILEMOVE =
626
+ new PreparedQuery (getQuery ("addFilemove" ));
620
627
621
628
/**
622
629
* Get ID value for revision string by querying the DB.
@@ -646,6 +653,7 @@ private void storeHistory(ConnectionResource conn, History history,
646
653
PreparedStatement addChangeset = null ;
647
654
PreparedStatement addDirchange = null ;
648
655
PreparedStatement addFilechange = null ;
656
+ PreparedStatement addFilemove = null ;
649
657
RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
650
658
651
659
// return immediately when there is nothing to do
@@ -687,6 +695,10 @@ private void storeHistory(ConnectionResource conn, History history,
687
695
addFilechange = conn .getStatement (ADD_FILECHANGE );
688
696
}
689
697
698
+ if (addFilemove == null ) {
699
+ addFilemove = conn .getStatement (ADD_FILEMOVE );
700
+ }
701
+
690
702
// Success! Break out of the loop.
691
703
break ;
692
704
@@ -748,7 +760,6 @@ private void storeHistory(ConnectionResource conn, History history,
748
760
file .substring (repodir .length () + 1 ))) {
749
761
int fileId = files .get (fullPath );
750
762
addFilechange .setInt (2 , fileId );
751
- addFilechange .setInt (3 , 0 );
752
763
addFilechange .executeUpdate ();
753
764
}
754
765
String [] pathElts = splitPath (fullPath );
@@ -801,19 +812,22 @@ private void storeHistory(ConnectionResource conn, History history,
801
812
for (int i = 0 ;; i ++) {
802
813
try {
803
814
int changesetId = getIdForRevision (entry .getRevision ());
804
- addFilechange .setInt (1 , changesetId );
805
- addFilechange .setInt (2 , fileId );
815
+
806
816
/*
807
- * If the file exists in the changeset, set its
808
- * moved value to 0 so it can be found when performing
809
- * historyget on directory.
817
+ * If the file exists in the changeset, store it in
818
+ * the table tracking moves of the file when it had
819
+ * one of its precedent names so it can be found
820
+ * when performing historyget on directory.
810
821
*/
811
822
if (entry .getFiles ().contains (repo_path )) {
812
- addFilechange .setInt (3 , 0 );
823
+ addFilechange .setInt (1 , changesetId );
824
+ addFilechange .setInt (2 , fileId );
825
+ addFilechange .executeUpdate ();
813
826
} else {
814
- addFilechange .setInt (3 , 1 );
827
+ addFilemove .setInt (1 , changesetId );
828
+ addFilemove .setInt (2 , fileId );
829
+ addFilemove .executeUpdate ();
815
830
}
816
- addFilechange .executeUpdate ();
817
831
818
832
conn .commit ();
819
833
break retry ;
0 commit comments