merge with stable
authorMatt Mackall <mpm@selenic.com>
Mon, 14 Jul 2014 18:53:03 -0500
changeset 21873 cf599f8a2da8
parent 21872 abae1eb695c0 (current diff)
parent 21868 3420346174b1 (diff)
child 21874 8da01b6e7b49
merge with stable
hgext/convert/git.py
mercurial/templatefilters.py
tests/test-hgweb-commands.t
--- a/hgext/bugzilla.py	Sat Jul 12 20:44:00 2014 -0700
+++ b/hgext/bugzilla.py	Mon Jul 14 18:53:03 2014 -0500
@@ -777,32 +777,25 @@
                        r'(?P<ids>(?:#?\d+\s*(?:,?\s*(?:and)?)?\s*)+)'
                        r'\.?\s*(?:h(?:ours?)?\s*(?P<hours>\d*(?:\.\d+)?))?')
 
-    _bz = None
-
     def __init__(self, ui, repo):
         self.ui = ui
         self.repo = repo
 
-    def bz(self):
-        '''return object that knows how to talk to bugzilla version in
-        use.'''
+        bzversion = self.ui.config('bugzilla', 'version')
+        try:
+            bzclass = bugzilla._versions[bzversion]
+        except KeyError:
+            raise util.Abort(_('bugzilla version %s not supported') %
+                             bzversion)
+        self.bzdriver = bzclass(self.ui)
 
-        if bugzilla._bz is None:
-            bzversion = self.ui.config('bugzilla', 'version')
-            try:
-                bzclass = bugzilla._versions[bzversion]
-            except KeyError:
-                raise util.Abort(_('bugzilla version %s not supported') %
-                                 bzversion)
-            bugzilla._bz = bzclass(self.ui)
-        return bugzilla._bz
-
-    def __getattr__(self, key):
-        return getattr(self.bz(), key)
-
-    _bug_re = None
-    _fix_re = None
-    _split_re = None
+        self.bug_re = re.compile(
+            self.ui.config('bugzilla', 'regexp',
+                           bugzilla._default_bug_re), re.IGNORECASE)
+        self.fix_re = re.compile(
+            self.ui.config('bugzilla', 'fixregexp',
+                           bugzilla._default_fix_re), re.IGNORECASE)
+        self.split_re = re.compile(r'\D+')
 
     def find_bugs(self, ctx):
         '''return bugs dictionary created from commit comment.
@@ -811,19 +804,11 @@
         not known to Bugzilla, and any that already have a reference to
         the given changeset in their comments.
         '''
-        if bugzilla._bug_re is None:
-            bugzilla._bug_re = re.compile(
-                self.ui.config('bugzilla', 'regexp',
-                               bugzilla._default_bug_re), re.IGNORECASE)
-            bugzilla._fix_re = re.compile(
-                self.ui.config('bugzilla', 'fixregexp',
-                               bugzilla._default_fix_re), re.IGNORECASE)
-            bugzilla._split_re = re.compile(r'\D+')
         start = 0
         hours = 0.0
         bugs = {}
-        bugmatch = bugzilla._bug_re.search(ctx.description(), start)
-        fixmatch = bugzilla._fix_re.search(ctx.description(), start)
+        bugmatch = self.bug_re.search(ctx.description(), start)
+        fixmatch = self.fix_re.search(ctx.description(), start)
         while True:
             bugattribs = {}
             if not bugmatch and not fixmatch:
@@ -839,11 +824,11 @@
                     m = fixmatch
             start = m.end()
             if m is bugmatch:
-                bugmatch = bugzilla._bug_re.search(ctx.description(), start)
+                bugmatch = self.bug_re.search(ctx.description(), start)
                 if 'fix' in bugattribs:
                     del bugattribs['fix']
             else:
-                fixmatch = bugzilla._fix_re.search(ctx.description(), start)
+                fixmatch = self.fix_re.search(ctx.description(), start)
                 bugattribs['fix'] = None
 
             try:
@@ -860,14 +845,14 @@
             except ValueError:
                 self.ui.status(_("%s: invalid hours\n") % m.group('hours'))
 
-            for id in bugzilla._split_re.split(ids):
+            for id in self.split_re.split(ids):
                 if not id:
                     continue
                 bugs[int(id)] = bugattribs
         if bugs:
-            self.filter_real_bug_ids(bugs)
+            self.bzdriver.filter_real_bug_ids(bugs)
         if bugs:
-            self.filter_cset_known_bug_ids(ctx.node(), bugs)
+            self.bzdriver.filter_cset_known_bug_ids(ctx.node(), bugs)
         return bugs
 
     def update(self, bugid, newstate, ctx):
@@ -902,7 +887,11 @@
                root=self.repo.root,
                webroot=webroot(self.repo.root))
         data = self.ui.popbuffer()
-        self.updatebug(bugid, newstate, data, util.email(ctx.user()))
+        self.bzdriver.updatebug(bugid, newstate, data, util.email(ctx.user()))
+
+    def notify(self, bugs, committer):
+        '''ensure Bugzilla users are notified of bug change.'''
+        self.bzdriver.notify(bugs, committer)
 
 def hook(ui, repo, hooktype, node=None, **kwargs):
     '''add comment to bugzilla for each changeset that refers to a
--- a/hgext/convert/git.py	Sat Jul 12 20:44:00 2014 -0700
+++ b/hgext/convert/git.py	Mon Jul 14 18:53:03 2014 -0500
@@ -133,6 +133,8 @@
         return data
 
     def getfile(self, name, rev):
+        if rev == hex(nullid):
+            raise IOError
         if name == '.hgsub':
             data = '\n'.join([m.hgsub() for m in self.submoditer()])
             mode = ''
@@ -184,6 +186,7 @@
         seen = set()
         entry = None
         subexists = False
+        subdeleted = False
         for l in fh.read().split('\x00'):
             if not entry:
                 if not l.startswith(':'):
@@ -200,7 +203,11 @@
 
                 if f == '.gitmodules':
                     subexists = True
-                    changes.append(('.hgsub', ''))
+                    if entry[4] == 'D':
+                        subdeleted = True
+                        changes.append(('.hgsub', hex(nullid)))
+                    else:
+                        changes.append(('.hgsub', ''))
                 elif entry[1] == '160000' or entry[0] == ':160000':
                     subexists = True
                 else:
@@ -211,8 +218,11 @@
             raise util.Abort(_('cannot read changes in %s') % version)
 
         if subexists:
-            self.retrievegitmodules(version)
-            changes.append(('.hgsubstate', ''))
+            if subdeleted:
+                changes.append(('.hgsubstate', hex(nullid)))
+            else:
+                self.retrievegitmodules(version)
+                changes.append(('.hgsubstate', ''))
         return (changes, {})
 
     def getcommit(self, version):
--- a/mercurial/templatefilters.py	Sat Jul 12 20:44:00 2014 -0700
+++ b/mercurial/templatefilters.py	Mon Jul 14 18:53:03 2014 -0500
@@ -216,7 +216,7 @@
 _escapes = [
     ('\\', '\\\\'), ('"', '\\"'), ('\t', '\\t'), ('\n', '\\n'),
     ('\r', '\\r'), ('\f', '\\f'), ('\b', '\\b'),
-    ('<', '\\u003c'), ('>', '\\u003e')
+    ('<', '\\u003c'), ('>', '\\u003e'), ('\0', '\\u0000')
 ]
 
 def jsonescape(s):
--- a/tests/test-convert-git.t	Sat Jul 12 20:44:00 2014 -0700
+++ b/tests/test-convert-git.t	Mon Jul 14 18:53:03 2014 -0500
@@ -363,6 +363,23 @@
 
   $ cd ../..
 
+convert the revision removing '.gitmodules' itself (and related
+submodules)
+
+  $ cd git-repo6
+  $ git rm .gitmodules
+  rm '.gitmodules'
+  $ git rm --cached git-repo5
+  rm 'git-repo5'
+  $ commit -a -m 'remove .gitmodules and submodule git-repo5'
+  $ cd ..
+
+  $ hg convert -q git-repo6 git-repo6-hg
+  $ hg -R git-repo6-hg tip -T "{desc|firstline}\n"
+  remove .gitmodules and submodule git-repo5
+  $ hg -R git-repo6-hg tip -T "{file_dels}\n"
+  .hgsub .hgsubstate
+
 damaged git repository tests:
 In case the hard-coded hashes change, the following commands can be used to
 list the hashes and their corresponding types in the repository:
--- a/tests/test-hgweb-commands.t	Sat Jul 12 20:44:00 2014 -0700
+++ b/tests/test-hgweb-commands.t	Mon Jul 14 18:53:03 2014 -0500
@@ -1730,7 +1730,7 @@
   <script>
   <!-- hide script content
   
-  var data = [["cad8025a2e87", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch commit with null character: \x00", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]]; (esc)
+  var data = [["cad8025a2e87", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch commit with null character: \u0000", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]];
   var graph = new Graph();
   graph.scale(39);
   
@@ -2042,7 +2042,7 @@
   >>> for line in open("out"):
   ...     if line.startswith("var data ="):
   ...         print line,
-  var data = [["061dd13ba3c3", [0, 1], [[0, 0, 1, -1, ""]], "\\u80fd", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["cad8025a2e87", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch commit with null character: \x00", "test", "1970-01-01", ["unstable", false], [], []], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]]; (esc)
+  var data = [["061dd13ba3c3", [0, 1], [[0, 0, 1, -1, ""]], "\u80fd", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["cad8025a2e87", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch commit with null character: \u0000", "test", "1970-01-01", ["unstable", false], [], []], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]];
 
 capabilities