Commit e116db11 authored by Steve Borho's avatar Steve Borho
Browse files

thgrepo: extract file flag changes from git headers

Shows exec bit changes and symlink status in file views
parent d6f41346cda1
......@@ -572,6 +572,17 @@ class FileData(object):
repo = ctx._repo
self.flabel += u'<b>%s</b>' % hglib.tounicode(wfile)
if type(ctx.rev()) == str: # unapplied patch
self.diff = ctx.thgmqpatchdata(wfile)
flags = ctx.flags(wfile)
if flags in ('x', '-'):
lbl = _("exec mode has been <font color='red'>%s</font>")
change = (flags == 'x') and _('set') or _('unset')
self.elabel = lbl % change
elif flags == 'l':
self.flabel += _(' <i>(is a symlink)</i>')
absfile = repo.wjoin(wfile)
if (wfile in ctx and 'l' in ctx.flags(wfile)) or \
......@@ -583,10 +594,6 @@ class FileData(object):
self.flabel += _(' <i>(is a symlink)</i>')
if type(ctx.rev()) == str: # unapplied patch
self.diff = ctx.thgmqpatchdata(wfile)
if status is None:
status = getstatus(repo, ctx.p1().node(), ctx.node(), wfile)
if ctx2 is None:
......@@ -661,9 +668,9 @@ class FileData(object):
change = None
for pfctx in fctx.parents():
if 'x' in fctx.flags() and 'x' not in pfctx.flags():
change = 'set'
change = _('set')
elif 'x' not in fctx.flags() and 'x' in pfctx.flags():
change = 'unset'
change = _('unset')
if change:
lbl = _("exec mode has been <font color='red'>%s</font>")
self.elabel = lbl % change
......@@ -578,7 +578,6 @@ class patchctx(object):
def __str__(self): return node.short(self.node())
def node(self): return self._node
def files(self): return self._files.keys()
def flags(self, key): return ''
def rev(self): return self._rev
def hex(self): return node.hex(self.node())
def user(self): return self._user
......@@ -620,6 +619,22 @@ class patchctx(object):
return [], [], []
def flags(self, wfile):
if wfile in self._files:
for gp in patch.readgitpatch(self._files[wfile][0].header):
if gp.mode:
islink, isexec = gp.mode
if islink:
return 'l'
elif isexec:
return 'x'
# techincally, this case could mean the file has had its
# exec bit cleared OR its symlink state removed
# TODO: change readgitpatch() to differentiate
return '-'
return ''
def thgmqpatchdata(self, wfile):
# return file diffs as string list without line ends
if wfile in self._files:
......@@ -656,6 +671,8 @@ class patchctx(object):
top = patch.parsefilename(chunk.header[-2])
bot = patch.parsefilename(chunk.header[-1])
type, path = get_path(top, bot)
if path not in chunk.files():
type, path = 0, chunk.files()[-1]
if path not in files:
files[path] = [chunk]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment