def get_parent_revision(self, number, branch, exact=False):
     '''Get the parent revision hash for a commit on a specific branch.
     '''
     tag = self.get_path_tag(self.remotename(branch))
     if tag:
         # Reference a tag being created
         if tag in self.addedtags:
             tbranch, trev = self.addedtags[tag]
             fromtag = self.get_path_tag(self.remotename(tbranch))
             if not fromtag:
                 # Created from a regular branch, not another tag
                 tagged = self.get_parent_svn_branch_and_rev(trev, tbranch)
                 return node.hex(self.revmap[tagged])
             tag = fromtag
         # Reference an existing tag
         limitedtags = maps.Tags(self, endrev=number - 1)
         if tag in limitedtags:
             return limitedtags[tag]
     r, br = self.get_parent_svn_branch_and_rev(number - 1, branch, exact)
     if r is not None:
         return self.revmap[r, br]
     return revlog.nullid
Beispiel #2
0
 def tags(self):
     if self._tags is None:
         self._tags = maps.Tags(self.ui, self.tagfile)
     return self._tags
 def tags(self):
     if self._tags is None:
         self._tags = maps.Tags(self)
     return self._tags
Beispiel #4
0
    def __init__(self, repo, uuid=None, subdir=None):
        """path is the path to the target hg repo.

        subdir is the subdirectory of the edits *on the svn server*.
        It is needed for stripping paths off in certain cases.
        """
        self.ui = repo.ui
        self.repo = repo
        self.path = os.path.normpath(repo.join('..'))

        if not os.path.isdir(self.meta_data_dir):
            os.makedirs(self.meta_data_dir)
        self.uuid = uuid
        self.subdir = subdir
        self.revmap = maps.RevMap(repo)

        author_host = self.ui.config('hgsubversion', 'defaulthost', uuid)
        authors = self.ui.config('hgsubversion', 'authormap')
        tag_locations = self.ui.configlist('hgsubversion', 'tagpaths',
                                           ['tags'])
        self.usebranchnames = self.ui.configbool('hgsubversion',
                                                 'usebranchnames', True)
        branchmap = self.ui.config('hgsubversion', 'branchmap')
        tagmap = self.ui.config('hgsubversion', 'tagmap')

        self.branches = {}
        if os.path.exists(self.branch_info_file):
            f = open(self.branch_info_file)
            self.branches = pickle.load(f)
            f.close()
        self.prevbranches = dict(self.branches)
        self.tags = maps.Tags(repo)
        if os.path.exists(self.tag_locations_file):
            f = open(self.tag_locations_file)
            self.tag_locations = pickle.load(f)
            f.close()
        else:
            self.tag_locations = tag_locations
        if os.path.exists(self.layoutfile):
            f = open(self.layoutfile)
            self._layout = f.read().strip()
            f.close()
            self.repo.ui.setconfig('hgsubversion', 'layout', self._layout)
        else:
            self._layout = None
        pickle_atomic(self.tag_locations, self.tag_locations_file,
                      self.meta_data_dir)
        # ensure nested paths are handled properly
        self.tag_locations.sort()
        self.tag_locations.reverse()

        self.authors = maps.AuthorMap(self.ui,
                                      self.authors_file,
                                      defaulthost=author_host)
        if authors: self.authors.load(authors)

        self.branchmap = maps.BranchMap(self.ui, self.branchmapfile)
        if branchmap:
            self.branchmap.load(branchmap)

        self.tagmap = maps.TagMap(self.ui, self.tagmapfile)
        if tagmap:
            self.tagmap.load(tagmap)

        self.lastdate = '1970-01-01 00:00:00 -0000'
        self.filemap = maps.FileMap(repo)
        self.addedtags = {}
        self.deletedtags = {}