Patchwork [2,of,5] tags: move 'repo.tag' in the 'tags' module

login
register
mail settings
Submitter Pierre-Yves David
Date March 27, 2017, 4:28 p.m.
Message ID <983954c3aeebf13202b8.1490632105@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19756/
State Accepted
Headers show

Comments

Pierre-Yves David - March 27, 2017, 4:28 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1490623111 -7200
#      Mon Mar 27 15:58:31 2017 +0200
# Node ID 983954c3aeebf13202b870a476671441bab9f6bf
# Parent  5ccbaa368644a534514cc79a3375848f2733d616
# EXP-Topic tags
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 983954c3aeeb
tags: move 'repo.tag' in the 'tags' module

Similar logic, pretty much nobody use this method (that creates a tag) so we
move it into the 'tags' module were it belong.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -650,35 +650,8 @@  class localrepository(object):
         return hook.hook(self.ui, self, name, throw, **args)
 
     def tag(self, names, node, message, local, user, date, editor=False):
-        '''tag a revision with one or more symbolic names.
-
-        names is a list of strings or, when adding a single tag, names may be a
-        string.
-
-        if local is True, the tags are stored in a per-repository file.
-        otherwise, they are stored in the .hgtags file, and a new
-        changeset is committed with the change.
-
-        keyword arguments:
-
-        local: whether to store tags in non-version-controlled file
-        (default False)
-
-        message: commit message to use if committing
-
-        user: name of user to use if committing
-
-        date: date tuple to use if committing'''
-
-        if not local:
-            m = matchmod.exact(self.root, '', ['.hgtags'])
-            if any(self.status(match=m, unknown=True, ignored=True)):
-                raise error.Abort(_('working copy of .hgtags is changed'),
-                                 hint=_('please commit .hgtags manually'))
-
-        self.tags() # instantiate the cache
-        tagsmod._tag(self.unfiltered(), names, node, message, local, user, date,
-                     editor=editor)
+        tagsmod.tag(self, names, node, message, local, user, date,
+                    editor=editor)
 
     @filteredpropertycache
     def _tagscache(self):
diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -395,6 +395,37 @@  def _writetagcache(ui, repo, valid, cach
     except (OSError, IOError):
         pass
 
+def tag(repo, names, node, message, local, user, date, editor=False):
+    '''tag a revision with one or more symbolic names.
+
+    names is a list of strings or, when adding a single tag, names may be a
+    string.
+
+    if local is True, the tags are stored in a per-repository file.
+    otherwise, they are stored in the .hgtags file, and a new
+    changeset is committed with the change.
+
+    keyword arguments:
+
+    local: whether to store tags in non-version-controlled file
+    (default False)
+
+    message: commit message to use if committing
+
+    user: name of user to use if committing
+
+    date: date tuple to use if committing'''
+
+    if not local:
+        m = matchmod.exact(repo.root, '', ['.hgtags'])
+        if any(repo.status(match=m, unknown=True, ignored=True)):
+            raise error.Abort(_('working copy of .hgtags is changed'),
+                             hint=_('please commit .hgtags manually'))
+
+    repo.tags() # instantiate the cache
+    _tag(repo.unfiltered(), names, node, message, local, user, date,
+         editor=editor)
+
 def _tag(repo, names, node, message, local, user, date, extra=None,
          editor=False):
     if isinstance(names, str):