Tarball support v0.2
Goffredo Baroncelli
kreijack at libero.it
Sat Aug 20 09:37:13 CDT 2005
On Saturday 20 August 2005 15:10, Wojciech Milkowski wrote:
> Sorry for discontinuing thread, I have some problems with receiving
> e-mails from mercurial list, probably SPF related, so I changed my
> address temporarily.
>
> Goffredo Baroncelli wrote:
>
> > he patch attached should highlight how obtain the changeset hash; if
> you change
> > #node# in #node|short# in the changeset.tmpl you get the short hash
> [...]
> I would rather obtain revision internally basing on manifest
> hash. I believe it's simple task, can anybody confirm that?
>
You can obtain the changeset hash by the revision number via
changelog.node(rev)
see my patch below
diff -r 7b3d873b2bdd mercurial/hgweb.py
--- a/mercurial/hgweb.py Sat Aug 20 05:38:54 2005
+++ b/mercurial/hgweb.py Sat Aug 20 16:34:42 2005
@@ -601,17 +601,19 @@
tmp = tempfile.mkstemp()[1]
zf = zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED)
mf = self.repo.manifest.read(bin(mnode))
- rev = str(self.repo.manifest.rev(bin(mnode)))
+ rev = self.repo.manifest.rev(bin(mnode))
+ cnode = hex(self.repo.changelog.node(rev))
+ rev = str(rev)
name = os.path.basename(self.repo.path[:-4]) # without '/.hg' suffix
for fname in mf.keys():
r = self.repo.file(fname)
- zf.writestr(name + '-' + rev + '/' + fname, r.read(mf[fname]))
+ zf.writestr(name + '-' + rev + '-' + cnode + '/' + fname, r.read(mf[fname]))
zf.close()
f = open(tmp, 'r')
httphdr('application/zip',
- name + '-' + rev + '.zip', os.path.getsize(tmp))
+ name + '-' + rev + '-' + cnode + '.zip', os.path.getsize(tmp))
sys.stdout.write(f.read())
f.close()
os.unlink(tmp)
@@ -624,7 +626,9 @@
tmp = tempfile.mkstemp()[1]
tf = tarfile.open(tmp, "w:" + type)
mf = self.repo.manifest.read(bin(mnode))
- rev = str(self.repo.manifest.rev(bin(mnode)))
+ rev = self.repo.manifest.rev(bin(mnode))
+ cnode = hex(self.repo.changelog.node(rev))
+ rev = str(rev)
mff = self.repo.manifest.readflags(bin(mnode))
mtime = int(time.time())
name = os.path.basename(self.repo.path[:-4]) # without '/.hg' suffix
@@ -632,7 +636,7 @@
for fname in mf.keys():
r = self.repo.file(fname)
rcont = r.read(mf[fname])
- finfo = tarfile.TarInfo(name + '-' + rev + '/' + fname)
+ finfo = tarfile.TarInfo(name + '-' + rev + '-' + cnode + '/' + fname)
finfo.mtime = mtime
finfo.size = len(rcont)
finfo.mode = mff[fname] and 0755 or 0644
@@ -641,7 +645,7 @@
f = open(tmp, 'r')
httphdr('application/octet-stream',
- name + '-' + rev + '.tar.' + type, os.path.getsize(tmp))
+ name + '-' + rev + '-' + cnode + '.tar.' + type, os.path.getsize(tmp))
sys.stdout.write(f.read())
f.close()
os.unlink(tmp)
> Wojtek
Goffredo
--
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack at inwind.it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87 87C0 BB86 505C 6B2A CFF9
More information about the Mercurial
mailing list