Mercurial > hg-stable
changeset 7148:7d84e5b00e29
patch: extract and rename gitpatch into patchmeta, document
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 18 Oct 2008 23:45:45 +0200 |
parents | 94cf0d1f48a3 |
children | 01a056c54385 |
files | mercurial/patch.py |
diffstat | 1 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Sat Oct 18 23:45:45 2008 +0200 +++ b/mercurial/patch.py Sat Oct 18 23:45:45 2008 +0200 @@ -143,17 +143,24 @@ GP_FILTER = 1 << 1 # there's some copy/rename operation GP_BINARY = 1 << 2 # there's a binary patch +class patchmeta: + """Patched file metadata + + 'op' is the performed operation within ADD, DELETE, RENAME, MODIFY + or COPY. 'path' is patched file path. 'oldpath' is set to the + origin file when 'op' is either COPY or RENAME, None + otherwise. 'mode' is set to the new mode of patched file or None. + """ + def __init__(self, path): + self.path = path + self.oldpath = None + self.mode = None + self.op = 'MODIFY' + self.lineno = 0 + self.binary = False + def readgitpatch(fp, firstline=None): """extract git-style metadata about patches from <patchname>""" - class gitpatch: - "op is one of ADD, DELETE, RENAME, MODIFY or COPY" - def __init__(self, path): - self.path = path - self.oldpath = None - self.mode = None - self.op = 'MODIFY' - self.lineno = 0 - self.binary = False def reader(fp, firstline): if firstline is not None: @@ -177,7 +184,7 @@ if gp: gitpatches.append(gp) src, dst = m.group(1, 2) - gp = gitpatch(dst) + gp = patchmeta(dst) gp.lineno = lineno elif gp: if line.startswith('--- '):