def get_file_metas(self, source_files): from mercurial import ui, hg from mercurial.context import changectx, filectx self.repo = hg.repository(ui.ui(), self.rootpath) files = [] cctx = changectx(self.repo) for afile in source_files: idx = 0 fdict = self._init_ctx(afile) authors = [] fctx = filectx(self.repo, afile.replace(self.rootpath,''), changectx=cctx) idx = 0 for id in fctx.filelog(): fctx_parent = fctx.filectx(id) if idx == 0: fdict.update(self._secs_to_str(fctx_parent.date()[0])) authors.append(fctx_parent.user()) idx += 1 fdict['author'] = ', '.join([u for u in set(authors) if u != self.method]) files.append(fdict) return files
def getfilectx(repo, memctx, f): info = files.get(f) if info != None: # it's a file reported as modified from Git delete, mode, sha = info if delete: raise IOError if not sha: # indicates there's no git counterpart e = '' copied_path = None if '.hgsubstate' == f: data = util.serialize_hgsubstate(hgsubstate) elif '.hgsub' == f: data = util.serialize_hgsub(hgsub) else: data = self.git[sha].data copied_path = hg_renames.get(f) e = self.convert_git_int_mode(mode) else: # it's a converged file fc = context.filectx(self.repo, f, changeid=memctx.p1().rev()) data = fc.data() e = fc.flags() copied_path = fc.renamed() return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
def __init__(self, filectx): """filectx can be a context.filectx or a context.workingfilectx if useworking is true, this object acts more like a workingfilectx, otherwise it acts more like a filectx.""" self.original = filectx if isinstance( filectx, context.workingfilectx): ctx, node, id = self.fakeCtx( filectx) self.proxy = context.filectx(filectx._repo, filectx.path(), filelog = filectx.filelog(), changectx = ctx, changeid = node, fileid = id) else: self.proxy = filectx
def next_rev(self, rev, path=''): n = self.hg_node(rev) if path and len(path): # might be a file fc = filectx(self.repo, path, n) if fc: # it is a file for child_fc in fc.children(): return self.hg_display(child_fc.node()) else: return None # it might be a directory (not supported for now) FIXME log = self.repo.changelog for c in log.children(n): return self.hg_display(c) # always follow first child
def __init__(self, filectx): """filectx can be a context.filectx or a context.workingfilectx if useworking is true, this object acts more like a workingfilectx, otherwise it acts more like a filectx.""" self.original = filectx if isinstance(filectx, context.workingfilectx): ctx, node, id = self.fakeCtx(filectx) self.proxy = context.filectx(filectx._repo, filectx.path(), filelog=filectx.filelog(), changectx=ctx, changeid=node, fileid=id) else: self.proxy = filectx
def getfilectx(repo, memctx, f): info = files.get(f) if info != None: # it's a file reported as modified from Git delete, mode, sha = info if delete: raise IOError data = self.git[sha].data copied_path = hg_renames.get(f) e = self.convert_git_int_mode(mode) else: # it's a converged file fc = context.filectx(self.repo, f, changeid=memctx.p1().rev()) data = fc.data() e = fc.flags() copied_path = fc.renamed() return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
def getnode(self, path, fnode): '''Derives changenode from file path and filenode.''' # used by kwfilelog.read and kwexpand c = context.filectx(self.repo, path, fileid=fnode) return c.node()
def _getfilectx(rev, mf, path): fileid = mf.get(path) return context.filectx(rev._repo, path, fileid=fileid, changectx=rev)