From: Han-Wen Nienhuys Date: Fri, 25 May 2007 02:32:51 +0000 (-0300) Subject: minor fixes. X-Git-Url: https://repo.or.cz/w/darcs2git.git/commitdiff_plain/dffefd3378dc0e414640fe9bc44ca4e59bafcabb minor fixes. --- diff --git a/darcs2git.py b/darcs2git.py index 85d1a8c..d3f8ff3 100644 --- a/darcs2git.py +++ b/darcs2git.py @@ -1,11 +1,27 @@ -# -# Copyright (c) 2007 Han-Wen Nienhuys -# -# Distributed under terms of the GNU General Public License -# This program comes with NO WARRANTY. -# -# -# +#! /usr/bin/python + +""" + + darcs2git -- Darcs to git converter. + + Copyright (c) 2007 Han-Wen Nienhuys + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +""" + # TODO: # @@ -13,7 +29,7 @@ # # - file modes # -# - use binary search to find from-patch ica. conflict. +# - use binary search to find from-patch in case of conflict. # import glob @@ -116,8 +132,7 @@ This program comes with NO WARRANTY. type='int', default=0, help='Look back this many patches as conflict ancestors.\n' - 'Default is 0 (no limit)' - ) + 'Default is 0 (no limit)') p.add_option ('--debug', action='store_true', dest='debug', @@ -201,6 +216,10 @@ going back (obliterate) and forward (pull). self._short_id_dict = dict ((p.short_id (), p) for p in patches) + def __del__ (self): + if not options.debug: + system ('rm -fr %s' % self.dir) + def is_contiguous (self): return (len (self.inventory_dict ()) == self._current_number+1 and self.contains_contiguous (self._current_number)) @@ -639,14 +658,24 @@ def export_tag (patch, gfi): ################################################################ # main. + def test_conversion (darcs_repo, git_repo): + pristine = '%(darcs_repo)s/_darcs/pristine' % locals () + if not os.path.exists (pristine): + progress ("darcs repository does not contain pristine tree?!") + return + gd = options.basename + '.checkouttmp.git' system ('rm -rf %(gd)s && git clone %(git_repo)s %(gd)s' % locals ()) - diff = read_pipe ('diff --exclude .git -urN %(gd)s %(darcs_repo)s/_darcs/pristine' % locals (), ignore_errors=True) + diff_cmd = 'diff --exclude .git -urN %(gd)s %(pristine)s' % locals () system ('rm -rf %(gd)s' % locals ()) + + diff = read_pipe (diff_cmd, ignore_errors=True) if diff: + if len (diff) > 1024: + diff = diff[:512] + '\n...\n' + diff[512:] + progress ("Conversion introduced changes: %s" % diff) - sys.exit (1) else: progress ("Checkout matches pristine darcs tree.") @@ -704,6 +733,7 @@ def main (): conv_repo.go_from_to (parent_patch, p) break except PullConflict: + ## simplistic, may not be enough. progress ('conflict, going one back') parent_number -= 1