aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Bex <peter@more-magic.net>2011-04-03 22:38:04 +0200
committerPeter Bex <peter@more-magic.net>2011-04-03 22:38:04 +0200
commitd811f069ab5b251fa8610a06d99199499c41bed0 (patch)
treebaab99b7209cbd7f3f666d411ad99218fb1331f6
parent1ce44e728f276bfd12b8e1bb13e960c730eef9a5 (diff)
downloadhg-egg-author-d811f069ab5b251fa8610a06d99199499c41bed0.tar.gz
Add meta-file updating feature to eggtag command, controlled by an hgrc option
-rw-r--r--README26
-rw-r--r--egg-author.py28
2 files changed, 46 insertions, 8 deletions
diff --git a/README b/README
index 193b106..c63a0de 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
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.
@@ -10,5 +10,25 @@ You only need the python file (can be downloaded using the source code
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/egg-author.py
+ [extensions]
+ egg-author=~/.hg/egg-author.py
+
+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. \ No newline at end of file
diff --git a/egg-author.py b/egg-author.py
index ddeeb54..297bc04 100644
--- a/egg-author.py
+++ b/egg-author.py
@@ -6,15 +6,17 @@
# [extensions]
# egg-author=~/.hg/egg-author.py
#
+# 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 http://mercurial.selenic.com/wiki/License 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'''
@@ -71,11 +73,26 @@ def eggtag(ui, repo, name1, *names, **opts):
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))
fp.seek(0, 2) # to the end
for n in allnames:
fp.write("(release %s)\n" % _to_scheme_string(n))
@@ -83,6 +100,7 @@ def eggtag(ui, repo, name1, *names, **opts):
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 = f.read(1)