Rev 20: All tests are passing again in http://bzr.arbash-meinel.com/plugins/git
John Arbash Meinel
john at arbash-meinel.com
Fri Nov 9 04:40:49 GMT 2007
At http://bzr.arbash-meinel.com/plugins/git
------------------------------------------------------------
revno: 20
revision-id:john at arbash-meinel.com-20071109044042-l0d388d8w9by06lg
parent: john at arbash-meinel.com-20071109041701-63ivdne9bip3f9fr
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: git
timestamp: Thu 2007-11-08 23:40:42 -0500
message:
All tests are passing again
modified:
gitlib/git_branch.py git_branch.py-20071108230535-su8dxk529f4uk9fx-2
gitlib/git_repository.py git_repository.py-20071108234408-ygidvy5hviixghsd-2
gitlib/model.py model.py-20071109031625-vi84303d1n5gnha1-1
tests/test_git_branch.py test_git_branch.py-20071108234408-ygidvy5hviixghsd-3
tests/test_model.py test_model.py-20071109031625-vi84303d1n5gnha1-2
-------------- next part --------------
=== modified file 'gitlib/git_branch.py'
--- a/gitlib/git_branch.py 2007-11-09 04:17:01 +0000
+++ b/gitlib/git_branch.py 2007-11-09 04:40:42 +0000
@@ -23,6 +23,8 @@
)
from bzrlib.decorators import needs_read_lock
+from bzrlib.plugins.git.gitlib import ids
+
class GitBranchConfig(config.BranchConfig):
"""BranchConfig that uses locations.conf in place of branch.conf"""
@@ -70,6 +72,8 @@
@needs_read_lock
def revision_history(self):
node = self.last_revision()
+ if node == revision.NULL_REVISION:
+ return []
ancestors = self.repository.get_revision_graph(node)
history = []
while node is not None:
=== modified file 'gitlib/git_repository.py'
--- a/gitlib/git_repository.py 2007-11-09 04:17:01 +0000
+++ b/gitlib/git_repository.py 2007-11-09 04:40:42 +0000
@@ -17,11 +17,15 @@
"""An adapter between a Git Repository and a Bazaar Branch"""
from bzrlib import (
+ deprecated_graph,
repository,
urlutils,
)
-from bzrlib.plugins.git.gitlib import model
+from bzrlib.plugins.git.gitlib import (
+ ids,
+ model,
+ )
class GitRepository(repository.Repository):
@@ -53,10 +57,12 @@
return self.get_revision_graph_with_ghosts(revisions).get_ancestors()
def get_revision_graph_with_ghosts(self, revision_ids=None):
- result = deprecated_graph.Graph()
- for revision in self._ancestor_revisions(revision_ids):
- result.add_node(revision.revision_id, revision.parent_ids)
- self._revision_cache[revision.revision_id] = revision
+ result = {}
+ for node, parents in self._git.ancestry(None).iteritems():
+ bzr_node = ids.convert_revision_id_git_to_bzr(node)
+ bzr_parents = [ids.convert_revision_id_git_to_bzr(n)
+ for n in parents]
+ result[bzr_node] = bzr_parents
return result
def get_revision(self, revision_id):
=== modified file 'gitlib/model.py'
--- a/gitlib/model.py 2007-11-09 04:17:01 +0000
+++ b/gitlib/model.py 2007-11-09 04:40:42 +0000
@@ -16,6 +16,7 @@
"""The model for interacting with the git process, etc."""
+import os
import subprocess
from bzrlib.plugins.git.gitlib import errors
@@ -28,13 +29,16 @@
self.git_dir = git_dir
def git_command(self, command, args):
- return ['git', '--git-dir', self.git_dir, command] + args
+ return ['git', command] + args
def git_lines(self, command, args):
cmd = self.git_command(command, args)
+ env = os.environ.copy()
+ env['GIT_DIR'] = self.git_dir
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.PIPE,
+ env=env)
lines = p.stdout.readlines()
if p.wait() != 0:
raise errors.GitCommandError(cmd, p.returncode,
@@ -70,7 +74,7 @@
def rev_parse(self, git_id):
args = ['--verify', git_id]
- return self.git_line('rev-parse', args)
+ return self.git_line('rev-parse', args).strip()
def get_head(self):
try:
=== modified file 'tests/test_git_branch.py'
--- a/tests/test_git_branch.py 2007-11-09 04:17:01 +0000
+++ b/tests/test_git_branch.py 2007-11-09 04:40:42 +0000
@@ -21,7 +21,10 @@
from bzrlib import branch, revision
from bzrlib.plugins.git import tests
-from bzrlib.plugins.git.gitlib import git_branch
+from bzrlib.plugins.git.gitlib import (
+ git_branch,
+ ids,
+ )
class TestGitBranch(tests.TestCaseInTempDir):
@@ -41,3 +44,14 @@
self.assertEqual(revision.NULL_REVISION, thebranch.last_revision())
self.assertEqual((0, revision.NULL_REVISION),
thebranch.last_revision_info())
+
+ def test_last_revision_is_valid(self):
+ tests.run_git('init')
+ self.build_tree(['a'])
+ tests.run_git('add', 'a')
+ tests.run_git('commit', '-m', 'a')
+ head = tests.run_git('rev-parse', 'HEAD').strip()
+
+ thebranch = branch.Branch.open('.')
+ self.assertEqual(ids.convert_revision_id_git_to_bzr(head),
+ thebranch.last_revision())
=== modified file 'tests/test_model.py'
--- a/tests/test_model.py 2007-11-09 04:17:01 +0000
+++ b/tests/test_model.py 2007-11-09 04:40:42 +0000
@@ -57,4 +57,5 @@
}
themodel = model.GitModel('.git')
+ self.assertEqual(revisions[0], themodel.get_head())
self.assertEqual(graph, themodel.ancestry([revisions[0]]))
More information about the bazaar-commits
mailing list