def pull_bundle(repo, ui_, bundle_file): """ Pull an hg bundle file. bundle_file must be an absolute path. """ # Not commands.unbundle(ui_, repo, bundle_file, rev=[], force=None, update=None)
def fetch_review_request(self, request): bundles = self.reviewboard.download_attachement_with_given_caption( request.id, 'changeset bundle') if not bundles: self.ui.status( _("Warning: no mercurial bundles were found in review request %s\n" ) % request.id) return False self.ui.status(_("Bundles found: %s\n") % str(bundles)) self.ui.pushbuffer() try: try: self.ui.status("Apply bundle to local repository\n") commands.unbundle(self.ui, self.repo, *bundles) except LookupError, e: self.ui.status(_("Cannot unbundle: %s\n") % e.message) raise util.Abort("Cannot unbundle: %s" % e.message) finally: self.ui.popbuffer() # find and merge any heads, introduced by importing bundle heads = self.repo.heads() #heads = repo.heads() openheads = [ h for h in heads if not self.repo[h].extra().get('close', False) ] branchheads = {} for head in openheads: ctx = self.repo[head] branch = ctx.branch() if branch not in branchheads: branchheads[branch] = [] branchheads[branch].append(ctx) for branch, heads in branchheads.items(): self.merge_heads(branch, heads, request.id) for bundle in bundles: self.ui.status(_("Deleting local bundle: %s\n") % str(bundle)) os.unlink(bundle) return True
def get_shipable_bundles(ui, repo, rev='.', **opts): """TBD """ ui.status('postreview plugin, version %s\n' % __version__) find_server(ui, opts) reviewboard = getreviewboard(ui, opts) opts['unbundle'] = opts['submit'] or opts['unbundle'] try: repo_id = find_reviewboard_repo_id(ui, reviewboard, opts) shipable = reviewboard.shipable_requests(repo_id) fnames_per_request = [(reviewboard.download_attachement_with_given_caption(request.id, BUNDLE_ATTACHMENT_CAPTION), request.id) for request in shipable] if opts['unbundle']: for fnames, request_id in fnames_per_request: [unbundle(ui, repo, fname) for fname in fnames] if opts['submit']: reviewboard.submit(request_id) print "submitted" except ReviewBoardError, msg: raise error.Abort(_(unicode(msg)))
TESTDIR = os.environ["TESTDIR"] BUNDLEPATH = os.path.join(TESTDIR, 'bundles', 'test-no-symlinks.hg') # only makes sense to test on os which supports symlinks if not getattr(os, "symlink", False): sys.exit(80) # SKIPPED_STATUS defined in run-tests.py u = uimod.ui.load() # hide outer repo hg.peer(u, {}, b'.', create=True) # unbundle with symlink support hg.peer(u, {}, b'test0', create=True) repo = hg.repository(u, b'test0') commands.unbundle(u, repo, pycompat.fsencode(BUNDLEPATH), update=True) # wait a bit, or the status call wont update the dirstate time.sleep(1) commands.status(u, repo) # now disable symlink support -- this is what os.symlink would do on a # non-symlink file system def symlink_failure(src, dst): raise OSError(1, "Operation not permitted") os.symlink = symlink_failure def islink_failure(path): return False os.path.islink = islink_failure # dereference links as if a Samba server has exported this to a