Daniel Dehennin <daniel.dehen...@baby-gnu.org> writes:

[...]

>> Here[1] is a new version of the patch.
>>
>> The path is splited in 3 parts, nosetests are OK at each steps:
>>
>> 1. Add guess_version_from_upstream() to
>>    gbp.deb.git.DebianGitRepository: this is required for next patch
>>
>> 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted
>>    version of gbp.scripts.dch ones
>>
>> 3. Update gbp.scripts.dch to use new methods.
>
> After rebasing my create-inexistant-changelog patches on this, I figure
> that ChangeLog.add_section() should not manipulate repo object nor
> upstream_tag_format.
>
> I'll redo the patches to solve this point.

I think it's much better now[1].

Changelog methods do not care about DebianGitRepository or options
anymore.

Thanks, and sorry for the noise.

Pull request:
=============

The following changes since commit a116edd739e9ff529058a2d9df6fe67bdb17670d:

  Refactor deb helpers: move PristineTar class (2012-05-25 10:45:13 +0200)

are available in the git repository at:

  git://git.baby-gnu.net/git-buildpackage.git 
tags/dad/move-spawn_dch-to-ChangeLog/rebased/on-a116edd-2

for you to fetch changes up to 595b774f82f69960b0e7e342ba54b31f8f2947fc:

  Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. 
(2012-05-31 01:06:06 +0200)

----------------------------------------------------------------
New version on latest experimental.

The path is splited in 3 parts, nosetests are OK at each steps:

1. Add guess_version_from_upstream() to
   gbp.deb.git.DebianGitRepository: this is required for next patch

2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted
   version of gbp.scripts.dch without using DebianGitRepository nor
   options.

3. Update gbp.scripts.dch to use new methods.

----------------------------------------------------------------
Daniel Dehennin (3):
      Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository.
      Add spawn_dch(), add_changelog_entry() and add_changelog_section() to 
gbp.deb.changelog.ChangeLog.
      Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls.

 gbp/deb/changelog.py                               |   98 ++++++++++++++
 gbp/deb/git.py                                     |   17 +++
 gbp/scripts/dch.py                                 |  140 +++-----------------
 ...anGitRepository_guess_version_from_upstream.py} |   13 +-
 tests/test_Changelog.py                            |   85 ++++++++++++
 5 files changed, 225 insertions(+), 128 deletions(-)
 rename tests/{03_test_dch_guess_version.py => 
03_test_DebianGitRepository_guess_version_from_upstream.py} (75%)


Patches:
========

From 851a858d8a5ef79194929596ea1de6282b4de06b Mon Sep 17 00:00:00 2001
From: Daniel Dehennin <daniel.dehen...@baby-gnu.org>
Date: Wed, 30 May 2012 21:12:41 +0200
Subject: [PATCH 1/3] Add guess_version_from_upstream() to
 gbp.deb.git.DebianGitRepository.

* gbp/deb/git.py: Update imports.
  (guess_version_from_upstream): New method adapted from
  gbp.scripts.dch. Remove the logging. Caller is responsible of handling
  possible GitRepositoryError exception.

* tests/03_test_DebianGitRepository_guess_version_from_upstream.py:
  Adapt 03_test_dch_guess_version.py.
  (MockGitRepository): Inherit from DebianGitRepository.
  (TestGuessVersionFromUpstream.test_guess_no_epoch): Test calls of
  guess_version_from_upstream().
  (TestGuessVersionFromUpstream.test_guess_epoch): Ditoo with epoch in
  version.
---
 gbp/deb/git.py                                     |   17 +++++++
 ...ianGitRepository_guess_version_from_upstream.py |   47 ++++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 
tests/03_test_DebianGitRepository_guess_version_from_upstream.py

diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index 7e13b5e..2d2dc18 100644
--- a/gbp/deb/git.py
+++ b/gbp/deb/git.py
@@ -19,6 +19,7 @@
 import re
 from gbp.git import GitRepository, GitRepositoryError
 from gbp.deb.pristinetar import DebianPristineTar
+from gbp.deb import compare_versions
 
 class DebianGitRepository(GitRepository):
     """A git repository that holds the source of a Debian package"""
@@ -117,6 +118,22 @@ class DebianGitRepository(GitRepository):
             return version
         return None
 
+    def guess_version_from_upstream(self, upstream_tag_format, cp):
+        """
+        Guess the version based on the latest version on the upstream branch
+        """
+        pattern = upstream_tag_format % dict(version='*')
+        tag = self.find_tag('HEAD', pattern=pattern)
+        version = self.tag_to_version(tag, upstream_tag_format)
+        if version:
+            if cp == None:
+                return "%s-1" % version
+            if cp.has_epoch():
+                version = "%s:%s" % (cp.epoch, version)
+            if compare_versions(version, cp.version) > 0:
+                return "%s-1" % version
+        return None
+    
     @property
     def pristine_tar_branch(self):
         """
diff --git a/tests/03_test_DebianGitRepository_guess_version_from_upstream.py 
b/tests/03_test_DebianGitRepository_guess_version_from_upstream.py
new file mode 100644
index 0000000..1cfb439
--- /dev/null
+++ b/tests/03_test_DebianGitRepository_guess_version_from_upstream.py
@@ -0,0 +1,47 @@
+# vim: set fileencoding=utf-8 :
+
+"""Test L{Changelog}'s guess_version_from_upstream"""
+
+import unittest
+
+from gbp.errors import GbpError
+from gbp.deb.changelog import ChangeLog
+from gbp.deb.git import DebianGitRepository
+
+class MockGitRepository(DebianGitRepository):
+    def __init__(self, upstream_tag):
+        self.upstream_tag = upstream_tag
+
+    def find_tag(self, branch, pattern):
+        return self.upstream_tag
+
+    def tag_to_version(self, tag, format):
+        return DebianGitRepository.tag_to_version(tag, format)
+
+
+class MockedChangeLog(ChangeLog):
+    contents = """foo (%s) experimental; urgency=low
+
+  * a important change
+
+ -- Debian Maintainer <ma...@debian.org>  Sat, 01 Jan 2012 00:00:00 +0100"""
+
+    def __init__(self, version):
+        ChangeLog.__init__(self, contents=self.contents % version)
+
+
+class TestGuessVersionFromUpstream(unittest.TestCase):
+    """Test guess_version_from_upstream"""
+    def test_guess_no_epoch(self):
+        """Guess the new version from the upstream tag"""
+        repo = MockGitRepository(upstream_tag='upstream/1.1')
+        cp = MockedChangeLog('1.0-1')
+        guessed = repo.guess_version_from_upstream('upstream/%(version)s', cp)
+        self.assertEqual('1.1-1', guessed)
+
+    def test_guess_epoch(self):
+        """Check if we picked up the epoch correctly (#652366)"""
+        repo = MockGitRepository(upstream_tag='upstream/1.1')
+        cp = MockedChangeLog('1:1.0-1')
+        guessed = repo.guess_version_from_upstream('upstream/%(version)s', cp)
+        self.assertEqual('1:1.1-1', guessed)
-- 
1.7.10


From 7ade367f059cf72caad27906e44f70ba3307d2a7 Mon Sep 17 00:00:00 2001
From: Daniel Dehennin <daniel.dehen...@baby-gnu.org>
Date: Wed, 30 May 2012 21:30:45 +0200
Subject: [PATCH 2/3] Add spawn_dch(), add_changelog_entry() and
 add_changelog_section() to gbp.deb.changelog.ChangeLog.

spawn_dch use gbp.command.wrappers.Command.

* gbp/deb/changelog.py (ChangeLog.spawn_dch): static method adapted from
  gbp.scripts.dch and converted to gbp.command_wrappers.Command.
  (add_entry): New method adapted from
  gbp.scripts.dch.add_changelog_entry.
  (add_section): New method adapted from
  gbp.scripts.dch.add_changelog_entry. Remove DebianGitRepository and
  options, this has nothing to do with changelog management.

* tests/test_Changelog.py: Test new methods.
---
 gbp/deb/changelog.py    |   98 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/test_Changelog.py |   85 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 183 insertions(+)

diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py
index 0f9bace..5e42291 100644
--- a/gbp/deb/changelog.py
+++ b/gbp/deb/changelog.py
@@ -19,6 +19,7 @@
 import email
 import os
 import subprocess
+from gbp.command_wrappers import Command
 
 class NoChangeLogError(Exception):
     """No changelog found"""
@@ -214,3 +215,100 @@ class ChangeLog(object):
         Get sections in the changelog
         """
         return list(self.sections_iter)
+
+    @staticmethod
+    def spawn_dch(msg=[], author=None, email=None, newversion=False, 
version=None,
+                  release=False, distribution=None, dch_options=[]):
+        """
+        Spawn dch
+    
+        @param author: committers name
+        @type author: C{str}
+        @param email: committers email
+        @type email: C{str}
+        @param newversion: start a new version
+        @type newversion: C{bool}
+        @param version: the verion to use
+        @type version: C{str}
+        @param release: finalize changelog for releaze
+        @type release: C{bool}
+        @param distribution: distribution to use
+        @type distribution: C{str}
+        @param dch_options: options passed verbatim to dch
+        @type dch_options: C{list}
+        """
+        distopt = ""
+        versionopt = ""
+        env = {}
+        args = ['--no-auto-nmu']
+        if newversion:
+            if version:
+                try:
+                    args.append(version['increment'])
+                except KeyError:
+                    args.append('--newversion=%s' % version['version'])
+            else:
+                args.append('-i')
+        elif release:
+            args.extend(["--release", "--no-force-save-on-release"])
+            msg = None
+    
+        if author and email:
+            env = {'DEBFULLNAME': author, 'DEBEMAIL': email}
+    
+        if distribution:
+            args.append("--distribution=%s" % distribution)
+
+        args.extend(dch_options)
+        args.append('--')
+        if msg:
+            args.append('[[[insert-git-dch-commit-message-here]]]')
+        else:
+            args.append('')
+        dch = Command('dch', args, extra_env=env)
+        dch.call([])
+        if msg:
+            old_cl = open("debian/changelog", "r")
+            new_cl = open("debian/changelog.bak", "w")
+            for line in old_cl:
+                if line == "  * [[[insert-git-dch-commit-message-here]]]\n":
+                    print >> new_cl, "  * " + msg[0]
+                    for line in msg[1:]:
+                        print >> new_cl, "    " + line
+                else:
+                    print >> new_cl, line,
+            os.rename("debian/changelog.bak", "debian/changelog")
+
+    def add_entry(self, msg, author=None, email=None, dch_options=[]):
+        """Add a single changelog entry
+
+        @param msg: log message to add
+        @type msg: C{str}
+        @param author: name of the author of the log message
+        @type author: C{str}
+        @param email: email of the author of the log message
+        @type email: C{str}
+        @param dch_options: options passed verbatim to dch
+        @type dch_options: C{list}
+        """
+        self.spawn_dch(msg=msg, author=author, email=email, 
dch_options=dch_options)
+
+    def add_section(self, msg, distribution, author=None, email=None,
+                    version={}, dch_options=[]):
+        """Add a new section to the changelog
+
+        @param msg: log message to add
+        @type msg: C{str}
+        @param distribution: distribution to set for the new changelog entry
+        @type distribution: C{str}
+        @param author: name of the author of the log message
+        @type author: C{str}
+        @param email: email of the author of the log message
+        @type email: C{str}
+        @param version: version to set for the new changelog entry
+        @param version: C{dict}
+        @param dch_options: options passed verbatim to dch
+        @type dch_options: C{list}
+        """
+        self.spawn_dch(msg=msg, newversion=True, version=version, 
author=author,
+                       email=email, distribution=distribution, 
dch_options=dch_options)
diff --git a/tests/test_Changelog.py b/tests/test_Changelog.py
index 48b370e..94cf409 100644
--- a/tests/test_Changelog.py
+++ b/tests/test_Changelog.py
@@ -216,3 +216,88 @@ def test_parse_sections():
     >>> cl.sections[1].version
     '0.5.31'
     """
+
+def test_add_section():
+    """
+    Test if we can add a section to an existant changelog
+
+    Methods tested:
+         - L{gbp.deb.changelog.ChangeLog.__init__}
+         - L{gbp.deb.changelog.ChangeLog._parse}
+         - L{gbp.deb.changelog.ChangeLog.add_section}
+         - L{gbp.deb.changelog.ChangeLog.spawn_dch}
+
+    >>> import os
+    >>> import tempfile
+    >>> import shutil
+    >>> import gbp.deb.changelog
+    >>> olddir = os.path.abspath(os.path.curdir)
+    >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-')
+    >>> testdebdir = os.path.join(testdir, 'debian')
+    >>> testclname = os.path.join(testdebdir, "changelog")
+    >>> os.mkdir(testdebdir)
+    >>> clh = open(os.path.join(testdebdir, "changelog"), "w")
+    >>> clh.write(cl_debian)
+    >>> clh.close()
+    >>> os.chdir(testdir)
+    >>> os.path.abspath(os.path.curdir) == testdir
+    True
+    >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname)
+    >>> cl.add_section(msg=["Test add section"], distribution=None, 
author="Debian Maintainer", email="ma...@debian.org")
+    >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname)
+    >>> cl.version
+    '0.5.33'
+    >>> cl.debian_version
+    '0.5.33'
+    >>> cl['Distribution']
+    'UNRELEASED'
+    >>> 'Test add section' in cl['Changes']
+    True
+    >>> os.chdir(olddir)
+    >>> os.path.abspath(os.path.curdir) == olddir
+    True
+    >>> shutil.rmtree(testdir, ignore_errors=True)
+    """
+
+def test_add_entry():
+    """
+    Test if we can add an entry to an existant changelog
+
+    Methods tested:
+         - L{gbp.deb.changelog.ChangeLog.__init__}
+         - L{gbp.deb.changelog.ChangeLog._parse}
+         - L{gbp.deb.changelog.ChangeLog.add_entry}
+         - L{gbp.deb.changelog.ChangeLog.spawn_dch}
+
+    >>> import os
+    >>> import tempfile
+    >>> import shutil
+    >>> import gbp.deb.changelog
+    >>> olddir = os.path.abspath(os.path.curdir)
+    >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-')
+    >>> testdebdir = os.path.join(testdir, 'debian')
+    >>> testclname = os.path.join(testdebdir, "changelog")
+    >>> os.mkdir(testdebdir)
+    >>> clh = open(os.path.join(testdebdir, "changelog"), "w")
+    >>> clh.write(cl_debian)
+    >>> clh.close()
+    >>> os.chdir(testdir)
+    >>> os.path.abspath(os.path.curdir) == testdir
+    True
+    >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname)
+    >>> cl.add_section(msg=["Test add section"], distribution=None, 
author="Debian Maintainer", email="ma...@debian.org")
+    >>> cl.add_entry(msg=["Test add entry"], author="Debian Maintainer", 
email="ma...@debian.org")
+    >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname)
+    >>> cl.version
+    '0.5.33'
+    >>> cl.debian_version
+    '0.5.33'
+    >>> cl['Distribution']
+    'UNRELEASED'
+    >>> 'Test add entry' in cl['Changes']
+    True
+    >>> os.chdir(olddir)
+    >>> os.path.abspath(os.path.curdir) == olddir
+    True
+    >>> shutil.rmtree(testdir, ignore_errors=True)
+    """
-- 
1.7.10


From 595b774f82f69960b0e7e342ba54b31f8f2947fc Mon Sep 17 00:00:00 2001
From: Daniel Dehennin <daniel.dehen...@baby-gnu.org>
Date: Wed, 30 May 2012 21:39:51 +0200
Subject: [PATCH 3/3] Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog
 method calls.

* gbp/scripts/dch.py: compare_version became useless.
  Remove useless functions: system(), spawn_dch(),
  add_changelog_section(), add_changelog_entry() and
  guess_version_from_upstream().
  Update calls accordingly.
  (fixup_trailer): Use spawn_dch() method of ChangeLog class.
  (process_options): dch_options became a list.
  (main): Use add_section() and add_entry() methods of ChangeLog object.
  Take care of upstream version since ChangeLog.add_section() does not
  manage it anymore.
  Update exception handling, ChangeLog.spawn_dch() can raise
  "CommandExecFailed" exception.

* tests/03_test_dch_guess_version.py: No more
  gbp.scripts.dch.guess_version_from_upstream() to test.
---
 gbp/scripts/dch.py                 |  140 ++++++------------------------------
 tests/03_test_dch_guess_version.py |   54 --------------
 2 files changed, 22 insertions(+), 172 deletions(-)
 delete mode 100644 tests/03_test_dch_guess_version.py

diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index ba96631..5700d53 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -28,7 +28,6 @@ import gbp.dch as dch
 import gbp.log
 from gbp.config import GbpOptionParserDebian, GbpOptionGroup
 from gbp.errors import GbpError
-from gbp.deb import compare_versions
 from gbp.deb.git import GitRepositoryError, DebianGitRepository
 from gbp.deb.changelog import ChangeLog, NoChangeLogError
 
@@ -36,102 +35,6 @@ user_customizations = {}
 snapshot_re = re.compile("\s*\*\* SNAPSHOT build 
@(?P<commit>[a-z0-9]+)\s+\*\*")
 
 
-def system(cmd):
-    try:
-        gbpc.Command(cmd, shell=True)()
-    except gbpc.CommandExecFailed:
-        raise GbpError
-
-
-def spawn_dch(msg=[], author=None, email=None, newversion=False, version=None,
-              release=False, distribution=None, dch_options=''):
-    """
-    Spawn dch
-
-    @param author: committers name
-    @param email: committers email
-    @param newversion: start a new version
-    @param version: the verion to use
-    @param release: finalize changelog for releaze
-    @param distribution: distribution to use
-    @param dch_options: options passed verbatim to dch
-    """
-    distopt = ""
-    versionopt = ""
-    env = ""
-
-    if newversion:
-        if version:
-            try:
-                versionopt = version['increment']
-            except KeyError:
-                versionopt = '--newversion=%s' % version['version']
-        else:
-            versionopt = '-i'
-    elif release:
-        versionopt = "--release --no-force-save-on-release"
-        msg = None
-
-    if author and email:
-        env = """DEBFULLNAME="%s" DEBEMAIL="%s" """ % (author, email)
-
-    if distribution:
-        distopt = "--distribution=%s" % distribution
-
-    cmd = '%(env)s dch --no-auto-nmu  %(distopt)s %(versionopt)s 
%(dch_options)s ' % locals()
-    if msg:
-        cmd += '-- "[[[insert-git-dch-commit-message-here]]]"'
-    else:
-        cmd += '-- ""'
-    system(cmd)
-    if msg:
-        old_cl = open("debian/changelog", "r")
-        new_cl = open("debian/changelog.bak", "w")
-        for line in old_cl:
-            if line == "  * [[[insert-git-dch-commit-message-here]]]\n":
-                print >> new_cl, "  * " + msg[0]
-                for line in msg[1:]:
-                    print >> new_cl, "    " + line
-            else:
-                print >> new_cl, line,
-        os.rename("debian/changelog.bak", "debian/changelog")
-
-
-def add_changelog_entry(msg, author, email, dch_options):
-    """Add a single changelog entry"""
-    spawn_dch(msg=msg, author=author, email=email, dch_options=dch_options)
-
-
-def guess_version_from_upstream(repo, upstream_tag_format, cp):
-    """
-    Guess the version based on the latest version on the upstream branch
-    """
-    pattern = upstream_tag_format % dict(version='*')
-    try:
-        tag = repo.find_tag('HEAD', pattern=pattern)
-        version = repo.tag_to_version(tag, upstream_tag_format)
-        if version:
-            gbp.log.debug("Found upstream version %s." % version)
-            if cp.has_epoch():
-                version = "%s:%s" % (cp.epoch, version)
-            if compare_versions(version, cp.version) > 0:
-                return "%s-1" % version
-    except GitRepositoryError:
-        gbp.log.debug("No tag found matching pattern %s." % pattern)
-    return None
-
-
-def add_changelog_section(msg, distribution, repo, options, cp,
-                          author=None, email=None, version={}, dch_options=''):
-    """Add a new section to the changelog"""
-    if not version and not cp.is_native():
-        v = guess_version_from_upstream(repo, options.upstream_tag, cp)
-        if v:
-            version['version'] = v
-    spawn_dch(msg=msg, newversion=True, version=version, author=author,
-              email=email, distribution=distribution, dch_options=dch_options)
-
-
 def get_author_email(repo, use_git_config):
     """Get author and email from git configuration"""
     author = email = None
@@ -153,7 +56,7 @@ def fixup_trailer(repo, git_author, dch_options):
     creating the changelog
     """
     author, email = get_author_email(repo, git_author)
-    spawn_dch(msg='', author=author, email=email, dch_options=dch_options)
+    ChangeLog.spawn_dch(msg='', author=author, email=email, 
dch_options=dch_options)
 
 
 def snapshot_version(version):
@@ -294,15 +197,16 @@ def process_options(options, parser):
     if options.since and options.auto:
         parser.error("'--since' and '--auto' are incompatible options")
 
+    dch_options = []
     if options.multimaint_merge:
-        dch_options = "--multimaint-merge"
+        dch_options.append("--multimaint-merge")
     else:
-        dch_options = "--nomultimaint-merge"
+        dch_options.append("--nomultimaint-merge")
 
     if options.multimaint:
-        dch_options += " --multimaint"
+        dch_options.append(" --multimaint")
     else:
-        dch_options += " --nomultimaint"
+        dch_options.append(" --nomultimaint")
 
     get_customizations(options.customization_file)
     return dch_options
@@ -472,6 +376,12 @@ def main(argv):
         else:
             add_section = False
 
+        if add_section and not version_change and not cp.is_native():
+            # Get version from upstream if none provided
+            v = guess_version_from_upstream(repo, options.upstream_tag, cp)
+            if v:
+                version['version'] = v
+
         i = 0
         for c in commits:
             i += 1
@@ -485,18 +395,15 @@ def main(argv):
             if add_section:
                 # Add a section containing just this message (we can't
                 # add an empty section with dch)
-                add_changelog_section(distribution="UNRELEASED", 
msg=commit_msg,
-                                      version=version_change,
-                                      author=commit_author,
-                                      email=commit_email,
-                                      dch_options=dch_options,
-                                      repo=repo,
-                                      options=options,
-                                      cp=cp)
+                cp.add_section(distribution="UNRELEASED", msg=commit_msg,
+                               version=version_change,
+                               author=commit_author,
+                               email=commit_email,
+                               dch_options=dch_options)
                 # Adding a section only needs to happen once.
                 add_section = False
             else:
-                add_changelog_entry(commit_msg, commit_author, commit_email, 
dch_options)
+                cp.add_entry(commit_msg, commit_author, commit_email, 
dch_options)
 
 
         # Show a message if there were no commits (not even ignored
@@ -507,12 +414,9 @@ def main(argv):
         if add_section:
             # If we end up here, then there were no commits to include,
             # so we put a dummy message in the new section.
-            add_changelog_section(distribution="UNRELEASED", 
msg=["UNRELEASED"],
-                                  version=version_change,
-                                  dch_options=dch_options,
-                                  repo=repo,
-                                  options=options,
-                                  cp=cp)
+            cp.add_section(distribution="UNRELEASED", msg=["UNRELEASED"],
+                           version=version_change,
+                           dch_options=dch_options)
 
         fixup_trailer(repo, git_author=options.git_author,
                       dch_options=dch_options)
@@ -537,7 +441,7 @@ def main(argv):
             repo.commit_files([changelog], msg)
             gbp.log.info("Changelog has been committed for version %s" % 
version)
 
-    except (GbpError, GitRepositoryError, NoChangeLogError), err:
+    except (CommandExecFailed, GbpError, GitRepositoryError, 
NoChangeLogError), err:
         if len(err.__str__()):
             gbp.log.err(err)
         ret = 1
diff --git a/tests/03_test_dch_guess_version.py 
b/tests/03_test_dch_guess_version.py
deleted file mode 100644
index d954459..0000000
--- a/tests/03_test_dch_guess_version.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# vim: set fileencoding=utf-8 :
-
-"""Test L{Changelog}'s guess_version_from_upstream"""
-
-import unittest
-
-from gbp.scripts import dch
-from gbp.errors import GbpError
-from gbp.deb.changelog import ChangeLog
-from gbp.deb.git import DebianGitRepository
-
-class MockGitRepository(object):
-    def __init__(self, upstream_tag):
-        self.upstream_tag = upstream_tag
-
-    def find_tag(self, branch, pattern):
-        return self.upstream_tag
-
-    def tag_to_version(self, tag, format):
-        return DebianGitRepository.tag_to_version(tag, format)
-
-
-class MockedChangeLog(ChangeLog):
-    contents = """foo (%s) experimental; urgency=low
-
-  * a important change
-
- -- Debian Maintainer <ma...@debian.org>  Sat, 01 Jan 2012 00:00:00 +0100"""
-
-    def __init__(self, version):
-        ChangeLog.__init__(self, contents=self.contents % version)
-
-
-class TestGuessVersionFromUpstream(unittest.TestCase):
-    """Test guess_version_from_upstream"""
-    def test_guess_no_epoch(self):
-        """Guess the new version from the upstream tag"""
-        repo = MockGitRepository(upstream_tag='upstream/1.1')
-        cp = MockedChangeLog('1.0-1')
-        guessed = dch.guess_version_from_upstream(repo,
-                                                  'upstream/%(version)s',
-                                                  cp)
-        self.assertEqual('1.1-1', guessed)
-
-    def test_guess_epoch(self):
-        """Check if we picked up the epoch correctly (#652366)"""
-        repo = MockGitRepository(upstream_tag='upstream/1.1')
-        cp = MockedChangeLog('1:1.0-1')
-        guessed = dch.guess_version_from_upstream(repo,
-                                                  'upstream/%(version)s',
-                                                  cp)
-        self.assertEqual('1:1.1-1', guessed)
-
-
-- 
1.7.10


Footnotes: 
[1]  
http://git.baby-gnu.net/gitweb/?p=git-buildpackage.git;a=tag;h=abcc51eb7255982029cd9876e2768bd8cf7a9475

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF

Attachment: pgptNVrjR6NNs.pgp
Description: PGP signature

Reply via email to