Skip to content

Commit 3825387

Browse files
committed
Merge master for a new release
--HG-- branch : release
2 parents cf1f97f + 73245c6 commit 3825387

File tree

9 files changed

+123
-65
lines changed

9 files changed

+123
-65
lines changed

.hgtags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
91d2ec54cf909ab56b0de299730171fbe1a18226 release/1a1
22
244657cb77ec52ebd9829bb06f76ea97b0bbbc95 release/1a2
3+
bbc1637021c22706c8ccbe76eb6f71bf48f4126a release/1.0
4+
bba7efe4f12f4148e1481b105316dd2bf7f6f912 release/1.1

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@
77
"**/*.rej": true,
88
"**/*.orig": true,
99
"**/*~": true
10-
}
10+
},
11+
"python.testing.unittestEnabled": true,
12+
"python.testing.unittestArgs": [
13+
"-s",
14+
"test"
15+
]
1116
}

.vscode/tasks.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"command": "${config:python.pythonPath}",
88
"args": [
99
"./setup.py",
10-
"test"
10+
"build"
1111
],
12-
"group": "build"
12+
"group": "build",
13+
"problemMatcher": []
1314
},
1415
{
1516
"label": "Rebuild",
@@ -18,9 +19,10 @@
1819
"args": [
1920
"./setup.py",
2021
"clean",
21-
"test"
22+
"build"
2223
],
23-
"group": "build"
24+
"group": "build",
25+
"problemMatcher": []
2426
},
2527
{
2628
"label": "Clean",

azure-pipelines.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,34 @@ stages:
1414
jobs:
1515
- job: Build
1616
pool:
17-
vmImage: ubuntu-latest
17+
vmImage: ubuntu-16.04
18+
container: kazssym/python-prcs:3
1819
steps:
19-
- task: UsePythonVersion@0
2020
- bash: |
21-
pip install "setuptools>=38.6" wheel
21+
pip install \
22+
"setuptools>=38.6" \
23+
unittest-xml-reporting \
24+
wheel
2225
displayName: Install dependencies
2326
- bash: |
24-
python ./setup.py test
27+
python ./setup.py build
28+
displayName: Build
29+
- bash: |
30+
#python test/prepare.py test/testproject.prcs.b64
31+
python -m xmlrunner discover -s test -o test-reports
2532
displayName: Test
33+
env:
34+
PRCS_REPOSITORY: $(Agent.TempDirectory)/PRCS
2635
- task: PublishTestResults@2
36+
condition: succeededOrFailed()
2737
- bash: |
2838
python ./setup.py sdist bdist_wheel
2939
displayName: Create archives
3040
- publish: dist
3141
artifact: dist
3242
- stage: Release
33-
condition: >-
43+
dependsOn: Default
44+
condition:
3445
and(succeeded(),
3546
startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))
3647
jobs:

hgext3rd/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# __init__.py - initialization of the 'hgext3rd' package
2+
# Copyright (C) 2020 Kaz Nishimura
3+
#
4+
# This program is free software: you can redistribute it and/or modify it
5+
# under the terms of the GNU General Public License as published by the Free
6+
# Software Foundation, either version 3 of the License, or (at your option)
7+
# any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful, but WITHOUT
10+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+
# more details.
13+
#
14+
# You should have received a copy of the GNU General Public License along with
15+
# this program. If not, see <http://www.gnu.org/licenses/>.
16+
#
17+
# SPDX-License-Identifier: GPL-3.0-or-later
18+
19+
"""
20+
empty package
21+
22+
This file is not for installation.
23+
"""

hgext3rd/convert_prcs/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"""
2525

2626
from __future__ import absolute_import, unicode_literals
27+
2728
from hgext.convert import convcmd
2829
from .prcs import prcs_source
2930

@@ -32,7 +33,7 @@
3233

3334
def extsetup(ui):
3435
"""
35-
set up the 'convert_prcs' extension
36+
Set up the 'convert_prcs' extension.
3637
"""
3738
convcmd.source_converters.append(
3839
(b"prcs", prcs_source, b"branchsort")

hgext3rd/convert_prcs/prcs.py

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"""
2222

2323
from __future__ import absolute_import, unicode_literals
24+
2425
import re
25-
import os
26-
import sys
2726
from hgext.convert.common import NoRepo, commit, converter_source
27+
from mercurial.util import unlinkpath
2828
from prcslib import PrcsVersion, PrcsProject, PrcsError
2929

3030
# Regular expression pattern that checks for main branches.
@@ -43,7 +43,7 @@ def __init__(self, ui, scm, path, revs=None):
4343

4444
try:
4545
self._project = PrcsProject(path.decode())
46-
self._revisions = self._project.versions()
46+
self._versions = self._project.versions()
4747
except PrcsError:
4848
raise NoRepo(b"%s does not look like a PRCS project" % path)
4949

@@ -66,7 +66,7 @@ def _nearest_ancestor(self, version):
6666
version = PrcsVersion(version)
6767

6868
deleted = False
69-
while self._revisions[str(version)]['deleted']:
69+
while self._versions[str(version)]['deleted']:
7070
self.ui.note(version, " is deleted\n")
7171
deleted = True
7272
version = PrcsVersion(version.major(), version.minor() - 1)
@@ -82,61 +82,81 @@ def getheads(self):
8282
return all the head versions of the PRCS source
8383
"""
8484
last_minors = {}
85-
for key in self._revisions:
86-
if not self._revisions[key]["deleted"]:
85+
for key in self._versions:
86+
if not self._versions[key]["deleted"]:
8787
version = PrcsVersion(key)
8888
if last_minors.get(version.major(), 0) < version.minor():
8989
last_minors[version.major()] = version.minor()
9090
return map(
9191
lambda item: str(PrcsVersion(*item)).encode(),
9292
last_minors.items())
9393

94-
def getfile(self, name, version):
94+
def getfile(self, name, rev):
9595
"""
96-
get the content of a file
96+
Return the content and mode of a file as a 'tuple' value
9797
"""
98-
version = version.decode()
99-
descriptor = self._descriptor(version)
98+
if rev is None:
99+
return None, None
100+
101+
rev = rev.decode()
102+
descriptor = self._descriptor(rev)
100103
files = descriptor.files()
101-
if name.decode() in files:
102-
attr = files[name.decode()]
103-
if "symlink" in attr:
104-
return attr["symlink"].encode(), b"l"
104+
if not name.decode() in files:
105+
self.ui.debug(b"%s not found for %s" % (name, rev.encode()))
106+
return None, None
105107

106-
self._project.checkout(version, files=[name.decode()])
108+
attr = files[name.decode()]
109+
if "symlink" in attr:
110+
return attr["symlink"].encode(), b"l"
107111

112+
self._project.checkout(rev, files=[name.decode()])
113+
114+
try:
108115
with open(name, "rb") as stream:
109116
content = stream.read()
117+
finally:
118+
unlinkpath(name)
110119

111-
# NOTE: Win32 does not always releases the file name.
112-
if sys.platform != "win32":
113-
os.unlink(name)
114-
dir = os.path.dirname(name)
115-
if dir:
116-
os.removedirs(dir)
117-
118-
return content, b"x" if attr["mode"] & (0x1 << 6) else b""
120+
return content, b"x" if attr["mode"] & (0x1 << 6) else b""
119121

120-
# The file with the specified name was deleted.
121-
return None, None
122+
def _removedfiles(self, files, parentfiles):
123+
"""
124+
Return a (files, copies) tuple for removed or renamed files.
125+
"""
126+
changes = []
127+
copies = {}
128+
pnamebyid = {}
129+
for pname, pa in parentfiles.items():
130+
if pname not in files:
131+
changes.append((pname.encode(), None))
132+
if "symlink" not in pa:
133+
pnamebyid[pa['id']] = pname
134+
# To process renamed files for copies.
135+
for name, attr in files.items():
136+
if not "symlink" in attr and attr['id'] in pnamebyid:
137+
pname = pnamebyid[attr['id']]
138+
if name != pname:
139+
self.ui.note(b"%s was renamed to %s\n" % \
140+
(pname.encode(), name.encode()))
141+
copies[name.encode()] = pname.encode()
142+
return changes, copies
122143

123144
def getchanges(self, version, full=False):
124145
version = version.decode()
125-
revision = self._revisions[version]
126146
descriptor = self._descriptor(version)
127147

128148
files = []
129149
copies = {}
130150
f = descriptor.files()
131-
p = descriptor.parentversion()
151+
parent = descriptor.parent()
132152
# Preparing for a deleted parent.
133-
p = self._nearest_ancestor(p)
134-
if full or p is None:
153+
parent = self._nearest_ancestor(parent)
154+
if full or parent is None:
135155
# This is the initial checkin so all files are affected.
136156
for name in f:
137157
files.append((name.encode(), version.encode()))
138158
else:
139-
pf = self._descriptor(p).files()
159+
pf = self._descriptor(parent).files()
140160
# Handling added or changed files.
141161
for name, a in f.items():
142162
if name in pf:
@@ -155,34 +175,22 @@ def getchanges(self, version, full=False):
155175
else:
156176
# Added.
157177
files.append((name.encode(), version.encode()))
158-
# Handling deleted or renamed files.
159-
pnamebyid = {}
160-
for pname, pa in pf.items():
161-
if pname not in f:
162-
# Removed (or renamed).
163-
files.append((pname.encode(), version.encode()))
164-
if "symlink" not in pa:
165-
pnamebyid[pa['id']] = pname
166-
# Handling renamed files for copies.
167-
for name, a in f.items():
168-
if "symlink" not in a and a['id'] in pnamebyid:
169-
pname = pnamebyid[a['id']]
170-
if name != pname:
171-
self.ui.note(b"%s was renamed to %s\n" % (pname.encode(), name.encode()))
172-
copies[name.encode()] = pname.encode()
178+
# To process removed or renamed files.
179+
removes, copies = self._removedfiles(f, pf)
180+
files.extend(removes)
173181
return files, copies, set()
174182

175183
def getcommit(self, version):
176184
version = version.decode()
177-
revision = self._revisions[version]
185+
revision = self._versions[version]
178186
descriptor = self._descriptor(version)
179187

180188
parents = []
181-
p = descriptor.parentversion()
189+
parent = descriptor.parent()
182190
# Preparing for a deleted parent.
183-
p = self._nearest_ancestor(p)
184-
if p is not None:
185-
parents.append(str(p).encode())
191+
parent = self._nearest_ancestor(parent)
192+
if not parent is None:
193+
parents.append(str(parent).encode())
186194
for mp in descriptor.mergeparents():
187195
# Preparing for a deleted merge parent.
188196
mp = self._nearest_ancestor(mp)
@@ -196,6 +204,12 @@ def getcommit(self, version):
196204
revision['author'].encode(), revision['date'].isoformat().encode(),
197205
descriptor.message().encode(), parents, branch)
198206

207+
def numcommits(self):
208+
"""
209+
Return the number of commits.
210+
"""
211+
return len(self._versions)
212+
199213
def gettags(self):
200214
"""Return an empty dictionary since PRCS has no tags."""
201215
return {}

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
"""
2222

2323
from __future__ import absolute_import
24+
2425
from os import path
2526
from setuptools import setup
2627

2728
# Package name.
2829
PACKAGE_NAME = "hg-convert-prcs-extension"
2930

3031
# Package version.
31-
PACKAGE_VERSION = "1.0"
32+
PACKAGE_VERSION = "2.0.0"
3233

3334
def long_description():
3435
"""
@@ -50,7 +51,7 @@ def long_description():
5051
description="PRCS source for the Mercurial convert extension.",
5152
url="https://vx68k.bitbucket.io/hg-convert-prcs/",
5253
project_urls={
53-
"GitHub": "https://github.com/vx68k/hg-convert-prcs-extension",
54+
"Source": "https://github.com/vx68k/hg-convert-prcs-extension",
5455
},
5556
author="Kaz Nishimura",
5657
author_email="kazssym@linuxfront.com",
@@ -65,12 +66,11 @@ def long_description():
6566
python_requires=">=2.7",
6667
install_requires=[
6768
"mercurial>=4.7",
68-
"prcslib>=2"
69+
"prcslib>=4.1"
6970
],
7071
zip_safe=True,
7172

7273
packages=[
7374
"hgext3rd.convert_prcs"
7475
],
75-
test_suite="testsuite",
7676
)
File renamed without changes.

0 commit comments

Comments
 (0)