summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlorry8
-rwxr-xr-xtests/hg-unnamed-head.script3
-rw-r--r--tests/hg-unnamed-head.stdout2
3 files changed, 9 insertions, 4 deletions
diff --git a/lorry b/lorry
index c2019d4..9a10045 100755
--- a/lorry
+++ b/lorry
@@ -743,6 +743,7 @@ class Lorry(cliapp.Application):
mark_re = re.compile(r':(\S+) ([0-9a-f]{40,})\n')
marks_temp_fd, marks_temp_name = \
tempfile.mkstemp(dir=os.path.dirname(marks_name))
+ n_pruned = 0
try:
with open(marks_temp_fd, 'w') as marks_out, \
open(marks_name, 'r') as marks_in:
@@ -759,11 +760,14 @@ class Lorry(cliapp.Application):
elif match.group(2) in reachable:
marks_out.write(line)
else:
- self.progress('%s: pruning unreachable commit %s'
- % (marks_name, match.group(2)))
+ n_pruned += 1
# On success, replace marks file with temporary file
os.rename(marks_temp_name, marks_name)
+
+ if n_pruned:
+ self.progress('%s: pruned %d unreachable commit(s)'
+ % (marks_name, n_pruned))
except:
# On failure, delete temporary file
os.unlink(marks_temp_name)
diff --git a/tests/hg-unnamed-head.script b/tests/hg-unnamed-head.script
index fa2693f..512938f 100755
--- a/tests/hg-unnamed-head.script
+++ b/tests/hg-unnamed-head.script
@@ -26,6 +26,7 @@ workdir="$DATADIR/work-dir"
"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \
"$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null
+grep -o 'pruned [0-9]* unreachable commit' < "$logfile" || true
# verify that the git repository was created correctly
(
@@ -48,4 +49,4 @@ workdir="$DATADIR/work-dir"
# that this involves pruning an unreachable commit
"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \
"$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null
-grep -c 'pruning unreachable commit' < "$logfile"
+grep -o 'pruned [0-9]* unreachable commit' < "$logfile"
diff --git a/tests/hg-unnamed-head.stdout b/tests/hg-unnamed-head.stdout
index 7354306..029b454 100644
--- a/tests/hg-unnamed-head.stdout
+++ b/tests/hg-unnamed-head.stdout
@@ -4,4 +4,4 @@ first line
third line
third commit
first commit
-1
+pruned 1 unreachable commit