Dulwich.io dulwich / 78a4c1e
Update upstream source from tag 'upstream/0.19.6' Update to upstream version '0.19.6' with Debian dir 043867b11bbd428ac0b6c23b518919b029229c0e Jelmer Vernooij 1 year, 3 months ago
11 changed file(s) with 170 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
2121 env: TEST_REQUIRE=fastimport
2222 - python: 3.3
2323 env: TEST_REQUIRE=fastimport
24 - python: 3.7
25 env: TEST_REQUIRE=fastimport
26 dist: xenial
27 sudo: true
28 - python: 3.8-dev
29 env: TEST_REQUIRE=fastimport
30 dist: xenial
31 sudo: true
32
2433
2534 install:
2635 - travis_retry pip install -U pip coverage codecov flake8 $TEST_REQUIRE
137137 Marcel Schnirring <mschnirring@marcel-schnirring.de>
138138 Adam Bradley <adam_bradley@brown.edu>
139139 Filipp Frizzy <filipp.s.frizzy@gmail.com>
140 Romain Keramitas <r.keramitas@gmail.com>
141 semyon-slepov <semyon.slepov@schibsted.com>
142 Daniel M. Capella <polyzen@users.noreply.github.com>
143 grun <grunseid@gmail.com>
144 Sylvia van Os <sylvia@hackerchick.me>
145 Boris Feld <lothiraldan@gmail.com>
140146
141147 If you contributed but are missing from this list, please send me an e-mail.
0 0.19.5 2018-08-08
0 0.19.6 2018-08-11
1
2 BUG FIXES
3
4 * Fix support for custom transport arguments in ``dulwich.porcelain.clone``.
5 (Semyon Slepov)
6
7 * Fix compatibility with Python 3.8 (Jelmer Vernooij, Daniel M. Capella)
8
9 * Fix some corner cases in ``path_to_tree_path``. (Romain Keramitas)
10
11 * Support paths as bytestrings in various places in ``dulwich.index``
12 (Jelmer Vernooij)
13
14 0.19.5 2018-07-08
115
216 IMPROVEMENTS
317
00 Metadata-Version: 2.1
11 Name: dulwich
2 Version: 0.19.5
2 Version: 0.19.6
33 Summary: [![Build Status](https://travis-ci.org/dulwich/dulwich.png?branch=master)](https://travis-ci.org/dulwich/dulwich)
44 [![Windows Build status](https://ci.appveyor.com/api/projects/status/mob7g4vnrfvvoweb?svg=true)](https://ci.appveyor.com/project/jelmer/dulwich/branch/master)
55
2121
2222 """Python implementation of the Git file formats and protocols."""
2323
24 __version__ = (0, 19, 5)
24 __version__ = (0, 19, 6)
5353 from urllib.parse import unquote as urlunquote
5454
5555 try:
56 import urllib2
5756 import urlparse
5857 except ImportError:
59 import urllib.request as urllib2
6058 import urllib.parse as urlparse
6159
6260 import dulwich
13521350
13531351 @classmethod
13541352 def from_parsedurl(cls, parsedurl, **kwargs):
1355 auth, host = urllib2.splituser(parsedurl.netloc)
13561353 password = parsedurl.password
13571354 if password is not None:
13581355 password = urlunquote(password)
13601357 if username is not None:
13611358 username = urlunquote(username)
13621359 # TODO(jelmer): This also strips the username
1363 parsedurl = parsedurl._replace(netloc=host)
1360 parsedurl = parsedurl._replace(netloc=parsedurl.hostname)
13641361 return cls(urlparse.urlunparse(parsedurl),
13651362 password=password, username=username, **kwargs)
13661363
589589 """
590590 from dulwich.errors import NotGitRepository
591591 from dulwich.repo import Repo
592 # Repo currently expects a "str", so decode if necessary.
593 # TODO(jelmer): Perhaps move this into Repo() ?
594 if not isinstance(path, str):
595 path = path.decode(sys.getfilesystemencoding())
592596 try:
593597 repo = Repo(path)
594598 except NotGitRepository:
689693 save new blobs in
690694 :return: An index entry
691695 """
696 assert isinstance(path, bytes)
692697 try:
693698 st = os.lstat(path)
694699 blob = blob_from_path_and_stat(path, st)
695700 except EnvironmentError as e:
696701 if e.errno == errno.EISDIR:
697 if os.path.exists(os.path.join(path, '.git')):
702 if os.path.exists(os.path.join(path, b'.git')):
698703 head = read_submodule_head(path)
699704 if head is None:
700705 return None
173173
174174
175175 def path_to_tree_path(repopath, path):
176 """Convert a path to a path usable in e.g. an index.
177
178 :param repo: Repository
179 :param path: A path
176 """Convert a path to a path usable in an index, e.g. bytes and relative to
177 the repository root.
178
179 :param repopath: Repository path, absolute or relative to the cwd
180 :param path: A path, absolute or relative to the cwd
180181 :return: A path formatted for use in e.g. an index
181182 """
182 os.path.relpath(path, repopath)
183 if os.path.sep != '/':
184 path = path.replace(os.path.sep, '/')
185 return path.encode(sys.getfilesystemencoding())
183 if not isinstance(path, bytes):
184 path = path.encode(sys.getfilesystemencoding())
185 if not isinstance(repopath, bytes):
186 repopath = repopath.encode(sys.getfilesystemencoding())
187 treepath = os.path.relpath(path, repopath)
188 if treepath.startswith(b'..'):
189 raise ValueError('Path not in repo')
190 return treepath
186191
187192
188193 def archive(repo, committish=None, outstream=default_bytes_out_stream,
320325
321326 reflog_message = b'clone: from ' + source.encode('utf-8')
322327 try:
323 fetch_result = fetch(r, source, origin, message=reflog_message)
328 fetch_result = fetch(
329 r, source, origin, errstream=errstream, message=reflog_message,
330 **kwargs)
324331 target_config = r.get_config()
325332 if not isinstance(source, bytes):
326333 source = source.encode(DEFAULT_ENCODING)
11871194 index = r.open_index()
11881195 ignore_manager = IgnoreFilterManager.from_repo(r)
11891196 for path in paths:
1197 if not no_index and path_to_tree_path(r.path, path) in index:
1198 continue
11901199 if os.path.isabs(path):
11911200 path = os.path.relpath(path, r.path)
1192 if not no_index and path_to_tree_path(r.path, path) in index:
1193 continue
11941201 if ignore_manager.is_ignored(path):
11951202 yield path
11961203
826826 results.staged)
827827 self.assertEqual([], results.unstaged)
828828
829 def test_status(self):
829 def test_status_base(self):
830830 """Integration test for `status` functionality."""
831831
832832 # Commit a dummy file then modify it
857857 self.assertEqual(results.staged['add'][0],
858858 filename_add.encode('ascii'))
859859 self.assertEqual(results.unstaged, [b'foo'])
860
861 def test_status_all(self):
862 del_path = os.path.join(self.repo.path, 'foo')
863 mod_path = os.path.join(self.repo.path, 'bar')
864 add_path = os.path.join(self.repo.path, 'baz')
865 us_path = os.path.join(self.repo.path, 'blye')
866 ut_path = os.path.join(self.repo.path, 'blyat')
867 with open(del_path, 'w') as f:
868 f.write('origstuff')
869 with open(mod_path, 'w') as f:
870 f.write('origstuff')
871 with open(us_path, 'w') as f:
872 f.write('origstuff')
873 porcelain.add(repo=self.repo.path, paths=[del_path, mod_path, us_path])
874 porcelain.commit(repo=self.repo.path, message=b'test status',
875 author=b'author <email>',
876 committer=b'committer <email>')
877 porcelain.remove(self.repo.path, [del_path])
878 with open(add_path, 'w') as f:
879 f.write('origstuff')
880 with open(mod_path, 'w') as f:
881 f.write('more_origstuff')
882 with open(us_path, 'w') as f:
883 f.write('more_origstuff')
884 porcelain.add(repo=self.repo.path, paths=[add_path, mod_path])
885 with open(us_path, 'w') as f:
886 f.write('\norigstuff')
887 with open(ut_path, 'w') as f:
888 f.write('origstuff')
889 results = porcelain.status(self.repo.path)
890 self.assertDictEqual(
891 {'add': [b'baz'], 'delete': [b'foo'], 'modify': [b'bar']},
892 results.staged)
893 self.assertListEqual(results.unstaged, [b'blye'])
894 self.assertListEqual(results.untracked, ['blyat'])
860895
861896 def test_get_tree_changes_add(self):
862897 """Unit test for get_tree_changes add."""
12821317
12831318 def test_check_ignored(self):
12841319 with open(os.path.join(self.repo.path, '.gitignore'), 'w') as f:
1285 f.write("foo")
1286 with open(os.path.join(self.repo.path, 'foo'), 'w') as f:
1287 f.write("BAR")
1288 with open(os.path.join(self.repo.path, 'bar'), 'w') as f:
1289 f.write("BAR")
1320 f.write('foo')
1321 foo_path = os.path.join(self.repo.path, 'foo')
1322 with open(foo_path, 'w') as f:
1323 f.write('BAR')
1324 bar_path = os.path.join(self.repo.path, 'bar')
1325 with open(bar_path, 'w') as f:
1326 f.write('BAR')
12901327 self.assertEqual(
12911328 ['foo'],
1292 list(porcelain.check_ignore(self.repo, ['foo'])))
1293 self.assertEqual([], list(porcelain.check_ignore(self.repo, ['bar'])))
1294
1295 def test_check_added(self):
1296 with open(os.path.join(self.repo.path, 'foo'), 'w') as f:
1297 f.write("BAR")
1329 list(porcelain.check_ignore(self.repo, [foo_path])))
1330 self.assertEqual(
1331 [], list(porcelain.check_ignore(self.repo, [bar_path])))
1332
1333 def test_check_added_abs(self):
1334 path = os.path.join(self.repo.path, 'foo')
1335 with open(path, 'w') as f:
1336 f.write('BAR')
12981337 self.repo.stage(['foo'])
12991338 with open(os.path.join(self.repo.path, '.gitignore'), 'w') as f:
1300 f.write("foo\n")
1301 self.assertEqual(
1302 [], list(porcelain.check_ignore(self.repo, ['foo'])))
1339 f.write('foo\n')
1340 self.assertEqual(
1341 [], list(porcelain.check_ignore(self.repo, [path])))
13031342 self.assertEqual(
13041343 ['foo'],
1305 list(porcelain.check_ignore(self.repo, ['foo'], no_index=True)))
1344 list(porcelain.check_ignore(self.repo, [path], no_index=True)))
1345
1346 def test_check_added_rel(self):
1347 with open(os.path.join(self.repo.path, 'foo'), 'w') as f:
1348 f.write('BAR')
1349 self.repo.stage(['foo'])
1350 with open(os.path.join(self.repo.path, '.gitignore'), 'w') as f:
1351 f.write('foo\n')
1352 cwd = os.getcwd()
1353 os.mkdir(os.path.join(self.repo.path, 'bar'))
1354 os.chdir(os.path.join(self.repo.path, 'bar'))
1355 try:
1356 self.assertEqual(
1357 list(porcelain.check_ignore(self.repo, ['../foo'])), [])
1358 self.assertEqual(['../foo'], list(
1359 porcelain.check_ignore(self.repo, ['../foo'], no_index=True)))
1360 finally:
1361 os.chdir(cwd)
13061362
13071363
13081364 class UpdateHeadTests(PorcelainTestCase):
14301486 self.assertEqual(
14311487 'tryme-1-g{}'.format(sha[:7].decode('ascii')),
14321488 porcelain.describe(self.repo.path))
1489
1490
1491 class HelperTests(PorcelainTestCase):
1492 def test_path_to_tree_path_base(self):
1493 self.assertEqual(
1494 b'bar', porcelain.path_to_tree_path('/home/foo', '/home/foo/bar'))
1495 self.assertEqual(b'bar', porcelain.path_to_tree_path('.', './bar'))
1496 self.assertEqual(b'bar', porcelain.path_to_tree_path('.', 'bar'))
1497 cwd = os.getcwd()
1498 self.assertEqual(
1499 b'bar', porcelain.path_to_tree_path('.', os.path.join(cwd, 'bar')))
1500 self.assertEqual(b'bar', porcelain.path_to_tree_path(cwd, 'bar'))
1501
1502 def test_path_to_tree_path_syntax(self):
1503 self.assertEqual(b'bar', porcelain.path_to_tree_path(b'.', './bar'))
1504 self.assertEqual(b'bar', porcelain.path_to_tree_path('.', b'./bar'))
1505 self.assertEqual(b'bar', porcelain.path_to_tree_path(b'.', b'./bar'))
1506
1507 def test_path_to_tree_path_error(self):
1508 with self.assertRaises(ValueError):
1509 porcelain.path_to_tree_path('/home/foo/', '/home/bar/baz')
1510
1511 def test_path_to_tree_path_rel(self):
1512 cwd = os.getcwd()
1513 os.mkdir(os.path.join(self.repo.path, 'foo'))
1514 os.mkdir(os.path.join(self.repo.path, 'foo/bar'))
1515 try:
1516 os.chdir(os.path.join(self.repo.path, 'foo/bar'))
1517 self.assertEqual(b'bar/baz', porcelain.path_to_tree_path(
1518 '..', 'baz'))
1519 self.assertEqual(b'bar/baz', porcelain.path_to_tree_path(
1520 os.path.join(os.getcwd(), '..'),
1521 os.path.join(os.getcwd(), 'baz')))
1522 self.assertEqual(b'bar/baz', porcelain.path_to_tree_path(
1523 '..', os.path.join(os.getcwd(), 'baz')))
1524 self.assertEqual(b'bar/baz', porcelain.path_to_tree_path(
1525 os.path.join(os.getcwd(), '..'), 'baz'))
1526 finally:
1527 os.chdir(cwd)
00 Metadata-Version: 2.1
11 Name: dulwich
2 Version: 0.19.5
2 Version: 0.19.6
33 Summary: [![Build Status](https://travis-ci.org/dulwich/dulwich.png?branch=master)](https://travis-ci.org/dulwich/dulwich)
44 [![Windows Build status](https://ci.appveyor.com/api/projects/status/mob7g4vnrfvvoweb?svg=true)](https://ci.appveyor.com/project/jelmer/dulwich/branch/master)
55
1313 import os
1414 import sys
1515
16 dulwich_version_string = '0.19.5'
16 dulwich_version_string = '0.19.6'
1717
1818 include_dirs = []
1919 # Windows MSVC support