<commit_before>/*******************************************************************************
 * Copyright (c) 2005-2010 VecTrace (<NAME>) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * john	implementation
 *******************************************************************************/
package com.vectrace.MercurialEclipse.model;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;

import com.vectrace.MercurialEclipse.exception.HgException;
import com.vectrace.MercurialEclipse.team.cache.LocalChangesetCache;

/**
 *
 */
public abstract class HgRevisionResource extends HgResource implements IChangeSetHolder {

	/**
	 * If a local resource then then null
	 */
	protected final JHgChangeSet changeset;

	// constructors

	/**
	 * @param root the HgRoot, not null
	 * @param changeset is null if and only if resource != null, or this is a NullHgFile
	 * @param path relative path to HgRoot, not null
	 */
	public HgRevisionResource(HgRoot root, String changeset, IPath path) throws HgException {
		super(root, path.removeTrailingSeparator());

		LocalChangesetCache cache = LocalChangesetCache.getInstance();

		this.changeset = cache.get(root, changeset);

		Assert.isNotNull(this.changeset);
	}

	/**
	 * @param root the HgRoot, not null
	 * @param changeset =null if and only if wResource != null or this is a NullHgFile
	 * @param path relative path to HgRoot, not null
	 */
	public HgRevisionResource(HgRoot root, JHgChangeSet changeset, IPath path) {
		super(root, path.removeTrailingSeparator());

		this.changeset = changeset;
	}

	// operations

	public final JHgChangeSet getChangeSet() {
		return changeset;
	}

	/**
	 * @see com.vectrace.MercurialEclipse.model.IHgResource#getName()
	 */
	public String getName() {
		String name = path.lastSegment();
		if(name == null) {<commit_msg>Fix exception comparing at null revision. Fixes #371<commit_after>/*******************************************************************************
 * Copyright (c) 2005-2010 VecTrace (<NAME>) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * john	implementation
 *******************************************************************************/
package com.vectrace.MercurialEclipse.model;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;

import com.aragost.javahg.Changeset;
import com.vectrace.MercurialEclipse.exception.HgException;
import com.vectrace.MercurialEclipse.team.cache.LocalChangesetCache;

/**
 *
 */
public abstract class HgRevisionResource extends HgResource implements IChangeSetHolder {

	/**
	 * Not null. TODO: verify not null
	 */
	protected final JHgChangeSet changeset;

	// constructors

	/**
	 * @param root the HgRoot, not null
	 * @param changeset is null if and only if resource != null, or this is a NullHgFile
	 * @param path relative path to HgRoot, not null
	 */
	public HgRevisionResource(HgRoot root, String changeset, IPath path) throws HgException {
		super(root, path.removeTrailingSeparator());

		LocalChangesetCache cache = LocalChangesetCache.getInstance();

		if (Changeset.NULL_ID.equals(changeset)) {
			this.changeset = JHgChangeSet.makeNull(root);
		} else {
			this.changeset = cache.get(root, changeset);
		}

		Assert.isNotNull(this.changeset);
	}

	/**
	 * @param root the HgRoot, not null
	 * @param changeset =null if and only if wResource != null or this is a NullHgFile
	 * @param path relative path to HgRoot, not null
	 */
	public HgRevisionResource(HgRoot root, JHgChangeSet changeset, IPath path) {
		super(root, path.removeTrailingSeparator());

		this.changeset = changeset;

		// TODO: Assert.isNotNull(this.changeset);
		assert changeset != null;
	}

	// operations

	public final JHgChangeSet getChangeSet() {
		return changeset;
	}

	/**
	 * @see com.vectrace.MercurialEclipse.model.IHgResource#getName()
	 */
	public String getName() {
		String name = path.lastSegment();
		if(name == null) {
{'fraction_non_alphanumeric': 0.1653363740022805, 'fraction_numerical': 0.006157354618015963, 'mean_word_length': 4.652061855670103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '17635', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1213, 'n_words': 366}