25
25
from dulwich.ignore import (
26
26
IgnoreFilterManager,
28
from dulwich.config import ConfigFile as GitConfigFile
28
29
from dulwich.file import GitFile, FileLocked
29
30
from dulwich.index import (
1240
1243
def _read_submodule_head(self, path):
1241
1244
return read_submodule_head(self.abspath(path))
1243
def get_reference_revision(self, path):
1246
def get_reference_revision(self, path, branch=None):
1244
1247
hexsha = self._read_submodule_head(path)
1245
1248
if hexsha is None:
1246
1249
return _mod_revision.NULL_REVISION
1325
1328
new_parents = [revision_id]
1326
1329
tree.set_parent_ids(new_parents)
1331
def reference_parent(self, path, possible_transports=None):
1332
remote_url = self.get_reference_info(path)
1333
if remote_url is None:
1334
trace.warning("Unable to find submodule info for %s", path)
1336
return _mod_branch.Branch.open(remote_url, possible_transports=possible_transports)
1338
def get_reference_info(self, path):
1339
submodule_info = self._submodule_info()
1340
info = submodule_info.get(path.encode('utf-8'))
1343
return info[0].decode('utf-8')
1345
def set_reference_info(self, tree_path, branch_location):
1346
path = self.abspath('.gitmodules')
1348
config = GitConfigFile.from_path(path)
1349
except EnvironmentError as e:
1350
if e.errno == errno.ENOENT:
1351
config = GitConfigFile()
1354
section = (b'submodule', tree_path.encode('utf-8'))
1355
if branch_location is None:
1361
branch_location = urlutils.join(
1362
urlutils.strip_segment_parameters(self.branch.user_url),
1366
b'path', tree_path.encode('utf-8'))
1369
b'url', branch_location.encode('utf-8'))
1370
config.write_to_path(path)
1371
self.add('.gitmodules')
1329
1374
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat):