def pathto(self, f, cwd=None): if cwd is None: cwd = self.getcwd() path = util.pathto(self._root, cwd, f) if self._slash: return util.pconvert(path) return path
def updatedir(ui, repo, patches): '''Update dirstate after patch application according to metadata''' if not patches: return copies = [] removes = {} cfiles = patches.keys() cwd = repo.getcwd() if cwd: cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] for f in patches: ctype, gp = patches[f] if ctype == 'RENAME': copies.append((gp.oldpath, gp.path)) removes[gp.oldpath] = 1 elif ctype == 'COPY': copies.append((gp.oldpath, gp.path)) elif ctype == 'DELETE': removes[gp.path] = 1 for src, dst in copies: repo.copy(src, dst) removes = removes.keys() if removes: removes.sort() repo.remove(removes, True) for f in patches: ctype, gp = patches[f] if gp and gp.mode: flags = '' if gp.mode & 0100: flags = 'x' elif gp.mode & 020000: flags = 'l' dst = os.path.join(repo.root, gp.path) # patch won't create empty files if ctype == 'ADD' and not os.path.exists(dst): repo.wwrite(gp.path, '', flags) else: util.set_flags(dst, 'l' in flags, 'x' in flags) cmdutil.addremove(repo, cfiles) files = patches.keys() files.extend([r for r in removes if r not in files]) files.sort() return files
def updatedir(ui, repo, patches, similarity=0): '''Update dirstate after patch application according to metadata''' if not patches: return [] copies = [] removes = set() cfiles = patches.keys() cwd = repo.getcwd() if cwd: cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] for f in patches: gp = patches[f] if not gp: continue if gp.op == 'RENAME': copies.append((gp.oldpath, gp.path)) removes.add(gp.oldpath) elif gp.op == 'COPY': copies.append((gp.oldpath, gp.path)) elif gp.op == 'DELETE': removes.add(gp.path) wctx = repo[None] for src, dst in copies: dirstatecopy(ui, repo, wctx, src, dst, cwd=cwd) if (not similarity) and removes: wctx.remove(sorted(removes), True) for f in patches: gp = patches[f] if gp and gp.mode: islink, isexec = gp.mode dst = repo.wjoin(gp.path) # patch won't create empty files if gp.op == 'ADD' and not os.path.lexists(dst): flags = (isexec and 'x' or '') + (islink and 'l' or '') repo.wwrite(gp.path, '', flags) util.setflags(dst, islink, isexec) addremove(repo, cfiles, similarity=similarity) files = patches.keys() files.extend([r for r in removes if r not in files]) return sorted(files)
def updatedir(ui, repo, patches, similarity=0): '''Update dirstate after patch application according to metadata''' if not patches: return copies = [] removes = set() cfiles = patches.keys() cwd = repo.getcwd() if cwd: cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] for f in patches: gp = patches[f] if not gp: continue if gp.op == 'RENAME': copies.append((gp.oldpath, gp.path)) removes.add(gp.oldpath) elif gp.op == 'COPY': copies.append((gp.oldpath, gp.path)) elif gp.op == 'DELETE': removes.add(gp.path) wctx = repo[None] for src, dst in copies: dirstatecopy(ui, repo, wctx, src, dst, cwd=cwd) if (not similarity) and removes: wctx.remove(sorted(removes), True) for f in patches: gp = patches[f] if gp and gp.mode: islink, isexec = gp.mode dst = repo.wjoin(gp.path) # patch won't create empty files if gp.op == 'ADD' and not os.path.lexists(dst): flags = (isexec and 'x' or '') + (islink and 'l' or '') repo.wwrite(gp.path, '', flags) util.set_flags(dst, islink, isexec) addremove(repo, cfiles, similarity=similarity) files = patches.keys() files.extend([r for r in removes if r not in files]) return sorted(files)
def updatedir(ui, repo, patches, similarity=0): """Update dirstate after patch application according to metadata""" if not patches: return copies = [] removes = {} cfiles = patches.keys() cwd = repo.getcwd() if cwd: cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] for f in patches: gp = patches[f] if not gp: continue if gp.op == "RENAME": copies.append((gp.oldpath, gp.path)) removes[gp.oldpath] = 1 elif gp.op == "COPY": copies.append((gp.oldpath, gp.path)) elif gp.op == "DELETE": removes[gp.path] = 1 for src, dst in copies: repo.copy(src, dst) removes = removes.keys() if (not similarity) and removes: repo.remove(util.sort(removes), True) for f in patches: gp = patches[f] if gp and gp.mode: islink, isexec = gp.mode dst = repo.wjoin(gp.path) # patch won't create empty files if gp.op == "ADD" and not os.path.exists(dst): flags = (isexec and "x" or "") + (islink and "l" or "") repo.wwrite(gp.path, "", flags) elif gp.op != "DELETE": util.set_flags(dst, islink, isexec) cmdutil.addremove(repo, cfiles, similarity=similarity) files = patches.keys() files.extend([r for r in removes if r not in files]) return util.sort(files)
def verify(repo): """verify the consistency of a repository""" ret = verifymod.verify(repo) # Broken subrepo references in hidden csets don't seem worth worrying about, # since they can't be pushed/pulled, and --hidden can be used if they are a # concern. # pathto() is needed for -R case revs = repo.revs("filelog(%s)", util.pathto(repo.root, repo.getcwd(), ".hgsubstate")) if revs: repo.ui.status(_("checking subrepo links\n")) for rev in revs: ctx = repo[rev] try: for subpath in ctx.substate: ret = ctx.sub(subpath).verify() or ret except Exception: repo.ui.warn(_(".hgsubstate is corrupt in revision %s\n") % node.short(ctx.node())) return ret
def verify(repo): """verify the consistency of a repository""" ret = verifymod.verify(repo) # Broken subrepo references in hidden csets don't seem worth worrying about, # since they can't be pushed/pulled, and --hidden can be used if they are a # concern. # pathto() is needed for -R case revs = repo.revs("filelog(%s)", util.pathto(repo.root, repo.getcwd(), '.hgsubstate')) if revs: repo.ui.status(_('checking subrepo links\n')) for rev in revs: ctx = repo[rev] try: for subpath in ctx.substate: ret = ctx.sub(subpath).verify() or ret except Exception: repo.ui.warn(_('.hgsubstate is corrupt in revision %s\n') % node.short(ctx.node())) return ret
def rel(self, f): '''Convert repo path back to path that is relative to cwd of matcher.''' return util.pathto(self._root, self._cwd, f)
def rel(self, f): return util.pathto(self._root, self._cwd, f)