Opened 9 years ago

Closed 9 years ago

#12258 closed defect (fixed)

Prune .hgtags files

Reported by: kini Owned by: leif
Priority: trivial Milestone: sage-4.8
Component: scripts Keywords: .hgtags mercurial repository
Cc: Merged in: sage-4.8.rc0
Authors: Keshav Kini Reviewers: Punarbasu Purkayastha
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by kini)

Our .hgtags files have some cruft in them which I noticed when trying to import the Sage library into git. These patches remove invalid tag references in the .hgtags files.


  1. trac_12258-local-bin.patch to $SAGE_LOCAL
  2. trac_12258-devel-sage.patch to $SAGE_ROOT/devel/sage
  3. trac_12258-data-extcode.patch to $SAGE_DATA/extcode

Attachments (3)

trac_12258-local-bin.patch (1.1 KB) - added by kini 9 years ago.
apply to $SAGE_LOCAL
trac_12258-devel-sage.patch (5.6 KB) - added by kini 9 years ago.
apply to $SAGE_ROOT/devel/sage
trac_12258-data-extcode.patch (1.1 KB) - added by kini 9 years ago.
apply to $SAGE_DATA/extcode

Download all attachments as: .zip

Change History (8)

Changed 9 years ago by kini

apply to $SAGE_LOCAL

Changed 9 years ago by kini

apply to $SAGE_ROOT/devel/sage

Changed 9 years ago by kini

apply to $SAGE_DATA/extcode

comment:1 Changed 9 years ago by kini

  • Description modified (diff)
  • Status changed from new to needs_review

comment:2 Changed 9 years ago by kini

Oh, here is the code I used to generate this patch:

#!/usr/bin/env python

import subprocess

real_tags = subprocess.check_output('hg tags', shell=True).splitlines()
real_tags = [x.split(':')[1] for x in real_tags]

infile = open('.hgtags')
tags =
outfile = open('.hgtags', 'w')

for tag in tags:
    if tag[:12] in real_tags:


Basically it checks what tags Mercurial itself is able to find when it reads the .hgtags file, against what is actually in the .hgtags file, and deletes any invalid tags which Mercurial is not recognizing. I ran the script on all the Mercurial repositories in the Sage source distribution which had a .hgtags file.

comment:3 Changed 9 years ago by ppurka

  • Reviewers set to Punarbasu Purkayastha
  • Status changed from needs_review to positive_review

Patches look good. I get the same output as the deleted lines in the patches with the following bash/zsh code:

...ons/sage-4.7.2/devel/sage> hgtags="$(hg tags)"; while read line; do
    if ! echo -e "${hgtags}" | grep -qE "${line:0:12}$"; then
        echo "$line"
done < .hgtags

After applying the patches, there is no more output to the above command.

comment:4 Changed 9 years ago by kini

Thanks for the review, ppurka!

comment:5 Changed 9 years ago by jdemeyer

  • Merged in set to sage-4.8.rc0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.