##// END OF EJS Templates
git: use new sync_fetch that uses git subcommand instead of fragile dulwich code.
marcink -
r549:ed3e9024 default
parent child Browse files
Show More
@@ -14,7 +14,7 b''
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software Foundation,
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17 import collections
18 18 import logging
19 19 import os
20 20 import posixpath as vcspath
@@ -448,13 +448,49 b' class GitRemote(object):'
448 448 return remote_refs
449 449
450 450 @reraise_safe_exceptions
451 def sync_fetch(self, wire, url, refs=None):
452 repo = self._factory.repo(wire)
453 if refs and not isinstance(refs, (list, tuple)):
454 refs = [refs]
455
456 # get remote heads
457 output, __ = self.run_git_command(
458 wire, ['ls-remote', url], fail_on_stderr=False,
459 _copts=['-c', 'core.askpass=""'],
460 extra_env={'GIT_TERMINAL_PROMPT': '0'})
461
462 remote_refs = collections.OrderedDict()
463 fetch_refs = []
464 for ref_line in output.splitlines():
465 sha, ref = ref_line.split('\t')
466 sha = sha.strip()
467 remote_refs[ref] = sha
468
469 if refs and sha in refs:
470 # we filter fetch using our specified refs
471 fetch_refs.append('{}:{}'.format(ref, ref))
472 elif not refs:
473 fetch_refs.append('{}:{}'.format(ref, ref))
474
475 fetch_refs.append('{}:{}'.format(ref, ref))
476
477 _out, _err = self.run_git_command(
478 wire, ['fetch', url, '--'] + fetch_refs, fail_on_stderr=False,
479 _copts=['-c', 'core.askpass=""'],
480 extra_env={'GIT_TERMINAL_PROMPT': '0'})
481
482 return remote_refs
483
484 @reraise_safe_exceptions
451 485 def sync_push(self, wire, url, refs=None):
452 if self.check_url(url, wire):
453 repo = self._factory.repo(wire)
454 self.run_git_command(
455 wire, ['push', url, '--mirror'], fail_on_stderr=False,
456 _copts=['-c', 'core.askpass=""'],
457 extra_env={'GIT_TERMINAL_PROMPT': '0'})
486 if not self.check_url(url, wire):
487 return
488
489 repo = self._factory.repo(wire)
490 self.run_git_command(
491 wire, ['push', url, '--mirror'], fail_on_stderr=False,
492 _copts=['-c', 'core.askpass=""'],
493 extra_env={'GIT_TERMINAL_PROMPT': '0'})
458 494
459 495 @reraise_safe_exceptions
460 496 def get_remote_refs(self, wire, url):
@@ -585,19 +585,21 b' class HgRemote(object):'
585 585
586 586 @reraise_safe_exceptions
587 587 def sync_push(self, wire, url):
588 if self.check_url(url, wire['config']):
589 repo = self._factory.repo(wire)
588 if not self.check_url(url, wire['config']):
589 return
590 590
591 # Disable any prompts for this repo
592 repo.ui.setconfig('ui', 'interactive', 'off', '-y')
591 repo = self._factory.repo(wire)
592
593 # Disable any prompts for this repo
594 repo.ui.setconfig('ui', 'interactive', 'off', '-y')
593 595
594 bookmarks = dict(repo._bookmarks).keys()
595 remote = peer(repo, {}, url)
596 # Disable any prompts for this remote
597 remote.ui.setconfig('ui', 'interactive', 'off', '-y')
596 bookmarks = dict(repo._bookmarks).keys()
597 remote = peer(repo, {}, url)
598 # Disable any prompts for this remote
599 remote.ui.setconfig('ui', 'interactive', 'off', '-y')
598 600
599 return exchange.push(
600 repo, remote, newbranch=True, bookmarks=bookmarks).cgresult
601 return exchange.push(
602 repo, remote, newbranch=True, bookmarks=bookmarks).cgresult
601 603
602 604 @reraise_safe_exceptions
603 605 def revision(self, wire, rev):
General Comments 0
You need to be logged in to leave comments. Login now