def ensure_repo_and_revision(self): """Makes sure that `dest` is has `revision` or `branch` checked out from `repo`. Do what it takes to make that happen, including possibly clobbering dest. """ c = self.vcs_config for conf_item in ('dest', 'repo'): assert self.vcs_config[conf_item] dest = os.path.abspath(c['dest']) repo = c['repo'] branch = c.get('branch') revision = c.get('revision') if not os.path.exists(dest): base_repo = self.config.get('base_repo', repo) cmd = self.tc_vcs[:] cmd.extend(['clone', base_repo, dest]) if self.run_command(cmd): raise VCSException("Unable to checkout") if not branch: branch = "master" if revision: cmd = self.tc_vcs[:] cmd.extend(['checkout-revision', dest, repo, branch, revision]) if self.run_command(cmd): raise VCSException("Unable to checkout") return revision cmd = self.tc_vcs[:] cmd.extend(['revision', dest]) return self.get_output_from_command(cmd, output_parser=parser)
def update(self, dest, branch=None, revision=None): """Updates working copy `dest` to `branch` or `revision`. If revision is set, branch will be ignored. If neither is set then the working copy will be updated to the latest revision on the current branch. Local changes will be discarded. """ # If we have a revision, switch to that msg = "Updating %s" % dest if branch: msg += " to branch %s" % branch if revision: msg += " revision %s" % revision self.info("%s." % msg) if revision is not None: cmd = self.hg + ['update', '-C', '-r', revision] if self.run_command(cmd, cwd=dest, error_list=HgErrorList): raise VCSException("Unable to update %s to %s!" % (dest, revision)) else: # Check & switch branch local_branch = self.get_branch_from_path(dest) cmd = self.hg + ['update', '-C'] # If this is different, checkout the other branch if branch and branch != local_branch: cmd.append(branch) if self.run_command(cmd, cwd=dest, error_list=HgErrorList): raise VCSException("Unable to update %s!" % dest) return self.get_revision_from_path(dest)
def git_tag(self, hg_repo_name, gaia_git_revision, b2g_branch_config): """ Attempt to tag and push gaia. On failure, throw a VCSException. """ git = self.query_exe("git", return_type="list") dirs = self.query_abs_dirs() tag_name = self.query_tag_name(b2g_branch_config) cmd = git + ['tag', tag_name] if gaia_git_revision is None: if self.run_command( git + ["checkout", b2g_branch_config["gaia_branch"]], cwd=dirs["abs_gaia_dir"], error_list=GitErrorList, ): raise VCSException("Can't checkout %s branch!" % b2g_branch_config["gaia_branch"]) else: cmd.append(gaia_git_revision) if self.run_command( cmd, cwd=dirs["abs_gaia_dir"], error_list=GitErrorList, ): raise VCSException("Can't tag gaia for %s!" % hg_repo_name) if self.run_command( # Debugging! Echo only for now. git + ["push", "--tags"], # comment out for testing # git + ["push", "--tags"], cwd=dirs["abs_gaia_dir"], error_list=GitErrorList, ): raise VCSException("Can't push gaia tag for %s!" % hg_repo_name)
def hg_tag(self, repo_name, b2g_branch_config): """ Attempt to tag and push goanna. This assumes the trees are open. On failure, throw a VCSException. """ hg = self.query_exe("hg", return_type="list") dirs = self.query_abs_dirs() hg_dir = os.path.join(dirs["abs_work_dir"], repo_name) tag_name = self.query_tag_name(b2g_branch_config) short_tag_name = self.query_short_tag_name(b2g_branch_config) push_url = self.query_repo_push_url(repo_name) cmd = hg + [ "tag", tag_name, "-m", "tagging %s for mergeday. r=a=mergeday CLOSED TREE DONTBUILD" % short_tag_name, ] if self.run_command(cmd, cwd=hg_dir, error_list=HgErrorList): raise VCSException("Can't tag %s with %s" % (repo_name, tag_name)) # Debugging! Echo only for now. # cmd = hg + ["push", push_url] cmd = hg + ["push", push_url] if self.run_command(cmd, cwd=hg_dir, error_list=HgErrorList): self.run_command(hg + [ "--config", "extensions.mq=", "strip", "--no-backup", "outgoing()" ], cwd=hg_dir) self.run_command(hg + ["up", "-C"], cwd=hg_dir) self.run_command( hg + ["--config", "extensions.purge=", "purge", "--all"], cwd=hg_dir) raise VCSException("Can't push to %s!" % push_url)
def query_gaia_git_revision(self, repo_name, b2g_branch_config): """ For most repos, read b2g/config/gaia.json, read the hg gaia revision, convert that in mapper, and return it. In the case of not being able to determine the git revision, throw a VCSException. Otherwise return None, and we'll tag the tip of the branch. """ dirs = self.query_abs_dirs() if not b2g_branch_config.get("use_gaia_json", True): return None json_path = os.path.join(dirs["abs_work_dir"], repo_name, "b2g", "config", "gaia.json") if not os.path.exists(json_path): raise VCSException("%s doesn't exist!" % json_path) contents = self.read_from_file(json_path) try: json_contents = json.loads(contents) hg_revision = json_contents['revision'] except ValueError: raise VCSException("%s is invalid json!" % json_path) except KeyError: raise VCSException("%s has no 'revision' set!" % json_path) try: url = "%s/%s" % (self.config["gaia_mapper_base_url"], hg_revision) json_contents = self.load_json_from_url(url) git_rev = json_contents["git_rev"] assert git_rev return git_rev except: raise VCSException("Unable to get git_rev from %s !" % url)
def apply_and_push(self, localrepo, remote, changer, max_attempts=10, ssh_username=None, ssh_key=None): """This function calls `changer' to make changes to the repo, and tries its hardest to get them to the origin repo. `changer' must be a callable object that receives two arguments: the directory of the local repository, and the attempt number. This function will push ALL changesets missing from remote. """ self.info("Applying and pushing local changes from %s to %s." % (localrepo, remote)) assert callable(changer) branch = self.get_branch_from_path(localrepo) changer(localrepo, 1) for n in range(1, max_attempts + 1): try: new_revs = self.out(src=localrepo, remote=remote, ssh_username=ssh_username, ssh_key=ssh_key) if len(new_revs) < 1: raise VCSException("No revs to push") self.push(src=localrepo, remote=remote, ssh_username=ssh_username, ssh_key=ssh_key) return except VCSException, e: self.debug("Hit error when trying to push: %s" % str(e)) if n == max_attempts: self.debug("Tried %d times, giving up" % max_attempts) for r in reversed(new_revs): self.run_command(self.hg + ['strip', '-n', r[REVISION]], cwd=localrepo, error_list=HgErrorList) raise VCSException("Failed to push") self.pull(remote, localrepo, update_dest=False, ssh_username=ssh_username, ssh_key=ssh_key) # After we successfully rebase or strip away heads the push # is is attempted again at the start of the loop try: self.run_command(self.hg + ['rebase'], cwd=localrepo, error_list=HgErrorList, throw_exception=True) except subprocess.CalledProcessError, e: self.debug("Failed to rebase: %s" % str(e)) # clean up any hanging rebase. ignore errors if we aren't # in the middle of a rebase. self.run_command(self.hg + ['rebase', '--abort'], cwd=localrepo, success_codes=[0, 255]) self.update(localrepo, branch=branch) for r in reversed(new_revs): self.run_command(self.hg + ['strip', '-n', r[REVISION]], cwd=localrepo, error_list=HgErrorList) changer(localrepo, n + 1)
def pull(self, repo, dest, update_dest=True, **kwargs): """Pulls changes from hg repo and places it in `dest`. If `revision` is set, only the specified revision and its ancestors will be pulled. If `update_dest` is set, then `dest` will be updated to `revision` if set, otherwise to `branch`, otherwise to the head of default. """ msg = "Pulling %s to %s" % (repo, dest) if update_dest: msg += " and updating" self.info("%s." % msg) if not os.path.exists(dest): # Error or clone? # If error, should we have a halt_on_error=False above? self.error("Can't hg pull in nonexistent directory %s." % dest) return -1 # Convert repo to an absolute path if it's a local repository repo = self._make_absolute(repo) cmd = self.hg + ['pull'] cmd.extend(self.common_args(**kwargs)) cmd.append(repo) output_timeout = self.config.get("vcs_output_timeout", self.vcs_config.get("output_timeout")) if self.run_command(cmd, cwd=dest, error_list=HgErrorList, output_timeout=output_timeout) != 0: raise VCSException("Can't pull in %s!" % dest) if update_dest: branch = self.vcs_config.get('branch') revision = self.vcs_config.get('revision') return self.update(dest, branch=branch, revision=revision)
def vcs_checkout(self, vcs=None, error_level=FATAL, **kwargs): """Check out a single repo.""" c = self.config vcs_class = self._get_vcs_class(vcs) if not vcs_class: self.error("Running vcs_checkout with kwargs %s" % str(kwargs)) raise VCSException("No VCS set!") # need a better way to do this. if "dest" not in kwargs: kwargs["dest"] = self.query_dest(kwargs) if "vcs_share_base" not in kwargs: kwargs["vcs_share_base"] = c.get( "%s_share_base" % vcs, c.get("vcs_share_base") ) vcs_obj = vcs_class( log_obj=self.log_obj, config=self.config, vcs_config=kwargs, script_obj=self, ) return self.retry( self._get_revision, error_level=error_level, error_message="Automation Error: Can't checkout %s!" % kwargs["repo"], args=(vcs_obj, kwargs["dest"]), )
def vcs_checkout(self, vcs=None, error_level=FATAL, **kwargs): """ Check out a single repo. """ c = self.config if not vcs: if c.get('default_vcs'): vcs = c['default_vcs'] else: try: vcs = self.default_vcs except AttributeError: pass vcs_class = VCS_DICT.get(vcs) if not vcs_class: self.error("Running vcs_checkout with kwargs %s" % str(kwargs)) raise VCSException("No VCS set!") # need a better way to do this. if 'dest' not in kwargs: kwargs['dest'] = self.query_dest(kwargs) if 'vcs_share_base' not in kwargs: kwargs['vcs_share_base'] = c.get('%s_share_base' % vcs, c.get('vcs_share_base')) vcs_obj = vcs_class( log_obj=self.log_obj, config=self.config, vcs_config=kwargs, script_obj=self, ) return self.retry( self._get_revision, error_level=error_level, error_message="Automation Error: Can't checkout %s!" % kwargs['repo'], args=(vcs_obj, kwargs['dest']), )
def share(self, source, dest, branch=None, revision=None): """Creates a new working directory in "dest" that shares history with "source" using Mercurial's share extension """ self.info("Sharing %s to %s." % (source, dest)) if self.run_command(self.hg + ['share', '-U', source, dest], error_list=HgErrorList): raise VCSException("Unable to share %s to %s!" % (source, dest)) return self.update(dest, branch=branch, revision=revision)
def ensure_repo_and_revision(self): """Makes sure that `dest` is has `revision` or `branch` checked out from `repo`. Do what it takes to make that happen, including possibly clobbering dest. """ c = self.vcs_config for conf_item in ('dest', 'repo'): assert self.vcs_config[conf_item] dest = os.path.abspath(c['dest']) repo = c['repo'] revision = c.get('revision') branch = c.get('branch') clean = c.get('clean') share_base = c.get('vcs_share_base', os.environ.get("GIT_SHARE_BASE_DIR", None)) env = {'PATH': os.environ.get('PATH')} env.update(c.get('env', {})) if self._is_windows(): # git.exe is not in the PATH by default env['PATH'] = '%s;C:/mozilla-build/Git/bin' % env['PATH'] # SYSTEMROOT is needed for 'import random' if 'SYSTEMROOT' not in env: env['SYSTEMROOT'] = os.environ.get('SYSTEMROOT') if share_base is not None: env['GIT_SHARE_BASE_DIR'] = share_base cmd = self.gittool[:] if branch: cmd.extend(['-b', branch]) if revision: cmd.extend(['-r', revision]) if clean: cmd.append('--clean') for base_mirror_url in self.config.get( 'gittool_base_mirror_urls', self.config.get('vcs_base_mirror_urls', [])): bits = urlparse.urlparse(repo) mirror_url = urlparse.urljoin(base_mirror_url, bits.path) cmd.extend(['--mirror', mirror_url]) cmd.extend([repo, dest]) parser = GittoolParser(config=self.config, log_obj=self.log_obj, error_list=GitErrorList) retval = self.run_command(cmd, error_list=GitErrorList, env=env, output_parser=parser) if retval != 0: raise VCSException("Unable to checkout") return parser.got_revision
def ensure_repo_and_revision(self): """Makes sure that `dest` is has `revision` or `branch` checked out from `repo`. Do what it takes to make that happen, including possibly clobbering dest. """ c = self.vcs_config for conf_item in ("dest", "repo"): assert self.vcs_config[conf_item] dest = os.path.abspath(c["dest"]) repo = c["repo"] revision = c.get("revision") branch = c.get("branch") clean = c.get("clean") share_base = c.get("vcs_share_base", os.environ.get("GIT_SHARE_BASE_DIR", None)) env = {"PATH": os.environ.get("PATH")} env.update(c.get("env", {})) if self._is_windows(): # git.exe is not in the PATH by default env["PATH"] = "%s;C:/mozilla-build/Git/bin" % env["PATH"] # SYSTEMROOT is needed for 'import random' if "SYSTEMROOT" not in env: env["SYSTEMROOT"] = os.environ.get("SYSTEMROOT") if share_base is not None: env["GIT_SHARE_BASE_DIR"] = share_base cmd = self.gittool[:] if branch: cmd.extend(["-b", branch]) if revision: cmd.extend(["-r", revision]) if clean: cmd.append("--clean") for base_mirror_url in self.config.get( "gittool_base_mirror_urls", self.config.get("vcs_base_mirror_urls", [])): bits = urlparse.urlparse(repo) mirror_url = urlparse.urljoin(base_mirror_url, bits.path) cmd.extend(["--mirror", mirror_url]) cmd.extend([repo, dest]) parser = GittoolParser(config=self.config, log_obj=self.log_obj, error_list=GitErrorList) retval = self.run_command(cmd, error_list=GitErrorList, env=env, output_parser=parser) if retval != 0: raise VCSException("Unable to checkout") return parser.got_revision
def ensure_repo_and_revision(self): """Makes sure that `dest` is has `revision` or `branch` checked out from `repo`. Do what it takes to make that happen, including possibly clobbering dest. """ c = self.vcs_config for conf_item in ('dest', 'repo'): assert self.vcs_config[conf_item] dest = os.path.abspath(c['dest']) repo = c['repo'] revision = c.get('revision') branch = c.get('branch') share_base = c.get('vcs_share_base', os.environ.get("HG_SHARE_BASE_DIR", None)) env = {'PATH': os.environ.get('PATH')} if share_base is not None: env['HG_SHARE_BASE_DIR'] = share_base cmd = self.hgtool[:] if branch: cmd.extend(['-b', branch]) if revision: cmd.extend(['-r', revision]) for base_mirror_url in self.config.get( 'hgtool_base_mirror_urls', self.config.get('vcs_base_mirror_urls', [])): bits = urlparse.urlparse(repo) mirror_url = urlparse.urljoin(base_mirror_url, bits.path) cmd.extend(['--mirror', mirror_url]) for base_bundle_url in self.config.get( 'hgtool_base_bundle_urls', self.config.get('vcs_base_bundle_urls', [])): bundle_url = "%s/%s.hg" % (base_bundle_url, os.path.basename(repo)) cmd.extend(['--bundle', bundle_url]) cmd.extend([repo, dest]) parser = HgtoolParser(config=self.config, log_obj=self.log_obj, error_list=HgtoolErrorList) retval = self.run_command(cmd, error_list=HgtoolErrorList, env=env, output_parser=parser) if retval != 0: raise VCSException("Unable to checkout") return parser.got_revision
def vcs_query_pushinfo(self, repository, revision, vcs=None): """Query the pushid/pushdate of a repository/revision Returns a namedtuple with "pushid" and "pushdate" elements """ vcs_class = self._get_vcs_class(vcs) if not vcs_class: raise VCSException("No VCS set in vcs_query_pushinfo!") vcs_obj = vcs_class( log_obj=self.log_obj, config=self.config, script_obj=self, ) return vcs_obj.query_pushinfo(repository, revision)
def push(self, src, remote, push_new_branches=True, **kwargs): # This doesn't appear to work with hg_ver < (1, 6, 0). # Error out, or let you try? self.info("Pushing new changes from %s to %s." % (src, remote)) cmd = self.hg + ['push'] cmd.extend(self.common_args(**kwargs)) if push_new_branches and self.hg_ver() >= (1, 6, 0): cmd.append('--new-branch') cmd.append(remote) status = self.run_command(cmd, cwd=src, error_list=HgErrorList, success_codes=(0, 1), return_type="num_errors") if status: raise VCSException("Can't push %s to %s!" % (src, remote)) return status
def clone(self, repo, dest, branch=None, revision=None, update_dest=True): """Clones hg repo and places it at `dest`, replacing whatever else is there. The working copy will be empty. If `revision` is set, only the specified revision and its ancestors will be cloned. If revision is set, branch is ignored. If `update_dest` is set, then `dest` will be updated to `revision` if set, otherwise to `branch`, otherwise to the head of default. """ msg = "Cloning %s to %s" % (repo, dest) if branch: msg += " on branch %s" % branch if revision: msg += " to revision %s" % revision self.info("%s." % msg) parent_dest = os.path.dirname(dest) if parent_dest and not os.path.exists(parent_dest): self.mkdir_p(parent_dest) if os.path.exists(dest): self.info("Removing %s before clone." % dest) self.rmtree(dest) cmd = self.hg + ["clone"] if not update_dest: cmd.append("-U") if revision: cmd.extend(["-r", revision]) elif branch: # hg >= 1.6 supports -b branch for cloning ver = self.hg_ver() if ver >= (1, 6, 0): cmd.extend(["-b", branch]) cmd.extend([repo, dest]) output_timeout = self.config.get("vcs_output_timeout", self.vcs_config.get("output_timeout")) if (self.run_command(cmd, error_list=HgErrorList, output_timeout=output_timeout) != 0): raise VCSException("Unable to clone %s to %s!" % (repo, dest)) if update_dest: return self.update(dest, branch, revision)
def ensure_repo_and_revision(self): """Makes sure that `dest` is has `revision` or `branch` checked out from `repo`. Do what it takes to make that happen, including possibly clobbering dest. """ c = self.vcs_config dest = c['dest'] repo_url = c['repo'] rev = c.get('revision') branch = c.get('branch') purge = c.get('clone_with_purge', False) upstream = c.get('clone_upstream_url') # The API here is kind of bad because we're relying on state in # self.vcs_config instead of passing arguments. This confuses # scripts that have multiple repos. This includes the clone_tools() # step :( if not rev and not branch: self.warning('did not specify revision or branch; assuming "default"') branch = 'default' share_base = c.get('vcs_share_base', os.environ.get('HG_SHARE_BASE_DIR', None)) if share_base and c.get('use_vcs_unique_share'): # Bug 1277041 - update migration scripts to support robustcheckout # fake a share but don't really share share_base = os.path.join(share_base, hashlib.md5(dest).hexdigest()) # We require shared storage is configured because it guarantees we # only have 1 local copy of logical repo stores. if not share_base: raise VCSException('vcs share base not defined; ' 'refusing to operate sub-optimally') if not self.robustcheckout_path: raise VCSException('could not find the robustcheckout Mercurial extension') # Log HG version and install info to aid debugging. self.run_command(self.hg + ['--version']) self.run_command(self.hg + ['debuginstall']) args = self.hg + [ '--config', 'extensions.robustcheckout=%s' % self.robustcheckout_path, 'robustcheckout', repo_url, dest, '--sharebase', share_base, ] if purge: args.append('--purge') if upstream: args.extend(['--upstream', upstream]) if rev: args.extend(['--revision', rev]) if branch: args.extend(['--branch', branch]) parser = RepositoryUpdateRevisionParser(config=self.config, log_obj=self.log_obj) if self.run_command(args, output_parser=parser): raise VCSException('repo checkout failed!') if not parser.revision: raise VCSException('could not identify revision updated to') return parser.revision
def ensure_repo_and_revision(self): """Makes sure that `dest` is has `revision` or `branch` checked out from `repo`. Do what it takes to make that happen, including possibly clobbering dest. """ c = self.vcs_config for conf_item in ('dest', 'repo'): assert self.vcs_config[conf_item] dest = os.path.abspath(c['dest']) repo = c['repo'] revision = c.get('revision') branch = c.get('branch') share_base = c.get('vcs_share_base', os.environ.get("HG_SHARE_BASE_DIR", None)) clone_by_rev = c.get('clone_by_revision') clone_with_purge = c.get('clone_with_purge') env = {'PATH': os.environ.get('PATH')} if c.get('env'): env.update(c['env']) if share_base is not None: env['HG_SHARE_BASE_DIR'] = share_base if self._is_windows(): # SYSTEMROOT is needed for 'import random' if 'SYSTEMROOT' not in env: env['SYSTEMROOT'] = os.environ.get('SYSTEMROOT') # HOME is needed for the 'hg help share' check if 'HOME' not in env: env['HOME'] = os.environ.get('HOME') cmd = self.hgtool[:] if clone_by_rev: cmd.append('--clone-by-revision') if branch: cmd.extend(['-b', branch]) if revision: cmd.extend(['-r', revision]) for base_mirror_url in self.config.get( 'hgtool_base_mirror_urls', self.config.get('vcs_base_mirror_urls', [])): bits = urlparse.urlparse(repo) mirror_url = urlparse.urljoin(base_mirror_url, bits.path) cmd.extend(['--mirror', mirror_url]) for base_bundle_url in self.config.get( 'hgtool_base_bundle_urls', self.config.get('vcs_base_bundle_urls', [])): bundle_url = "%s/%s.hg" % (base_bundle_url, os.path.basename(repo)) cmd.extend(['--bundle', bundle_url]) cmd.extend([repo, dest]) if clone_with_purge: cmd.append('--purge') parser = HgtoolParser(config=self.config, log_obj=self.log_obj, error_list=HgtoolErrorList) retval = self.run_command(cmd, error_list=HgtoolErrorList, env=env, output_parser=parser) if retval != 0: raise VCSException("Unable to checkout") return parser.got_revision
def _ensure_shared_repo_and_revision(self, share_base): """The shared dir logic is complex enough to warrant its own helper method. If allow_unshared_local_clones is True and we're trying to use the share extension but fail, then we will be able to clone from the shared repo to our destination. If this is False, the default, the if we don't have the share extension we will just clone from the remote repository. """ c = self.vcs_config dest = os.path.abspath(c['dest']) repo = c['repo'] revision = c.get('revision') branch = c.get('branch') if not self.query_can_share(): raise VCSException("%s called when sharing is not allowed!" % __name__) # If the working directory already exists and isn't using share # when we want to use share, clobber. # # The original util.hg.mercurial() tried to pull repo into dest # instead. That can help if the share extension fails. # But it can also result in pulling a different repo B into an # existing clone of repo A, which may have unexpected results. if os.path.exists(dest): sppath = os.path.join(dest, ".hg", "sharedpath") if not os.path.exists(sppath): self.info("No file %s; removing %s." % (sppath, dest)) self.rmtree(dest) if not os.path.exists(os.path.dirname(dest)): self.mkdir_p(os.path.dirname(dest)) shared_repo = os.path.join(share_base, self.get_repo_path(repo)) dest_shared_path = os.path.join(dest, '.hg', 'sharedpath') if os.path.exists(dest_shared_path): # Make sure that the sharedpath points to shared_repo dest_shared_path_data = os.path.realpath(open(dest_shared_path).read()) norm_shared_repo = os.path.realpath(os.path.join(shared_repo, '.hg')) if dest_shared_path_data != norm_shared_repo: # Clobber! self.info("We're currently shared from %s, but are being requested to pull from %s (%s); clobbering" % (dest_shared_path_data, repo, norm_shared_repo)) self.rmtree(dest) self.info("Updating shared repo") if os.path.exists(shared_repo): try: self.pull(repo, shared_repo) except VCSException: self.warning("Error pulling changes into %s from %s; clobbering" % (shared_repo, repo)) self.exception(level='debug') self.clone(repo, shared_repo) else: self.clone(repo, shared_repo) if os.path.exists(dest): try: self.pull(shared_repo, dest) status = self.update(dest, branch=branch, revision=revision) return status except VCSException: self.rmtree(dest) try: self.info("Trying to share %s to %s" % (shared_repo, dest)) return self.share(shared_repo, dest, branch=branch, revision=revision) except VCSException: if not c.get('allow_unshared_local_clones'): # Re-raise the exception so it gets caught below. # We'll then clobber dest, and clone from original # repo raise self.warning("Error calling hg share from %s to %s; falling back to normal clone from shared repo" % (shared_repo, dest)) # Do a full local clone first, and then update to the # revision we want # This lets us use hardlinks for the local clone if the # OS supports it try: self.clone(shared_repo, dest, update_dest=False) return self.update(dest, branch=branch, revision=revision) except VCSException: # Need better fallback self.error("Error updating %s from shared_repo (%s): " % (dest, shared_repo)) self.exception(level='error') self.rmtree(dest)