本文整理汇总了Python中mercurial.commands.pull函数的典型用法代码示例。如果您正苦于以下问题:Python pull函数的具体用法?Python pull怎么用?Python pull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pull函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download_patch
def download_patch(source, lastrev, patchbranch):
from mercurial import hg, ui, localrepo, commands, bundlerepo
UI = ui.ui()
bundle = tempfile.mktemp(dir="/var/tmp")
cwd = os.getcwd()
os.chdir(base)
try:
repo0 = hg.repository(UI,base)
repo0.ui.quiet=True
repo0.ui.pushbuffer()
commands.pull(repo0.ui, repo0, quiet=True)
repo0.ui.popbuffer() # discard all pull output
# find out what the head revision of the given branch is
repo0.ui.pushbuffer()
head = repo0.ui.popbuffer().strip()
repo0.ui.pushbuffer()
if commands.incoming(repo0.ui, repo0, source=source, branch=[patchbranch], bundle=bundle, force=False) != 0:
raise ValueError, "Repository contains no changes"
rhead = repo0.ui.popbuffer()
if rhead:
# output is a list of revisions, one per line. last line should be newest revision
rhead = rhead.splitlines()[-1].split(':')[1]
if rhead == lastrev:
raise NotChanged
repo=bundlerepo.bundlerepository(UI, ".", bundle)
repo.ui.pushbuffer()
old = 'max(ancestors(branch("%s"))-outgoing("%s"))' % (patchbranch, base)
commands.diff(repo.ui, repo, rev=[old, patchbranch])
result = repo.ui.popbuffer()
finally:
os.chdir(cwd)
if os.path.exists(bundle):
os.unlink(bundle)
return result, rhead
示例2: pull
def pull(self, source=None, target=None):
from mercurial import commands, hg, ui, error
log.debug("Clone or update HG repository.")
source = source or self.source
target = target or self.target
# Folders need to be manually created
if not os.path.exists(target):
os.makedirs(target)
# Doesn't work with unicode type
url = str(source)
path = str(target)
try:
repo = hg.repository(ui.ui(), path)
commands.pull(ui.ui(), repo, source=url)
commands.update(ui.ui(), repo)
log.debug("Mercurial: repository at " + url + " updated.")
except error.RepoError, e:
log.debug("Mercurial: " + str(e))
try:
commands.clone(ui.ui(), url, path)
log.debug("Mercurial: repository at " + url + " cloned.")
except Exception, e:
log.debug("Mercurial: " + str(e))
raise PullFromRepositoryException(unicode(e))
示例3: test_onerevision_noupdate
def test_onerevision_noupdate(self):
repo, repo_path = self._loadupdate('single_rev.svndump')
state = repo.parents()
self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'})
commands.pull(self.repo.ui, repo)
self.assertEqual(state, repo.parents())
self.assertTrue('tip' not in repo[None].tags())
示例4: test_onerevision_doupdate
def test_onerevision_doupdate(self):
repo = self._load_fixture_and_fetch('single_rev.svndump')
state = repo.parents()
self._add_svn_rev({'trunk/alpha': 'Changed'})
commands.pull(self.repo.ui, repo, update=True)
self.failIfEqual(state, repo.parents())
self.assertTrue('tip' in repo[None].tags())
示例5: test_skip_delete_restore
def test_skip_delete_restore(self):
repo, repo_path = self._loadupdate('delete_restore_trunk.svndump',
rev=2)
repo.ui.setconfig('hgsubversion', 'unsafeskip', '3 4')
commands.pull(repo.ui, repo)
tip = repo['tip'].rev()
self.assertEqual(tip, 1)
self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 0)
示例6: test_old_tag_map_rebuilds
def test_old_tag_map_rebuilds(self):
repo = self._load_fixture_and_fetch('tag_name_same_as_branch.svndump')
tm = os.path.join(repo.path, 'svn', 'tagmap')
open(tm, 'w').write('1\n')
# force tags to load since it is lazily loaded when needed
repo.svnmeta().tags
commands.pull(repo.ui, repo)
self.assertEqual(open(tm).read().splitlines()[0], '2')
示例7: update
def update(self, branch=None):
""" Update the local repository for recent changes. """
if branch is None:
branch = self.branch
print "*** Updating to branch '%s'" % branch
commands.pull(ui.ui(), self._repository, self.url)
commands.update(ui.ui(), self._repository, None, branch, True)
示例8: update
def update(self, stdout=None):
"""
Pull and update all changes from hg repository
Note that this command destroy all local changes
"""
u, r = self._hg(stdout)
commands.pull(u, r)
commands.update(u, r, clean=True)
del u, r
示例9: update
def update(self):
self._send_callback(self.callback_on_action_notify,_('Updating repository %s') % self._remote_path)
try:
self.cleanup()
commands.pull(self.repo.ui, self.repo, rev=None, force=False, update=True)
commands.update(self.repo.ui, self.repo, self.branch)
self._process_files()
except RepoError, e:
raise BrowserException, e
示例10: test_skip_basic
def test_skip_basic(self):
repo, repo_path = self._loadupdate('single_rev.svndump')
self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'})
self.add_svn_rev(repo_path, {'trunk/beta': 'More changed'})
self.add_svn_rev(repo_path, {'trunk/gamma': 'Even more changeder'})
repo.ui.setconfig('hgsubversion', 'unsafeskip', '3 4')
commands.pull(repo.ui, repo)
tip = repo['tip'].rev()
self.assertEqual(tip, 1)
self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 1)
示例11: pull
def pull(self, url):
"""
Tries to pull changes from external location.
"""
url = self._get_url(url)
try:
pull(self.baseui, self._repo, url)
except Abort, err:
# Propagate error but with vcs's type
raise RepositoryError(str(err))
示例12: pop_queue
def pop_queue(request, queue_name):
# test count with
# curl -i http://localhost:8000/q/default/
# curl -i http://localhost:8000/q/default/json/
# print "GET queue_name is %s" % queue_name
q = None
# pre-emptive queue name checking...
try:
q = Queue.objects.get(name=queue_name)
except Queue.DoesNotExist:
return HttpResponseNotFound()
#
msg = q.message_set.pop()
response_message='void'
if msg:
u = ui.ui()
message = json_encode(msg.message)
project = Project.projects.get(project_id__exact = message['local_parent_project'])
repo = Repo.objects.get(directory_name__exact=message['directory_name'], local_parent_project__exact=project)
if (queue_name == 'repoclone'):
try:
hg.clone(u, str(repo.default_path), repo.repo_directory, True)
repo.created = True
except:
response_message = 'failed'
try:
m = Message.objects.get(id=msg.id, queue=q.id)
m.delete()
repo.save()
project.save()
response_message = 'success'
except:
response_message = 'failed'
elif (queue_name == 'repoupdate'):
location = hg.repository(u, repo.repo_directory)
try:
commands.pull(u, location, str(repo.default_path), rev=['tip'], force=True, update=True)
repo.folder_size = 0
for (path, dirs, files) in os.walk(repo.repo_directory):
for file in files:
filename = os.path.join(path, file)
repo.folder_size += os.path.getsize(filename)
repo.save()
m = Message.objects.get(id=msg.id, queue=q.id)
m.delete()
project.save()
response_message = 'success'
except:
response_message = 'failed'
if (response_message == 'failed'):
return HttpResponseServerError()
else:
return HttpResponse(response_message)
示例13: handlePushes
def handlePushes(repo_id, submits, do_update=True):
if not submits:
return
repo = Repository.objects.get(id=repo_id)
revisions = reduce(lambda r,l: r+l,
[p.changesets for p in submits],
[])
ui = _ui()
repopath = os.path.join(settings.REPOSITORY_BASE,
repo.name)
configpath = os.path.join(repopath, '.hg', 'hgrc')
if not os.path.isfile(configpath):
if not os.path.isdir(os.path.dirname(repopath)):
os.makedirs(os.path.dirname(repopath))
clone(ui, str(repo.url), str(repopath),
pull=False, uncompressed=False, rev=[],
noupdate=False)
cfg = open(configpath, 'a')
cfg.write('default-push = ssh%s\n' % str(repo.url)[4:])
cfg.close()
ui.readconfig(configpath)
hgrepo = repository(ui, repopath)
else:
ui.readconfig(configpath)
hgrepo = repository(ui, repopath)
cs = submits[-1].changesets[-1]
try:
hgrepo.changectx(cs)
except RepoError:
pull(ui, hgrepo, source = str(repo.url),
force=False, update=False,
rev=[])
if do_update:
update(ui, hgrepo)
for data in submits:
changesets = []
for revision in data.changesets:
try:
cs = getChangeset(repo, hgrepo, revision)
transaction.commit()
changesets.append(cs)
except Exception, e:
transaction.rollback()
raise
print repo.name, e
p = Push.objects.create(repository = repo,
push_id = data.id, user = data.user,
push_date =
datetime.utcfromtimestamp(data.date))
p.changesets = changesets
p.save()
transaction.commit()
示例14: update
def update(self):
"""
Pull updates from the upstream repository.
If ``newest`` is set to False in the recipe or in the buildout
configuration, no action is taken.
"""
if self.newest:
self.logger.info("Pulling repository %s and updating %s" % (
self.repository, self.directory
))
commands.pull(ui.ui(), hg.repository(ui.ui(), self.directory),
self.repository, update=True)
示例15: test_onerevision_divergent
def test_onerevision_divergent(self):
repo = self._load_fixture_and_fetch('single_rev.svndump')
self.commitchanges((('alpha', 'alpha', 'Changed another way'),))
state = repo.parents()
self._add_svn_rev({'trunk/alpha': 'Changed one way'})
try:
commands.pull(self.repo.ui, repo, update=True)
except hgutil.Abort:
# hg < 1.9 raised when crossing branches
pass
self.assertEqual(state, repo.parents())
self.assertTrue('tip' not in repo[None].tags())
self.assertEqual(len(repo.heads()), 2)