Software Engineering Laboratory Department of Computer Science Graduate
ソースコードの木構造を考慮した 差分計算を用いる 版管理システムの提案 早瀬 康裕, 松下 誠, 井上 克朗 大阪大学大学院情報科学研究科 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1
研究の背景 版管理システム ソースコードやドキュメントなどの開発履歴を保存するシ ステム CVS に代表される オープンソース開発では、必ずと言ってよいほど使わ れている CVS の使用例: Free. BSD, XFree 86, Postgre. SQL 等 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 2
問題点 1 不要な衝突 開発者 A と B が同じファイルを編集している 同じ行を編集すると変更点が衝突 行が同じでも衝突するとは限らない int refs; /* reference count */ マ ー int refs=0; ジ 失 敗 int refs=0; /* reference count */ Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 6
問題点 2 衝突の見逃し 開発者 A と B が同じファイルを編集している 衝突すべき変更を、行が違うために見逃す A が変数を削除 B が削除された変数を利用するコードを追加 int num, sum; int num, sum, avg; : avg = sum/num; int num, sum; : avg = sum/num; 不正なマージ結果 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 7
FMES アルゴリズム 差分スクリプトを求める近似アルゴリズム 時間計算量 O(ne+e 2) (e は差の大きさ) 良い近似を得るための条件: e << n 編集操作は insert, delete, update, move insert のコスト = delete のコスト = moveのコスト =1 update のコストは変更前後の値によって 0以上 2以下の値 提案手法では (1 – 文字列の共通部分の長さ*2/書換え前後の文字列の長さの和)*2 2つの段階に分けられる 1. ツリー間での頂点の対応関係の計算 葉と内部頂点を区別 類似度が閾値以下の頂点同士は対応しないと仮定 2. 頂点の対応が取れたツリー間で編集スクリプトを計算 S. Chawathe, A. Rajaraman, H. Garcia-Molina, and J. Widom. Change detection in hierarchically structured information. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 493 -504, Montr'eal, Qu'ebec, June 1996. Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 14
マージの例 A 0 B if 1 then 4 else 2 do. A 5 do. B x 3 6 C 0 1 then 4 2 do. A 8 update(6, i) move(5, 1, 1) delete(4) 1 5 else do. C update(6, i) move(5, 1, 1) move(8, delete(4) D 1 1 8 do. C 9 3 x 9 z 0 z if then do. B 6 y if 0 i 2 do. A 3 x D 2 if then 2 do. A 3 x 0 D 3 if 0 if 1 then 4 else 1 then 2 do. A 8 do. C 2 do. A 3 x 9 z Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 3 x 17
システムを使って解決する問題1 行単位のマージでは、同じ行の編集で衝突していた int refs; /* reference count */ ー int refs=0; マ ジ 失 敗 int refs=0; /* reference count */ Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 18
問題1 に提案手法を使った場合 Declare 元の行 int refs 0 親 ー 親 マ ジ 成 功 親 Declare int 親 int refs Declare int refs Comment 0 reference count Comment refs reference count ソースコード に変換 int refs=0; /* reference count */ Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 19
システムを使って解決する問題2 宣言されていない変数を使う問題を見逃していた int num, sum; int num, sum, avg; : avg = sum/num; int num, sum; : avg = sum/num; 不正なマージ結果 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 20
問題2 に提案手法を使った場合 Declare List int num sum 変数の参照先が無いので衝突 Declare List int num sum int avg num sum リンク切れ variable Declare List int num sum avg variable Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 21
システムの概要 subversion クライアント subversion サーバ 差分計算 FMES, xmdiff 制約検査して 違反数で整列 差分適用 XMLのマージ機能 リポジトリ ソースコードとXMLの変換 開 発 者 ソースコードに変換 頂点対応の計算 (FMESの前段階) XMLへ変換 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 23
- Slides: 26