Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
include:
- os: ubuntu-latest
python-version: 'pypy3.9'
python-version: 'pypy3.11'

steps:
- uses: actions/checkout@v3
Expand All @@ -34,7 +34,6 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install coverage flake8 pytest
python -m pip install mercurial
python -m pip install dulwich
python -m pip install -e .
# - name: Lint with flake8
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.8.0 - 2025-??-??
------------------

- Drop support for Mercurial.

0.7.0 - 2024-08-02
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '0.7.0'
version = '0.8.0'

long_description = (
open('README.rst').read()
Expand Down
76 changes: 1 addition & 75 deletions src/pmr2/wfctrl/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,80 +57,6 @@ def push(self, workspace, **kw):
self.queue.append([self.binary, 'push'])


class MercurialDvcsCmd(BaseDvcsCmdBin):
cmd_binary = 'hg'
name = 'mercurial'
marker = '.hg'
default_remote = 'default'
_hgrc = 'hgrc'
_committer = None

def _args(self, workspace, *args):
result = ['-R', workspace.working_dir]
result.extend(args)
return result

def set_committer(self, name, email, **kw):
# TODO persist config.
self._committer = '%s <%s>' % (name, email)

def clone(self, workspace, **kw):
return self.execute('clone', self.remote, workspace.working_dir)

def init_new(self, workspace, **kw):
return self.execute('init', workspace.working_dir)

def add(self, workspace, path, **kw):
return self.execute(*self._args(workspace, 'add', path))

def commit(self, workspace, message, **kw):
# XXX need to customize the user name
cmd = ['commit', '-m', message]
if self._committer:
cmd.extend(['-u', self._committer])
return self.execute(*self._args(workspace, *cmd))

def read_remote(self, workspace, target_remote=None, **kw):
target_remote = target_remote or self.default_remote
target = join(workspace.working_dir, self.marker, self._hgrc)
cp = ConfigParser()
cp.read(target)
if cp.has_option('paths', target_remote):
return cp.get('paths', target_remote)

def write_remote(self, workspace, target_remote=None, **kw):
target_remote = target_remote or self.default_remote
target = join(workspace.working_dir, self.marker, self._hgrc)
cp = ConfigParser()
cp.read(target)
if not cp.has_section('paths'):
cp.add_section('paths')
cp.set('paths', target_remote, self.remote)
with open(target, 'w') as fd:
cp.write(fd)

def pull(self, workspace, username=None, password=None, **kw):
# XXX origin may be undefined
target = self.get_remote(workspace,
username=username, password=password)
# XXX assuming repo is clean
args = self._args(workspace, 'pull', target)
return self.execute(*args)

def push(self, workspace, username=None, password=None, **kw):
# XXX origin may be undefined
push_target = self.get_remote(workspace,
username=username, password=password)
args = self._args(workspace, 'push', push_target)
return self.execute(*args)

def reset_to_remote(self, workspace, branch=None):
if branch is None:
branch = 'tip'
args = self._args(workspace, 'update', '-C', '-r', branch)
return self.execute(*args)


class GitDvcsCmd(BaseDvcsCmdBin):
cmd_binary = 'git'
name = 'git'
Expand Down Expand Up @@ -422,7 +348,7 @@ def push(self, workspace, **kw):


def _register():
register_cmd(MercurialDvcsCmd, DulwichDvcsCmd, GitDvcsCmd, AuthenticatedDulwichDvcsCmd, AuthenticatedGitDvcsCmd)
register_cmd(DulwichDvcsCmd, GitDvcsCmd, AuthenticatedDulwichDvcsCmd, AuthenticatedGitDvcsCmd)


register = _register
Expand Down
37 changes: 0 additions & 37 deletions tests/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from pmr2.wfctrl.core import get_cmd_by_name
from pmr2.wfctrl.core import CmdWorkspace
from pmr2.wfctrl.cmd import GitDvcsCmd
from pmr2.wfctrl.cmd import MercurialDvcsCmd
from pmr2.wfctrl.cmd import DulwichDvcsCmd
from pmr2.wfctrl.cmd import AuthenticatedGitDvcsCmd
from pmr2.wfctrl.cmd import AuthenticatedDulwichDvcsCmd
Expand Down Expand Up @@ -284,42 +283,6 @@ def test_auto_init(self): # pragma: no cover
super(GitDvcsCmdTestCase, self).test_auto_init()


@skipIf(not MercurialDvcsCmd.available(), 'mercurial is not available')
@skipIf(
platform.python_implementation() != 'CPython',
'only doing mercurial tests with CPython',
)
class MercurialDvcsCmdTestCase(CoreTestCase, RawCmdTests):
cmdcls = MercurialDvcsCmd

def setUp(self):
super(MercurialDvcsCmdTestCase, self).setUp()
self.cmd = MercurialDvcsCmd()
self.workspace = CmdWorkspace(self.workspace_dir, self.cmd)

def _log(self, workspace=None):
return MercurialDvcsCmd._execute(self.cmd._args(self.workspace, 'log'))

def _ls_root(self, workspace=None):
return MercurialDvcsCmd._execute(
self.cmd._args(self.workspace, 'manifest'))

def _make_remote(self):
target = os.path.join(self.working_dir, 'remote')
MercurialDvcsCmd._execute(['init', target])
return target

def test_read_write_remote(self):
self.cmd.init_new(self.workspace)
cmd = MercurialDvcsCmd(remote='http://example.com/hg')
cmd.write_remote(self.workspace)
with open(os.path.join(self.workspace_dir, '.hg', 'hgrc')) as fd:
self.assertTrue('default = http://example.com/hg' in fd.read())

def test_get_cmd_by_name(self):
self.assertEqual(get_cmd_by_name('mercurial'), self.cmdcls)


@skipIf(not DulwichDvcsCmd.available(), 'dulwich is not available')
class DulwichDvcsCmdTestCase(CoreTestCase, RawCmdTests):
cmdcls = DulwichDvcsCmd
Expand Down
Loading