Peter Bex committed 9269593

Add meta-file updating feature to eggtag command, controlled by an hgrc option

Comments (0)

Files changed (2)

 This is a simple Mercurial extension which adds an "eggtag" command.
 When you want to make a new release, just type
- hg eggtag 0.1
+   hg eggtag 0.1
 The command will automatically tag and add an entry to your egg's
 release-info file corresponding to this release.
 browser, and then viewing the "raw" source). Just drop it in your ~/.hg
 directory and add the following to your .hgrc:
+   [extensions]
+   egg-author=~/.hg/
+By default, eggtag will also update the .meta-file of your egg.
+If you don't like this behaviour, you can turn it off by adding
+the following to your .hgrc:
+   [egg-author]
+   update-meta=False
+This can also be overridden on a per-repository basis by adding the
+section to your repository's .hg/hgrc file.  The value can obviously
+also be True if you want to override the False value from your ~/.hgrc.
+If you want to run the meta-file updater manually (regardless of the
+update-meta option), you can run the update-meta command:
+   hg update-meta
+This will only update the file, but not commit it so that you can
+review it before committing it.
 # [extensions]
 # egg-author=~/.hg/
+# If you don't want automatic updates of your .meta-files, you can turn
+# it off by putting this in ~/.hg or in the repository-specific .hg/hgrc file:
+# [egg-author]
+# update-meta=False
 # This silly file may be used and distributed according to the terms of
 # the GNU General Public License, version 2 or later "(at your option)".
 # See for more info, including
 # a link to the license text.
-# TODO: Add automatic meta-file updates when tagging tip?  Or perhaps
-# based on a repo-specific setting, since people using the tarball method
-# might not want their meta-files cluttered with long lists of files...
 '''Tools to help make egg authors' lives easier'''
     allnames = [t.strip() for t in (name1,) + names]
     release_info_file = _find_egg_info_file(repo, 'release-info')
+    # Duplicate check in tag() to prevent meta-file from getting updated
+    # while tagging might fail afterwards
+    for n in allnames:
+        if n in repo.tags():
+            raise util.Abort('Release %s already exists!' % n)
+    if ui.configbool('egg-author', 'update-meta', default=True):
+        meta_message = 'Updated meta-file for release %s' % (', '.join(allnames))
+        meta_file = _find_egg_info_file(repo, 'meta')
+        update_meta(ui, repo)
+        m = matchmod.exact(repo.root, '', [meta_file])
+        repo.commit(text=meta_message, user=opts.get('user'), date=opts.get('date'), match=m)
     fp = repo.wfile(release_info_file, 'r+')
     commands.tag(ui, repo, name1, *names, **opts)
+    ui.status(_('Tagged %s\n') % (', '.join(allnames)))
     # if hg's original tag command succeeded, we can do our stuff
-    relinfo_message = ('Updated release-info file for release tag %s' % (', '.join(allnames)))
+    relinfo_message = 'Updated release-info file for release tag %s' % (', '.join(allnames)), 2) # to the end
     for n in allnames:
         fp.write("(release %s)\n" % _to_scheme_string(n))
     m = matchmod.exact(repo.root, '', [release_info_file])
     repo.commit(text=relinfo_message, user=opts.get('user'), date=opts.get('date'), match=m)
+    ui.status(_('Updated and committed release-info %s\n') % (', '.join(allnames)))
 def read_byte(f,res):
     byte =