{"action":"created","comment":{"url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments/77340051","id":77340051,"diff_hunk":"@@ -1,140 +1,158 @@\n use std::path::PathBuf;\n-use std::path::Path;\n-use std::borrow::Borrow;\n-use std::ops::Deref;\n \n-use semver::Version;\n use std::fmt::{Display, Debug, Formatter};\n use std::fmt::Error as FmtError;\n use std::result::Result as RResult;\n+use std::path::Components;\n+\n+use libimagerror::into::IntoError;\n \n use error::StoreErrorKind as SEK;\n use store::Result;\n use store::Store;\n \n /// The Index into the Store\n #[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd, Ord)]\n-pub struct StoreId(PathBuf);\n+pub struct StoreId {\n+    base: Option<PathBuf>,\n+    id:   PathBuf,\n+}\n \n impl StoreId {\n \n-    pub fn storified(self, store: &Store) -> StoreId {\n-        if self.starts_with(store.path()) {\n-            debug!(\"Not storifying {:?}, because it is already.\", self);\n-            self\n+    pub fn new(base: Option<PathBuf>, id: PathBuf) -> Result<StoreId> {\n+        StoreId::new_baseless(id).map(|mut sid| { sid.base = base; sid })\n+    }\n+\n+    pub fn new_baseless(id: PathBuf) -> Result<StoreId> {\n+        if id.is_absolute() {\n+            Err(SEK::StoreIdLocalPartAbsoluteError.into_error())\n         } else {\n-            debug!(\"Create new store id out of: {:?} and {:?}\", store.path(), self);\n-            let mut new_id = store.path().clone();\n-            new_id.push(self);\n-            debug!(\"Created: '{:?}'\", new_id);\n-            StoreId::from(new_id)\n+            Ok(StoreId {\n+                base: None,\n+                id: id\n+            })\n         }\n     }\n \n-}\n-\n-impl Into<PathBuf> for StoreId {\n-\n-    fn into(self) -> PathBuf {\n-        self.0\n+    pub fn without_base(mut self) -> StoreId {\n+        self.base = None;\n+        self\n     }\n \n-}\n-\n-impl Display for StoreId {\n+    pub fn with_base(mut self, base: PathBuf) -> Self {\n+        self.base = Some(base);\n+        self\n+    }\n \n-    fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> {\n-        match self.0.to_str() {\n-            Some(s) => write!(fmt, \"{}\", s),\n-            None    => write!(fmt, \"{}\", self.0.to_string_lossy()),\n+    pub fn storified(self, store: &Store) -> StoreId {\n+        StoreId {\n+            base: Some(store.path().clone()),\n+            id: self.id\n         }\n     }\n \n-}\n-\n-impl Deref for StoreId {\n-    type Target = PathBuf;\n-\n-    fn deref(&self) -> &PathBuf {\n-        &self.0\n+    pub fn exists(&self) -> bool {\n+        let pb : PathBuf = self.clone().into();\n+        pb.exists()\n     }\n \n-}\n-\n-impl From<PathBuf> for StoreId {\n+    pub fn is_file(&self) -> bool {\n+        true\n+    }\n \n-    fn from(pb: PathBuf) -> StoreId {\n-        StoreId(pb)\n+    pub fn is_dir(&self) -> bool {\n+        false\n     }\n \n-}\n+    pub fn to_str(&self) -> Result<String> {\n+        if self.base.is_some() {\n+            let mut base = self.base.as_ref().cloned().unwrap();\n+            base.push(self.id.clone());\n+            base\n+        } else {\n+            self.id.clone()\n+        }\n+        .to_str()\n+        .map(String::from)\n+        .ok_or(SEK::StoreIdHandlingError.into_error())\n+    }\n \n-impl From<String> for StoreId {\n+    /// Returns the components of the `id` part of the StoreId object.\n+    ///\n+    /// Can be used to check whether a StoreId points to an entry in a specific collection of\n+    /// StoreIds.\n+    pub fn components(&self) -> Components {\n+        self.id.components()\n+    }\n \n-    fn from(string: String) -> StoreId {\n-        StoreId(string.into())\n+    /// Check whether a StoreId points to an entry in a specific collection.\n+    ///\n+    /// A \"collection\" here is simply a directory. So `foo/bar/baz` is an entry which is in\n+    /// collection [\"foo\", \"bar\"].","path":"libimagstore/src/storeid.rs","position":135,"original_position":135,"commit_id":"8e779fc87e2dda5d45dc7d2ee805228a3ada7079","original_commit_id":"8e779fc87e2dda5d45dc7d2ee805228a3ada7079","user":{"login":"TheNeikos","id":1631166,"avatar_url":"https://avatars.githubusercontent.com/u/1631166?v=3","gravatar_id":"","url":"https://api.github.com/users/TheNeikos","html_url":"https://github.com/TheNeikos","followers_url":"https://api.github.com/users/TheNeikos/followers","following_url":"https://api.github.com/users/TheNeikos/following{/other_user}","gists_url":"https://api.github.com/users/TheNeikos/gists{/gist_id}","starred_url":"https://api.github.com/users/TheNeikos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheNeikos/subscriptions","organizations_url":"https://api.github.com/users/TheNeikos/orgs","repos_url":"https://api.github.com/users/TheNeikos/repos","events_url":"https://api.github.com/users/TheNeikos/events{/privacy}","received_events_url":"https://api.github.com/users/TheNeikos/received_events","type":"User","site_admin":false},"body":"Hm, does the order matter? Otherwise an Array would be wrong type with which to show this","created_at":"2016-09-02T12:48:01Z","updated_at":"2016-09-02T12:48:01Z","html_url":"https://github.com/matthiasbeyer/imag/pull/667#discussion_r77340051","pull_request_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667","_links":{"self":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments/77340051"},"html":{"href":"https://github.com/matthiasbeyer/imag/pull/667#discussion_r77340051"},"pull_request":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667"}}},"pull_request":{"url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667","id":82666442,"html_url":"https://github.com/matthiasbeyer/imag/pull/667","diff_url":"https://github.com/matthiasbeyer/imag/pull/667.diff","patch_url":"https://github.com/matthiasbeyer/imag/pull/667.patch","issue_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/667","number":667,"state":"open","locked":false,"title":"Rewrite storeid type","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"body":"@TheNeikos Feel free to provide patches here\r\n\r\nThis might be a long-running one. It is intended to rewrite the `StoreId` type so we can rely on its properties.","created_at":"2016-08-25T06:59:21Z","updated_at":"2016-09-02T12:48:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99752ad7305a896a96458a1a2684e7c9a77be575","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/matthiasbeyer/imag/milestones/2","html_url":"https://github.com/matthiasbeyer/imag/milestones/0.2.0","labels_url":"https://api.github.com/repos/matthiasbeyer/imag/milestones/2/labels","id":1960223,"number":2,"title":"0.2.0","description":"A intermediate release containing _some_ functionality which could be tested by potential users and/or contributors.\r\n\r\nThis cannot be expected to be stable at all. It is more like a starting point for potential reviewers/developers/users and other interested people to have a closer look and also to generate some more feedback from the Rust community to steer the project a bit less loosely.","creator":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":12,"state":"open","created_at":"2016-08-24T10:53:50Z","updated_at":"2016-09-02T06:25:37Z","due_on":"2016-12-31T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667/commits","review_comments_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667/comments","review_comment_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/667/comments","statuses_url":"https://api.github.com/repos/matthiasbeyer/imag/statuses/8e779fc87e2dda5d45dc7d2ee805228a3ada7079","head":{"label":"matthiasbeyer:rewrite-storeid-type","ref":"rewrite-storeid-type","sha":"8e779fc87e2dda5d45dc7d2ee805228a3ada7079","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"repo":{"id":45788713,"name":"imag","full_name":"matthiasbeyer/imag","owner":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthiasbeyer/imag","description":"imag - Text based personal information management suite","fork":false,"url":"https://api.github.com/repos/matthiasbeyer/imag","forks_url":"https://api.github.com/repos/matthiasbeyer/imag/forks","keys_url":"https://api.github.com/repos/matthiasbeyer/imag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthiasbeyer/imag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthiasbeyer/imag/teams","hooks_url":"https://api.github.com/repos/matthiasbeyer/imag/hooks","issue_events_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/events{/number}","events_url":"https://api.github.com/repos/matthiasbeyer/imag/events","assignees_url":"https://api.github.com/repos/matthiasbeyer/imag/assignees{/user}","branches_url":"https://api.github.com/repos/matthiasbeyer/imag/branches{/branch}","tags_url":"https://api.github.com/repos/matthiasbeyer/imag/tags","blobs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthiasbeyer/imag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthiasbeyer/imag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthiasbeyer/imag/statuses/{sha}","languages_url":"https://api.github.com/repos/matthiasbeyer/imag/languages","stargazers_url":"https://api.github.com/repos/matthiasbeyer/imag/stargazers","contributors_url":"https://api.github.com/repos/matthiasbeyer/imag/contributors","subscribers_url":"https://api.github.com/repos/matthiasbeyer/imag/subscribers","subscription_url":"https://api.github.com/repos/matthiasbeyer/imag/subscription","commits_url":"https://api.github.com/repos/matthiasbeyer/imag/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthiasbeyer/imag/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthiasbeyer/imag/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/comments{/number}","contents_url":"https://api.github.com/repos/matthiasbeyer/imag/contents/{+path}","compare_url":"https://api.github.com/repos/matthiasbeyer/imag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthiasbeyer/imag/merges","archive_url":"https://api.github.com/repos/matthiasbeyer/imag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthiasbeyer/imag/downloads","issues_url":"https://api.github.com/repos/matthiasbeyer/imag/issues{/number}","pulls_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls{/number}","milestones_url":"https://api.github.com/repos/matthiasbeyer/imag/milestones{/number}","notifications_url":"https://api.github.com/repos/matthiasbeyer/imag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthiasbeyer/imag/labels{/name}","releases_url":"https://api.github.com/repos/matthiasbeyer/imag/releases{/id}","deployments_url":"https://api.github.com/repos/matthiasbeyer/imag/deployments","created_at":"2015-11-08T16:34:25Z","updated_at":"2016-08-31T15:15:25Z","pushed_at":"2016-09-02T07:49:45Z","git_url":"git://github.com/matthiasbeyer/imag.git","ssh_url":"git@github.com:matthiasbeyer/imag.git","clone_url":"https://github.com/matthiasbeyer/imag.git","svn_url":"https://github.com/matthiasbeyer/imag","homepage":"http://imag-pim.org","size":9166,"stargazers_count":111,"watchers_count":111,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":17,"mirror_url":null,"open_issues_count":73,"forks":17,"open_issues":73,"watchers":111,"default_branch":"master"}},"base":{"label":"matthiasbeyer:master","ref":"master","sha":"4e0113f8467dd41a615ea0dec46bd2b93dc7cc81","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"repo":{"id":45788713,"name":"imag","full_name":"matthiasbeyer/imag","owner":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthiasbeyer/imag","description":"imag - Text based personal information management suite","fork":false,"url":"https://api.github.com/repos/matthiasbeyer/imag","forks_url":"https://api.github.com/repos/matthiasbeyer/imag/forks","keys_url":"https://api.github.com/repos/matthiasbeyer/imag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthiasbeyer/imag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthiasbeyer/imag/teams","hooks_url":"https://api.github.com/repos/matthiasbeyer/imag/hooks","issue_events_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/events{/number}","events_url":"https://api.github.com/repos/matthiasbeyer/imag/events","assignees_url":"https://api.github.com/repos/matthiasbeyer/imag/assignees{/user}","branches_url":"https://api.github.com/repos/matthiasbeyer/imag/branches{/branch}","tags_url":"https://api.github.com/repos/matthiasbeyer/imag/tags","blobs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthiasbeyer/imag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthiasbeyer/imag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthiasbeyer/imag/statuses/{sha}","languages_url":"https://api.github.com/repos/matthiasbeyer/imag/languages","stargazers_url":"https://api.github.com/repos/matthiasbeyer/imag/stargazers","contributors_url":"https://api.github.com/repos/matthiasbeyer/imag/contributors","subscribers_url":"https://api.github.com/repos/matthiasbeyer/imag/subscribers","subscription_url":"https://api.github.com/repos/matthiasbeyer/imag/subscription","commits_url":"https://api.github.com/repos/matthiasbeyer/imag/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthiasbeyer/imag/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthiasbeyer/imag/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/comments{/number}","contents_url":"https://api.github.com/repos/matthiasbeyer/imag/contents/{+path}","compare_url":"https://api.github.com/repos/matthiasbeyer/imag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthiasbeyer/imag/merges","archive_url":"https://api.github.com/repos/matthiasbeyer/imag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthiasbeyer/imag/downloads","issues_url":"https://api.github.com/repos/matthiasbeyer/imag/issues{/number}","pulls_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls{/number}","milestones_url":"https://api.github.com/repos/matthiasbeyer/imag/milestones{/number}","notifications_url":"https://api.github.com/repos/matthiasbeyer/imag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthiasbeyer/imag/labels{/name}","releases_url":"https://api.github.com/repos/matthiasbeyer/imag/releases{/id}","deployments_url":"https://api.github.com/repos/matthiasbeyer/imag/deployments","created_at":"2015-11-08T16:34:25Z","updated_at":"2016-08-31T15:15:25Z","pushed_at":"2016-09-02T07:49:45Z","git_url":"git://github.com/matthiasbeyer/imag.git","ssh_url":"git@github.com:matthiasbeyer/imag.git","clone_url":"https://github.com/matthiasbeyer/imag.git","svn_url":"https://github.com/matthiasbeyer/imag","homepage":"http://imag-pim.org","size":9166,"stargazers_count":111,"watchers_count":111,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":17,"mirror_url":null,"open_issues_count":73,"forks":17,"open_issues":73,"watchers":111,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667"},"html":{"href":"https://github.com/matthiasbeyer/imag/pull/667"},"issue":{"href":"https://api.github.com/repos/matthiasbeyer/imag/issues/667"},"comments":{"href":"https://api.github.com/repos/matthiasbeyer/imag/issues/667/comments"},"review_comments":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667/comments"},"review_comment":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/667/commits"},"statuses":{"href":"https://api.github.com/repos/matthiasbeyer/imag/statuses/8e779fc87e2dda5d45dc7d2ee805228a3ada7079"}}}}
{"actor":{"display_login":"TheNeikos"}}