| 246 | |
| 247 | |
| 248 | def test_update_rev(tmp_dir, dvc, scm, git_dir): |
| 249 | with git_dir.chdir(): |
| 250 | git_dir.scm_gen({"foo": "foo"}, commit="first") |
| 251 | |
| 252 | dvc.imp(os.fspath(git_dir), "foo") |
| 253 | assert (tmp_dir / "foo.dvc").exists() |
| 254 | |
| 255 | with git_dir.chdir(), git_dir.branch("branch1", new=True): |
| 256 | git_dir.scm_gen({"foo": "foobar"}, commit="branch1 commit") |
| 257 | branch1_head = git_dir.scm.get_rev() |
| 258 | |
| 259 | with git_dir.chdir(), git_dir.branch("branch2", new=True): |
| 260 | git_dir.scm_gen({"foo": "foobar foo"}, commit="branch2 commit") |
| 261 | branch2_head = git_dir.scm.get_rev() |
| 262 | |
| 263 | stage = dvc.update(["foo.dvc"], rev="branch1")[0] |
| 264 | assert stage.deps[0].def_repo == { |
| 265 | "url": os.fspath(git_dir), |
| 266 | "rev": "branch1", |
| 267 | "rev_lock": branch1_head, |
| 268 | } |
| 269 | with open(tmp_dir / "foo", encoding="utf-8") as f: |
| 270 | assert f.read() == "foobar" |
| 271 | |
| 272 | stage = dvc.update(["foo.dvc"], rev="branch2")[0] |
| 273 | assert stage.deps[0].def_repo == { |
| 274 | "url": os.fspath(git_dir), |
| 275 | "rev": "branch2", |
| 276 | "rev_lock": branch2_head, |
| 277 | } |
| 278 | with open(tmp_dir / "foo", encoding="utf-8") as f: |
| 279 | assert f.read() == "foobar foo" |
| 280 | |
| 281 | |
| 282 | def test_update_recursive(tmp_dir, dvc, erepo_dir): |